@@ -62,6 +62,7 @@ import to.bitkit.ui.components.Caption13Up
6262import to.bitkit.ui.components.FillHeight
6363import to.bitkit.ui.components.PrimaryButton
6464import to.bitkit.ui.components.SwipeToConfirm
65+ import to.bitkit.ui.components.SyncNodeView
6566import to.bitkit.ui.components.TagButton
6667import to.bitkit.ui.components.TextInput
6768import to.bitkit.ui.components.VerticalSpacer
@@ -88,6 +89,7 @@ import java.time.Instant
8889fun SendConfirmScreen (
8990 savedStateHandle : SavedStateHandle ,
9091 uiState : SendUiState ,
92+ isNodeRunning : Boolean ,
9193 canGoBack : Boolean ,
9294 onBack : () -> Unit ,
9395 onEvent : (SendEvent ) -> Unit ,
@@ -133,6 +135,7 @@ fun SendConfirmScreen(
133135
134136 Content (
135137 uiState = uiState,
138+ isNodeRunning = isNodeRunning,
136139 isLoading = isLoading,
137140 showBiometrics = showBiometrics,
138141 canGoBack = canGoBack,
@@ -163,6 +166,7 @@ fun SendConfirmScreen(
163166@Composable
164167private fun Content (
165168 uiState : SendUiState ,
169+ isNodeRunning : Boolean ,
166170 isLoading : Boolean ,
167171 showBiometrics : Boolean ,
168172 modifier : Modifier = Modifier ,
@@ -194,47 +198,22 @@ private fun Content(
194198
195199 Spacer (Modifier .height(16 .dp))
196200
197- Column (
198- modifier = Modifier
199- .padding(horizontal = 16 .dp)
200- .fillMaxSize()
201- .verticalScroll(rememberScrollState())
202- ) {
203- BalanceHeaderView (
204- sats = uiState.amount.toLong(),
205- useSwipeToHide = false ,
206- onClick = { onEvent(SendEvent .BackToAmount ) },
201+ if (isNodeRunning) {
202+ ContentRunning (
203+ uiState = uiState,
204+ onEvent = onEvent,
205+ isLoading = isLoading,
206+ onClickAddTag = onClickAddTag,
207+ onClickTag = onClickTag,
208+ onSwipeToConfirm = onSwipeToConfirm,
209+ )
210+ } else {
211+ SyncNodeView (
207212 modifier = Modifier
208213 .fillMaxWidth()
209- .testTag(" ReviewAmount" ),
210- testTag = " ReviewAmount"
211- )
212-
213- Spacer (modifier = Modifier .height(16 .dp))
214-
215- when (uiState.payMethod) {
216- SendMethod .ONCHAIN -> OnChainDescription (uiState = uiState, onEvent = onEvent)
217- SendMethod .LIGHTNING -> LightningDescription (uiState = uiState, onEvent = onEvent)
218- }
219-
220- if (isLnurlPay) {
221- if (uiState.lnurl.data.commentAllowed()) {
222- LnurlCommentSection (uiState, onEvent)
223- }
224- } else {
225- TagsSection (uiState, onClickTag, onClickAddTag)
226- }
227-
228- FillHeight ()
229- VerticalSpacer (16 .dp)
230-
231- SwipeToConfirm (
232- text = stringResource(R .string.wallet__send_swipe),
233- loading = isLoading,
234- confirmed = isLoading,
235- onConfirm = onSwipeToConfirm,
214+ .weight(1f )
215+ .testTag(" sync_node_view" )
236216 )
237- VerticalSpacer (16 .dp)
238217 }
239218 }
240219
@@ -264,6 +243,59 @@ private fun Content(
264243 }
265244}
266245
246+ @Composable
247+ fun ContentRunning (
248+ uiState : SendUiState ,
249+ onEvent : (SendEvent ) -> Unit ,
250+ isLoading : Boolean ,
251+ onClickAddTag : () -> Unit ,
252+ onClickTag : (String ) -> Unit ,
253+ onSwipeToConfirm : () -> Unit ,
254+ ) {
255+ Column (
256+ modifier = Modifier
257+ .padding(horizontal = 16 .dp)
258+ .fillMaxSize()
259+ .verticalScroll(rememberScrollState())
260+ ) {
261+ BalanceHeaderView (
262+ sats = uiState.amount.toLong(),
263+ useSwipeToHide = false ,
264+ onClick = { onEvent(SendEvent .BackToAmount ) },
265+ modifier = Modifier
266+ .fillMaxWidth()
267+ .testTag(" ReviewAmount" ),
268+ testTag = " ReviewAmount"
269+ )
270+
271+ Spacer (modifier = Modifier .height(16 .dp))
272+
273+ when (uiState.payMethod) {
274+ SendMethod .ONCHAIN -> OnChainDescription (uiState = uiState, onEvent = onEvent)
275+ SendMethod .LIGHTNING -> LightningDescription (uiState = uiState, onEvent = onEvent)
276+ }
277+
278+ if (uiState.lnurl is LnurlParams .LnurlPay ) {
279+ if (uiState.lnurl.data.commentAllowed()) {
280+ LnurlCommentSection (uiState, onEvent)
281+ }
282+ } else {
283+ TagsSection (uiState, onClickTag, onClickAddTag)
284+ }
285+
286+ FillHeight ()
287+ VerticalSpacer (16 .dp)
288+
289+ SwipeToConfirm (
290+ text = stringResource(R .string.wallet__send_swipe),
291+ loading = isLoading,
292+ confirmed = isLoading,
293+ onConfirm = onSwipeToConfirm,
294+ )
295+ VerticalSpacer (16 .dp)
296+ }
297+ }
298+
267299@Composable
268300private fun LnurlCommentSection (
269301 uiState : SendUiState ,
@@ -574,6 +606,7 @@ private fun PreviewOnChain() {
574606 fee = SendFee .OnChain (1_234 ),
575607 speed = TransactionSpeed .Medium ,
576608 ),
609+ isNodeRunning = true ,
577610 isLoading = false ,
578611 showBiometrics = false ,
579612 modifier = Modifier .sheetHeight(),
@@ -594,6 +627,7 @@ private fun PreviewOnChainLongFeeSmallScreen() {
594627 fee = SendFee .OnChain (654_321 ),
595628 speed = TransactionSpeed .Custom (12_345u ),
596629 ),
630+ isNodeRunning = true ,
597631 isLoading = false ,
598632 showBiometrics = false ,
599633 modifier = Modifier .sheetHeight(),
@@ -612,6 +646,7 @@ private fun PreviewOnChainFeeLoading() {
612646 selectedTags = listOf (" car" , " house" , " uber" ),
613647 fee = null ,
614648 ),
649+ isNodeRunning = true ,
615650 isLoading = false ,
616651 showBiometrics = false ,
617652 modifier = Modifier .sheetHeight(),
@@ -632,6 +667,7 @@ private fun PreviewLightning() {
632667 selectedTags = emptyList(),
633668 fee = SendFee .Lightning (43 ),
634669 ),
670+ isNodeRunning = true ,
635671 isLoading = false ,
636672 showBiometrics = false ,
637673 modifier = Modifier .sheetHeight(),
@@ -661,6 +697,7 @@ private fun PreviewLnurl() {
661697 ),
662698 ),
663699 ),
700+ isNodeRunning = true ,
664701 isLoading = false ,
665702 showBiometrics = false ,
666703 modifier = Modifier .sheetHeight(),
@@ -676,6 +713,7 @@ private fun PreviewBio() {
676713 BottomSheetPreview {
677714 Content (
678715 uiState = sendUiState(),
716+ isNodeRunning = true ,
679717 isLoading = false ,
680718 showBiometrics = true ,
681719 modifier = Modifier .sheetHeight(),
@@ -693,10 +731,41 @@ private fun PreviewDialog() {
693731 uiState = sendUiState().copy(
694732 showSanityWarningDialog = SanityWarning .VALUE_OVER_100_USD ,
695733 ),
734+ isNodeRunning = true ,
696735 isLoading = false ,
697736 showBiometrics = true ,
698737 modifier = Modifier .sheetHeight(),
699738 )
700739 }
701740 }
702741}
742+
743+ @Preview(showSystemUi = true )
744+ @Composable
745+ private fun PreviewNodeNotRunning () {
746+ AppThemeSurface {
747+ BottomSheetPreview {
748+ Content (
749+ uiState = sendUiState().copy(
750+ payMethod = SendMethod .LIGHTNING ,
751+ lnurl = LnurlParams .LnurlPay (
752+ data = LnurlPayData (
753+ uri = " veryLongLnurlPayUri12345677890123456789012345678901234567890" ,
754+ callback = " " ,
755+ metadataStr = " " ,
756+ commentAllowed = 255u ,
757+ minSendable = 1000u ,
758+ maxSendable = 1000_000u ,
759+ allowsNostr = false ,
760+ nostrPubkey = null ,
761+ ),
762+ ),
763+ ),
764+ isNodeRunning = false ,
765+ isLoading = false ,
766+ showBiometrics = false ,
767+ modifier = Modifier .sheetHeight(),
768+ )
769+ }
770+ }
771+ }
0 commit comments