|
1 | 1 | package com.x8bit.bitwarden.ui.auth.feature.preventaccountlockout
|
2 | 2 |
|
3 |
| -import androidx.compose.foundation.background |
4 | 3 | import androidx.compose.foundation.layout.Column
|
5 |
| -import androidx.compose.foundation.layout.Row |
6 | 4 | import androidx.compose.foundation.layout.Spacer
|
7 | 5 | import androidx.compose.foundation.layout.fillMaxSize
|
8 | 6 | import androidx.compose.foundation.layout.fillMaxWidth
|
9 | 7 | import androidx.compose.foundation.layout.height
|
10 | 8 | import androidx.compose.foundation.layout.navigationBarsPadding
|
11 | 9 | import androidx.compose.foundation.layout.padding
|
12 |
| -import androidx.compose.foundation.layout.size |
13 |
| -import androidx.compose.foundation.layout.width |
14 | 10 | import androidx.compose.foundation.rememberScrollState
|
15 |
| -import androidx.compose.foundation.shape.RoundedCornerShape |
16 | 11 | import androidx.compose.foundation.verticalScroll
|
17 | 12 | import androidx.compose.material3.ExperimentalMaterial3Api
|
18 |
| -import androidx.compose.material3.Icon |
19 | 13 | import androidx.compose.material3.Text
|
20 | 14 | import androidx.compose.material3.TopAppBarDefaults
|
21 | 15 | import androidx.compose.material3.rememberTopAppBarState
|
22 | 16 | import androidx.compose.runtime.Composable
|
23 | 17 | import androidx.compose.runtime.remember
|
24 |
| -import androidx.compose.ui.Alignment |
25 | 18 | import androidx.compose.ui.Modifier
|
26 |
| -import androidx.compose.ui.draw.clip |
27 |
| -import androidx.compose.ui.graphics.painter.Painter |
28 | 19 | import androidx.compose.ui.input.nestedscroll.nestedScroll
|
29 | 20 | import androidx.compose.ui.res.stringResource
|
30 |
| -import androidx.compose.ui.semantics.clearAndSetSemantics |
| 21 | +import androidx.compose.ui.text.style.TextAlign |
31 | 22 | import androidx.compose.ui.tooling.preview.Preview
|
32 | 23 | import androidx.compose.ui.unit.dp
|
33 | 24 | import androidx.hilt.navigation.compose.hiltViewModel
|
34 | 25 | import com.x8bit.bitwarden.R
|
35 | 26 | import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
|
36 | 27 | import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
|
37 | 28 | import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
|
38 |
| -import com.x8bit.bitwarden.ui.platform.components.divider.BitwardenHorizontalDivider |
| 29 | +import com.x8bit.bitwarden.ui.platform.components.card.BitwardenContentCard |
| 30 | +import com.x8bit.bitwarden.ui.platform.components.model.ContentBlockData |
39 | 31 | import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
|
40 | 32 | import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
|
41 | 33 | import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
| 34 | +import kotlinx.collections.immutable.persistentListOf |
42 | 35 |
|
43 | 36 | /**
|
44 | 37 | * Top level screen component for the prevent account lockout info screen.
|
@@ -75,102 +68,57 @@ fun PreventAccountLockoutScreen(
|
75 | 68 | )
|
76 | 69 | },
|
77 | 70 | ) {
|
78 |
| - Column( |
| 71 | + PreventAccountLockoutContent( |
79 | 72 | modifier = Modifier
|
80 | 73 | .fillMaxWidth()
|
81 | 74 | .standardHorizontalMargin()
|
82 | 75 | .verticalScroll(rememberScrollState()),
|
83 |
| - ) { |
84 |
| - NeverLoseAccessContent() |
85 |
| - Spacer(modifier = Modifier.navigationBarsPadding()) |
86 |
| - } |
| 76 | + ) |
87 | 77 | }
|
88 | 78 | }
|
89 | 79 |
|
90 | 80 | @Composable
|
91 |
| -private fun NeverLoseAccessContent( |
92 |
| - modifier: Modifier = Modifier, |
93 |
| -) { |
94 |
| - Column( |
95 |
| - modifier = modifier |
96 |
| - .fillMaxWidth() |
97 |
| - .clip(RoundedCornerShape(size = 4.dp)) |
98 |
| - .background(BitwardenTheme.colorScheme.background.tertiary), |
99 |
| - ) { |
| 81 | +private fun PreventAccountLockoutContent(modifier: Modifier = Modifier) { |
| 82 | + Column(modifier = modifier) { |
100 | 83 | Spacer(modifier = Modifier.height(24.dp))
|
101 | 84 | Text(
|
102 | 85 | text = stringResource(R.string.never_lose_access_to_your_vault),
|
| 86 | + textAlign = TextAlign.Center, |
103 | 87 | style = BitwardenTheme.typography.titleMedium,
|
104 | 88 | color = BitwardenTheme.colorScheme.text.primary,
|
105 |
| - modifier = Modifier.padding(horizontal = 24.dp), |
| 89 | + modifier = Modifier |
| 90 | + .fillMaxWidth() |
| 91 | + .padding(horizontal = 12.dp), |
106 | 92 | )
|
107 | 93 | Spacer(modifier = Modifier.height(8.dp))
|
108 | 94 | Text(
|
109 | 95 | text = stringResource(
|
110 | 96 | R.string.the_best_way_to_make_sure_you_can_always_access_your_account,
|
111 | 97 | ),
|
| 98 | + textAlign = TextAlign.Center, |
112 | 99 | style = BitwardenTheme.typography.bodyMedium,
|
113 | 100 | color = BitwardenTheme.colorScheme.text.primary,
|
114 |
| - modifier = Modifier.padding(horizontal = 24.dp), |
| 101 | + modifier = Modifier.padding(horizontal = 12.dp), |
115 | 102 | )
|
116 | 103 | Spacer(modifier = Modifier.height(24.dp))
|
117 |
| - BitwardenHorizontalDivider() |
118 |
| - Spacer(modifier = Modifier.height(16.dp)) |
119 |
| - AccountRecoveryTipRow( |
120 |
| - title = stringResource(R.string.create_a_hint), |
121 |
| - description = stringResource( |
122 |
| - R.string.your_hint_will_be_send_to_you_via_email_when_you_request_it, |
| 104 | + BitwardenContentCard( |
| 105 | + contentItems = persistentListOf( |
| 106 | + ContentBlockData( |
| 107 | + headerText = stringResource(R.string.create_a_hint), |
| 108 | + subtitleText = stringResource( |
| 109 | + R.string.your_hint_will_be_send_to_you_via_email_when_you_request_it, |
| 110 | + ), |
| 111 | + iconVectorResource = R.drawable.ic_light_bulb, |
| 112 | + ), |
| 113 | + ContentBlockData( |
| 114 | + headerText = stringResource(R.string.write_your_password_down), |
| 115 | + subtitleText = stringResource(R.string.keep_it_secret_keep_it_safe), |
| 116 | + iconVectorResource = R.drawable.ic_pencil, |
| 117 | + ), |
123 | 118 | ),
|
124 |
| - icon = rememberVectorPainter(id = R.drawable.ic_light_bulb), |
125 |
| - modifier = Modifier.padding(horizontal = 16.dp), |
126 |
| - ) |
127 |
| - Spacer(modifier = Modifier.height(16.dp)) |
128 |
| - BitwardenHorizontalDivider() |
129 |
| - Spacer(modifier = Modifier.height(16.dp)) |
130 |
| - AccountRecoveryTipRow( |
131 |
| - title = stringResource(R.string.write_your_password_down), |
132 |
| - description = stringResource(R.string.keep_it_secret_keep_it_safe), |
133 |
| - icon = rememberVectorPainter(id = R.drawable.ic_pencil), |
134 |
| - modifier = Modifier.padding(horizontal = 16.dp), |
135 |
| - ) |
136 |
| - Spacer(modifier = Modifier.height(16.dp)) |
137 |
| - } |
138 |
| -} |
139 |
| - |
140 |
| -@Composable |
141 |
| -private fun AccountRecoveryTipRow( |
142 |
| - title: String, |
143 |
| - description: String, |
144 |
| - icon: Painter, |
145 |
| - modifier: Modifier = Modifier, |
146 |
| -) { |
147 |
| - Row( |
148 |
| - modifier = modifier, |
149 |
| - verticalAlignment = Alignment.CenterVertically, |
150 |
| - ) { |
151 |
| - Icon( |
152 |
| - painter = icon, |
153 |
| - contentDescription = null, |
154 |
| - tint = BitwardenTheme.colorScheme.icon.primary, |
155 |
| - modifier = Modifier |
156 |
| - .size(32.dp) |
157 |
| - .clearAndSetSemantics { }, |
158 | 119 | )
|
159 |
| - Spacer(modifier = Modifier.width(8.dp)) |
160 |
| - Column { |
161 |
| - Text( |
162 |
| - text = title, |
163 |
| - style = BitwardenTheme.typography.titleSmall, |
164 |
| - color = BitwardenTheme.colorScheme.text.primary, |
165 |
| - ) |
166 |
| - Spacer(modifier = Modifier.height(4.dp)) |
167 |
| - Text( |
168 |
| - text = description, |
169 |
| - style = BitwardenTheme.typography.bodyMedium, |
170 |
| - color = BitwardenTheme.colorScheme.text.primary, |
171 |
| - ) |
172 |
| - } |
173 | 120 | }
|
| 121 | + Spacer(modifier = Modifier.navigationBarsPadding()) |
174 | 122 | }
|
175 | 123 |
|
176 | 124 | @Preview
|
|
0 commit comments