Skip to content

Commit 49bf047

Browse files
authored
Merge pull request #179 from code-payments/chore/currency-glitch-fix
fix: prevent remeasuring of cells
2 parents aed74d1 + 59cf3f5 commit 49bf047

5 files changed

Lines changed: 15 additions & 40 deletions

File tree

app/src/main/java/com/getcode/ui/components/chat/ChatNode.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.getcode.ui.components.chat
22

3-
import androidx.compose.animation.AnimatedVisibility
43
import androidx.compose.foundation.clickable
54
import androidx.compose.foundation.layout.Arrangement
65
import androidx.compose.foundation.layout.Column
@@ -20,21 +19,14 @@ import androidx.compose.ui.graphics.Color
2019
import androidx.compose.ui.platform.LocalContext
2120
import androidx.compose.ui.text.style.TextOverflow
2221
import com.getcode.BuildConfig
23-
import com.getcode.LocalCurrencyUtils
2422
import com.getcode.model.Chat
25-
import com.getcode.model.Currency
26-
import com.getcode.model.GenericAmount
2723
import com.getcode.model.MessageContent
2824
import com.getcode.model.Title
29-
import com.getcode.model.Verb
3025
import com.getcode.theme.BrandLight
3126
import com.getcode.theme.CodeTheme
32-
import com.getcode.util.DateUtils
33-
import com.getcode.util.Kin
34-
import com.getcode.util.formatted
35-
import com.getcode.utils.FormatUtils
3627
import com.getcode.ui.components.Badge
3728
import com.getcode.ui.components.chat.utils.localizedText
29+
import com.getcode.util.DateUtils
3830
import java.util.Locale
3931

4032
object ChatNodeDefaults {

app/src/main/java/com/getcode/util/DateUtils.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import androidx.compose.runtime.Composable
66
import androidx.compose.ui.platform.LocalContext
77
import kotlinx.datetime.Clock
88
import kotlinx.datetime.Instant
9-
import kotlinx.datetime.TimeZone
10-
import kotlinx.datetime.daysUntil
11-
import timber.log.Timber
12-
import java.util.*
13-
import kotlin.math.abs
9+
import java.util.Calendar
10+
import java.util.Locale
1411
import kotlin.time.Duration.Companion.days
1512

1613
object DateUtils {

app/src/main/java/com/getcode/view/main/currency/CurrencySelectionSheet.kt

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun CurrencySelectionSheet(
149149
modifier = Modifier
150150
.fillMaxWidth()
151151
.background(Brand)
152-
.wrapContentHeight()
152+
.weight(1f)
153153
) {
154154
if (state.loading) {
155155
item {
@@ -172,13 +172,6 @@ fun CurrencySelectionSheet(
172172
.fillMaxWidth()
173173
.height(if (listItem !is CurrencyListItem.TitleItem) 70.dp else 60.dp)
174174
) {
175-
Divider(
176-
color = White05,
177-
modifier = Modifier
178-
.fillMaxWidth()
179-
.height(1.dp)
180-
.align(Alignment.BottomCenter)
181-
)
182175

183176
when (listItem) {
184177
is CurrencyListItem.TitleItem -> {
@@ -203,18 +196,13 @@ fun CurrencySelectionSheet(
203196
mutableStateOf(false)
204197
}
205198

206-
var height by remember {
207-
mutableStateOf(0.dp)
208-
}
209-
210-
val animatedHeight by animateDpAsState(targetValue = if (!isSwipedAway) height else 0.dp)
199+
val animatedHeight by animateDpAsState(
200+
targetValue = if (!isSwipedAway) 70.dp else 0.dp,
201+
label = "height animation"
202+
)
211203

212204
SwipeableView(
213-
modifier = Modifier.measured {
214-
if (height == 0.dp) {
215-
height = it.height
216-
}
217-
}.addIf(height != 0.dp) { Modifier.height(animatedHeight) },
205+
modifier = Modifier.height(animatedHeight),
218206
isSwipeEnabled = listItem.isRecent,
219207
leftSwiped = {
220208
isSwipedAway = true
@@ -247,14 +235,6 @@ fun CurrencySelectionSheet(
247235
)
248236
)
249237
}
250-
251-
Divider(
252-
color = White05,
253-
modifier = Modifier
254-
.fillMaxWidth()
255-
.height(1.dp)
256-
.align(Alignment.BottomCenter)
257-
)
258238
}
259239
}
260240
}

app/src/main/res/values-en-rGB/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@
247247
<string name="sdk_payments_insufficient_funds_description">Please get more Kin and then try paying again.</string>
248248
<string name="button_get_more_kin">Get More Kin</string>
249249

250+
<string name="today">Today</string>
251+
<string name="yesterday">Yesterday</string>
252+
250253
<string name="title_badge_no_connection">No Connection</string>
251254
<string name="subtitle_youHaveInvitesSingular">You Have %d Invite</string>
252255
<string name="withdraw_address_invalid_destination">Invalid destination account</string>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@
290290
<string name="withdraw_address_valid_owner_account">Valid owner account</string>
291291
<string name="withdraw_address_valid_token_account">Valid token account</string>
292292

293+
<string name="today">Today</string>
294+
<string name="yesterday">Yesterday</string>
295+
293296
<string name="beta_bucket_debugger_description">If enabled, you\'ll gain the ability to tap the balance on the Balance screen to inspect individual bucket balances.</string>
294297
<string name="beta_network_connectivity_description">If enabled, a \"No Connection\" badge will show on the scan screen when no internet is detected.</string>
295298
<string name="beta_vibrate_on_scan_description">If enabled, the device will vibrate once to indicate that the camera has registered the code on the bill.</string>

0 commit comments

Comments
 (0)