mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-03-06 12:37:44 +01:00
Move radio item list building for SleepTimer into a separate function
This commit is contained in:
parent
4b7c4350d4
commit
f25601db6b
@ -172,17 +172,7 @@ class MainActivity : ComponentActivity() {
|
||||
val lastSleepTimerSeconds by preferences.lastSleepTimerSecondsFlow.collectAsStateWithLifecycle(preferences.lastSleepTimerSeconds)
|
||||
val items by remember {
|
||||
derivedStateOf {
|
||||
val finalItems = ArrayList(listOf(10, 30, 60, 5 * 60, 10 * 60, 30 * 60).map {
|
||||
RadioItem(it, secondsToString(it))
|
||||
})
|
||||
|
||||
if (finalItems.none { it.id == lastSleepTimerSeconds }) {
|
||||
finalItems.add(RadioItem(lastSleepTimerSeconds, secondsToString(lastSleepTimerSeconds)))
|
||||
}
|
||||
|
||||
finalItems.sortBy { it.id }
|
||||
finalItems.add(RadioItem(-1, getString(com.simplemobiletools.commons.R.string.custom)))
|
||||
finalItems.toImmutableList()
|
||||
buildSleepTimerRadioItemsList(lastSleepTimerSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,6 +190,21 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildSleepTimerRadioItemsList(
|
||||
lastSleepTimerSeconds: Int
|
||||
) = buildList<RadioItem> {
|
||||
addAll(listOf(10, 30, 60, 5 * 60, 10 * 60, 30 * 60).map {
|
||||
RadioItem(it, secondsToString(it))
|
||||
})
|
||||
|
||||
if (none { it.id == lastSleepTimerSeconds }) {
|
||||
add(RadioItem(lastSleepTimerSeconds, secondsToString(lastSleepTimerSeconds)))
|
||||
}
|
||||
|
||||
sortBy { it.id }
|
||||
add(RadioItem(-1, getString(com.simplemobiletools.commons.R.string.custom)))
|
||||
}.toImmutableList()
|
||||
|
||||
@Composable
|
||||
private fun AppLaunched(
|
||||
donateAlertDialogState: AlertDialogState = getDonateAlertDialogState(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user