Skip to content

Commit c5ef9a2

Browse files
authored
Merge pull request #109 from code-payments/fix/amount-area-sizing
Fix/amount area sizing
2 parents 193145a + 22bccbf commit c5ef9a2

12 files changed

Lines changed: 99 additions & 56 deletions

File tree

app/src/main/java/com/getcode/view/components/CodeButton.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ fun CodeButton(
4747
isTextSuccess: Boolean = false,
4848
enabled: Boolean = true,
4949
buttonState: ButtonState = ButtonState.Bordered,
50-
isPaddedVertical: Boolean = true,
5150
textColor: Color = Color.Unspecified,
5251
shape: Shape = CodeTheme.shapes.small,
5352
) {
@@ -80,8 +79,8 @@ fun CodeButton(
8079
),
8180
shape = shape,
8281
contentPadding = ButtonDefaults.ContentPadding.plus(
83-
top = if (isPaddedVertical) CodeTheme.dimens.grid.x3 else 0.dp,
84-
bottom = if (isPaddedVertical) CodeTheme.dimens.grid.x3 else 0.dp,
82+
top = CodeTheme.dimens.grid.x3,
83+
bottom = CodeTheme.dimens.grid.x3,
8584
)
8685
) {
8786
when {

app/src/main/java/com/getcode/view/login/AccessKey.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ fun AccessKey(
190190
text = stringResource(R.string.action_wroteThemDownInstead),
191191
buttonState = ButtonState.Subtle,
192192
enabled = dataState.isEnabled,
193-
isPaddedVertical = false,
194193
)
195194
}
196195
}

app/src/main/java/com/getcode/view/login/NotificationPermission.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ fun NotificationPermission(navigator: CodeNavigator = LocalCodeNavigator.current
9797
},
9898
text = stringResource(R.string.action_notNow),
9999
buttonState = ButtonState.Subtle,
100-
isPaddedVertical = false,
101100
)
102101
}
103102
}

app/src/main/java/com/getcode/view/main/balance/BalanceSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fun BalanceTop(
285285
isLoading = state.historicalTransactionsLoading,
286286
currencyResId = state.currencyFlag,
287287
isClickable = isClickable,
288-
onClick = onClick
288+
onClick = onClick,
289289
)
290290
}
291291

app/src/main/java/com/getcode/view/main/getKin/BuyAndSellKin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ fun BuyAndSellKin(
120120
},
121121
text = stringResource(id = R.string.action_shareVideo),
122122
buttonState = ButtonState.Subtle,
123-
isPaddedVertical = false,
124123
)
125124
}
126125
}

app/src/main/java/com/getcode/view/main/giveKin/AmountArea.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically
1515
import androidx.compose.ui.Modifier
1616
import androidx.compose.ui.graphics.Color
1717
import androidx.compose.ui.res.painterResource
18+
import androidx.compose.ui.text.TextStyle
1819
import androidx.compose.ui.text.style.TextAlign
1920
import androidx.compose.ui.tooling.preview.Preview
21+
import androidx.compose.ui.unit.TextUnit
2022
import com.getcode.LocalNetworkObserver
2123
import com.getcode.R
2224
import com.getcode.theme.Alert
@@ -42,6 +44,7 @@ fun AmountArea(
4244
isClickable: Boolean = true,
4345
isLoading: Boolean = false,
4446
isAnimated: Boolean = false,
47+
textStyle: TextStyle = CodeTheme.typography.h1,
4548
uiModel: AmountAnimatedInputUiModel? = null,
4649
networkState: NetworkState = LocalNetworkObserver.current.state.value,
4750
onClick: () -> Unit = {}
@@ -59,14 +62,16 @@ fun AmountArea(
5962
if (!isAnimated) {
6063
AmountText(
6164
currencyResId = currencyResId,
62-
"${amountPrefix.orEmpty()}$amountText${amountSuffix.orEmpty()}"
65+
amountText = "${amountPrefix.orEmpty()}$amountText${amountSuffix.orEmpty()}",
66+
textStyle = textStyle,
6367
)
6468
} else {
6569
AmountTextAnimated(
6670
uiModel = uiModel,
6771
currencyResId = currencyResId,
6872
amountPrefix = amountPrefix.orEmpty(),
69-
amountSuffix = amountSuffix.orEmpty()
73+
amountSuffix = amountSuffix.orEmpty(),
74+
textStyle = textStyle,
7075
)
7176
}
7277
}

app/src/main/java/com/getcode/view/main/giveKin/AmountText.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.ui.draw.clip
1111
import androidx.compose.ui.draw.drawWithContent
1212
import androidx.compose.ui.res.painterResource
1313
import androidx.compose.ui.text.TextLayoutResult
14+
import androidx.compose.ui.text.TextStyle
1415
import androidx.compose.ui.text.style.TextAlign
1516
import com.getcode.theme.CodeTheme
1617
import com.getcode.theme.White
@@ -19,9 +20,10 @@ import com.getcode.theme.displayLarge
1920
@Composable
2021
fun AmountText(
2122
currencyResId: Int?,
22-
amountText: String
23+
amountText: String,
24+
textStyle: TextStyle = CodeTheme.typography.h1,
2325
) {
24-
val displayLarge = CodeTheme.typography.displayLarge.copy(textAlign = TextAlign.Center)
26+
val displayLarge = textStyle.copy(textAlign = TextAlign.Center)
2527
var scaledTextStyle by remember { mutableStateOf(displayLarge) }
2628
var isReadyToDraw by remember { mutableStateOf(false) }
2729

app/src/main/java/com/getcode/view/main/giveKin/AmountTextAnimated.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.ui.draw.clip
1313
import androidx.compose.ui.graphics.Color
1414
import androidx.compose.ui.platform.LocalDensity
1515
import androidx.compose.ui.res.painterResource
16+
import androidx.compose.ui.text.TextStyle
1617
import androidx.compose.ui.text.font.FontWeight
1718
import androidx.compose.ui.text.style.TextOverflow
1819
import androidx.compose.ui.unit.*
@@ -132,11 +133,12 @@ fun AnimatedPlaceholderDigit(
132133

133134
@ExperimentalAnimationApi
134135
@Composable
135-
fun AmountTextAnimated(
136+
internal fun AmountTextAnimated(
136137
currencyResId: Int?,
137138
amountPrefix: String,
138139
amountSuffix: String,
139140
uiModel: AmountAnimatedInputUiModel?,
141+
textStyle: TextStyle,
140142
) {
141143
uiModel ?: return
142144

@@ -157,10 +159,9 @@ fun AmountTextAnimated(
157159
var firstDigit by remember { mutableStateOf("") }
158160

159161
//Font states
160-
val displayLarge = CodeTheme.typography.displayLarge
161-
var textSize by remember { mutableStateOf(displayLarge.fontSize) }
162+
var textSize by remember { mutableStateOf(textStyle.fontSize) }
162163
val fontDecreasePoints = remember { HashMap<Int, Float>() }
163-
val maxFontSize = displayLarge.fontSize
164+
val maxFontSize = textStyle.fontSize
164165

165166
val commaVisibility = uiModel.amountData.commaVisibility
166167
val amountSplit = uiModel.amountData.amount.split(DECIMAL_SEPARATOR)

app/src/main/java/com/getcode/view/main/giveKin/GiveKinSheet.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.getcode.navigation.screens.HomeResult
2424
import com.getcode.theme.Alert
2525
import com.getcode.theme.BrandLight
2626
import com.getcode.theme.CodeTheme
27+
import com.getcode.theme.displayLarge
2728
import com.getcode.util.showNetworkError
2829
import com.getcode.utils.ErrorUtils
2930
import com.getcode.view.components.ButtonState
@@ -65,6 +66,7 @@ fun GiveKinSheet(
6566
uiModel = dataState.amountAnimatedModel,
6667
isAnimated = true,
6768
networkState = networkState,
69+
textStyle = CodeTheme.typography.displayLarge,
6870
modifier = Modifier
6971
.align(Alignment.Center)
7072
) {

app/src/main/java/com/getcode/view/main/home/HomeScan.kt

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import com.getcode.view.main.home.components.BillManagementOptions
8282
import com.getcode.view.main.home.components.HomeBill
8383
import com.getcode.view.main.home.components.PaymentConfirmation
8484
import com.getcode.view.main.home.components.PermissionsBlockingView
85+
import com.getcode.view.main.home.components.ReceivedKinConfirmation
8586
import kotlinx.coroutines.delay
8687
import kotlinx.coroutines.flow.filterIsInstance
8788
import kotlinx.coroutines.flow.launchIn
@@ -480,46 +481,10 @@ private fun BillContainer(
480481
Box(
481482
contentAlignment = BottomCenter
482483
) {
483-
Column(
484-
modifier = Modifier
485-
.clip(
486-
CodeTheme.shapes.medium.copy(
487-
bottomStart = ZeroCornerSize,
488-
bottomEnd = ZeroCornerSize
489-
)
490-
)
491-
.background(Brand)
492-
.padding(
493-
horizontal = CodeTheme.dimens.inset,
494-
vertical = CodeTheme.dimens.grid.x3
495-
)
496-
.windowInsetsPadding(WindowInsets.navigationBars),
497-
horizontalAlignment = CenterHorizontally
498-
) {
499-
Text(
500-
modifier = Modifier.padding(top = CodeTheme.dimens.grid.x3),
501-
style = CodeTheme.typography.subtitle1.copy(
502-
fontWeight = FontWeight.Bold
503-
),
504-
text = stringResource(id = R.string.subtitle_youReceived)
505-
)
506-
507-
Row {
508-
val bill = updatedState.billState.bill as Bill.Cash
509-
AmountArea(
510-
amountText = bill.amount.formatted(),
511-
currencyResId = bill.amount.rate.currency.flagResId,
512-
isClickable = false
513-
)
514-
515-
}
516-
CodeButton(
517-
modifier = Modifier.fillMaxWidth(),
518-
onClick = { homeViewModel.cancelSend() },
519-
buttonState = ButtonState.Filled,
520-
text = stringResource(id = R.string.action_putInWallet)
521-
)
522-
}
484+
ReceivedKinConfirmation(
485+
bill = updatedState.billState.bill as Bill.Cash,
486+
onClaim = { homeViewModel.cancelSend() }
487+
)
523488
}
524489
}
525490
}

0 commit comments

Comments
 (0)