@@ -10,8 +10,10 @@ import androidx.compose.foundation.layout.Arrangement
1010import androidx.compose.foundation.layout.Box
1111import androidx.compose.foundation.layout.Column
1212import androidx.compose.foundation.layout.Row
13+ import androidx.compose.foundation.layout.Spacer
1314import androidx.compose.foundation.layout.fillMaxSize
1415import androidx.compose.foundation.layout.fillMaxWidth
16+ import androidx.compose.foundation.layout.height
1517import androidx.compose.foundation.layout.padding
1618import androidx.compose.foundation.layout.wrapContentHeight
1719import androidx.compose.foundation.layout.wrapContentWidth
@@ -46,16 +48,19 @@ import androidx.compose.ui.res.stringResource
4648import androidx.compose.ui.semantics.heading
4749import androidx.compose.ui.semantics.semantics
4850import androidx.compose.ui.semantics.testTagsAsResourceId
51+ import androidx.compose.ui.text.font.FontWeight
4952import androidx.compose.ui.text.style.TextAlign
5053import androidx.compose.ui.text.style.TextOverflow
5154import androidx.compose.ui.tooling.preview.Preview
55+ import androidx.compose.ui.unit.dp
5256import androidx.hilt.navigation.compose.hiltViewModel
5357import androidx.lifecycle.asFlow
5458import androidx.navigation.NavHostController
5559import androidx.navigation.compose.rememberNavController
5660import ee.ria.DigiDoc.R
5761import ee.ria.DigiDoc.domain.model.IdentityAction
5862import ee.ria.DigiDoc.ui.component.menu.SettingsMenuBottomSheet
63+ import ee.ria.DigiDoc.ui.component.settings.SettingsSwitchItem
5964import ee.ria.DigiDoc.ui.component.shared.DynamicText
6065import ee.ria.DigiDoc.ui.component.shared.InvisibleElement
6166import ee.ria.DigiDoc.ui.component.shared.TopBar
@@ -70,6 +75,7 @@ import ee.ria.DigiDoc.viewmodel.WebEidViewModel
7075import ee.ria.DigiDoc.viewmodel.shared.SharedContainerViewModel
7176import ee.ria.DigiDoc.viewmodel.shared.SharedMenuViewModel
7277import ee.ria.DigiDoc.viewmodel.shared.SharedSettingsViewModel
78+ import ee.ria.DigiDoc.webEid.domain.model.WebEidAuthRequest
7379import kotlinx.coroutines.Dispatchers.Main
7480import kotlinx.coroutines.flow.filterNot
7581import kotlinx.coroutines.flow.filterNotNull
@@ -105,6 +111,7 @@ fun WebEidScreen(
105111 val messages by SnackBarManager .messages.collectAsState(emptyList())
106112 val dialogError by viewModel.dialogError.asFlow().collectAsState(0 )
107113 val showErrorDialog = rememberSaveable { mutableStateOf(false ) }
114+ var rememberMe by rememberSaveable { mutableStateOf(true ) }
108115
109116 LaunchedEffect (messages) {
110117 messages.forEach { message ->
@@ -247,35 +254,12 @@ fun WebEidScreen(
247254 modifier = Modifier .semantics { heading() },
248255 )
249256 if (authRequest != null ) {
250- Column (
251- horizontalAlignment = Alignment .CenterHorizontally ,
252- modifier = Modifier .fillMaxWidth(),
253- ) {
254- Text (
255- text = stringResource(R .string.web_eid_auth_consent_text),
256- style = MaterialTheme .typography.bodySmall,
257- color = MaterialTheme .colorScheme.onBackground,
258- textAlign = TextAlign .Center ,
259- )
260- Text (
261- text = authRequest.origin.take(80 ),
262- style = MaterialTheme .typography.labelSmall,
263- color = MaterialTheme .colorScheme.onBackground,
264- textAlign = TextAlign .Center ,
265- maxLines = 1 ,
266- overflow = TextOverflow .Ellipsis ,
267- )
268- Text (
269- text = stringResource(R .string.web_eid_requests_authentication),
270- style = MaterialTheme .typography.bodyMedium,
271- color = MaterialTheme .colorScheme.onBackground,
272- textAlign = TextAlign .Center ,
273- )
274- }
257+ WebEidAuthInfo (authRequest = authRequest)
275258
276259 NFCView (
277260 activity = activity,
278261 identityAction = IdentityAction .AUTH ,
262+ rememberMe = rememberMe,
279263 isSigning = false ,
280264 isDecrypting = false ,
281265 isWebEidAuthenticating = isWebEidAuthenticating,
@@ -306,6 +290,11 @@ fun WebEidScreen(
306290 isAuthenticated = { _, _ -> },
307291 webEidViewModel = viewModel,
308292 )
293+
294+ WebEidRememberMe (
295+ rememberMe = rememberMe,
296+ onRememberMeChange = { rememberMe = it },
297+ )
309298 } else if (signRequest != null ) {
310299 val responseUri = signRequest.responseUri.lowercase()
311300 val isCertificateFlow = responseUri.contains(" /certificate" ) && ! responseUri.contains(" /signature" )
@@ -466,6 +455,80 @@ fun WebEidScreen(
466455 }
467456}
468457
458+ @Composable
459+ private fun WebEidAuthInfo (
460+ authRequest : WebEidAuthRequest ,
461+ ) {
462+ Column (
463+ modifier = Modifier .fillMaxWidth(),
464+ ) {
465+ Text (
466+ text = stringResource(R .string.web_eid_auth_request_from),
467+ style = MaterialTheme .typography.labelMedium,
468+ textAlign = TextAlign .Left ,
469+ )
470+
471+ Spacer (modifier = Modifier .height(2 .dp))
472+
473+ Text (
474+ text = authRequest.origin.take(80 ),
475+ style = MaterialTheme .typography.bodySmall,
476+ fontWeight = FontWeight .Medium ,
477+ textAlign = TextAlign .Left ,
478+ maxLines = 2 ,
479+ overflow = TextOverflow .Ellipsis ,
480+ )
481+
482+ Spacer (modifier = Modifier .height(16 .dp))
483+
484+ Text (
485+ text = stringResource(R .string.web_eid_auth_details_forwarded),
486+ style = MaterialTheme .typography.labelMedium,
487+ textAlign = TextAlign .Left ,
488+ )
489+
490+ Spacer (modifier = Modifier .height(2 .dp))
491+
492+ Text (
493+ text = " NAME, PERSONAL IDENTIFICATION CODE" ,
494+ style = MaterialTheme .typography.bodySmall,
495+ textAlign = TextAlign .Left ,
496+ )
497+
498+ Spacer (modifier = Modifier .height(16 .dp))
499+
500+ Text (
501+ text = stringResource(R .string.web_eid_auth_consent_text),
502+ style = MaterialTheme .typography.bodySmall,
503+ color = MaterialTheme .colorScheme.onBackground,
504+ textAlign = TextAlign .Left ,
505+ modifier = Modifier .fillMaxWidth(),
506+ )
507+ }
508+ }
509+
510+ @Composable
511+ private fun WebEidRememberMe (
512+ rememberMe : Boolean ,
513+ onRememberMeChange : (Boolean ) -> Unit ,
514+ ) {
515+ val rememberMeText = stringResource(R .string.signature_update_remember_me)
516+
517+ SettingsSwitchItem (
518+ checked = rememberMe,
519+ onCheckedChange = onRememberMeChange,
520+ title = rememberMeText,
521+ contentDescription = rememberMeText,
522+ testTag = " webEidRememberMeSwitch" ,
523+ )
524+
525+ if (rememberMe) {
526+ Text (
527+ text = stringResource(R .string.web_eid_remember_me_message),
528+ )
529+ }
530+ }
531+
469532@Preview(showBackground = true )
470533@Preview(showBackground = true , uiMode = Configuration .UI_MODE_NIGHT_YES )
471534@Composable
0 commit comments