Skip to content

Commit

Permalink
feat: improve ux when creating new wallpaper changer rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Dec 9, 2024
1 parent f65f5f1 commit 66a347a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/com/bnyro/wallpaper/ui/pages/SettingsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ fun SettingsPage(
)
}

var newWallpaperConfig by remember {
mutableStateOf<WallpaperConfig?>(null)
}

Button(
onClick = {
val maxId = if (wallpaperConfigs.isNotEmpty()) {
Expand All @@ -203,10 +207,7 @@ fun SettingsPage(
-1
}

val newConfig = WallpaperConfig(id = maxId + 1)
wallpaperConfigs.add(newConfig)
Preferences.setWallpaperConfigs(wallpaperConfigs)
WorkerHelper.enqueue(context, newConfig, true)
newWallpaperConfig = WallpaperConfig(id = maxId + 1)
}
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Expand All @@ -215,6 +216,18 @@ fun SettingsPage(
Text(stringResource(R.string.add_wallpaper_changer_rule))
}
}

newWallpaperConfig?.let { config ->
WallpaperChangerPrefDialog(
config,
onConfigChange = { newConfig ->
wallpaperConfigs.add(newConfig)
Preferences.setWallpaperConfigs(wallpaperConfigs)
WorkerHelper.enqueue(context, newConfig, true)
},
onDismissRequest = { newWallpaperConfig = null }
)
}
}
}
}
Expand Down

0 comments on commit 66a347a

Please sign in to comment.