-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Iulia Stana
committed
May 4, 2023
1 parent
3da1552
commit e02e18c
Showing
2 changed files
with
98 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters