Skip to content

Commit

Permalink
Cleanup file
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulia Stana committed May 4, 2023
1 parent 3da1552 commit e02e18c
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 68 deletions.
98 changes: 98 additions & 0 deletions app/src/main/kotlin/nl/eduid/ui/InfoField.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package nl.eduid.ui

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import nl.eduid.R
import nl.eduid.ui.theme.BlueButton
import nl.eduid.ui.theme.EduidAppAndroidTheme
import nl.eduid.ui.theme.TextGrayScale
import java.util.Locale

@Composable
fun InfoField(
title: String,
subtitle: String,
onClick: () -> Unit = {},
label: String = "",
@DrawableRes endIcon: Int = R.drawable.edit_icon,
) = Column(modifier = Modifier.fillMaxWidth()) {
if (label.isNotBlank()) {
Text(
text = label,
style = MaterialTheme.typography.bodyLarge.copy(
textAlign = TextAlign.Start,
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
)
}
}

@Preview
@Composable
private fun PreviewInfoField() = EduidAppAndroidTheme {
InfoField(
title = "Vetinari", subtitle = "Lord", label = "Full Name"
)
}
68 changes: 0 additions & 68 deletions app/src/main/kotlin/nl/eduid/ui/InfoTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.constraintlayout.compose.ConstraintLayout
Expand All @@ -50,71 +49,11 @@ import nl.eduid.screens.twofactorkey.IdentityData
import nl.eduid.ui.theme.BlueButton
import nl.eduid.ui.theme.BlueText
import nl.eduid.ui.theme.ButtonRed
import nl.eduid.ui.theme.EduidAppAndroidTheme
import nl.eduid.ui.theme.InfoTabDarkFill
import nl.eduid.ui.theme.TextBlack
import nl.eduid.ui.theme.TextGrayScale
import java.util.Locale

@Composable
fun InfoField(
title: String,
subtitle: String,
onClick: () -> Unit = {},
label: String = "",
@DrawableRes endIcon: Int = R.drawable.edit_icon,
) = Column(modifier = Modifier.fillMaxWidth()) {
if (label.isNotBlank()) {
Text(
text = label,
style = MaterialTheme.typography.bodyLarge.copy(
textAlign = TextAlign.Start,
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
)
}
}

@Composable
fun InfoTab(
header: String = "",
Expand Down Expand Up @@ -542,10 +481,3 @@ private fun twoFaBlock(
}
}

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

0 comments on commit e02e18c

Please sign in to comment.