Scaffold(
topBar = {
CenterAlignedTopAppBar(
title = {
Text(
text = stringResource(R.string.app_name),
fontWeight = FontWeight.Bold
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer
)
)
}
) { innerPadding ->
Surface(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.background(MaterialTheme.colorScheme.tertiaryContainer),
color = MaterialTheme.colorScheme.background
) {
when (currentStep) {
1 -> {
LemonTextAndImage(
textLabelResourceId = R.string.lemon_select,
drawableResourceId = R.drawable.lemon_tree,
contentDescriptionResourceId = R.string.lemon_tree_content_description,
onImageClick = {
currentStep = 2
squeezeCount = (2..4).random()
}
)
}
2 -> {
LemonTextAndImage(
textLabelResourceId = R.string.lemon_squeeze,
drawableResourceId = R.drawable.lemon_squeeze,
contentDescriptionResourceId = R.string.lemon_content_description,
onImageClick = {
squeezeCount--
if (squeezeCount == 0) {
currentStep = 3
}
}
)
}
3 -> {
LemonTextAndImage(
textLabelResourceId = R.string.lemon_drink,
drawableResourceId = R.drawable.lemon_drink,
contentDescriptionResourceId = R.string.lemonade_content_description,
onImageClick = {
currentStep = 4
}
)
}
4 -> {
LemonTextAndImage(
textLabelResourceId = R.string.lemon_empty_glass,
drawableResourceId = R.drawable.lemon_restart,
contentDescriptionResourceId = R.string.empty_glass_content_description,
onImageClick = {
currentStep = 1
}
)
}
}
}
}
@composable
fun LemonadeApp() {
var currentStep by remember { mutableIntStateOf(1) }
var squeezeCount by remember { mutableIntStateOf(0) }
}
5 warnings:
Assigned value is never read: 91
Assigned value is never read: 92
Assigned value is never read: 104
Assigned value is never read: 115
Assigned value is never read: 125
Android Studio Otter 3 Feature Drop