Skip to content

Commit

Permalink
chore: some code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Oct 28, 2024
1 parent b8b5b90 commit 4dc1aad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions app/src/main/java/com/bnyro/clock/navigation/NavRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import androidx.navigation.navArgument
sealed class NavRoutes(
val route: String
) {
object Home : NavRoutes("home")
object Settings : NavRoutes("settings")
object AlarmPicker : NavRoutes("alarmPicker") {
const val alarmId = "alarmId"
val routeWithArgs = "$route/{$alarmId}"
val args = listOf(navArgument(alarmId) { NavType.LongType })
data object Home : NavRoutes("home")
data object Settings : NavRoutes("settings")
data object AlarmPicker : NavRoutes("alarmPicker") {
const val ALARM_ID = "alarmId"
val routeWithArgs = "$route/{$ALARM_ID}"
val args = listOf(navArgument(ALARM_ID) { NavType.LongType })
}

object Permissions : NavRoutes("permissions")
data object Permissions : NavRoutes("permissions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun TimePickerDialog(
initialHour = initialTime?.hours ?: 0,
initialMinute = initialTime?.minutes ?: 0
)
var keyboardPickerState by remember {
val keyboardPickerState by remember {
mutableStateOf(KeyboardPickerState())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlin.time.Duration.Companion.milliseconds

class AlarmPickerModel(application: Application, savedStateHandle: SavedStateHandle) :
AndroidViewModel(application) {
private val id: String? = savedStateHandle[NavRoutes.AlarmPicker.alarmId]
private val id: String? = savedStateHandle[NavRoutes.AlarmPicker.ALARM_ID]

private val alarmRepository = (application as App).container.alarmRepository
private val createUpdateDeleteAlarmUseCase =
Expand All @@ -30,10 +30,10 @@ class AlarmPickerModel(application: Application, savedStateHandle: SavedStateHan

init {
val alarmId = id?.toLong() ?: 0L
if (alarmId == 0L) {
alarm = Alarm(time = 0)
alarm = if (alarmId == 0L) {
Alarm(time = 0)
} else {
alarm = runBlocking(Dispatchers.IO) {
runBlocking(Dispatchers.IO) {
alarmRepository.getAlarmById(alarmId)
}
}
Expand Down

0 comments on commit 4dc1aad

Please sign in to comment.