Skip to content

Commit e81a4ff

Browse files
authored
Merge branch 'feat/send-v60' into feat/connection-issues-view
2 parents 46f955f + f92708f commit e81a4ff

25 files changed

Lines changed: 111 additions & 41 deletions

File tree

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendConfirmScreen.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.height
1616
import androidx.compose.foundation.layout.navigationBarsPadding
1717
import androidx.compose.foundation.layout.padding
1818
import androidx.compose.foundation.layout.size
19+
import androidx.compose.foundation.layout.wrapContentHeight
1920
import androidx.compose.foundation.rememberScrollState
2021
import androidx.compose.foundation.verticalScroll
2122
import androidx.compose.material3.CircularProgressIndicator
@@ -264,7 +265,7 @@ private fun Content(
264265
}
265266

266267
@Composable
267-
fun ContentRunning(
268+
private fun ContentRunning(
268269
uiState: SendUiState,
269270
isLoading: Boolean,
270271
modifier: Modifier = Modifier,
@@ -447,7 +448,7 @@ private fun AddTagButton(
447448
.clip(shape)
448449
.drawBehind {
449450
drawRoundRect(
450-
color = Colors.White32,
451+
color = Colors.White64,
451452
style = Stroke(
452453
width = 1.dp.toPx(),
453454
pathEffect = PathEffect.dashPathEffect(floatArrayOf(4f, 4f)),
@@ -509,6 +510,7 @@ private fun OnChainDetails(
509510
overflow = TextOverflow.MiddleEllipsis,
510511
modifier = Modifier
511512
.height(28.dp)
513+
.wrapContentHeight(Alignment.CenterVertically)
512514
.clickableAlpha { onEvent(SendEvent.NavToAddress) }
513515
.testTag("ReviewUri")
514516
)
@@ -628,6 +630,7 @@ private fun LightningDetails(
628630
overflow = TextOverflow.MiddleEllipsis,
629631
modifier = Modifier
630632
.height(28.dp)
633+
.wrapContentHeight(Alignment.CenterVertically)
631634
.clickableAlpha { onEvent(SendEvent.NavToAddress) }
632635
.testTag("ReviewUri")
633636
)
@@ -743,6 +746,7 @@ private fun LnurlPayDetails(
743746
overflow = TextOverflow.MiddleEllipsis,
744747
modifier = Modifier
745748
.height(28.dp)
749+
.wrapContentHeight(Alignment.CenterVertically)
746750
.clickableAlpha { onEvent(SendEvent.NavToAddress) }
747751
.testTag("ReviewUri")
748752
)

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendFeeRateScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fun SendFeeRateScreen(
6767

6868
Content(
6969
uiState = uiState,
70-
isUnified = sendUiState.isUnified,
70+
isUnified = sendUiState.canSwitchWallet,
7171
payMethod = sendUiState.payMethod,
7272
estimatedRoutingFee = sendUiState.estimatedRoutingFee.toLong(),
7373
onBack = onBack,

app/src/main/java/to/bitkit/ui/settings/AdvancedSettingsViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import to.bitkit.repositories.LightningRepo
1717
import javax.inject.Inject
1818

1919
private const val NODE_ID_PREFIX_LENGTH = 5
20-
private const val ELECTRUM_HOST_PREFIX_LENGTH = 10
20+
private const val ELECTRUM_HOST_PREFIX_LENGTH = 5
2121

2222
@HiltViewModel
2323
class AdvancedSettingsViewModel @Inject constructor(
@@ -43,6 +43,7 @@ class AdvancedSettingsViewModel @Inject constructor(
4343
""
4444
} else {
4545
val host = ElectrumServer.parse(it.electrumServer).host
46+
.substringAfter("://")
4647
if (host.length > ELECTRUM_HOST_PREFIX_LENGTH) {
4748
"${host.take(ELECTRUM_HOST_PREFIX_LENGTH)}..."
4849
} else {

app/src/main/java/to/bitkit/ui/settings/pin/PinManagementScreen.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import androidx.compose.foundation.layout.size
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.runtime.LaunchedEffect
1313
import androidx.compose.runtime.getValue
14-
import androidx.compose.runtime.mutableStateOf
1514
import androidx.compose.runtime.remember
16-
import androidx.compose.runtime.setValue
1715
import androidx.compose.ui.Alignment
1816
import androidx.compose.ui.Modifier
1917
import androidx.compose.ui.platform.testTag
@@ -45,13 +43,10 @@ fun PinManagementScreen(
4543
val app = appViewModel ?: return
4644
val settings = settingsViewModel ?: return
4745
val isPinEnabled by settings.isPinEnabled.collectAsStateWithLifecycle()
48-
val currentSheet by app.currentSheet.collectAsStateWithLifecycle()
49-
var pinSheetWasShown by remember { mutableStateOf(false) }
46+
val initialPinState = remember { isPinEnabled }
5047

51-
LaunchedEffect(currentSheet) {
52-
if (currentSheet is Sheet.Pin || currentSheet is Sheet.ChangePin || currentSheet is Sheet.DisablePin) {
53-
pinSheetWasShown = true
54-
} else if (pinSheetWasShown && currentSheet == null) {
48+
LaunchedEffect(isPinEnabled) {
49+
if (isPinEnabled != initialPinState) {
5550
navController.popBackStack()
5651
}
5752
}

app/src/main/java/to/bitkit/ui/settings/support/SupportScreen.kt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ import androidx.compose.foundation.layout.Arrangement
77
import androidx.compose.foundation.layout.Box
88
import androidx.compose.foundation.layout.Column
99
import androidx.compose.foundation.layout.Row
10+
import androidx.compose.foundation.layout.Spacer
11+
import androidx.compose.foundation.layout.WindowInsets
12+
import androidx.compose.foundation.layout.fillMaxSize
1013
import androidx.compose.foundation.layout.fillMaxWidth
1114
import androidx.compose.foundation.layout.height
1215
import androidx.compose.foundation.layout.heightIn
16+
import androidx.compose.foundation.layout.navigationBars
1317
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.statusBarsPadding
19+
import androidx.compose.foundation.layout.windowInsetsBottomHeight
1420
import androidx.compose.foundation.rememberScrollState
1521
import androidx.compose.foundation.verticalScroll
1622
import androidx.compose.material3.HorizontalDivider
23+
import androidx.compose.material3.MaterialTheme
1724
import androidx.compose.runtime.Composable
1825
import androidx.compose.runtime.getValue
1926
import androidx.compose.runtime.mutableIntStateOf
@@ -52,7 +59,6 @@ import to.bitkit.ui.components.settings.SettingsIcon
5259
import to.bitkit.ui.navigateTo
5360
import to.bitkit.ui.scaffold.AppTopBar
5461
import to.bitkit.ui.scaffold.DrawerNavIcon
55-
import to.bitkit.ui.scaffold.ScreenColumn
5662
import to.bitkit.ui.settingsViewModel
5763
import to.bitkit.ui.shared.modifiers.clickableAlpha
5864
import to.bitkit.ui.shared.util.shareText
@@ -137,7 +143,12 @@ private fun Content(
137143
) {
138144
val appVersion = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
139145

140-
ScreenColumn {
146+
Column(
147+
modifier = Modifier
148+
.fillMaxSize()
149+
.background(MaterialTheme.colorScheme.background)
150+
.statusBarsPadding()
151+
) {
141152
AppTopBar(
142153
titleText = stringResource(R.string.settings__support_title),
143154
onBackClick = onBack,
@@ -244,7 +255,7 @@ private fun SupportFooter() {
244255
)
245256
}
246257

247-
// Solid orange background for bottom content
258+
// Solid orange background for bottom content (extends behind nav bar)
248259
Column(
249260
modifier = Modifier
250261
.fillMaxWidth()
@@ -268,6 +279,14 @@ private fun SupportFooter() {
268279

269280
VerticalSpacer(32.dp)
270281
}
282+
283+
// Brand-colored spacer that fills the nav bar inset area
284+
Spacer(
285+
modifier = Modifier
286+
.fillMaxWidth()
287+
.background(Colors.Brand)
288+
.windowInsetsBottomHeight(WindowInsets.navigationBars)
289+
)
271290
}
272291

273292
@Composable

app/src/main/java/to/bitkit/ui/sheets/ChangePinSheet.kt

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ private fun ValidateContent(
186186

187187
VerticalSpacer(32.dp)
188188

189+
FillHeight()
190+
189191
AnimatedVisibility(visible = attemptsRemaining < Env.PIN_ATTEMPTS) {
190192
if (isLastAttempt) {
191193
BodyS(
@@ -208,14 +210,13 @@ private fun ValidateContent(
208210
.testTag("AttemptsRemaining")
209211
)
210212
}
211-
VerticalSpacer(16.dp)
212213
}
213214

214-
FillHeight()
215+
VerticalSpacer(16.dp)
215216

216217
PinDots(pin = pin)
217218

218-
VerticalSpacer(32.dp)
219+
FillHeight()
219220

220221
NumberPad(
221222
onPress = onKeyPress,
@@ -257,7 +258,7 @@ private fun NewPinContent(
257258

258259
PinDots(pin = pin)
259260

260-
VerticalSpacer(32.dp)
261+
FillHeight()
261262

262263
NumberPad(
263264
onPress = onKeyPress,
@@ -297,6 +298,8 @@ private fun ConfirmContent(
297298

298299
VerticalSpacer(32.dp)
299300

301+
FillHeight()
302+
300303
AnimatedVisibility(visible = showError) {
301304
BodyS(
302305
text = stringResource(R.string.security__cp_try_again),
@@ -308,11 +311,11 @@ private fun ConfirmContent(
308311
)
309312
}
310313

311-
FillHeight()
314+
VerticalSpacer(16.dp)
312315

313316
PinDots(pin = pin)
314317

315-
VerticalSpacer(32.dp)
318+
FillHeight()
316319

317320
NumberPad(
318321
onPress = onKeyPress,
@@ -386,6 +389,37 @@ private fun PreviewValidate() {
386389
}
387390
}
388391

392+
@Preview(showSystemUi = true)
393+
@Composable
394+
private fun PreviewValidateError() {
395+
AppThemeSurface {
396+
BottomSheetPreview {
397+
ValidateContent(
398+
pin = "12",
399+
attemptsRemaining = 3,
400+
onKeyPress = {},
401+
onBackClick = {},
402+
onClickForgotPin = {},
403+
)
404+
}
405+
}
406+
}
407+
408+
@Preview(showSystemUi = true)
409+
@Composable
410+
private fun PreviewConfirmError() {
411+
AppThemeSurface {
412+
BottomSheetPreview {
413+
ConfirmContent(
414+
pin = "12",
415+
showError = true,
416+
onKeyPress = {},
417+
onBackClick = {},
418+
)
419+
}
420+
}
421+
}
422+
389423
@Preview(showSystemUi = true)
390424
@Composable
391425
private fun PreviewNew() {

app/src/main/java/to/bitkit/ui/sheets/ForgotPinSheet.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fun ForgotPinSheet(
3535
) {
3636
BottomSheet(onDismissRequest = onDismiss) {
3737
Content(
38+
onBackClick = onDismiss,
3839
onResetClick = {
3940
onDismiss()
4041
onResetClick()
@@ -45,6 +46,7 @@ fun ForgotPinSheet(
4546

4647
@Composable
4748
private fun Content(
49+
onBackClick: (() -> Unit)? = null,
4850
onResetClick: () -> Unit,
4951
modifier: Modifier = Modifier,
5052
) {
@@ -56,7 +58,10 @@ private fun Content(
5658
.gradientBackground()
5759
.padding(horizontal = 16.dp)
5860
) {
59-
SheetTopBar(stringResource(R.string.security__pin_forgot_title))
61+
SheetTopBar(
62+
titleText = stringResource(R.string.security__pin_forgot_title),
63+
onBack = onBackClick,
64+
)
6065
VerticalSpacer(16.dp)
6166

6267
BodyM(
@@ -88,6 +93,7 @@ private fun Preview() {
8893
AppThemeSurface {
8994
BottomSheetPreview {
9095
Content(
96+
onBackClick = {},
9197
onResetClick = {},
9298
)
9399
}

app/src/main/java/to/bitkit/ui/sheets/PinSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fun PinSheet(
4949
onPinChosen = { pin ->
5050
navController.navigateTo(PinRoute.Confirm(pin))
5151
},
52-
onBack = { navController.popBackStack() },
52+
onBack = { if (!navController.popBackStack()) onDismiss() },
5353
)
5454
}
5555
composableWithDefaultTransitions<PinRoute.Confirm> {

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,16 @@ class AppViewModel @Inject constructor(
787787

788788
is SendEvent.CommentChange -> onCommentChange(it.value)
789789

790-
SendEvent.SpeedAndFee -> setSendEffect(SendEffect.NavigateToFee)
790+
SendEvent.SpeedAndFee -> {
791+
if (_sendUiState.value.fees.isEmpty()) {
792+
viewModelScope.launch {
793+
refreshFeeEstimates()
794+
setSendEffect(SendEffect.NavigateToFee)
795+
}
796+
} else {
797+
setSendEffect(SendEffect.NavigateToFee)
798+
}
799+
}
791800
SendEvent.SwipeToPay -> onSwipeToPay()
792801
is SendEvent.ConfirmAmountWarning -> onConfirmAmountWarning(it.warning)
793802
SendEvent.DismissAmountWarning -> onDismissAmountWarning()
@@ -1185,6 +1194,7 @@ class AppViewModel @Inject constructor(
11851194
refreshOnchainSendIfNeeded()
11861195
estimateLightningRoutingFeesIfNeeded()
11871196
_sendUiState.update { it.copy(isLoading = false) }
1197+
updateCanSwitchWallet()
11881198

11891199
setSendEffect(SendEffect.NavigateToConfirm)
11901200
}
@@ -1330,6 +1340,7 @@ class AppViewModel @Inject constructor(
13301340
payMethod = lnInvoice?.let { SendMethod.LIGHTNING } ?: SendMethod.ONCHAIN,
13311341
)
13321342
}
1343+
updateCanSwitchWallet()
13331344

13341345
val lnAmountSats = lnInvoice?.amountSatoshis ?: 0u
13351346
if (lnAmountSats > 0u) {

app/src/main/res/values-ar/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@
945945
<string name="wallet__send_max_spending__title">الرصيد الاحتياطي</string>
946946
<string name="wallet__send_quickpay__nav_title">QuickPay</string>
947947
<string name="wallet__send_quickpay__title">جارٍ دفع\n&lt;accent&gt;الفاتورة...&lt;/accent&gt;</string>
948-
<string name="wallet__send_review">مراجعة وإرسال</string>
948+
<string name="wallet__send_review">تأكيد</string>
949949
<string name="wallet__send_sent">تم إرسال Bitcoin</string>
950950
<string name="wallet__send_swipe">اسحب للدفع</string>
951951
<string name="wallet__send_to">إلى</string>

0 commit comments

Comments
 (0)