Skip to content

Commit 605e40c

Browse files
authored
Merge pull request #179 from synonymdev/feat/backup-restore-settings
feat: Backup sheet flow UI
2 parents 3765cb4 + 4f72dd3 commit 605e40c

36 files changed

+2151
-650
lines changed

app/src/main/java/to/bitkit/data/SettingsStore.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ data class SettingsData(
8181
val hideBalanceOnOpen: Boolean = false,
8282
val enableAutoReadClipboard: Boolean = false,
8383
val enableSendAmountWarning: Boolean = false,
84+
val backupVerified: Boolean = false,
8485
)

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

Lines changed: 298 additions & 229 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import androidx.compose.ui.layout.ContentScale
1818
import androidx.compose.ui.res.painterResource
1919
import androidx.compose.ui.res.stringResource
2020
import androidx.compose.ui.text.AnnotatedString
21-
import androidx.compose.ui.text.SpanStyle
22-
import androidx.compose.ui.text.font.FontWeight
2321
import androidx.compose.ui.tooling.preview.Preview
2422
import androidx.compose.ui.unit.dp
2523
import to.bitkit.R
@@ -28,6 +26,7 @@ import to.bitkit.ui.scaffold.ScreenColumn
2826
import to.bitkit.ui.theme.AppThemeSurface
2927
import to.bitkit.ui.theme.Colors
3028
import to.bitkit.ui.utils.withAccent
29+
import to.bitkit.ui.utils.withAccentBoldBright
3130

