Skip to content

Commit 37193a0

Browse files
committed
chore(preferences): modify toDisplayText to not take context as a parameter
1 parent 98426ba commit 37193a0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

app/src/main/java/com/android/unio/model/preferences/AppPreferences.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.android.unio.model.preferences
22

3-
import android.content.Context
43
import com.android.unio.R
54
import me.zhanghai.compose.preference.Preferences
65

@@ -30,13 +29,11 @@ object AppPreferences {
3029

3130
val asList = listOf(LIGHT, DARK, SYSTEM)
3231

33-
fun toDisplayText(theme: String, context: Context) =
32+
fun toDisplayText(theme: String) =
3433
when (theme) {
35-
LIGHT -> context.getString(R.string.app_preferences_theme_text_display_light)
36-
DARK -> context.getString(R.string.app_preferences_theme_text_display_dark)
37-
SYSTEM ->
38-
context.getString(R.string.app_preferences_theme_text_display_system_default_auto)
39-
else -> theme
34+
LIGHT -> R.string.app_preferences_theme_text_display_light
35+
DARK -> R.string.app_preferences_theme_text_display_dark
36+
else -> R.string.app_preferences_theme_text_display_system_default_auto
4037
}
4138
}
4239

app/src/main/java/com/android/unio/ui/settings/Settings.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ fun SettingsContainer(onPasswordChange: (() -> Unit) -> Unit) {
127127
modifier = Modifier.testTag(AppPreferences.THEME),
128128
key = AppPreferences.THEME,
129129
title = { Text(context.getString(R.string.settings_theme_title)) },
130-
summary = { Text(AppPreferences.Theme.toDisplayText(it, context)) },
131-
valueToText = { AnnotatedString(AppPreferences.Theme.toDisplayText(it, context)) },
130+
summary = { Text(context.getString(AppPreferences.Theme.toDisplayText(it))) },
131+
valueToText = {
132+
AnnotatedString(context.getString(AppPreferences.Theme.toDisplayText(it)))
133+
},
132134
values = AppPreferences.Theme.asList,
133135
defaultValue = AppPreferences.Theme.default,
134136
icon = {

0 commit comments

Comments
 (0)