11package to.bitkit.ui.onboarding
22
33import androidx.compose.foundation.background
4- import androidx.compose.foundation.border
5- import androidx.compose.foundation.clickable
64import androidx.compose.foundation.layout.Box
75import androidx.compose.foundation.layout.Column
8- import androidx.compose.foundation.layout.Row
96import androidx.compose.foundation.layout.Spacer
107import androidx.compose.foundation.layout.fillMaxSize
118import androidx.compose.foundation.layout.fillMaxWidth
129import androidx.compose.foundation.layout.height
1310import androidx.compose.foundation.layout.padding
14- import androidx.compose.foundation.layout.size
15- import androidx.compose.foundation.layout.width
1611import androidx.compose.foundation.rememberScrollState
17- import androidx.compose.foundation.shape.RoundedCornerShape
1812import androidx.compose.foundation.verticalScroll
19- import androidx.compose.material.icons.Icons
20- import androidx.compose.material.icons.filled.Check
2113import androidx.compose.material3.HorizontalDivider
22- import androidx.compose.material3.Icon
2314import androidx.compose.material3.MaterialTheme
2415import androidx.compose.material3.Scaffold
2516import androidx.compose.runtime.Composable
26- import androidx.compose.runtime.getValue
27- import androidx.compose.runtime.mutableStateOf
28- import androidx.compose.runtime.saveable.rememberSaveable
29- import androidx.compose.runtime.setValue
3017import androidx.compose.ui.Alignment
3118import androidx.compose.ui.Modifier
3219import androidx.compose.ui.graphics.Brush
@@ -42,6 +29,7 @@ import to.bitkit.ui.components.BodyMSB
4229import to.bitkit.ui.components.BodySSB
4330import to.bitkit.ui.components.Display
4431import to.bitkit.ui.components.PrimaryButton
32+ import to.bitkit.ui.components.VerticalSpacer
4533import to.bitkit.ui.theme.AppThemeSurface
4634import to.bitkit.ui.theme.Colors
4735import to.bitkit.ui.utils.withAccent
@@ -53,8 +41,6 @@ private val horizontalPadding = 32.dp
5341fun TermsOfUseScreen (
5442 onNavigateToIntro : () -> Unit ,
5543) {
56- var termsAccepted by rememberSaveable { mutableStateOf(false ) }
57- var privacyAccepted by rememberSaveable { mutableStateOf(false ) }
5844 Scaffold { contentPadding ->
5945 Column (
6046 modifier = Modifier
@@ -98,22 +84,18 @@ fun TermsOfUseScreen(
9884 .fillMaxWidth()
9985 .padding(bottom = 24 .dp)
10086 ) {
101- CheckButton (
87+ TermsText (
10288 title = stringResource(R .string.onboarding__tos_checkbox),
10389 htmlText = stringResource(R .string.onboarding__tos_checkbox_value)
10490 .withAccentLink(Env .TERMS_OF_USE_URL ),
105- isChecked = termsAccepted,
106- onCheckedChange = { termsAccepted = it },
10791 modifier = Modifier
10892 .padding(horizontal = horizontalPadding)
10993 .testTag(" Check1" )
11094 )
111- CheckButton (
95+ TermsText (
11296 title = stringResource(R .string.onboarding__pp_checkbox),
11397 htmlText = stringResource(R .string.onboarding__pp_checkbox_value)
11498 .withAccentLink(Env .PRIVACY_POLICY_URL ),
115- isChecked = privacyAccepted,
116- onCheckedChange = { privacyAccepted = it },
11799 modifier = Modifier
118100 .padding(horizontal = horizontalPadding)
119101 .testTag(" Check2" )
@@ -124,7 +106,6 @@ fun TermsOfUseScreen(
124106 PrimaryButton (
125107 text = stringResource(R .string.common__continue),
126108 onClick = onNavigateToIntro,
127- enabled = termsAccepted && privacyAccepted,
128109 modifier = Modifier
129110 .padding(horizontal = horizontalPadding)
130111 .testTag(" Continue" )
@@ -135,63 +116,25 @@ fun TermsOfUseScreen(
135116}
136117
137118@Composable
138- private fun CheckButton (
119+ private fun TermsText (
139120 title : String ,
140121 htmlText : AnnotatedString ,
141- isChecked : Boolean ,
142- onCheckedChange : (Boolean ) -> Unit ,
143122 modifier : Modifier = Modifier ,
144123) {
145124 Column (
146125 modifier = Modifier
147126 .fillMaxWidth()
148- .clickable { onCheckedChange(! isChecked) }
149127 .then(modifier)
150128 ) {
151- Spacer (modifier = Modifier .height(14 .dp))
152- Row (
153- verticalAlignment = Alignment .CenterVertically ,
154- modifier = Modifier .fillMaxWidth()
155- ) {
156- Column (
157- modifier = Modifier .weight(1f )
158- ) {
159- BodyMSB (title)
160- Spacer (modifier = Modifier .height(4 .dp))
161- BodySSB (text = htmlText, color = Colors .White64 )
162- }
163- Spacer (modifier = Modifier .width(48 .dp))
164- CheckmarkBox (isChecked)
165- }
166- Spacer (modifier = Modifier .height(14 .dp))
129+ VerticalSpacer (14 .dp)
130+ BodyMSB (title)
131+ VerticalSpacer (4 .dp)
132+ BodySSB (text = htmlText, color = Colors .White64 )
133+ VerticalSpacer (14 .dp)
167134 HorizontalDivider ()
168135 }
169136}
170137
171- @Composable
172- private fun CheckmarkBox (isChecked : Boolean ) {
173- val borderColor = if (isChecked) Colors .Brand else Colors .White32
174- val backgroundColor = if (isChecked) Color (0x52FF6600 ) else Colors .White10
175-
176- Box (
177- contentAlignment = Alignment .Center ,
178- modifier = Modifier
179- .border(width = 1 .dp, color = borderColor, shape = RoundedCornerShape (size = 8 .dp))
180- .background(color = backgroundColor, shape = RoundedCornerShape (size = 8 .dp))
181- .size(32 .dp)
182- ) {
183- if (isChecked) {
184- Icon (
185- imageVector = Icons .Default .Check ,
186- contentDescription = null ,
187- tint = Colors .Brand ,
188- modifier = Modifier
189- .align(Alignment .Center )
190- .size(22 .dp)
191- )
192- }
193- }
194- }
195138
196139@Preview(showSystemUi = true )
197140@Composable
0 commit comments