@@ -9,12 +9,9 @@ import androidx.compose.foundation.layout.fillMaxSize
99import androidx.compose.foundation.layout.fillMaxWidth
1010import androidx.compose.foundation.layout.height
1111import androidx.compose.foundation.layout.padding
12- import androidx.compose.material3.Button
1312import androidx.compose.material3.ExperimentalMaterial3Api
1413import androidx.compose.material3.MaterialTheme
1514import androidx.compose.material3.ModalBottomSheet
16- import androidx.compose.material3.SheetState
17- import androidx.compose.material3.Text
1815import androidx.compose.material3.rememberModalBottomSheetState
1916import androidx.compose.runtime.Composable
2017import androidx.compose.runtime.LaunchedEffect
@@ -33,22 +30,34 @@ import to.bitkit.ui.components.BalanceHeaderView
3330import to.bitkit.ui.components.PrimaryButton
3431import to.bitkit.ui.components.SecondaryButton
3532import to.bitkit.ui.scaffold.SheetTopBar
36- import to.bitkit.ui.shared.moneyString
3733import to.bitkit.ui.shared.util.gradientBackground
3834import to.bitkit.ui.theme.AppShapes
3935import to.bitkit.ui.theme.AppThemeSurface
4036import to.bitkit.viewmodels.AppViewModel
41- import to.bitkit.viewmodels.SendEvent
4237
43- @OptIn(ExperimentalMaterial3Api ::class )
4438@Composable
4539fun NewTransactionSheet (
4640 appViewModel : AppViewModel ,
4741) {
42+
43+ NewTransactionSheet (
44+ onDismissRequest = { appViewModel.hideNewTransactionSheet() },
45+ details = appViewModel.newTransaction,
46+ onCloseClick = { appViewModel.hideNewTransactionSheet() }
47+ )
48+ }
49+
50+ @OptIn(ExperimentalMaterial3Api ::class )
51+ @Composable
52+ fun NewTransactionSheet (
53+ onDismissRequest : () -> Unit ,
54+ details : NewTransactionSheetDetails ,
55+ onCloseClick : () -> Unit
56+ ) {
4857 val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true )
4958
5059 ModalBottomSheet (
51- onDismissRequest = { appViewModel.hideNewTransactionSheet() } ,
60+ onDismissRequest = onDismissRequest ,
5261 sheetState = sheetState,
5362 shape = AppShapes .sheet,
5463 containerColor = MaterialTheme .colorScheme.surface,
@@ -57,19 +66,18 @@ fun NewTransactionSheet(
5766 .gradientBackground()
5867 ) {
5968 NewTransactionSheetView (
60- details = appViewModel.newTransaction ,
61- sheetState = sheetState ,
62- onCloseClick = { appViewModel.hideNewTransactionSheet() }
69+ details = details ,
70+ onCloseClick = onCloseClick ,
71+ onDetailClick = onCloseClick // TODO IMPLEMENT
6372 )
6473 }
6574}
6675
67- @OptIn(ExperimentalMaterial3Api ::class )
6876@Composable
6977private fun NewTransactionSheetView (
7078 details : NewTransactionSheetDetails ,
71- sheetState : SheetState ,
7279 onCloseClick : () -> Unit ,
80+ onDetailClick : () -> Unit ,
7381) {
7482 Column (
7583 horizontalAlignment = Alignment .CenterHorizontally ,
@@ -115,7 +123,7 @@ private fun NewTransactionSheetView(
115123 ) {
116124 SecondaryButton (
117125 text = stringResource(R .string.wallet__send_details),
118- onClick = onCloseClick, // TODO IMPLEMENT
126+ onClick = onDetailClick,
119127 fullWidth = false ,
120128 modifier = Modifier .weight(1f )
121129 )
@@ -136,53 +144,6 @@ private fun NewTransactionSheetView(
136144 Spacer (modifier = Modifier .height(16 .dp))
137145 }
138146}
139- /*
140- @OptIn(ExperimentalMaterial3Api::class)
141- @Composable
142- private fun NewTransactionSheetView(
143- details: NewTransactionSheetDetails,
144- sheetState: SheetState,
145- onCloseClick: () -> Unit,
146- ) {
147- Column(
148- horizontalAlignment = Alignment.CenterHorizontally,
149- modifier = Modifier
150- .fillMaxWidth()
151- .padding(16.dp),
152- ) {
153- Text(
154- text = when (details.type) {
155- NewTransactionSheetType.LIGHTNING -> when (details.direction) {
156- NewTransactionSheetDirection.SENT -> "Sent Instant Bitcoin"
157- else -> "Received Instant Bitcoin"
158- }
159-
160- NewTransactionSheetType.ONCHAIN -> when (details.direction) {
161- NewTransactionSheetDirection.SENT -> "Sent Bitcoin"
162- else -> "Received Bitcoin"
163- }
164- },
165- style = MaterialTheme.typography.titleMedium,
166- )
167-
168- Spacer(modifier = Modifier.height(24.dp))
169-
170- Text(
171- text = moneyString(details.sats),
172- style = MaterialTheme.typography.titleLarge,
173- modifier = Modifier.align(Alignment.Start)
174- )
175-
176- Spacer(modifier = Modifier.weight(1f))
177- Spacer(modifier = Modifier.weight(1f))
178-
179- Button(
180- onClick = onCloseClick,
181- ) {
182- Text(stringResource(R.string.close))
183- }
184- }
185- }*/
186147
187148@OptIn(ExperimentalMaterial3Api ::class )
188149@Preview(showBackground = true )
@@ -200,8 +161,8 @@ private fun Preview() {
200161 direction = NewTransactionSheetDirection .SENT ,
201162 sats = 123456789 ,
202163 ),
203- sheetState,
204164 onCloseClick = {},
165+ onDetailClick = {},
205166 )
206167 }
207168}
@@ -222,8 +183,8 @@ private fun Preview2() {
222183 direction = NewTransactionSheetDirection .SENT ,
223184 sats = 123456789 ,
224185 ),
225- sheetState,
226186 onCloseClick = {},
187+ onDetailClick = {},
227188 )
228189 }
229190}
@@ -244,8 +205,8 @@ private fun Preview3() {
244205 direction = NewTransactionSheetDirection .RECEIVED ,
245206 sats = 123456789 ,
246207 ),
247- sheetState,
248208 onCloseClick = {},
209+ onDetailClick = {},
249210 )
250211 }
251212}
@@ -266,8 +227,8 @@ private fun Preview4() {
266227 direction = NewTransactionSheetDirection .RECEIVED ,
267228 sats = 123456789 ,
268229 ),
269- sheetState,
270230 onCloseClick = {},
231+ onDetailClick = {},
271232 )
272233 }
273234}
0 commit comments