- Move toNightMode() extension to core:ui module to eliminate code duplication - Refactor MainActivity flow logic to use filterIsInstance<Success>() for better readability - Remove duplicate DarkThemeConfigExt.kt files from app and feature:settings modules - Update imports in MainActivity and SettingsViewModelpull/2059/head
parent
02fa916bb4
commit
12262491b8
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2022 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.samples.apps.nowinandroid.feature.settings.impl
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
|
||||||
import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts [DarkThemeConfig] to the corresponding [AppCompatDelegate] night mode constant.
|
|
||||||
* This is used to set the application-level night mode for the splash screen and system UI.
|
|
||||||
*/
|
|
||||||
internal fun DarkThemeConfig.toNightMode(): Int = when (this) {
|
|
||||||
DarkThemeConfig.FOLLOW_SYSTEM -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
|
||||||
DarkThemeConfig.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
|
||||||
DarkThemeConfig.DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue