Skip to content

Commit 529f14b

Browse files
authored
Add string localization for purchases (#147)
Updated Strings to add missing translations. Also fix UI bug due to missing recomposition.
1 parent 8fc301b commit 529f14b

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ allprojects {
3333
repositories {
3434
google()
3535
mavenCentral()
36-
maven(url = "https://weareplanet.jfrog.io/artifactory/mobile-sdk/")
36+
maven(url = "https://datatrans.jfrog.io/artifactory/mobile-sdk/")
3737
maven(url = "https://jitpack.io")
3838
}
3939

ui-toolkit/src/main/kotlin/io/snabble/sdk/widgets/snabble/purchase/ui/PurchaseWidget.kt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ import androidx.compose.material.ripple.rememberRipple
1515
import androidx.compose.material3.MaterialTheme
1616
import androidx.compose.material3.Text
1717
import androidx.compose.runtime.Composable
18+
import androidx.compose.runtime.getValue
19+
import androidx.compose.runtime.mutableStateOf
1820
import androidx.compose.runtime.remember
1921
import androidx.compose.ui.Alignment
2022
import androidx.compose.ui.Modifier
2123
import androidx.compose.ui.res.painterResource
24+
import androidx.compose.ui.res.stringResource
2225
import androidx.compose.ui.text.style.TextAlign
2326
import androidx.compose.ui.text.style.TextOverflow
2427
import androidx.compose.ui.tooling.preview.Preview
@@ -76,33 +79,37 @@ fun Purchases(
7679
purchaseList: List<Purchase>,
7780
onAction: OnDynamicAction,
7881
) {
82+
val isSinglePurchase: Boolean by remember(key1 = purchaseList.size == 1) { mutableStateOf(purchaseList.size == 1) }
83+
7984
ConstraintLayout(
8085
modifier = Modifier
8186
.fillMaxWidth()
8287
.padding(bottom = model.padding.bottom.dp)
8388
) {
8489
val (title, more, purchases) = createRefs()
90+
val lastPurchasesTitleStringRes = if (isSinglePurchase) {
91+
R.string.Snabble_DynamicView_lastPurchase
92+
} else {
93+
R.string.Snabble_DynamicView_lastPurchases
94+
}
8595
Text(
86-
text = "Previous purchases",
96+
text = stringResource(id = lastPurchasesTitleStringRes),
8797
style = MaterialTheme.typography.titleLarge,
8898
color = MaterialTheme.colorScheme.onSurface,
8999
maxLines = 1,
90100
overflow = TextOverflow.Ellipsis,
91101
modifier = Modifier
92102
.padding(PaddingValues(horizontal = model.padding.start.dp + MaterialTheme.padding.small))
93103
.constrainAs(title) {
94-
linkTo(start = parent.start, end = more.start, bias = 0f)
95-
top.linkTo(parent.top)
96-
width = Dimension.preferredWrapContent
104+
linkTo(start = parent.start, top = parent.top, end = more.start, bottom = purchases.top)
105+
width = Dimension.fillToConstraints
97106
}
98107
)
99108
Box(
100109
contentAlignment = Alignment.Center,
101110
modifier = Modifier
102111
.constrainAs(more) {
103-
end.linkTo(parent.end)
104-
top.linkTo(title.top)
105-
bottom.linkTo(title.bottom)
112+
linkTo(start = title.end, top = title.top, end = parent.end, bottom = title.bottom)
106113
height = Dimension.fillToConstraints
107114
}
108115
.padding(PaddingValues(horizontal = model.padding.start.dp + MaterialTheme.padding.small))
@@ -117,7 +124,7 @@ fun Purchases(
117124
}
118125
) {
119126
Text(
120-
text = "More",
127+
text = stringResource(id = R.string.Snabble_DynamicView_LastPurchases_all),
121128
style = MaterialTheme.typography.titleMedium,
122129
color = MaterialTheme.colorScheme.inversePrimary,
123130
textAlign = TextAlign.Center,
@@ -173,7 +180,12 @@ private fun PurchaseDetail(
173180
.fillMaxWidth()
174181
.padding(PaddingValues(MaterialTheme.padding.medium))
175182
) {
176-
val (icon, amount, title, time) = createRefs()
183+
val (
184+
icon,
185+
amount,
186+
title,
187+
time
188+
) = createRefs()
177189
Image(
178190
painter = painterResource(id = R.drawable.ic_snabble),
179191
contentDescription = "",

0 commit comments

Comments
 (0)