@@ -13,8 +13,10 @@ import androidx.compose.runtime.Composable
1313import androidx.compose.ui.Alignment
1414import androidx.compose.ui.Modifier
1515import androidx.compose.ui.res.stringResource
16+ import androidx.compose.ui.tooling.preview.Preview
1617import androidx.compose.ui.unit.dp
1718import to.bitkit.R
19+ import to.bitkit.models.NodeLifecycleState
1820import to.bitkit.models.PrimaryDisplay
1921import to.bitkit.ui.LocalBalances
2022import to.bitkit.ui.LocalCurrencies
@@ -23,13 +25,15 @@ import to.bitkit.ui.components.Keyboard
2325import to.bitkit.ui.components.MoneySSB
2426import to.bitkit.ui.components.OutlinedColorButton
2527import to.bitkit.ui.components.PrimaryButton
28+ import to.bitkit.ui.components.SyncNodeView
2629import to.bitkit.ui.components.Text13Up
2730import to.bitkit.ui.components.UnitButton
2831import to.bitkit.ui.scaffold.SheetTopBar
29- import to.bitkit.ui.shared.util.DarkModePreview
32+ import to.bitkit.ui.shared.util.gradientBackground
3033import to.bitkit.ui.theme.AppThemeSurface
3134import to.bitkit.ui.theme.Colors
3235import to.bitkit.viewmodels.CurrencyUiState
36+ import to.bitkit.viewmodels.MainUiState
3337import to.bitkit.viewmodels.SendEvent
3438import to.bitkit.viewmodels.SendMethod
3539import to.bitkit.viewmodels.SendUiState
@@ -38,101 +42,132 @@ import to.bitkit.viewmodels.SendUiState
3842@Composable
3943fun SendAmountScreen (
4044 uiState : SendUiState ,
45+ walletUiState : MainUiState ,
4146 currencyUiState : CurrencyUiState = LocalCurrencies .current,
4247 onBack : () -> Unit ,
4348 onEvent : (SendEvent ) -> Unit ,
4449) {
4550 Column (
46- modifier = Modifier .fillMaxSize()
51+ modifier = Modifier
52+ .fillMaxSize()
53+ .gradientBackground()
4754 ) {
4855 SheetTopBar (stringResource(R .string.title_send_amount)) {
4956 onEvent(SendEvent .AmountReset )
5057 onBack()
5158 }
5259
53- Spacer (Modifier .height(16 .dp))
60+ if (walletUiState.nodeLifecycleState is NodeLifecycleState .Running ) {
61+ Spacer (Modifier .height(16 .dp))
5462
55- Column (
56- modifier = Modifier .padding(horizontal = 16 .dp)
57- ) {
58- BalanceHeaderView (sats = uiState.amountInput.toLong(), modifier = Modifier .fillMaxWidth())
59-
60- Spacer (modifier = Modifier .height(24 .dp))
61-
62- Text13Up (
63- text = stringResource(R .string.wallet__send_available),
64- color = Colors .White64 ,
65- )
66- Spacer (modifier = Modifier .height(4 .dp))
67-
68- Row (
69- verticalAlignment = Alignment .CenterVertically ,
63+ Column (
64+ modifier = Modifier .padding(horizontal = 16 .dp)
7065 ) {
71- val balances = LocalBalances .current
72- val availableAmount = when (uiState.payMethod) {
73- SendMethod .ONCHAIN -> balances.totalOnchainSats.toLong()
74- SendMethod .LIGHTNING -> balances.totalLightningSats.toLong()
75- }
76- MoneySSB (sats = availableAmount.toLong())
66+ BalanceHeaderView (sats = uiState.amountInput.toLong(), modifier = Modifier .fillMaxWidth())
7767
78- Spacer (modifier = Modifier .weight(1f ))
68+ Spacer (modifier = Modifier .height(24 .dp))
69+
70+ Text13Up (
71+ text = stringResource(R .string.wallet__send_available),
72+ color = Colors .White64 ,
73+ )
74+ Spacer (modifier = Modifier .height(4 .dp))
7975
80- OutlinedColorButton (
81- onClick = { onEvent(SendEvent .PaymentMethodSwitch ) },
82- enabled = uiState.isUnified,
83- color = when (uiState.payMethod) {
84- SendMethod .ONCHAIN -> Colors .Brand
85- SendMethod .LIGHTNING -> Colors .Purple
86- },
87- modifier = Modifier .height(28 .dp)
76+ Row (
77+ verticalAlignment = Alignment .CenterVertically ,
8878 ) {
89- Text13Up (
90- text = when (uiState.payMethod) {
91- SendMethod .ONCHAIN -> stringResource(R .string.savings)
92- SendMethod .LIGHTNING -> stringResource(R .string.spending)
93- },
79+ val balances = LocalBalances .current
80+ val availableAmount = when (uiState.payMethod) {
81+ SendMethod .ONCHAIN -> balances.totalOnchainSats.toLong()
82+ SendMethod .LIGHTNING -> balances.totalLightningSats.toLong()
83+ }
84+ MoneySSB (sats = availableAmount.toLong())
85+
86+ Spacer (modifier = Modifier .weight(1f ))
87+
88+ OutlinedColorButton (
89+ onClick = { onEvent(SendEvent .PaymentMethodSwitch ) },
90+ enabled = uiState.isUnified,
9491 color = when (uiState.payMethod) {
9592 SendMethod .ONCHAIN -> Colors .Brand
9693 SendMethod .LIGHTNING -> Colors .Purple
97- }
94+ },
95+ modifier = Modifier .height(28 .dp)
96+ ) {
97+ Text13Up (
98+ text = when (uiState.payMethod) {
99+ SendMethod .ONCHAIN -> stringResource(R .string.savings)
100+ SendMethod .LIGHTNING -> stringResource(R .string.spending)
101+ },
102+ color = when (uiState.payMethod) {
103+ SendMethod .ONCHAIN -> Colors .Brand
104+ SendMethod .LIGHTNING -> Colors .Purple
105+ }
106+ )
107+ }
108+ Spacer (modifier = Modifier .width(8 .dp))
109+ UnitButton (
110+ modifier = Modifier .height(28 .dp)
98111 )
99112 }
100- Spacer (modifier = Modifier .width(8 .dp))
101- UnitButton (
102- modifier = Modifier .height(28 .dp)
103- )
104- }
105113
106- Spacer (modifier = Modifier .weight(1f ))
114+ Spacer (modifier = Modifier .weight(1f ))
107115
108- HorizontalDivider (modifier = Modifier .padding(vertical = 24 .dp))
116+ HorizontalDivider (modifier = Modifier .padding(vertical = 24 .dp))
109117
110- Keyboard (
111- onClick = { number -> onEvent(SendEvent .AmountChange (number)) },
112- isDecimal = currencyUiState.primaryDisplay == PrimaryDisplay .FIAT ,
113- modifier = Modifier .fillMaxWidth(),
114- )
118+ Keyboard (
119+ onClick = { number -> onEvent(SendEvent .AmountChange (number)) },
120+ isDecimal = currencyUiState.primaryDisplay == PrimaryDisplay .FIAT ,
121+ modifier = Modifier .fillMaxWidth(),
122+ )
115123
116- Spacer (modifier = Modifier .height(41 .dp))
124+ Spacer (modifier = Modifier .height(41 .dp))
117125
118- PrimaryButton (
119- text = stringResource(R .string.continue_button),
120- enabled = uiState.isAmountInputValid,
121- onClick = { onEvent(SendEvent .AmountContinue (uiState.amountInput)) },
122- )
126+ PrimaryButton (
127+ text = stringResource(R .string.continue_button),
128+ enabled = uiState.isAmountInputValid,
129+ onClick = { onEvent(SendEvent .AmountContinue (uiState.amountInput)) },
130+ )
123131
124- Spacer (modifier = Modifier .height(16 .dp))
132+ Spacer (modifier = Modifier .height(16 .dp))
133+ }
134+ } else {
135+ SyncNodeView (modifier = Modifier
136+ .fillMaxWidth()
137+ .weight(1f ))
125138 }
126139 }
127140}
128141
129- @DarkModePreview
142+ @Preview(showBackground = true )
130143@Composable
131- private fun SendAmountViewPreview () {
144+ private fun Preview1 () {
132145 AppThemeSurface {
133146 SendAmountScreen (
134147 uiState = SendUiState (
135148 payMethod = SendMethod .LIGHTNING ,
149+ amountInput = " 100"
150+ ),
151+ walletUiState = MainUiState (
152+ nodeLifecycleState = NodeLifecycleState .Running
153+ ),
154+ onBack = {},
155+ onEvent = {},
156+ )
157+ }
158+ }
159+
160+ @Preview(showBackground = true )
161+ @Composable
162+ private fun Preview2 () {
163+ AppThemeSurface {
164+ SendAmountScreen (
165+ uiState = SendUiState (
166+ payMethod = SendMethod .LIGHTNING ,
167+ amountInput = " 100"
168+ ),
169+ walletUiState = MainUiState (
170+ nodeLifecycleState = NodeLifecycleState .Initializing
136171 ),
137172 onBack = {},
138173 onEvent = {},
0 commit comments