Skip to content

Commit 6d1d09d

Browse files
committed
refactor: extract SendRecipientScreen to screens
1 parent 366d726 commit 6d1d09d

File tree

2 files changed

+136
-125
lines changed

2 files changed

+136
-125
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package to.bitkit.ui.screens.wallets.send
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Spacer
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.foundation.layout.fillMaxWidth
8+
import androidx.compose.foundation.layout.navigationBarsPadding
9+
import androidx.compose.foundation.layout.padding
10+
import androidx.compose.foundation.layout.size
11+
import androidx.compose.material3.Icon
12+
import androidx.compose.runtime.Composable
13+
import androidx.compose.runtime.rememberCoroutineScope
14+
import androidx.compose.ui.Modifier
15+
import androidx.compose.ui.layout.ContentScale
16+
import androidx.compose.ui.res.painterResource
17+
import androidx.compose.ui.res.stringResource
18+
import androidx.compose.ui.tooling.preview.Preview
19+
import androidx.compose.ui.unit.dp
20+
import kotlinx.coroutines.launch
21+
import to.bitkit.R
22+
import to.bitkit.ui.appViewModel
23+
import to.bitkit.ui.components.BottomSheetPreview
24+
import to.bitkit.ui.components.Caption13Up
25+
import to.bitkit.ui.components.RectangleButton
26+
import to.bitkit.ui.components.VerticalSpacer
27+
import to.bitkit.ui.scaffold.SheetTopBar
28+
import to.bitkit.ui.shared.util.gradientBackground
29+
import to.bitkit.ui.theme.AppThemeSurface
30+
import to.bitkit.ui.theme.Colors
31+
import to.bitkit.viewmodels.SendEvent
32+
33+
@Composable
34+
fun SendRecipientScreen(
35+
onEvent: (SendEvent) -> Unit,
36+
) {
37+
val scope = rememberCoroutineScope()
38+
val app = appViewModel
39+
Column(
40+
modifier = Modifier.Companion
41+
.fillMaxSize()
42+
.gradientBackground()
43+
.navigationBarsPadding()
44+
) {
45+
SheetTopBar(titleText = stringResource(R.string.wallet__send_bitcoin))
46+
Column(
47+
modifier = Modifier.padding(horizontal = 16.dp)
48+
) {
49+
VerticalSpacer(32.dp)
50+
Caption13Up(text = stringResource(R.string.wallet__send_to), color = Colors.White64)
51+
VerticalSpacer(16.dp)
52+
53+
RectangleButton(
54+
label = stringResource(R.string.wallet__recipient_contact),
55+
icon = {
56+
Icon(
57+
painter = painterResource(R.drawable.ic_users),
58+
contentDescription = null,
59+
tint = Colors.Brand,
60+
modifier = Modifier.size(28.dp),
61+
)
62+
},
63+
modifier = Modifier.padding(bottom = 4.dp)
64+
) {
65+
scope.launch {
66+
app?.toast(Exception("Coming soon: Contact"))
67+
}
68+
}
69+
70+
RectangleButton(
71+
label = stringResource(R.string.wallet__recipient_invoice),
72+
icon = {
73+
Icon(
74+
painter = painterResource(R.drawable.ic_clipboard_text),
75+
contentDescription = null,
76+
tint = Colors.Brand,
77+
modifier = Modifier.size(28.dp),
78+
)
79+
},
80+
modifier = Modifier.padding(bottom = 4.dp)
81+
) {
82+
onEvent(SendEvent.Paste)
83+
}
84+
85+
RectangleButton(
86+
label = stringResource(R.string.wallet__recipient_manual),
87+
icon = {
88+
Icon(
89+
painter = painterResource(R.drawable.ic_pencil_simple),
90+
contentDescription = null,
91+
tint = Colors.Brand,
92+
modifier = Modifier.size(28.dp),
93+
)
94+
},
95+
modifier = Modifier.padding(bottom = 4.dp)
96+
) {
97+
onEvent(SendEvent.EnterManually)
98+
}
99+
100+
RectangleButton(
101+
label = stringResource(R.string.wallet__recipient_scan),
102+
icon = {
103+
Icon(
104+
painter = painterResource(R.drawable.ic_scan),
105+
contentDescription = null,
106+
tint = Colors.Brand,
107+
modifier = Modifier.size(28.dp),
108+
)
109+
},
110+
) {
111+
onEvent(SendEvent.Scan)
112+
}
113+
Spacer(modifier = Modifier.weight(1f))
114+
115+
Image(
116+
painter = painterResource(R.drawable.coin_stack_logo),
117+
contentDescription = null,
118+
contentScale = ContentScale.Companion.FillWidth,
119+
modifier = Modifier.fillMaxWidth()
120+
)
121+
}
122+
}
123+
}
124+
125+
@Preview(showSystemUi = true)
126+
@Composable
127+
private fun Preview() {
128+
AppThemeSurface {
129+
BottomSheetPreview {
130+
SendRecipientScreen(
131+
onEvent = {},
132+
)
133+
}
134+
}
135+
}

