Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/src/main/java/to/bitkit/env/Env.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ internal object Env {
return storagePathOf(walletIndex, network.name.lowercase(), "core")
}

fun buildBitrefillUri(
page: String
): String {
return "$BIT_REFILL_URL/$page/$BITREFILL_PARAMS"
}

private fun storagePathOf(walletIndex: Int, network: String, dir: String): String {
require(::appStoragePath.isInitialized) { "App storage path should be 'context.filesDir.absolutePath'." }
val path = Path(appStoragePath, network, "wallet$walletIndex", dir)
Expand Down Expand Up @@ -174,7 +180,11 @@ internal object Env {
const val APP_STORE_URL = "https://apps.apple.com/app/bitkit-wallet/id6502440655"
const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=to.bitkit"
const val EXCHANGES_URL = "https://bitcoin.org/en/exchanges#international"
const val BIT_REFILL_URL = "https://www.bitrefill.com/br/en/gift-cards/"
const val BIT_REFILL_URL = "https://embed.bitrefill.com"
private const val BITREFILL_REF = "AL6dyZYt"
private const val BITREFILL_PAYMENT_METHOD = "bitcoin" // Payment method "bitcoin" gives a unified invoice
private const val BITREFILL_APP_NAME = "Bitkit"
private const val BITREFILL_PARAMS = "?ref=${BITREFILL_REF}&paymentMethod=${BITREFILL_PAYMENT_METHOD}&theme=dark&utm_source=${BITREFILL_APP_NAME}"
const val BITKIT_WEBSITE = "https://bitkit.to/"
const val SYNONYM_CONTACT = "https://synonym.to/contact"
const val SYNONYM_MEDIUM = "https://medium.com/synonym-to"
Expand Down
60 changes: 60 additions & 0 deletions app/src/main/java/to/bitkit/models/BitrefillCategory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package to.bitkit.models

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CardGiftcard
import androidx.compose.material.icons.filled.Checkroom
import androidx.compose.material.icons.filled.DeliveryDining
import androidx.compose.material.icons.filled.DirectionsBoat
import androidx.compose.material.icons.filled.DirectionsCar
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.Flight
import androidx.compose.material.icons.filled.Headphones
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Layers
import androidx.compose.material.icons.filled.Pets
import androidx.compose.material.icons.filled.Phone
import androidx.compose.material.icons.filled.Print
import androidx.compose.material.icons.filled.Public
import androidx.compose.material.icons.filled.Restaurant
import androidx.compose.material.icons.filled.ShoppingBag
import androidx.compose.material.icons.filled.ShoppingCart
import androidx.compose.material.icons.filled.Storefront
import androidx.compose.material.icons.filled.Videocam
import androidx.compose.material.icons.filled.VideogameAsset
import androidx.compose.ui.graphics.vector.ImageVector

/**
* Represents the categories for purchases.
*
* @property title The display name of the category.
* @property route The navigation route associated with the category.
* @property icon The visual icon for the category.
*/
enum class BitrefillCategory(
val title: String,
val route: String,
val icon: ImageVector
) {
APPAREL("Apparel", "buy/apparel", Icons.Filled.Checkroom),
AUTOMOBILES("Automobiles", "buy/automobiles", Icons.Filled.DirectionsCar),
CRUISES("Cruises", "buy/cruises", Icons.Filled.DirectionsBoat),
ECOMMERCE("Ecommerce", "buy/ecommerce", Icons.Filled.ShoppingCart),
ELECTRONICS("Electronics", "buy/electronics", Icons.Filled.Print),
ENTERTAINMENT("Entertainment", "buy/entertainment", Icons.Filled.Headphones),
EXPERIENCES("Experiences", "buy/experiences", Icons.Filled.Public),
FLIGHTS("Flights", "buy/flights", Icons.Filled.Flight),
FOOD("Food", "buy/food", Icons.Filled.Storefront),
FOOD_DELIVERY("Food Delivery", "buy/food-delivery", Icons.Filled.DeliveryDining),
GAMES("Games", "buy/games", Icons.Filled.VideogameAsset),
GIFTS("Gifts", "buy/gifts", Icons.Filled.CardGiftcard),
GROCERIES("Groceries", "buy/groceries", Icons.Filled.ShoppingBag),
HEALTH_AND_BEAUTY("Health & Beauty", "buy/health-beauty", Icons.Filled.FavoriteBorder),
HOME("Home", "buy/home", Icons.Filled.Home),
MULTI_BRAND("Multi-Brand", "buy/multi-brand", Icons.Filled.Layers),
PETS("Pets", "buy/pets", Icons.Filled.Pets),
RESTAURANTS("Restaurants", "buy/restaurants", Icons.Filled.Restaurant),
RETAIL("Retail", "buy/retail", Icons.Filled.Storefront),
STREAMING("Streaming", "buy/streaming", Icons.Filled.Videocam),
TRAVEL("Travel", "buy/travel", Icons.Filled.Flight),
VOIP("VoIP", "buy/voip", Icons.Filled.Phone)
}
22 changes: 21 additions & 1 deletion app/src/main/java/to/bitkit/ui/ContentView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import to.bitkit.ui.screens.scanner.QrScanningScreen
import to.bitkit.ui.screens.scanner.SCAN_REQUEST_KEY
import to.bitkit.ui.screens.shop.ShopDiscoverScreen
import to.bitkit.ui.screens.shop.ShopIntroScreen
import to.bitkit.ui.screens.shop.ShopWebViewScreen
import to.bitkit.ui.screens.transfer.FundingAdvancedScreen
import to.bitkit.ui.screens.transfer.FundingScreen
import to.bitkit.ui.screens.transfer.LiquidityScreen
Expand Down Expand Up @@ -405,7 +406,7 @@ private fun RootNavHost(
home(walletViewModel, appViewModel, activityListViewModel, settingsViewModel, navController)
settings(navController, settingsViewModel)
profile(navController, settingsViewModel)
shop(navController, settingsViewModel)
shop(navController, settingsViewModel, appViewModel)
generalSettings(navController)
advancedSettings(navController)
aboutSettings(navController)
Expand Down Expand Up @@ -706,6 +707,7 @@ private fun NavGraphBuilder.profile(
private fun NavGraphBuilder.shop(
navController: NavHostController,
settingsViewModel: SettingsViewModel,
appViewModel: AppViewModel,
) {
composableWithDefaultTransitions<Routes.ShopIntro> {
ShopIntroScreen(
Expand All @@ -719,6 +721,21 @@ private fun NavGraphBuilder.shop(
composableWithDefaultTransitions<Routes.ShopDiscover> {
ShopDiscoverScreen(
onClose = { navController.navigateToHome() },
onBack = { navController.popBackStack() },
navigateWebView = { page, title ->
navController.navigate(Routes.ShopWebView(page = page, title = title))
}
)
}
composableWithDefaultTransitions<Routes.ShopWebView> { navBackEntry ->
ShopWebViewScreen (
onClose = { navController.navigateToHome() },
onBack = { navController.popBackStack() },
page = navBackEntry.toRoute<Routes.ShopWebView>().page,
title = navBackEntry.toRoute<Routes.ShopWebView>().title,
onPaymentIntent = { data ->
appViewModel.onScanSuccess(data)
}
)
}
}
Expand Down Expand Up @@ -1589,6 +1606,9 @@ sealed interface Routes {
@Serializable
data object ShopDiscover : Routes

@Serializable
data class ShopWebView(val page: String, val title: String) : Routes

@Serializable
data object WidgetsIntro : Routes

Expand Down
30 changes: 18 additions & 12 deletions app/src/main/java/to/bitkit/ui/components/SuggestionCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
Expand All @@ -34,12 +35,14 @@ fun SuggestionCard(
title: String,
description: String,
@DrawableRes icon: Int,
onClose: () -> Unit,
onClose: (() -> Unit)? = null,
size: Int = 152,
captionColor: Color = Colors.White64,
onClick: () -> Unit,
) {
Box(
modifier = modifier
.size(152.dp)
.size(size.dp)
.clip(ShapeDefaults.Large)
.gradientBackground(gradientColor.copy(alpha = 0.30f))
.clickableAlpha { onClick() }
Expand All @@ -58,18 +61,21 @@ fun SuggestionCard(
Image(
painter = painterResource(icon),
contentDescription = null,
contentScale = ContentScale.FillHeight,
modifier = Modifier.weight(1f)
)

IconButton(
onClick = onClose,
modifier = Modifier.size(16.dp)
) {
Icon(
painter = painterResource(R.drawable.ic_x),
contentDescription = null,
tint = Colors.White,
)
onClose?.let {
IconButton(
onClick = it,
modifier = Modifier.size(16.dp)
) {
Icon(
painter = painterResource(R.drawable.ic_x),
contentDescription = null,
tint = Colors.White,
)
}
}
}

Expand All @@ -80,7 +86,7 @@ fun SuggestionCard(

CaptionB(
text = description,
color = Colors.White,
color = captionColor,
)
}
}
Expand Down
Loading
Loading