Skip to content

Commit cc9d235

Browse files
committed
refactor(widget): 简化主题检测逻辑,直接使用系统主题
1 parent 709ff2e commit cc9d235

1 file changed

Lines changed: 1 addition & 24 deletions

File tree

  • android/app/src/main/kotlin/com/dawndrizzle/wing/cqut/widget

android/app/src/main/kotlin/com/dawndrizzle/wing/cqut/widget/WidgetTheme.kt

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,8 @@ import android.content.Context
44
import android.content.res.Configuration
55

66
object WidgetTheme {
7-
private const val PREFS_NAME = "FlutterSharedPreferences"
8-
private const val FLUTTER_PREFIX = "flutter."
9-
private const val KEY_THEME_MODE = "${FLUTTER_PREFIX}theme_mode"
10-
11-
enum class Mode {
12-
SYSTEM,
13-
LIGHT,
14-
DARK,
15-
}
16-
17-
fun mode(context: Context): Mode {
18-
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
19-
return when (prefs.getString(KEY_THEME_MODE, null)) {
20-
"ThemeMode.dark" -> Mode.DARK
21-
"ThemeMode.light" -> Mode.LIGHT
22-
else -> Mode.SYSTEM
23-
}
24-
}
25-
267
fun isDark(context: Context): Boolean {
27-
return when (mode(context)) {
28-
Mode.DARK -> true
29-
Mode.LIGHT -> false
30-
Mode.SYSTEM -> isSystemDark(context)
31-
}
8+
return isSystemDark(context)
329
}
3310

3411
private fun isSystemDark(context: Context): Boolean {

0 commit comments

Comments
 (0)