Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Waseef Akhtar waseefakhtar

🎯
Focusing
View GitHub Profile
View ProfileScreen.kt
@Composable
fun ProfileProperty(label: String, value: String) {
Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp)) {
Divider(modifier = Modifier.padding(bottom = 4.dp))
Text(
text = label,
modifier = Modifier.height(24.dp),
style = MaterialTheme.typography.caption,
)
Text(
View ProfileScreen.kt
@Composable
private fun ProfileContent(puppy: Puppy, containerHeight: Dp) {
Column {
Title(puppy)
ProfileProperty(stringResource(R.string.sex), puppy.sex)
ProfileProperty(stringResource(R.string.age), puppy.age.toString())
ProfileProperty(stringResource(R.string.personality), puppy.description)
Spacer(Modifier.height((containerHeight - 320.dp).coerceAtLeast(0.dp)))
}
View strings.xml
<resources>
<string name="personality">Personality</string>
<string name="sex">Sex</string>
<string name="age">Age</string>
</resources>
View ProfileScreen.kt
@Composable
private fun ProfileContent(puppy: Puppy, containerHeight: Dp) {
Column {
Title(puppy)
ProfileProperty(stringResource(R.string.sex), puppy.sex)
ProfileProperty(stringResource(R.string.age), puppy.age.toString())
ProfileProperty(stringResource(R.string.personality), puppy.description)
}
}
View ProfileScreen.kt
@Composable
private fun Title(
puppy: Puppy
) {
Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp, top = 16.dp)) {
Text(
text = puppy.title,
style = MaterialTheme.typography.h5,
fontWeight = FontWeight.Bold
)
View ProfileScreen.kt
@Composable
fun ProfileScreen(puppy: Puppy) {
val scrollState = rememberScrollState()
Column(modifier = Modifier.fillMaxSize()) {
BoxWithConstraints {
Surface {
Column(
modifier = Modifier
.fillMaxSize()
View ProfileScreen.kt
@Composable
private fun ProfileHeader(
puppy: Puppy,
containerHeight: Dp
) {
Image(
modifier = Modifier
.heightIn(max = containerHeight / 2)
.fillMaxWidth(),
painter = painterResource(id = puppy.puppyImageId),
View ProfileActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BarkTheme {
ProfileScreen(puppy = puppy)
}
}
}
View ProfileScreen.kt
@Composable
fun ProfileScreen(puppy: Puppy) {
val scrollState = rememberScrollState()
Column(modifier = Modifier.fillMaxSize()) {
BoxWithConstraints {
Surface {
Column(
modifier = Modifier
.fillMaxSize()
View MainActivity.kt
startActivity(ProfileActivity.newIntent(this, it))