Skip to content

Commit

Permalink
Removing responsibilities from InfoTab.
Browse files Browse the repository at this point in the history
Simplest form is InfoField with title, subtitle, end icon (chevron or edit) and optional click
Edured-105: Fixed - Android: password add/change in app not showing password (visually).
  • Loading branch information
Iulia Stana committed May 4, 2023
1 parent fbecd68 commit 3da1552
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import nl.eduid.screens.personalinfo.PersonalInfo
import nl.eduid.screens.personalinfo.PersonalInfoViewModel
import nl.eduid.ui.AlertDialogWithSingleButton
import nl.eduid.ui.EduIdTopAppBar
import nl.eduid.ui.InfoField
import nl.eduid.ui.InfoTab
import nl.eduid.ui.PrimaryButton
import nl.eduid.ui.theme.EduidAppAndroidTheme
Expand Down Expand Up @@ -97,22 +98,17 @@ private fun AccountLinkedContent(
} else {
Spacer(Modifier.height(12.dp))
}
InfoTab(
header = stringResource(R.string.infotab_fullname),
InfoField(
title = personalInfo.name,
subtitle = if (personalInfo.nameProvider == null) {
stringResource(
R.string.infotab_providedby_you
)
stringResource(R.string.infotab_providedby_you)
} else {
stringResource(
R.string.infotab_providedby, personalInfo.nameProvider
)
stringResource(R.string.infotab_providedby, personalInfo.nameProvider)
},
onClick = { },
endIcon = R.drawable.shield_tick_blue
endIcon = R.drawable.shield_tick_blue,
label = stringResource(R.string.infotab_fullname)
)

Spacer(Modifier.height(16.dp))
personalInfo.institutionAccounts.forEachIndexed { index, account ->
InfoTab(
header = if (index < 1) stringResource(R.string.infotab_role_institution) else "",
Expand Down
23 changes: 9 additions & 14 deletions app/src/main/kotlin/nl/eduid/screens/editname/EditNameScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import nl.eduid.screens.firsttimedialog.LinkAccountContract
import nl.eduid.screens.personalinfo.PersonalInfo
import nl.eduid.screens.personalinfo.PersonalInfoViewModel
import nl.eduid.ui.EduIdTopAppBar
import nl.eduid.ui.InfoField
import nl.eduid.ui.InfoTab
import nl.eduid.ui.theme.ButtonGreen
import nl.eduid.ui.theme.EduidAppAndroidTheme
Expand All @@ -44,11 +45,10 @@ fun EditNameScreen(
onBackClicked = goBack,
) {
var isGettingLinkUrl by rememberSaveable { mutableStateOf(false) }
val launcher =
rememberLauncherForActivityResult(contract = LinkAccountContract(), onResult = {
/**We don't have to explicitly handle the result intent. The deep linking will
* automatically open the [AccountLinkedScreen()] and ensure the backstack is correct.*/
})
val launcher = rememberLauncherForActivityResult(contract = LinkAccountContract(), onResult = {
/**We don't have to explicitly handle the result intent. The deep linking will
* automatically open the [AccountLinkedScreen()] and ensure the backstack is correct.*/
})

if (isGettingLinkUrl && viewModel.uiState.haveValidLinkIntent()) {
LaunchedEffect(key1 = viewModel) {
Expand Down Expand Up @@ -91,9 +91,7 @@ private fun EditNameContent(
Text(
style = MaterialTheme.typography.titleLarge.copy(
color = ButtonGreen
),
text = stringResource(R.string.edit_name_subtitle),
modifier = Modifier.fillMaxWidth()
), text = stringResource(R.string.edit_name_subtitle), modifier = Modifier.fillMaxWidth()
)
if (isLoading) {
Spacer(modifier = Modifier.height(8.dp))
Expand All @@ -118,10 +116,9 @@ private fun EditNameContent(
),
)
}
InfoTab(
InfoField(
title = personalInfo.name,
subtitle = stringResource(R.string.infotab_providedby_you),
onClick = { /**Not going anywhere from here*/ },
endIcon = R.drawable.edit_icon
)

Expand All @@ -132,8 +129,7 @@ private fun EditNameContent(
if (personalInfo.nameProvider != null) {
Row(verticalAlignment = Alignment.CenterVertically) {
Image(
painter = painterResource(R.drawable.ic_verified_badge),
contentDescription = null
painter = painterResource(R.drawable.ic_verified_badge), contentDescription = null
)
Spacer(
modifier = Modifier.width(8.dp)
Expand Down Expand Up @@ -177,8 +173,7 @@ private fun EditNameContent(
private fun Preview_LinkAccountCard() {
EduidAppAndroidTheme {
EditNameContent(
isLoading = false,
personalInfo = PersonalInfo.demoData()
isLoading = false, personalInfo = PersonalInfo.demoData()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import nl.eduid.R
import nl.eduid.screens.firsttimedialog.LinkAccountContract
import nl.eduid.ui.AlertDialogWithSingleButton
import nl.eduid.ui.EduIdTopAppBar
import nl.eduid.ui.InfoField
import nl.eduid.ui.InfoTab
import nl.eduid.ui.getDateTimeString
import nl.eduid.ui.theme.ButtonGreen
Expand Down Expand Up @@ -138,33 +139,30 @@ fun PersonalInfoScreenContent(
Spacer(modifier = Modifier.height(16.dp))
}
Spacer(Modifier.height(12.dp))
InfoTab(
header = stringResource(R.string.infotab_name),
InfoField(
title = personalInfo.name,
subtitle = if (personalInfo.nameProvider == null) {
stringResource(
R.string.infotab_providedby_you
)
stringResource(R.string.infotab_providedby_you)
} else {
stringResource(
R.string.infotab_providedby, personalInfo.nameProvider
)
stringResource(R.string.infotab_providedby, personalInfo.nameProvider)
},
onClick = onNameClicked,
endIcon = if (personalInfo.nameProvider == null) {
R.drawable.edit_icon
} else {
R.drawable.shield_tick_blue
}
},
label = stringResource(R.string.infotab_name)
)
InfoTab(
header = stringResource(R.string.infotab_email),
Spacer(Modifier.height(16.dp))
InfoField(
title = personalInfo.email,
subtitle = stringResource(R.string.infotab_providedby_you),
onClick = onEmailClicked,
endIcon = R.drawable.edit_icon
endIcon = R.drawable.edit_icon,
label = stringResource(R.string.infotab_email),
)

Spacer(Modifier.height(16.dp))
personalInfo.institutionAccounts.forEachIndexed { index, account ->
InfoTab(
header = if (index < 1) stringResource(R.string.infotab_role_institution) else "",
Expand Down
35 changes: 25 additions & 10 deletions app/src/main/kotlin/nl/eduid/screens/security/SecurityScreen.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package nl.eduid.screens.security

import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
Expand All @@ -14,7 +22,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import nl.eduid.R
import nl.eduid.ui.EduIdTopAppBar
import nl.eduid.ui.InfoTab
import nl.eduid.ui.InfoField
import nl.eduid.ui.theme.ButtonGreen
import nl.eduid.ui.theme.EduidAppAndroidTheme

Expand Down Expand Up @@ -76,29 +84,36 @@ fun SecurityScreenContent(
.align(alignment = Alignment.CenterHorizontally)
)
} else {
InfoTab(
header = stringResource(R.string.security_sign_in_methods),
InfoField(
title = stringResource(R.string.security_2fa_key),
subtitle = stringResource(R.string.security_provided_by_eduid),
onClick = on2FaClicked,
endIcon = R.drawable.shield_tick_blue
endIcon = R.drawable.shield_tick_blue,
label = stringResource(R.string.security_sign_in_methods)
)
InfoTab(
Spacer(Modifier.height(16.dp))
InfoField(
title = stringResource(R.string.security_send_a_magic_link_to),
subtitle = securityInfo.email,
onClick = onEditEmailClicked,
endIcon = R.drawable.edit_icon
)
InfoTab(
Spacer(Modifier.height(16.dp))
InfoField(
title = if (securityInfo.hasPassword) {
stringResource(R.string.security_change_password)
} else {
stringResource(R.string.security_add_a_password)
},
subtitle = "",
subtitle = if (securityInfo.hasPassword) {
"****"
} else {
""
},
onClick = onConfigurePasswordClicked,
endIcon = R.drawable.edit_icon
)
Spacer(Modifier.height(16.dp))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.lifecycle.map
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import org.tiqr.data.model.Identity
import org.tiqr.data.model.IdentityWithProvider
import org.tiqr.data.repository.IdentityRepository
import javax.inject.Inject
Expand All @@ -31,4 +33,8 @@ class TwoFactorKeyViewModel @Inject constructor(
biometricFlag = twoFaDetails.identity.biometricInUse,
)
}

fun upgradeBiometric(identity: Identity, use: Boolean) = viewModelScope.launch {

}
}
100 changes: 47 additions & 53 deletions app/src/main/kotlin/nl/eduid/ui/InfoTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,58 @@ fun InfoField(
title: String,
subtitle: String,
onClick: () -> Unit = {},
@DrawableRes endIcon: Int = 0,
) = Row(modifier = Modifier
.clip(RoundedCornerShape(6.dp))
.border(
width = 3.dp, color = BlueButton
)
.sizeIn(minHeight = 72.dp)
.padding(start = 18.dp, end = 18.dp, top = 12.dp, bottom = 12.dp)
.fillMaxWidth()
.clickable {
onClick()
}) {
Column {
label: String = "",
@DrawableRes endIcon: Int = R.drawable.edit_icon,
) = Column(modifier = Modifier.fillMaxWidth()) {
if (label.isNotBlank()) {
Text(
text = title.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() },
text = label,
style = MaterialTheme.typography.bodyLarge.copy(
textAlign = TextAlign.Start, fontWeight = FontWeight.Bold, lineHeight = 20.sp
),
)
Spacer(Modifier.height(4.dp))
Text(
text = subtitle,
style = MaterialTheme.typography.bodySmall.copy(
textAlign = TextAlign.Start,
color = TextGrayScale,
fontWeight = FontWeight.SemiBold,
),
)
Spacer(Modifier.height(6.dp))
}
Row(verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clip(RoundedCornerShape(6.dp))
.border(
width = 3.dp, color = BlueButton
)
.sizeIn(minHeight = 72.dp)
.padding(start = 18.dp, end = 18.dp, top = 12.dp, bottom = 12.dp)
.fillMaxWidth()
.clickable {
onClick()
}) {
Column(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
) {
Text(
text = title.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() },
style = MaterialTheme.typography.bodyLarge.copy(
textAlign = TextAlign.Start, fontWeight = FontWeight.Bold, lineHeight = 20.sp
),
)
Spacer(Modifier.height(4.dp))
Text(
text = subtitle,
style = MaterialTheme.typography.bodySmall.copy(
textAlign = TextAlign.Start,
color = TextGrayScale,
),
)
}
Image(
painter = painterResource(endIcon),
contentDescription = "",
modifier = Modifier.padding(start = 12.dp),
alignment = Alignment.Center
)
}
Image(
painter = painterResource(endIcon),
contentDescription = "",
modifier = Modifier.padding(start = 12.dp)
)
}

@Composable
Expand Down Expand Up @@ -523,35 +542,10 @@ private fun twoFaBlock(
}
}


@Preview
@Composable
private fun PreviewInfoTab() {
EduidAppAndroidTheme {
InfoTab(
header = "Header",
title = "OK a very long long long long long long long long long long",
subtitle = "OK long long long long long long long long long long long long",
onClick = { },
endIcon = R.drawable.shield_tick_blue,
institutionInfo = PersonalInfo.InstitutionAccount(
role = "Long string here",
roleProvider = "Long string here",
institution = "Long string here",
affiliationString = "Long string here",
createdStamp = 1231321321321,
expiryStamp = 12313213131313,
id = "123",
),
startIconLargeUrl = "https://static.surfconext.nl/media/sp/eduid.png"
)
}
}

@Preview
@Composable
private fun PreviewInfoField() = EduidAppAndroidTheme {
InfoField(
title = "Vetinari", subtitle = "Lord"
title = "Vetinari", subtitle = "Lord", label = "Full Name"
)
}

0 comments on commit 3da1552

Please sign in to comment.