app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt

Lines changed: 1 addition & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
11
package to.bitkit.ui.sheets
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.layout.Column
5-
import androidx.compose.foundation.layout.Spacer
6-
import androidx.compose.foundation.layout.fillMaxSize
74
import androidx.compose.foundation.layout.fillMaxWidth
85
import androidx.compose.foundation.layout.imePadding
9-
import androidx.compose.foundation.layout.navigationBarsPadding
10-
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.foundation.layout.size
12-
import androidx.compose.material3.Icon
136
import androidx.compose.runtime.Composable
147
import androidx.compose.runtime.LaunchedEffect
158
import androidx.compose.runtime.getValue
16-
import androidx.compose.runtime.rememberCoroutineScope
179
import androidx.compose.ui.Modifier
18-
import androidx.compose.ui.layout.ContentScale
19-
import androidx.compose.ui.res.painterResource
20-
import androidx.compose.ui.res.stringResource
21-
import androidx.compose.ui.tooling.preview.Preview
22-
import androidx.compose.ui.unit.dp
2310
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2411
import androidx.navigation.compose.NavHost
2512
import androidx.navigation.compose.rememberNavController
2613
import androidx.navigation.toRoute
27-
import kotlinx.coroutines.launch
2814
import kotlinx.serialization.Serializable
29-
import to.bitkit.R
3015
import to.bitkit.models.NewTransactionSheetDetails
31-
import to.bitkit.ui.appViewModel
32-
import to.bitkit.ui.components.Caption13Up
33-
import to.bitkit.ui.components.RectangleButton
34-
import to.bitkit.ui.components.VerticalSpacer
35-
import to.bitkit.ui.scaffold.SheetTopBar
3616
import to.bitkit.ui.screens.scanner.QrScanningScreen
3717
import to.bitkit.ui.screens.wallets.send.AddTagScreen
3818
import to.bitkit.ui.screens.wallets.send.PIN_CHECK_RESULT_KEY
@@ -43,13 +23,11 @@ import to.bitkit.ui.screens.wallets.send.SendConfirmScreen
4323
import to.bitkit.ui.screens.wallets.send.SendErrorScreen
4424
import to.bitkit.ui.screens.wallets.send.SendPinCheckScreen
4525
import to.bitkit.ui.screens.wallets.send.SendQuickPayScreen
26+
import to.bitkit.ui.screens.wallets.send.SendRecipientScreen
4627
import to.bitkit.ui.screens.wallets.withdraw.WithDrawErrorScreen
4728
import to.bitkit.ui.screens.wallets.withdraw.WithdrawConfirmScreen
4829
import to.bitkit.ui.settings.support.SupportScreen
4930
import to.bitkit.ui.shared.modifiers.sheetHeight
50-
import to.bitkit.ui.shared.util.gradientBackground
51-
import to.bitkit.ui.theme.AppThemeSurface
52-
import to.bitkit.ui.theme.Colors
5331
import to.bitkit.ui.utils.composableWithDefaultTransitions
5432
import to.bitkit.viewmodels.AppViewModel
5533
import to.bitkit.viewmodels.SendEffect
@@ -227,108 +205,6 @@ fun SendSheet(
227205
}
228206
}
229207

