1+ package com.flipcash.app.deposit.internal
2+
3+ import androidx.compose.foundation.background
4+ import androidx.compose.foundation.border
5+ import androidx.compose.foundation.layout.Row
6+ import androidx.compose.foundation.layout.fillMaxWidth
7+ import androidx.compose.foundation.layout.height
8+ import androidx.compose.foundation.layout.navigationBarsPadding
9+ import androidx.compose.foundation.layout.padding
10+ import androidx.compose.material.Text
11+ import androidx.compose.runtime.Composable
12+ import androidx.compose.runtime.getValue
13+ import androidx.compose.ui.Alignment
14+ import androidx.compose.ui.Modifier
15+ import androidx.compose.ui.draw.clip
16+ import androidx.compose.ui.res.stringResource
17+ import androidx.compose.ui.text.style.TextAlign
18+ import androidx.compose.ui.text.style.TextOverflow
19+ import androidx.lifecycle.compose.collectAsStateWithLifecycle
20+ import com.flipcash.features.deposit.R
21+ import com.getcode.theme.CodeTheme
22+ import com.getcode.theme.White
23+ import com.getcode.theme.White05
24+ import com.getcode.theme.extraSmall
25+ import com.getcode.ui.core.rememberedClickable
26+ import com.getcode.ui.theme.ButtonState
27+ import com.getcode.ui.theme.CodeButton
28+ import com.getcode.ui.theme.CodeScaffold
29+
30+ @Composable
31+ internal fun DepositScreen (viewModel : DepositViewModel ) {
32+ val state by viewModel.stateFlow.collectAsStateWithLifecycle()
33+ DepositScreenContent (state, viewModel::dispatchEvent)
34+ }
35+
36+ @Composable
37+ private fun DepositScreenContent (state : DepositViewModel .State , dispatchEvent : (DepositViewModel .Event ) -> Unit ) {
38+ CodeScaffold (
39+ topBar = {
40+ Text (
41+ modifier = Modifier
42+ .padding(horizontal = CodeTheme .dimens.inset)
43+ .fillMaxWidth(),
44+ text = stringResource(R .string.subtitle_howToDeposit),
45+ color = CodeTheme .colors.textSecondary,
46+ style = CodeTheme .typography.textSmall.copy(textAlign = TextAlign .Center ,),
47+ )
48+ },
49+ bottomBar = {
50+ CodeButton (
51+ modifier = Modifier
52+ .fillMaxWidth()
53+ .navigationBarsPadding()
54+ .padding(horizontal = CodeTheme .dimens.inset)
55+ .padding(bottom = CodeTheme .dimens.grid.x2),
56+ onClick = {
57+ dispatchEvent(DepositViewModel .Event .CopyAddress )
58+ },
59+ text = stringResource(if (state.isCopied) R .string.action_copied else R .string.action_copyAddress),
60+ enabled = ! state.isCopied,
61+ isSuccess = state.isCopied,
62+ buttonState = ButtonState .Filled ,
63+ )
64+ }
65+ ) { padding ->
66+ Row (
67+ modifier = Modifier
68+ .padding(padding)
69+ .padding(horizontal = CodeTheme .dimens.inset)
70+ .padding(vertical = CodeTheme .dimens.grid.x3)
71+ .clip(CodeTheme .shapes.extraSmall)
72+ .border(
73+ width = CodeTheme .dimens.border,
74+ color = CodeTheme .colors.brandLight,
75+ shape = CodeTheme .shapes.extraSmall
76+ )
77+ .fillMaxWidth()
78+ .height(CodeTheme .dimens.grid.x10)
79+ .background(White05 )
80+ .rememberedClickable { dispatchEvent(DepositViewModel .Event .CopyAddress ) }
81+ .padding(CodeTheme .dimens.grid.x2),
82+ ) {
83+ Text (
84+ modifier = Modifier
85+ .align(Alignment .CenterVertically )
86+ .weight(1f )
87+ .padding(top = CodeTheme .dimens.grid.x1),
88+ text = state.depositAddress,
89+ color = White ,
90+ style = CodeTheme .typography.textMedium.copy(textAlign = TextAlign .Center ),
91+ overflow = TextOverflow .MiddleEllipsis ,
92+ maxLines = 1
93+ )
94+ }
95+ }
96+ }
0 commit comments