Skip to content

Commit 4a835bc

Browse files
committed
feat: screen detail title
1 parent bca5dd8 commit 4a835bc

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

app/src/main/java/to/bitkit/ui/ContentView.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,8 @@ private fun NavGraphBuilder.shop(
722722
ShopDiscoverScreen(
723723
onClose = { navController.navigateToHome() },
724724
onBack = { navController.popBackStack() },
725-
navigateWebView = { page ->
726-
navController.navigate(Routes.ShopWebView(page = page))
725+
navigateWebView = { page, title ->
726+
navController.navigate(Routes.ShopWebView(page = page, title = title))
727727
}
728728
)
729729
}
@@ -732,6 +732,7 @@ private fun NavGraphBuilder.shop(
732732
onClose = { navController.navigateToHome() },
733733
onBack = { navController.popBackStack() },
734734
page = navBackEntry.toRoute<Routes.ShopWebView>().page,
735+
title = navBackEntry.toRoute<Routes.ShopWebView>().title,
735736
onPaymentIntent = { data ->
736737
appViewModel.onScanSuccess(data)
737738
}
@@ -1606,7 +1607,7 @@ sealed interface Routes {
16061607
data object ShopDiscover : Routes
16071608

16081609
@Serializable
1609-
data class ShopWebView(val page: String) : Routes
1610+
data class ShopWebView(val page: String, val title: String) : Routes
16101611

16111612
@Serializable
16121613
data object WidgetsIntro : Routes

app/src/main/java/to/bitkit/ui/screens/shop/ShopDiscoverScreen.kt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ import to.bitkit.ui.theme.Colors
3838
fun ShopDiscoverScreen(
3939
onClose: () -> Unit,
4040
onBack: () -> Unit,
41-
navigateWebView: (String) -> Unit,
41+
navigateWebView: (String, String) -> Unit, //Page, Title
4242
) {
4343
ScreenColumn(
44-
modifier = Modifier.gradientBackground()
44+
modifier = Modifier.gradientBackground(),
4545
) {
4646
AppTopBar(
4747
titleText = stringResource(R.string.other__shop__discover__nav_title),
@@ -50,37 +50,39 @@ fun ShopDiscoverScreen(
5050
)
5151

5252
LazyColumn(
53-
modifier = Modifier.padding(horizontal = 16.dp)
53+
modifier = Modifier.padding(horizontal = 16.dp),
5454
) {
5555
item {
5656
VerticalSpacer(16.dp)
5757

5858
Row(
5959
horizontalArrangement = Arrangement.spacedBy(16.dp),
6060
) {
61+
val title = stringResource(R.string.other__shop__discover__gift_cards__title)
6162
SuggestionCard(
6263
modifier = Modifier.weight(1f),
6364
gradientColor = Colors.Green,
64-
title = stringResource(R.string.other__shop__discover__gift_cards__title),
65+
title = title,
6566
description = stringResource(R.string.other__shop__discover__gift_cards__description),
6667
icon = R.drawable.gift,
6768
captionColor = Colors.Gray1,
6869
size = 164,
6970
onClick = {
70-
navigateWebView("gift-cards")
71-
}
71+
navigateWebView("gift-cards", title)
72+
},
7273
)
74+
val title2 = stringResource(R.string.other__shop__discover__esims__title)
7375
SuggestionCard(
7476
modifier = Modifier.weight(1f),
7577
gradientColor = Colors.Yellow,
76-
title = stringResource(R.string.other__shop__discover__esims__title),
78+
title = title2,
7779
description = stringResource(R.string.other__shop__discover__esims__description),
7880
icon = R.drawable.globe,
7981
captionColor = Colors.Gray1,
8082
size = 164,
8183
onClick = {
82-
navigateWebView("esims")
83-
}
84+
navigateWebView("esims", title2)
85+
},
8486
)
8587
}
8688

@@ -89,29 +91,31 @@ fun ShopDiscoverScreen(
8991
Row(
9092
horizontalArrangement = Arrangement.spacedBy(16.dp),
9193
) {
94+
val title = stringResource(R.string.other__shop__discover__refill__title)
9295
SuggestionCard(
9396
modifier = Modifier.weight(1f),
9497
gradientColor = Colors.Purple,
95-
title = stringResource(R.string.other__shop__discover__refill__title),
98+
title = title,
9699
description = stringResource(R.string.other__shop__discover__refill__description),
97100
icon = R.drawable.phone,
98101
captionColor = Colors.Gray1,
99102
size = 164,
100103
onClick = {
101-
navigateWebView("refill")
102-
}
104+
navigateWebView("refill", title)
105+
},
103106
)
107+
val title2 = stringResource(R.string.other__shop__discover__travel__title)
104108
SuggestionCard(
105109
modifier = Modifier.weight(1f),
106110
gradientColor = Colors.Red,
107-
title = stringResource(R.string.other__shop__discover__travel__title),
111+
title = title2,
108112
description = stringResource(R.string.other__shop__discover__travel__description),
109113
icon = R.drawable.rocket_2,
110114
size = 164,
111115
captionColor = Colors.Gray1,
112116
onClick = {
113-
navigateWebView("buy/travel")
114-
}
117+
navigateWebView("buy/travel", title2)
118+
},
115119
)
116120
}
117121

@@ -128,28 +132,29 @@ fun ShopDiscoverScreen(
128132
modifier = Modifier
129133
.padding(top = 8.5.dp, bottom = 10.5.dp)
130134
.clickable {
131-
navigateWebView(item.route)
135+
navigateWebView(item.route, item.title)
132136
},
133-
verticalAlignment = Alignment.CenterVertically
137+
verticalAlignment = Alignment.CenterVertically,
134138
) {
135139
Box(
136140
modifier = Modifier
137141
.clip(CircleShape)
138142
.size(32.dp)
139143
.background(Colors.White10),
140-
contentAlignment = Alignment.Center
144+
contentAlignment = Alignment.Center,
141145
) {
142146
Icon(
143147
imageVector = item.icon,
144148
contentDescription = null,
145149
tint = Colors.White64,
146-
modifier = Modifier.size(16.dp)
150+
modifier = Modifier.size(16.dp),
147151
)
148152
}
149153
BodyM(
150-
text = item.title, modifier = Modifier
154+
text = item.title,
155+
modifier = Modifier
151156
.weight(1f)
152-
.padding(horizontal = 8.dp)
157+
.padding(horizontal = 8.dp),
153158
)
154159
Icon(
155160
painter = painterResource(R.drawable.ic_chevron_right),
@@ -169,6 +174,6 @@ fun ShopDiscoverScreen(
169174
@Composable
170175
private fun Preview() {
171176
AppThemeSurface {
172-
ShopDiscoverScreen(onClose = {}, onBack = {}, navigateWebView = {})
177+
ShopDiscoverScreen(onClose = {}, onBack = {}, navigateWebView = { _, _ -> })
173178
}
174179
}

app/src/main/java/to/bitkit/ui/screens/shop/ShopWebViewScreen.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fun ShopWebViewScreen(
4848
onBack: () -> Unit,
4949
onPaymentIntent: (String) -> Unit,
5050
page: String,
51+
title: String,
5152
) {
5253
var isLoading by remember { mutableStateOf(true) }
5354
var webView: WebView? by remember { mutableStateOf(null) }
@@ -81,7 +82,7 @@ fun ShopWebViewScreen(
8182

8283
ScreenColumn {
8384
AppTopBar(
84-
titleText = stringResource(R.string.other__shop__discover__nav_title),
85+
titleText = "${stringResource(R.string.other__shop__discover__nav_title)} $title",
8586
onBackClick = onBack,
8687
actions = { CloseNavIcon(onClick = onClose) },
8788
)
@@ -174,9 +175,9 @@ fun ShopWebViewScreen(
174175
if (it.canGoBack()) {
175176
it.goBack()
176177
} else {
177-
onClose()
178+
onBack()
178179
}
179-
} ?: onClose()
180+
} ?: onBack()
180181
}
181182
}
182183
}
@@ -191,6 +192,7 @@ private fun Preview() {
191192
onPaymentIntent = { uri ->
192193
},
193194
page = "esims",
195+
title = "Gift Cards"
194196
)
195197
}
196198
}

0 commit comments

Comments
 (0)