@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.Spacer
2929import androidx.compose.foundation.layout.fillMaxWidth
3030import androidx.compose.foundation.layout.height
3131import androidx.compose.foundation.layout.padding
32+ import androidx.compose.foundation.layout.size
3233import androidx.compose.foundation.layout.width
3334import androidx.compose.foundation.rememberScrollState
3435import androidx.compose.foundation.verticalScroll
@@ -54,6 +55,7 @@ import com.dimension.maskbook.common.route.navigationComposeAnimComposable
5455import com.dimension.maskbook.common.route.navigationComposeAnimComposablePackage
5556import com.dimension.maskbook.common.routeProcessor.annotations.Back
5657import com.dimension.maskbook.common.routeProcessor.annotations.NavGraphDestination
58+ import com.dimension.maskbook.common.ui.theme.moreColor
5759import com.dimension.maskbook.common.ui.widget.MaskCard
5860import com.dimension.maskbook.common.ui.widget.MaskScaffold
5961import com.dimension.maskbook.common.ui.widget.MaskScene
@@ -104,78 +106,38 @@ fun PersonaMenuScene(
104106 .padding(ScaffoldPadding ),
105107 horizontalAlignment = Alignment .CenterHorizontally ,
106108 ) {
107- MaskCard (
108- modifier = Modifier .fillMaxWidth(),
109- elevation = 0 .dp,
109+ MenuItem (
110110 onClick = {
111111 navController.navigate(PersonaRoute .SwitchPersona )
112- }
113- ) {
114- Row (
115- modifier = Modifier .padding(16 .dp),
116- verticalAlignment = Alignment .CenterVertically ,
117- ) {
118- Image (
119- painterResource(id = R .drawable.ic_profile),
120- contentDescription = null
121- )
122- Spacer (modifier = Modifier .width(8 .dp))
123- Text (text = stringResource(R .string.scene_personas_action_change_add_persona))
124- }
125- }
112+ },
113+ icon = R .drawable.ic_profile,
114+ title = stringResource(R .string.scene_personas_action_change_add_persona)
115+ )
126116 Spacer (modifier = Modifier .height(16 .dp))
127- MaskCard (
128- modifier = Modifier .fillMaxWidth(),
129- elevation = 0 .dp,
117+ MenuItem (
130118 onClick = {
131119 currentPersona?.let {
132120 navController.navigate(PersonaRoute .RenamePersona (it.identifier))
133121 }
134- }
135- ) {
136- Row (
137- modifier = Modifier .padding(16 .dp),
138- verticalAlignment = Alignment .CenterVertically ,
139- ) {
140- Image (
141- painterResource(id = R .drawable.ic_edit),
142- contentDescription = null
143- )
144- Spacer (modifier = Modifier .width(8 .dp))
145- Text (text = stringResource(R .string.scene_personas_action_rename))
146- }
147- }
122+ },
123+ icon = R .drawable.ic_edit,
124+ title = stringResource(R .string.scene_personas_action_rename)
125+ )
148126 Spacer (modifier = Modifier .height(16 .dp))
149- MaskCard (
150- modifier = Modifier .fillMaxWidth(),
151- elevation = 0 .dp,
127+ MenuItem (
152128 onClick = {
153- // first check if it has backup password
154129 if (backupPassword.isEmpty()) {
155130 navController.navigateUri(Uri .parse(Deeplinks .Setting .SetupPasswordDialog (BackupActions .ExportPrivateKey .name)))
156131 } else {
157132 navController.navigate(Uri .parse(Deeplinks .Persona .BackUpPassword (PersonaRoute .ExportPrivateKey )))
158133 }
159- }
160- ) {
161- Row (
162- modifier = Modifier .padding(16 .dp),
163- verticalAlignment = Alignment .CenterVertically ,
164- ) {
165- Image (
166- painterResource(id = R .drawable.ic_password),
167- contentDescription = null
168- )
169- Spacer (modifier = Modifier .width(8 .dp))
170- Text (text = stringResource(R .string.scene_persona_export_private_key_title))
171- }
172- }
134+ },
135+ icon = R .drawable.ic_password,
136+ title = stringResource(R .string.scene_persona_export_private_key_title)
137+ )
173138 Spacer (modifier = Modifier .height(16 .dp))
174- MaskCard (
175- modifier = Modifier .fillMaxWidth(),
176- elevation = 0 .dp,
139+ MenuItem (
177140 onClick = {
178- // first check if it has backup password
179141 if (backupPassword.isEmpty()) {
180142 navController.navigateUri(Uri .parse(Deeplinks .Setting .SetupPasswordDialog (BackupActions .DownloadQrCode .name)))
181143 } else {
@@ -192,44 +154,22 @@ fun PersonaMenuScene(
192154 )
193155 }
194156 }
195- }
196- ) {
197- Row (
198- modifier = Modifier .padding(16 .dp),
199- verticalAlignment = Alignment .CenterVertically ,
200- ) {
201- Image (
202- painterResource(id = R .drawable.ic_download),
203- contentDescription = null
204- )
205- Spacer (modifier = Modifier .width(8 .dp))
206- Text (text = stringResource(R .string.scene_persona_download_qr_code_title))
207- }
208- }
157+ },
158+ icon = R .drawable.ic_download,
159+ title = stringResource(R .string.scene_persona_download_qr_code_title)
160+ )
209161 Spacer (modifier = Modifier .height(16 .dp))
210- MaskCard (
211- modifier = Modifier .fillMaxWidth(),
212- elevation = 0 .dp,
162+ MenuItem (
213163 onClick = {
214164 if (backupPassword.isEmpty()) {
215165 navController.navigateUri(Uri .parse(Deeplinks .Setting .SetupPasswordDialog (BackupActions .BackUp .name)))
216166 } else {
217167 navController.navigateUri(Uri .parse(Deeplinks .Setting .BackupData .BackupSelection ))
218168 }
219- }
220- ) {
221- Row (
222- modifier = Modifier .padding(16 .dp),
223- verticalAlignment = Alignment .CenterVertically ,
224- ) {
225- Image (
226- painterResource(id = R .drawable.ic_paper_plus),
227- contentDescription = null
228- )
229- Spacer (modifier = Modifier .width(8 .dp))
230- Text (text = stringResource(R .string.common_controls_back_up))
231- }
232- }
169+ },
170+ icon = R .drawable.ic_paper_plus,
171+ title = stringResource(R .string.common_controls_back_up)
172+ )
233173 Spacer (modifier = Modifier .height(16 .dp))
234174 MaskCard (
235175 modifier = Modifier .fillMaxWidth(),
@@ -252,11 +192,51 @@ fun PersonaMenuScene(
252192 tint = Color .Red ,
253193 )
254194 Spacer (modifier = Modifier .width(8 .dp))
255- Text (text = stringResource(R .string.scene_setting_profile_log_out), color = Color .Red )
195+ Text (text = stringResource(R .string.scene_setting_profile_log_out), color = Color .Red , modifier = Modifier .weight(1f ))
196+ Icon (
197+ painterResource(id = R .drawable.ic_arrow_right),
198+ contentDescription = null ,
199+ tint = Color .Red ,
200+ modifier = Modifier .size(6 .dp, 11 .dp)
201+ )
202+ Spacer (modifier = Modifier .width(8 .dp))
256203 }
257204 }
258205 }
259206 }
260207 }
261208 }
262209}
210+
211+ @Composable
212+ private fun MenuItem (
213+ onClick : () -> Unit ,
214+ icon : Int ,
215+ title : String ,
216+ ) {
217+ MaskCard (
218+ modifier = Modifier .fillMaxWidth(),
219+ elevation = 0 .dp,
220+ onClick = onClick
221+ ) {
222+ Row (
223+ modifier = Modifier .padding(16 .dp),
224+ verticalAlignment = Alignment .CenterVertically ,
225+ ) {
226+ Image (
227+ painterResource(id = icon),
228+ contentDescription = null ,
229+ modifier = Modifier .size(32 .dp)
230+ )
231+ Spacer (modifier = Modifier .width(8 .dp))
232+ Text (text = title, style = MaterialTheme .typography.h5, modifier = Modifier .weight(1f ))
233+ Icon (
234+ painterResource(id = R .drawable.ic_arrow_right),
235+ contentDescription = null ,
236+ tint = MaterialTheme .moreColor.onCaption,
237+ modifier = Modifier .size(6 .dp, 11 .dp)
238+ )
239+ Spacer (modifier = Modifier .width(8 .dp))
240+ }
241+ }
242+ }
0 commit comments