11package to.bitkit.ui.screens.wallets.sheets
22
3- import androidx.compose.animation.core.Animatable
4- import androidx.compose.animation.core.LinearEasing
5- import androidx.compose.animation.core.RepeatMode
6- import androidx.compose.animation.core.infiniteRepeatable
7- import androidx.compose.animation.core.tween
83import androidx.compose.foundation.layout.Column
94import androidx.compose.foundation.layout.Spacer
10- import androidx.compose.foundation.layout.fillMaxHeight
11- import androidx.compose.foundation.layout.fillMaxWidth
5+ import androidx.compose.foundation.layout.fillMaxSize
126import androidx.compose.foundation.layout.height
13- import androidx.compose.foundation.layout.offset
147import androidx.compose.foundation.layout.padding
158import androidx.compose.material3.Button
169import androidx.compose.material3.ExperimentalMaterial3Api
@@ -21,24 +14,20 @@ import androidx.compose.material3.Text
2114import androidx.compose.material3.rememberModalBottomSheetState
2215import androidx.compose.runtime.Composable
2316import androidx.compose.runtime.LaunchedEffect
24- import androidx.compose.runtime.remember
2517import androidx.compose.ui.Alignment
2618import androidx.compose.ui.Modifier
27- import androidx.compose.ui.draw.rotate
2819import androidx.compose.ui.res.stringResource
2920import androidx.compose.ui.tooling.preview.Preview
30- import androidx.compose.ui.unit.IntOffset
3121import androidx.compose.ui.unit.dp
32- import kotlinx.coroutines.launch
3322import to.bitkit.R
3423import to.bitkit.models.NewTransactionSheetDetails
3524import to.bitkit.models.NewTransactionSheetDirection
3625import to.bitkit.models.NewTransactionSheetType
37- import to.bitkit.viewmodels.AppViewModel
3826import to.bitkit.ui.shared.moneyString
27+ import to.bitkit.ui.shared.util.gradientBackground
3928import to.bitkit.ui.theme.AppShapes
4029import to.bitkit.ui.theme.AppThemeSurface
41- import kotlin.math.roundToInt
30+ import to.bitkit.viewmodels.AppViewModel
4231
4332@OptIn(ExperimentalMaterial3Api ::class )
4433@Composable
@@ -52,9 +41,7 @@ fun NewTransactionSheet(
5241 sheetState = sheetState,
5342 shape = AppShapes .sheet,
5443 containerColor = MaterialTheme .colorScheme.surface,
55- modifier = Modifier
56- .fillMaxHeight()
57- .padding(top = 100 .dp)
44+ modifier = Modifier .fillMaxSize().gradientBackground()
5845 ) {
5946 NewTransactionSheetView (
6047 details = appViewModel.newTransaction,
@@ -64,6 +51,53 @@ fun NewTransactionSheet(
6451 }
6552}
6653
54+ @OptIn(ExperimentalMaterial3Api ::class )
55+ @Composable
56+ private fun NewTransactionSheetView (
57+ details : NewTransactionSheetDetails ,
58+ sheetState : SheetState ,
59+ onCloseClick : () -> Unit ,
60+ ) {
61+ Column (
62+ horizontalAlignment = Alignment .CenterHorizontally ,
63+ modifier = Modifier
64+ .fillMaxSize()
65+ .padding(16 .dp),
66+ ) {
67+ Text (
68+ text = when (details.type) {
69+ NewTransactionSheetType .LIGHTNING -> when (details.direction) {
70+ NewTransactionSheetDirection .SENT -> " Sent Instant Bitcoin"
71+ else -> " Received Instant Bitcoin"
72+ }
73+
74+ NewTransactionSheetType .ONCHAIN -> when (details.direction) {
75+ NewTransactionSheetDirection .SENT -> " Sent Bitcoin"
76+ else -> " Received Bitcoin"
77+ }
78+ },
79+ style = MaterialTheme .typography.titleMedium,
80+ )
81+
82+ Spacer (modifier = Modifier .height(24 .dp))
83+
84+ Text (
85+ text = moneyString(details.sats),
86+ style = MaterialTheme .typography.titleLarge,
87+ modifier = Modifier .align(Alignment .Start )
88+ )
89+
90+ Spacer (modifier = Modifier .weight(1f ))
91+ Spacer (modifier = Modifier .weight(1f ))
92+
93+ Button (
94+ onClick = onCloseClick,
95+ ) {
96+ Text (stringResource(R .string.close))
97+ }
98+ }
99+ }
100+ /*
67101@OptIn(ExperimentalMaterial3Api::class)
68102@Composable
69103private fun NewTransactionSheetView(
@@ -101,7 +135,6 @@ private fun NewTransactionSheetView(
101135 )
102136
103137 Spacer(modifier = Modifier.weight(1f))
104- ConfettiAnimation (sheetState)
105138 Spacer(modifier = Modifier.weight(1f))
106139
107140 Button(
@@ -110,49 +143,56 @@ private fun NewTransactionSheetView(
110143 Text(stringResource(R.string.close))
111144 }
112145 }
146+ }*/
147+
148+ @OptIn(ExperimentalMaterial3Api ::class )
149+ @Preview(showBackground = true )
150+ @Composable
151+ private fun Preview () {
152+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true )
153+ LaunchedEffect (Unit ) {
154+ sheetState.show()
155+ }
156+
157+ AppThemeSurface {
158+ NewTransactionSheetView (
159+ details = NewTransactionSheetDetails (
160+ type = NewTransactionSheetType .LIGHTNING ,
161+ direction = NewTransactionSheetDirection .SENT ,
162+ sats = 123456789 ,
163+ ),
164+ sheetState,
165+ onCloseClick = {},
166+ )
167+ }
113168}
114169
115170@OptIn(ExperimentalMaterial3Api ::class )
171+ @Preview(showBackground = true )
116172@Composable
117- private fun ConfettiAnimation (sheetState : SheetState ) {
118- val rotateAnim = remember { Animatable (0f ) }
119- val offsetYAnim = remember { Animatable (0f ) }
120-
121- // Confetti Animation
122- LaunchedEffect (sheetState.isVisible) {
123- if (sheetState.isVisible) {
124- launch {
125- rotateAnim.animateTo(
126- targetValue = 360f ,
127- animationSpec = infiniteRepeatable(
128- animation = tween(3_200 , easing = LinearEasing ),
129- repeatMode = RepeatMode .Restart ,
130- )
131- )
132- }
133- launch {
134- offsetYAnim.animateTo(
135- targetValue = 100f ,
136- animationSpec = infiniteRepeatable(
137- animation = tween(10_000 , easing = LinearEasing ),
138- repeatMode = RepeatMode .Reverse ,
139- )
140- )
141- }
142- }
173+ private fun Preview2 () {
174+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true )
175+ LaunchedEffect (Unit ) {
176+ sheetState.show()
177+ }
178+
179+ AppThemeSurface {
180+ NewTransactionSheetView (
181+ details = NewTransactionSheetDetails (
182+ type = NewTransactionSheetType .ONCHAIN ,
183+ direction = NewTransactionSheetDirection .SENT ,
184+ sats = 123456789 ,
185+ ),
186+ sheetState,
187+ onCloseClick = {},
188+ )
143189 }
144- Text (
145- text = " 🎉" ,
146- modifier = Modifier
147- .rotate(rotateAnim.value)
148- .offset { IntOffset (x = 0 , y = offsetYAnim.value.roundToInt()) }
149- )
150190}
151191
152192@OptIn(ExperimentalMaterial3Api ::class )
153193@Preview(showBackground = true )
154194@Composable
155- private fun PreviewNewTransactionSheetView () {
195+ private fun Preview3 () {
156196 val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true )
157197 LaunchedEffect (Unit ) {
158198 sheetState.show()
@@ -170,3 +210,25 @@ private fun PreviewNewTransactionSheetView() {
170210 )
171211 }
172212}
213+
214+ @OptIn(ExperimentalMaterial3Api ::class )
215+ @Preview(showBackground = true )
216+ @Composable
217+ private fun Preview4 () {
218+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true )
219+ LaunchedEffect (Unit ) {
220+ sheetState.show()
221+ }
222+
223+ AppThemeSurface {
224+ NewTransactionSheetView (
225+ details = NewTransactionSheetDetails (
226+ type = NewTransactionSheetType .ONCHAIN ,
227+ direction = NewTransactionSheetDirection .RECEIVED ,
228+ sats = 123456789 ,
229+ ),
230+ sheetState,
231+ onCloseClick = {},
232+ )
233+ }
234+ }
0 commit comments