3231
@OptIn(ExperimentalMaterial3Api::class)
3332
@Composable
@@ -94,8 +93,7 @@ private fun Preview() {
9493
InfoScreenContent(
9594
navTitle = stringResource(R.string.lightning__transfer__nav_title),
9695
title = stringResource(R.string.lightning__savings_interrupted__title).withAccent(),
97-
description = stringResource(R.string.lightning__savings_interrupted__text)
98-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
96+
description = stringResource(R.string.lightning__savings_interrupted__text).withAccentBoldBright(),
9997
image = painterResource(R.drawable.check),
10098
buttonText = stringResource(R.string.common__ok),
10199
onButtonClick = {},

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,41 @@ import androidx.compose.foundation.clickable
77
import androidx.compose.foundation.layout.Box
88
import androidx.compose.foundation.layout.ColumnScope
99
import androidx.compose.foundation.layout.fillMaxSize
10+
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
1012
import androidx.compose.material3.BottomSheetScaffold
1113
import androidx.compose.material3.ExperimentalMaterial3Api
1214
import androidx.compose.material3.MaterialTheme
1315
import androidx.compose.material3.SheetState
1416
import androidx.compose.material3.SheetValue
17+
import androidx.compose.material3.Surface
1518
import androidx.compose.material3.rememberBottomSheetScaffoldState
1619
import androidx.compose.material3.rememberModalBottomSheetState
1720
import androidx.compose.runtime.Composable
1821
import androidx.compose.runtime.LaunchedEffect
1922
import androidx.compose.runtime.getValue
2023
import androidx.compose.runtime.rememberCoroutineScope
2124
import androidx.compose.ui.Modifier
25+
import androidx.compose.ui.semantics.contentDescription
26+
import androidx.compose.ui.semantics.semantics
2227
import androidx.compose.ui.unit.dp
2328
import kotlinx.coroutines.launch
2429
import to.bitkit.ui.screens.wallets.send.SendRoute
2530
import to.bitkit.ui.theme.AppShapes
2631
import to.bitkit.ui.theme.Colors
2732

33+
object SheetSize {
34+
const val LARGE = .875f
35+
const val MEDIUM = .755f
36+
const val SMALL = .5f
37+
}
38+
2839
sealed class BottomSheetType {
2940
data class Send(val route: SendRoute = SendRoute.Options) : BottomSheetType()
3041
data object Receive : BottomSheetType()
3142
data object PinSetup : BottomSheetType()
3243
data object Backup : BottomSheetType()
44+
data object BackupNavigation : BottomSheetType()
3345
data object ActivityDateRangeSelector : BottomSheetType()
3446
data object ActivityTagSelector : BottomSheetType()
3547
}
@@ -70,6 +82,7 @@ fun SheetHost(
7082
sheetPeekHeight = 0.dp,
7183
sheetShape = AppShapes.sheet,
7284
sheetContent = sheets,
85+
sheetDragHandle = { SheetDragHandle() },
7386
sheetContainerColor = Colors.Gray6,
7487
sheetContentColor = MaterialTheme.colorScheme.onSurface,
7588
) {
@@ -85,6 +98,21 @@ fun SheetHost(
8598
}
8699
}
87100

101+
@Composable
102+
private fun SheetDragHandle(
103+
modifier: Modifier = Modifier,
104+
) {
105+
Surface(
106+
color = Colors.White32,
107+
shape = MaterialTheme.shapes.extraLarge,
108+
modifier = modifier
109+
.padding(top = 12.dp, bottom = 4.dp)
110+
.semantics { contentDescription = "Drag handle" }
111+
) {
112+
Box(Modifier.size(width = 32.dp, height = 4.dp))
113+
}
114+
}
115+
88116
@Composable
89117
@OptIn(ExperimentalMaterial3Api::class)
90118
private fun Scrim(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ fun Subtitle(
130130
text: String,
131131
modifier: Modifier = Modifier,
132132
color: Color = MaterialTheme.colorScheme.primary,
133+
textAlign: TextAlign = TextAlign.Start,
133134
) {
134135
Text(
135136
text = text,
@@ -139,6 +140,7 @@ fun Subtitle(
139140
letterSpacing = 0.4.sp,
140141
fontFamily = InterFontFamily,
141142
color = color,
143+
textAlign = textAlign,
142144
),
143145
modifier = modifier,
144146
)

app/src/main/java/to/bitkit/ui/scaffold/SheetTopBar.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.compose.ui.text.style.TextAlign
2626
import androidx.compose.ui.tooling.preview.Preview
2727
import androidx.compose.ui.unit.dp
2828
import to.bitkit.R
29+
import to.bitkit.ui.components.Subtitle
2930
import to.bitkit.ui.theme.AppThemeSurface
3031

3132
@Composable
@@ -40,15 +41,13 @@ fun SheetTopBar(
4041
.fillMaxWidth()
4142
.height(42.dp)
4243
) {
43-
Text(
44+
Subtitle(
4445
text = titleText,
45-
style = MaterialTheme.typography.titleMedium,
46-
fontWeight = FontWeight.ExtraBold,
4746
textAlign = TextAlign.Center,
4847
modifier = Modifier
4948
.fillMaxWidth()
5049
.padding(horizontal = 24.dp)
51-
.align(Alignment.Center),
50+
.align(Alignment.Center)
5251
)
5352

5453
onBack?.let { callback ->

app/src/main/java/to/bitkit/ui/screens/transfer/SavingsAvailabilityScreen.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import androidx.compose.ui.Modifier
1616
import androidx.compose.ui.layout.ContentScale
1717
import androidx.compose.ui.res.painterResource
1818
import androidx.compose.ui.res.stringResource
19-
import androidx.compose.ui.text.SpanStyle
20-
import androidx.compose.ui.text.font.FontWeight
2119
import androidx.compose.ui.tooling.preview.Preview
2220
import androidx.compose.ui.unit.dp
2321
import to.bitkit.R
@@ -30,6 +28,7 @@ import to.bitkit.ui.scaffold.ScreenColumn
3028
import to.bitkit.ui.theme.AppThemeSurface
3129
import to.bitkit.ui.theme.Colors
3230
import to.bitkit.ui.utils.withAccent
31+
import to.bitkit.ui.utils.withAccentBoldBright
3332

3433
@Composable
3534
fun SavingsAvailabilityScreen(
@@ -51,8 +50,7 @@ fun SavingsAvailabilityScreen(
5150
Display(text = stringResource(R.string.lightning__availability__title).withAccent())
5251
Spacer(modifier = Modifier.height(8.dp))
5352
BodyM(
54-
text = stringResource(R.string.lightning__availability__text)
55-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
53+
text = stringResource(R.string.lightning__availability__text).withAccentBoldBright(),
5654
color = Colors.White64,
5755
)
5856

app/src/main/java/to/bitkit/ui/screens/transfer/SavingsProgressScreen.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import androidx.compose.ui.Modifier
2424
import androidx.compose.ui.layout.ContentScale
2525
import androidx.compose.ui.res.painterResource
2626
import androidx.compose.ui.res.stringResource
27-
import androidx.compose.ui.text.SpanStyle
28-
import androidx.compose.ui.text.font.FontWeight
2927
import androidx.compose.ui.tooling.preview.Preview
3028
import androidx.compose.ui.unit.dp
3129
import kotlinx.coroutines.delay
@@ -42,6 +40,7 @@ import to.bitkit.ui.theme.Colors
4240
import to.bitkit.ui.transferViewModel
4341
import to.bitkit.ui.utils.removeAccentTags
4442
import to.bitkit.ui.utils.withAccent
43+
import to.bitkit.ui.utils.withAccentBoldBright
4544
import to.bitkit.ui.walletViewModel
4645

4746
enum class SavingsProgressState { PROGRESS, SUCCESS, INTERRUPTED }
@@ -128,8 +127,7 @@ private fun SavingsProgressScreen(
128127
)
129128
Spacer(modifier = Modifier.height(8.dp))
130129
BodyM(
131-
text = stringResource(R.string.lightning__savings_progress__text)
132-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
130+
text = stringResource(R.string.lightning__savings_progress__text).withAccentBoldBright(),
133131
color = Colors.White64,
134132
)
135133
}
@@ -147,8 +145,7 @@ private fun SavingsProgressScreen(
147145
Display(text = stringResource(R.string.lightning__savings_interrupted__title).withAccent())
148146
Spacer(modifier = Modifier.height(8.dp))
149147
BodyM(
150-
text = stringResource(R.string.lightning__savings_interrupted__text)
151-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
148+
text = stringResource(R.string.lightning__savings_interrupted__text).withAccentBoldBright(),
152149
color = Colors.White64,
153150
)
154151
}

app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import androidx.compose.ui.Modifier
2020
import androidx.compose.ui.layout.ContentScale
2121
import androidx.compose.ui.res.painterResource
2222
import androidx.compose.ui.res.stringResource
23-
import androidx.compose.ui.text.SpanStyle
24-
import androidx.compose.ui.text.font.FontWeight
2523
import androidx.compose.ui.tooling.preview.Preview
2624
import androidx.compose.ui.unit.dp
2725
import kotlinx.coroutines.delay
@@ -41,6 +39,7 @@ import to.bitkit.ui.theme.AppThemeSurface
4139
import to.bitkit.ui.theme.Colors
4240
import to.bitkit.ui.utils.localizedRandom
4341
import to.bitkit.ui.utils.withAccent
42+
import to.bitkit.ui.utils.withAccentBoldBright
4443
import to.bitkit.utils.Logger
4544
import to.bitkit.viewmodels.TransferViewModel
4645
import uniffi.bitkitcore.regtestMine
@@ -122,8 +121,7 @@ private fun SettingUpScreen(
122121
)
123122
Spacer(modifier = Modifier.height(8.dp))
124123
BodyM(
125-
text = stringResource(R.string.lightning__setting_up_text)
126-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
124+
text = stringResource(R.string.lightning__setting_up_text).withAccentBoldBright(),
127125
color = Colors.White64,
128126
)
129127
} else {

app/src/main/java/to/bitkit/ui/screens/transfer/external/ExternalSuccessScreen.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package to.bitkit.ui.screens.transfer.external
33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.res.painterResource
55
import androidx.compose.ui.res.stringResource
6-
import androidx.compose.ui.text.SpanStyle
7-
import androidx.compose.ui.text.font.FontWeight
86
import androidx.compose.ui.tooling.preview.Preview
97
import to.bitkit.R
108
import to.bitkit.ui.components.InfoScreenContent
119
import to.bitkit.ui.theme.AppThemeSurface
1210
import to.bitkit.ui.theme.Colors
1311
import to.bitkit.ui.utils.localizedRandom
1412
import to.bitkit.ui.utils.withAccent
13+
import to.bitkit.ui.utils.withAccentBoldBright
1514

1615
@Composable
1716
fun ExternalSuccessScreen(
@@ -21,8 +20,7 @@ fun ExternalSuccessScreen(
2120
InfoScreenContent(
2221
navTitle = stringResource(R.string.lightning__external__nav_title),
2322
title = stringResource(R.string.lightning__external_success__title).withAccent(accentColor = Colors.Purple),
24-
description = stringResource(R.string.lightning__external_success__text)
25-
.withAccent(accentStyle = SpanStyle(color = Colors.White, fontWeight = FontWeight.Bold)),
23+
description = stringResource(R.string.lightning__external_success__text).withAccentBoldBright(),
2624
image = painterResource(R.drawable.switch_box),
2725
buttonText = localizedRandom(R.string.common__ok_random),
2826
onButtonClick = onContinue,

0 commit comments

Comments
 (0)