made the showRefreshButton setting work

This commit is contained in:
Odweta
2024-11-30 11:15:08 +01:00
parent 597971288e
commit f67e28b8f6
@@ -62,11 +62,7 @@ fun TimetableScreen() {
contentAlignment = Alignment.BottomCenter contentAlignment = Alignment.BottomCenter
) { ) {
DayPager() DayPager()
Box( if (settingsData.showRefreshButton.checked.value) {
modifier = Modifier
.padding(bottom = 10.dp)
.background(color = Color.Black, shape = RoundedCornerShape(roundedCornerDimen))
) {
RefreshButton() RefreshButton()
} }
} }
@@ -89,29 +85,35 @@ fun RefreshButton(modifier: Modifier = Modifier) {
val coscope = rememberCoroutineScope() val coscope = rememberCoroutineScope()
val ctx = LocalContext.current val ctx = LocalContext.current
Button( Box(
onClick = {
coscope.launch {
fetchNewData(ctx, coscope)
}
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier modifier = Modifier
.border( .padding(bottom = 10.dp)
width = 5.dp, .background(color = Color.Black, shape = RoundedCornerShape(roundedCornerDimen))
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.padding(vertical = 10.dp)
) { ) {
Icon( Button(
imageVector = Icons.Default.Refresh, onClick = {
contentDescription = "Refresh icon", coscope.launch {
modifier = Modifier.size(25.dp) fetchNewData(ctx, coscope)
) }
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.padding(vertical = 10.dp)
) {
Icon(
imageVector = Icons.Default.Refresh,
contentDescription = "Refresh icon",
modifier = Modifier.size(25.dp)
)
}
} }
} }
@@ -373,7 +375,9 @@ private fun DayScreen(day: Day) {
} }
} }
// TODO: remove when added settings to turn the refresh button on/off // TODO: remove when added settings to turn the refresh button on/off
Spacer(modifier = Modifier.height(90.dp)) if (settingsData.showRefreshButton.checked.value) {
Spacer(modifier = Modifier.height(90.dp))
}
} }
} }
} }