1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settingslib.spa.framework.theme 18 19 import android.os.Build 20 import androidx.compose.material3.ColorScheme 21 import androidx.compose.material3.darkColorScheme 22 import androidx.compose.material3.dynamicDarkColorScheme 23 import androidx.compose.material3.dynamicLightColorScheme 24 import androidx.compose.material3.lightColorScheme 25 import androidx.compose.runtime.Composable 26 import androidx.compose.runtime.remember 27 import androidx.compose.ui.graphics.Color 28 import androidx.compose.ui.platform.LocalContext 29 30 @Composable materialColorSchemenull31internal fun materialColorScheme(isDarkTheme: Boolean): ColorScheme { 32 val context = LocalContext.current 33 return remember(isDarkTheme) { 34 when { 35 Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 36 if (isDarkTheme) dynamicDarkColorScheme(context) 37 else dynamicLightColorScheme(context) 38 } 39 isDarkTheme -> darkColorScheme() 40 else -> lightColorScheme() 41 } 42 } 43 } 44 45 val ColorScheme.divider: Color 46 get() = onSurface.copy(SettingsOpacity.Divider) 47 48 val ColorScheme.surfaceTone: Color 49 get() = primary.copy(SettingsOpacity.SurfaceTone) 50 51 /** The overall background color in Settings. */ 52 val ColorScheme.settingsBackground: Color 53 get() = surfaceContainer 54