Skip to content
Open
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
6 changes: 5 additions & 1 deletion app/src/main/java/to/bitkit/ui/ContentView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,12 @@ fun ContentView(

TimedSheetType.QUICK_PAY -> {
QuickPayIntroSheet(
onLater = {
Comment thread
ovitrif marked this conversation as resolved.
settingsViewModel.setQuickPayIntroSeen(true)
appViewModel.dismissTimedSheet()
},
onContinue = {
settingsViewModel.setQuickPayIntroSeen(true)
appViewModel.dismissTimedSheet()
navController.navigateTo(Routes.QuickPaySettings)
},
Expand Down Expand Up @@ -1676,7 +1681,6 @@ private fun NavGraphBuilder.generalSettingsSubScreens(
}
BackgroundPaymentsIntroScreen(
onBack = { navController.popBackStack() },
onLater = { navController.popBackStack() },
onEnable = {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
Expand Down
151 changes: 151 additions & 0 deletions app/src/main/java/to/bitkit/ui/components/SheetIntro.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package to.bitkit.ui.components

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import to.bitkit.ui.scaffold.SheetTopBar
import to.bitkit.ui.shared.util.gradientBackground
import to.bitkit.ui.theme.Colors

/** Width fraction used by intro sheet artwork. */
const val SHEET_INTRO_IMAGE_WIDTH_FRACTION = 0.8f

@Composable
@Suppress("LongParameterList")
fun SheetIntro(
navTitle: String,
title: AnnotatedString,
description: AnnotatedString,
@DrawableRes image: Int,
continueText: String,
onContinue: () -> Unit,
modifier: Modifier = Modifier,
continueLoading: Boolean = false,
cancelText: String? = null,
onCancel: (() -> Unit)? = null,
testTag: String = "SheetIntro",
cancelTestTag: String = "${testTag}Cancel",
continueTestTag: String = "${testTag}Continue",
) {
Column(
modifier = modifier
.fillMaxSize()
.gradientBackground()
.navigationBarsPadding()
.testTag(testTag)
) {
SheetTopBar(navTitle)

Column(
modifier = Modifier.padding(horizontal = 32.dp),
) {
Box(
contentAlignment = Alignment.BottomCenter,
modifier = Modifier
.fillMaxWidth()
.weight(1f)
) {
Image(
painter = painterResource(image),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = Modifier
.fillMaxWidth(SHEET_INTRO_IMAGE_WIDTH_FRACTION)
.heightIn(max = 320.dp)
.testTag("${testTag}Image")
)
}

VerticalSpacer(32.dp)
Display(
text = title,
color = Colors.White,
modifier = Modifier.testTag("${testTag}Title")
)
VerticalSpacer(8.dp)
BodyM(
text = description,
color = Colors.White64,
modifier = Modifier.testTag("${testTag}Description")
)
VerticalSpacer(32.dp)

SheetIntroButtons(
continueText = continueText,
onContinue = onContinue,
continueLoading = continueLoading,
cancelText = cancelText,
Comment thread
pwltr marked this conversation as resolved.
onCancel = onCancel,
testTag = "${testTag}Buttons",
cancelTestTag = cancelTestTag,
continueTestTag = continueTestTag,
)
VerticalSpacer(16.dp)
}
}
}

@Composable
@Suppress("LongParameterList")
private fun SheetIntroButtons(
continueText: String,
onContinue: () -> Unit,
modifier: Modifier = Modifier,
continueLoading: Boolean = false,
cancelText: String? = null,
onCancel: (() -> Unit)? = null,
testTag: String = "SheetIntroButtons",
cancelTestTag: String = "SheetIntroCancel",
continueTestTag: String = "SheetIntroContinue",
) {
if (cancelText == null || onCancel == null) {
Comment thread
ovitrif marked this conversation as resolved.
PrimaryButton(
text = continueText,
onClick = onContinue,
isLoading = continueLoading,
modifier = modifier.testTag(continueTestTag)
)
return
}

Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = modifier
.fillMaxWidth()
.testTag(testTag)
) {
SecondaryButton(
text = cancelText,
fullWidth = false,
onClick = onCancel,
modifier = Modifier
.weight(1f)
.testTag(cancelTestTag)
)
PrimaryButton(
text = continueText,
fullWidth = false,
onClick = onContinue,
isLoading = continueLoading,
modifier = Modifier
.weight(1f)
.testTag(continueTestTag)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import to.bitkit.ui.components.BodySSB
import to.bitkit.ui.components.BottomSheetPreview
import to.bitkit.ui.components.ButtonSize
import to.bitkit.ui.components.Caption13Up
import to.bitkit.ui.components.MoneySSB
import to.bitkit.ui.components.MoneyCaptionM
import to.bitkit.ui.components.PrimaryButton
import to.bitkit.ui.components.PubkyContactAvatar
import to.bitkit.ui.components.TagButton
Expand Down Expand Up @@ -499,7 +499,7 @@ private fun ActivityDetailContent(
if (isHidden) {
BodySSB(text = UiConstants.HIDE_BALANCE_SHORT)
} else {
MoneySSB(sats = displayAmount.toLong())
MoneyCaptionM(sats = displayAmount.toLong())
}
}
}
Expand Down Expand Up @@ -536,7 +536,7 @@ private fun ActivityDetailContent(
if (isHidden) {
BodySSB(text = UiConstants.HIDE_BALANCE_SHORT)
} else {
MoneySSB(sats = fee.toLong())
MoneyCaptionM(sats = fee.toLong())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package to.bitkit.ui.settings.backgroundPayments

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
Expand All @@ -21,7 +19,6 @@ import to.bitkit.R
import to.bitkit.ui.components.BodyM
import to.bitkit.ui.components.Display
import to.bitkit.ui.components.PrimaryButton
import to.bitkit.ui.components.SecondaryButton
import to.bitkit.ui.components.VerticalSpacer
import to.bitkit.ui.scaffold.AppTopBar
import to.bitkit.ui.scaffold.DrawerNavIcon
Expand All @@ -34,7 +31,6 @@ import to.bitkit.viewmodels.SettingsViewModel
@Composable
fun BackgroundPaymentsIntroScreen(
onBack: () -> Unit,
onLater: () -> Unit,
onEnable: () -> Unit,
modifier: Modifier = Modifier,
settingsViewModel: SettingsViewModel = hiltViewModel(),
Expand All @@ -48,10 +44,6 @@ fun BackgroundPaymentsIntroScreen(
actions = { DrawerNavIcon() },
)
BackgroundPaymentsIntroContent(
onLater = {
settingsViewModel.setBgPaymentsIntroSeen(true)
onLater()
},
onEnable = {
settingsViewModel.setBgPaymentsIntroSeen(true)
onEnable()
Expand All @@ -62,15 +54,14 @@ fun BackgroundPaymentsIntroScreen(

@Composable
fun BackgroundPaymentsIntroContent(
onLater: () -> Unit,
onEnable: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(horizontal = 32.dp)
) {
Image(
painter = painterResource(R.drawable.bell),
painter = painterResource(R.drawable.bell_figure),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = Modifier
Expand All @@ -87,29 +78,11 @@ fun BackgroundPaymentsIntroContent(
VerticalSpacer(8.dp)
BodyM(text = stringResource(R.string.settings__bg__intro_desc), color = Colors.White64)
VerticalSpacer(32.dp)
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
.fillMaxWidth()
.testTag("BackgroundPaymentsIntro-buttons")
) {
SecondaryButton(
text = stringResource(R.string.common__later),
fullWidth = false,
onClick = onLater,
modifier = Modifier
.weight(1f)
.testTag("BackgroundPaymentsIntro-later")
)
PrimaryButton(
text = stringResource(R.string.settings__bg__intro_button),
fullWidth = false,
onClick = onEnable,
modifier = Modifier
.weight(1f)
.testTag("BackgroundPaymentsIntro-enable")
)
}
PrimaryButton(
text = stringResource(R.string.settings__bg__intro_button),
onClick = onEnable,
modifier = Modifier.testTag("BackgroundPaymentsIntro-enable")
)
VerticalSpacer(16.dp)
}
}
Expand All @@ -119,7 +92,6 @@ fun BackgroundPaymentsIntroContent(
private fun Preview() {
AppThemeSurface {
BackgroundPaymentsIntroContent(
onLater = {},
onEnable = {},
)
}
Expand Down
Loading
Loading