Skip to content

Commit b9e5356

Browse files
authored
Merge pull request #248 from synonymdev/feat/bitrefill
Bitrefill - Discover and Detail
2 parents fd2728d + 4a835bc commit b9e5356

File tree

11 files changed

+449
-82
lines changed

11 files changed

+449
-82
lines changed

app/src/main/java/to/bitkit/env/Env.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ internal object Env {
121121
return storagePathOf(walletIndex, network.name.lowercase(), "core")
122122
}
123123

124+
fun buildBitrefillUri(
125+
page: String
126+
): String {
127+
return "$BIT_REFILL_URL/$page/$BITREFILL_PARAMS"
128+
}
129+
124130
private fun storagePathOf(walletIndex: Int, network: String, dir: String): String {
125131
require(::appStoragePath.isInitialized) { "App storage path should be 'context.filesDir.absolutePath'." }
126132
val path = Path(appStoragePath, network, "wallet$walletIndex", dir)
@@ -174,7 +180,11 @@ internal object Env {
174180
const val APP_STORE_URL = "https://apps.apple.com/app/bitkit-wallet/id6502440655"
175181
const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=to.bitkit"
176182
const val EXCHANGES_URL = "https://bitcoin.org/en/exchanges#international"
177-
const val BIT_REFILL_URL = "https://www.bitrefill.com/br/en/gift-cards/"
183+
const val BIT_REFILL_URL = "https://embed.bitrefill.com"
184+
private const val BITREFILL_REF = "AL6dyZYt"
185+
private const val BITREFILL_PAYMENT_METHOD = "bitcoin" // Payment method "bitcoin" gives a unified invoice
186+
private const val BITREFILL_APP_NAME = "Bitkit"
187+
private const val BITREFILL_PARAMS = "?ref=${BITREFILL_REF}&paymentMethod=${BITREFILL_PAYMENT_METHOD}&theme=dark&utm_source=${BITREFILL_APP_NAME}"
178188
const val BITKIT_WEBSITE = "https://bitkit.to/"
179189
const val SYNONYM_CONTACT = "https://synonym.to/contact"
180190
const val SYNONYM_MEDIUM = "https://medium.com/synonym-to"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package to.bitkit.models
2+
3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.filled.CardGiftcard
5+
import androidx.compose.material.icons.filled.Checkroom
6+
import androidx.compose.material.icons.filled.DeliveryDining
7+
import androidx.compose.material.icons.filled.DirectionsBoat
8+
import androidx.compose.material.icons.filled.DirectionsCar
9+
import androidx.compose.material.icons.filled.FavoriteBorder
10+
import androidx.compose.material.icons.filled.Flight
11+
import androidx.compose.material.icons.filled.Headphones
12+
import androidx.compose.material.icons.filled.Home
13+
import androidx.compose.material.icons.filled.Layers
14+
import androidx.compose.material.icons.filled.Pets
15+
import androidx.compose.material.icons.filled.Phone
16+
import androidx.compose.material.icons.filled.Print
17+
import androidx.compose.material.icons.filled.Public
18+
import androidx.compose.material.icons.filled.Restaurant
19+
import androidx.compose.material.icons.filled.ShoppingBag
20+
import androidx.compose.material.icons.filled.ShoppingCart
21+
import androidx.compose.material.icons.filled.Storefront
22+
import androidx.compose.material.icons.filled.Videocam
23+
import androidx.compose.material.icons.filled.VideogameAsset
24+
import androidx.compose.ui.graphics.vector.ImageVector
25+
26+
/**
27+
* Represents the categories for purchases.
28+
*
29+
* @property title The display name of the category.
30+
* @property route The navigation route associated with the category.
31+
* @property icon The visual icon for the category.
32+
*/
33+
enum class BitrefillCategory(
34+
val title: String,
35+
val route: String,
36+
val icon: ImageVector
37+
) {
38+
APPAREL("Apparel", "buy/apparel", Icons.Filled.Checkroom),
39+
AUTOMOBILES("Automobiles", "buy/automobiles", Icons.Filled.DirectionsCar),
40+
CRUISES("Cruises", "buy/cruises", Icons.Filled.DirectionsBoat),
41+
ECOMMERCE("Ecommerce", "buy/ecommerce", Icons.Filled.ShoppingCart),
42+
ELECTRONICS("Electronics", "buy/electronics", Icons.Filled.Print),
43+
ENTERTAINMENT("Entertainment", "buy/entertainment", Icons.Filled.Headphones),
44+
EXPERIENCES("Experiences", "buy/experiences", Icons.Filled.Public),
45+
FLIGHTS("Flights", "buy/flights", Icons.Filled.Flight),
46+
FOOD("Food", "buy/food", Icons.Filled.Storefront),
47+
FOOD_DELIVERY("Food Delivery", "buy/food-delivery", Icons.Filled.DeliveryDining),
48+
GAMES("Games", "buy/games", Icons.Filled.VideogameAsset),
49+
GIFTS("Gifts", "buy/gifts", Icons.Filled.CardGiftcard),
50+
GROCERIES("Groceries", "buy/groceries", Icons.Filled.ShoppingBag),
51+
HEALTH_AND_BEAUTY("Health & Beauty", "buy/health-beauty", Icons.Filled.FavoriteBorder),
52+
HOME("Home", "buy/home", Icons.Filled.Home),
53+
MULTI_BRAND("Multi-Brand", "buy/multi-brand", Icons.Filled.Layers),
54+
PETS("Pets", "buy/pets", Icons.Filled.Pets),
55+
RESTAURANTS("Restaurants", "buy/restaurants", Icons.Filled.Restaurant),
56+
RETAIL("Retail", "buy/retail", Icons.Filled.Storefront),
57+
STREAMING("Streaming", "buy/streaming", Icons.Filled.Videocam),
58+
TRAVEL("Travel", "buy/travel", Icons.Filled.Flight),
59+
VOIP("VoIP", "buy/voip", Icons.Filled.Phone)
60+
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import to.bitkit.ui.screens.scanner.QrScanningScreen
4747
import to.bitkit.ui.screens.scanner.SCAN_REQUEST_KEY
4848
import to.bitkit.ui.screens.shop.ShopDiscoverScreen
4949
import to.bitkit.ui.screens.shop.ShopIntroScreen
50+
import to.bitkit.ui.screens.shop.ShopWebViewScreen
5051
import to.bitkit.ui.screens.transfer.FundingAdvancedScreen
5152
import to.bitkit.ui.screens.transfer.FundingScreen
5253
import to.bitkit.ui.screens.transfer.LiquidityScreen
@@ -405,7 +406,7 @@ private fun RootNavHost(
405406
home(walletViewModel, appViewModel, activityListViewModel, settingsViewModel, navController)
406407
settings(navController, settingsViewModel)
407408
profile(navController, settingsViewModel)
408-
shop(navController, settingsViewModel)
409+
shop(navController, settingsViewModel, appViewModel)
409410
generalSettings(navController)
410411
advancedSettings(navController)
411412
aboutSettings(navController)
@@ -706,6 +707,7 @@ private fun NavGraphBuilder.profile(
706707
private fun NavGraphBuilder.shop(
707708
navController: NavHostController,
708709
settingsViewModel: SettingsViewModel,
710+
appViewModel: AppViewModel,
709711
) {
710712
composableWithDefaultTransitions<Routes.ShopIntro> {
711713
ShopIntroScreen(
@@ -719,6 +721,21 @@ private fun NavGraphBuilder.shop(
719721
composableWithDefaultTransitions<Routes.ShopDiscover> {
720722
ShopDiscoverScreen(
721723
onClose = { navController.navigateToHome() },
724+
onBack = { navController.popBackStack() },
725+
navigateWebView = { page, title ->
726+
navController.navigate(Routes.ShopWebView(page = page, title = title))
727+
}
728+
)
729+
}
730+
composableWithDefaultTransitions<Routes.ShopWebView> { navBackEntry ->
731+
ShopWebViewScreen (
732+
onClose = { navController.navigateToHome() },
733+
onBack = { navController.popBackStack() },
734+
page = navBackEntry.toRoute<Routes.ShopWebView>().page,
735+
title = navBackEntry.toRoute<Routes.ShopWebView>().title,
736+
onPaymentIntent = { data ->
737+
appViewModel.onScanSuccess(data)
738+
}
722739
)
723740
}
724741
}
@@ -1589,6 +1606,9 @@ sealed interface Routes {
15891606
@Serializable
15901607
data object ShopDiscover : Routes
15911608

1609+
@Serializable
1610+
data class ShopWebView(val page: String, val title: String) : Routes
1611+
15921612
@Serializable
15931613
data object WidgetsIntro : Routes
15941614

app/src/main/java/to/bitkit/ui/components/SuggestionCard.kt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.runtime.Composable
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.draw.clip
1818
import androidx.compose.ui.graphics.Color
19+
import androidx.compose.ui.layout.ContentScale
1920
import androidx.compose.ui.res.painterResource
2021
import androidx.compose.ui.res.stringResource
2122
import androidx.compose.ui.text.AnnotatedString
@@ -34,12 +35,14 @@ fun SuggestionCard(
3435
title: String,
3536
description: String,
3637
@DrawableRes icon: Int,
37-
onClose: () -> Unit,
38+
onClose: (() -> Unit)? = null,
39+
size: Int = 152,
40+
captionColor: Color = Colors.White64,
3841
onClick: () -> Unit,
3942
) {
4043
Box(
4144
modifier = modifier
42-
.size(152.dp)
45+
.size(size.dp)
4346
.clip(ShapeDefaults.Large)
4447
.gradientBackground(gradientColor.copy(alpha = 0.30f))
4548
.clickableAlpha { onClick() }
@@ -58,18 +61,21 @@ fun SuggestionCard(
5861
Image(
5962
painter = painterResource(icon),
6063
contentDescription = null,
64+
contentScale = ContentScale.FillHeight,
6165
modifier = Modifier.weight(1f)
6266
)
6367

64-
IconButton(
65-
onClick = onClose,
66-
modifier = Modifier.size(16.dp)
67-
) {
68-
Icon(
69-
painter = painterResource(R.drawable.ic_x),
70-
contentDescription = null,
71-
tint = Colors.White,
72-
)
68+
onClose?.let {
69+
IconButton(
70+
onClick = it,
71+
modifier = Modifier.size(16.dp)
72+
) {
73+
Icon(
74+
painter = painterResource(R.drawable.ic_x),
75+
contentDescription = null,
76+
tint = Colors.White,
77+
)
78+
}
7379
}
7480
}
7581

@@ -80,7 +86,7 @@ fun SuggestionCard(
8086

8187
CaptionB(
8288
text = description,
83-
color = Colors.White,
89+
color = captionColor,
8490
)
8591
}
8692
}

0 commit comments

Comments
 (0)