Skip to content

Commit

Permalink
fix: Show auto theme option from API 24 to API 28 (#297)
Browse files Browse the repository at this point in the history
* fix: Show auto theme option from API 24 to API 28

* fix: Lint error
  • Loading branch information
Ephemera42 authored Aug 28, 2024
1 parent d7e1e38 commit 08fd9cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fun SelectionType.Companion.of(name: String?): SelectionType =
runCatching { SelectionType.valueOf(name!!.uppercase()) }.getOrDefault(SelectionType.DEFAULT)

fun ThemeType.Companion.of(name: String?): ThemeType =
runCatching { ThemeType.valueOf(name!!.uppercase()) }.getOrDefault(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ThemeType.AUTO else ThemeType.LIGHT_THEME)
runCatching { ThemeType.valueOf(name!!.uppercase()) }.getOrDefault(ThemeType.AUTO)

fun SmbAuthMode.Companion.indexOf(index: Int): SmbAuthMode = when (index) {
1 -> SmbAuthMode.GUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,23 @@ fun DarkThemeSelectable() {
val context = LocalContext.current
val dialogState = LocalSlotScope.current!!.dialogSlot
val items = remember {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
listOf(
DialogRadioItem(
enum = ThemeType.AUTO,
title = context.getString(R.string.theme_auto),
desc = context.getString(R.string.theme_auto_desc),
),
DialogRadioItem(
enum = ThemeType.LIGHT_THEME,
title = context.getString(R.string.theme_light),
desc = context.getString(R.string.theme_light_desc),
),
DialogRadioItem(
enum = ThemeType.DARK_THEME,
title = context.getString(R.string.theme_dark),
desc = context.getString(R.string.theme_dark_desc),
),
)
} else {
listOf(
DialogRadioItem(
enum = ThemeType.LIGHT_THEME,
title = context.getString(R.string.theme_light),
desc = context.getString(R.string.theme_light_desc),
),
DialogRadioItem(
enum = ThemeType.DARK_THEME,
title = context.getString(R.string.theme_dark),
desc = context.getString(R.string.theme_dark_desc),
),
)
}
listOf(
DialogRadioItem(
enum = ThemeType.AUTO,
title = context.getString(R.string.theme_auto),
desc = context.getString(R.string.theme_auto_desc),
),
DialogRadioItem(
enum = ThemeType.LIGHT_THEME,
title = context.getString(R.string.theme_light),
desc = context.getString(R.string.theme_light_desc),
),
DialogRadioItem(
enum = ThemeType.DARK_THEME,
title = context.getString(R.string.theme_dark),
desc = context.getString(R.string.theme_dark_desc),
),
)
}
val currentType by observeCurrentTheme()
val currentIndex by remember(currentType) { mutableIntStateOf(items.indexOfFirst { it.enum == currentType }) }
Expand Down

0 comments on commit 08fd9cb

Please sign in to comment.