230-
@Composable
231-
private fun SendRecipientScreen(
232-
onEvent: (SendEvent) -> Unit,
233-
) {
234-
val scope = rememberCoroutineScope()
235-
val app = appViewModel
236-
Column(
237-
modifier = Modifier
238-
.fillMaxSize()
239-
.gradientBackground()
240-
.navigationBarsPadding()
241-
) {
242-
SheetTopBar(titleText = stringResource(R.string.wallet__send_bitcoin))
243-
Column(
244-
modifier = Modifier.padding(horizontal = 16.dp)
245-
) {
246-
VerticalSpacer(32.dp)
247-
Caption13Up(text = stringResource(R.string.wallet__send_to), color = Colors.White64)
248-
VerticalSpacer(16.dp)
249-
250-
RectangleButton(
251-
label = stringResource(R.string.wallet__recipient_contact),
252-
icon = {
253-
Icon(
254-
painter = painterResource(R.drawable.ic_users),
255-
contentDescription = null,
256-
tint = Colors.Brand,
257-
modifier = Modifier.size(28.dp),
258-
)
259-
},
260-
modifier = Modifier.padding(bottom = 4.dp)
261-
) {
262-
scope.launch {
263-
app?.toast(Exception("Coming soon: Contact"))
264-
}
265-
}
266-
267-
RectangleButton(
268-
label = stringResource(R.string.wallet__recipient_invoice),
269-
icon = {
270-
Icon(
271-
painter = painterResource(R.drawable.ic_clipboard_text),
272-
contentDescription = null,
273-
tint = Colors.Brand,
274-
modifier = Modifier.size(28.dp),
275-
)
276-
},
277-
modifier = Modifier.padding(bottom = 4.dp)
278-
) {
279-
onEvent(SendEvent.Paste)
280-
}
281-
282-
RectangleButton(
283-
label = stringResource(R.string.wallet__recipient_manual),
284-
icon = {
285-
Icon(
286-
painter = painterResource(R.drawable.ic_pencil_simple),
287-
contentDescription = null,
288-
tint = Colors.Brand,
289-
modifier = Modifier.size(28.dp),
290-
)
291-
},
292-
modifier = Modifier.padding(bottom = 4.dp)
293-
) {
294-
onEvent(SendEvent.EnterManually)
295-
}
296-
297-
RectangleButton(
298-
label = stringResource(R.string.wallet__recipient_scan),
299-
icon = {
300-
Icon(
301-
painter = painterResource(R.drawable.ic_scan),
302-
contentDescription = null,
303-
tint = Colors.Brand,
304-
modifier = Modifier.size(28.dp),
305-
)
306-
},
307-
) {
308-
onEvent(SendEvent.Scan)
309-
}
310-
Spacer(modifier = Modifier.weight(1f))
311-
312-
Image(
313-
painter = painterResource(R.drawable.coin_stack_logo),
314-
contentDescription = null,
315-
contentScale = ContentScale.FillWidth,
316-
modifier = Modifier.fillMaxWidth()
317-
)
318-
}
319-
}
320-
}
321-
322-
@Preview(showSystemUi = true)
323-
@Composable
324-
private fun Preview() {
325-
AppThemeSurface {
326-
SendRecipientScreen(
327-
onEvent = {},
328-
)
329-
}
330-
}
331-
332208
sealed interface SendRoute {
333209
@Serializable
334210
data object Recipient : SendRoute

0 commit comments

Comments
 (0)