@@ -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,10 +25,11 @@ 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
@@ -45,98 +48,123 @@ fun SendAmountScreen(
4548 onEvent : (SendEvent ) -> Unit ,
4649) {
4750 Column (
48- modifier = Modifier .fillMaxSize()
51+ modifier = Modifier .fillMaxSize().gradientBackground()
4952 ) {
5053 SheetTopBar (stringResource(R .string.title_send_amount)) {
5154 onEvent(SendEvent .AmountReset )
5255 onBack()
5356 }
5457
55- Spacer (Modifier .height(16 .dp))
58+ if (walletUiState.nodeLifecycleState is NodeLifecycleState .Running ) {
59+ Spacer (Modifier .height(16 .dp))
5660
57- Column (
58- modifier = Modifier .padding(horizontal = 16 .dp)
59- ) {
60- BalanceHeaderView (sats = uiState.amountInput.toLong(), modifier = Modifier .fillMaxWidth())
61-
62- Spacer (modifier = Modifier .height(24 .dp))
63-
64- Text13Up (
65- text = stringResource(R .string.wallet__send_available),
66- color = Colors .White64 ,
67- )
68- Spacer (modifier = Modifier .height(4 .dp))
69-
70- Row (
71- verticalAlignment = Alignment .CenterVertically ,
61+ Column (
62+ modifier = Modifier .padding(horizontal = 16 .dp)
7263 ) {
73- val balances = LocalBalances .current
74- val availableAmount = when (uiState.payMethod) {
75- SendMethod .ONCHAIN -> balances.totalOnchainSats.toLong()
76- SendMethod .LIGHTNING -> balances.totalLightningSats.toLong()
77- }
78- MoneySSB (sats = availableAmount.toLong())
64+ BalanceHeaderView (sats = uiState.amountInput.toLong(), modifier = Modifier .fillMaxWidth())
7965
80- Spacer (modifier = Modifier .weight(1f ))
66+ Spacer (modifier = Modifier .height(24 .dp))
67+
68+ Text13Up (
69+ text = stringResource(R .string.wallet__send_available),
70+ color = Colors .White64 ,
71+ )
72+ Spacer (modifier = Modifier .height(4 .dp))
8173
82- OutlinedColorButton (
83- onClick = { onEvent(SendEvent .PaymentMethodSwitch ) },
84- enabled = uiState.isUnified,
85- color = when (uiState.payMethod) {
86- SendMethod .ONCHAIN -> Colors .Brand
87- SendMethod .LIGHTNING -> Colors .Purple
88- },
89- modifier = Modifier .height(28 .dp)
74+ Row (
75+ verticalAlignment = Alignment .CenterVertically ,
9076 ) {
91- Text13Up (
92- text = when (uiState.payMethod) {
93- SendMethod .ONCHAIN -> stringResource(R .string.savings)
94- SendMethod .LIGHTNING -> stringResource(R .string.spending)
95- },
77+ val balances = LocalBalances .current
78+ val availableAmount = when (uiState.payMethod) {
79+ SendMethod .ONCHAIN -> balances.totalOnchainSats.toLong()
80+ SendMethod .LIGHTNING -> balances.totalLightningSats.toLong()
81+ }
82+ MoneySSB (sats = availableAmount.toLong())
83+
84+ Spacer (modifier = Modifier .weight(1f ))
85+
86+ OutlinedColorButton (
87+ onClick = { onEvent(SendEvent .PaymentMethodSwitch ) },
88+ enabled = uiState.isUnified,
9689 color = when (uiState.payMethod) {
9790 SendMethod .ONCHAIN -> Colors .Brand
9891 SendMethod .LIGHTNING -> Colors .Purple
99- }
92+ },
93+ modifier = Modifier .height(28 .dp)
94+ ) {
95+ Text13Up (
96+ text = when (uiState.payMethod) {
97+ SendMethod .ONCHAIN -> stringResource(R .string.savings)
98+ SendMethod .LIGHTNING -> stringResource(R .string.spending)
99+ },
100+ color = when (uiState.payMethod) {
101+ SendMethod .ONCHAIN -> Colors .Brand
102+ SendMethod .LIGHTNING -> Colors .Purple
103+ }
104+ )
105+ }
106+ Spacer (modifier = Modifier .width(8 .dp))
107+ UnitButton (
108+ modifier = Modifier .height(28 .dp)
100109 )
101110 }
102- Spacer (modifier = Modifier .width(8 .dp))
103- UnitButton (
104- modifier = Modifier .height(28 .dp)
105- )
106- }
107111
108- Spacer (modifier = Modifier .weight(1f ))
112+ Spacer (modifier = Modifier .weight(1f ))
109113
110- HorizontalDivider (modifier = Modifier .padding(vertical = 24 .dp))
114+ HorizontalDivider (modifier = Modifier .padding(vertical = 24 .dp))
111115
112- Keyboard (
113- onClick = { number -> onEvent(SendEvent .AmountChange (number)) },
114- isDecimal = currencyUiState.primaryDisplay == PrimaryDisplay .FIAT ,
115- modifier = Modifier .fillMaxWidth(),
116- )
116+ Keyboard (
117+ onClick = { number -> onEvent(SendEvent .AmountChange (number)) },
118+ isDecimal = currencyUiState.primaryDisplay == PrimaryDisplay .FIAT ,
119+ modifier = Modifier .fillMaxWidth(),
120+ )
117121
118- Spacer (modifier = Modifier .height(41 .dp))
122+ Spacer (modifier = Modifier .height(41 .dp))
119123
120- PrimaryButton (
121- text = stringResource(R .string.continue_button),
122- enabled = uiState.isAmountInputValid,
123- onClick = { onEvent(SendEvent .AmountContinue (uiState.amountInput)) },
124- )
124+ PrimaryButton (
125+ text = stringResource(R .string.continue_button),
126+ enabled = uiState.isAmountInputValid,
127+ onClick = { onEvent(SendEvent .AmountContinue (uiState.amountInput)) },
128+ )
125129
126- Spacer (modifier = Modifier .height(16 .dp))
130+ Spacer (modifier = Modifier .height(16 .dp))
131+ }
132+ } else {
133+ SyncNodeView (modifier = Modifier .fillMaxWidth().weight(1f ))
127134 }
128135 }
129136}
130137
131- @DarkModePreview
138+ @Preview(showBackground = true )
132139@Composable
133- private fun SendAmountViewPreview () {
140+ private fun Preview1 () {
134141 AppThemeSurface {
135142 SendAmountScreen (
136143 uiState = SendUiState (
137144 payMethod = SendMethod .LIGHTNING ,
145+ amountInput = " 100"
146+ ),
147+ walletUiState = MainUiState (
148+ nodeLifecycleState = NodeLifecycleState .Running
149+ ),
150+ onBack = {},
151+ onEvent = {},
152+ )
153+ }
154+ }
155+
156+ @Preview(showBackground = true )
157+ @Composable
158+ private fun Preview2 () {
159+ AppThemeSurface {
160+ SendAmountScreen (
161+ uiState = SendUiState (
162+ payMethod = SendMethod .LIGHTNING ,
163+ amountInput = " 100"
164+ ),
165+ walletUiState = MainUiState (
166+ nodeLifecycleState = NodeLifecycleState .Initializing
138167 ),
139- walletUiState = MainUiState (),
140168 onBack = {},
141169 onEvent = {},
142170 )
0 commit comments