1 /*
2 * Copyright (C) 2024 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.sharetest.ui.theme
18
19 import androidx.compose.foundation.isSystemInDarkTheme
20 import androidx.compose.material3.MaterialTheme
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.ui.platform.LocalContext
27
28 private val DarkColorScheme =
29 darkColorScheme(primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80)
30
31 private val LightColorScheme =
32 lightColorScheme(
33 primary = Purple40,
34 secondary = PurpleGrey40,
35 tertiary = Pink40,
36
37 /* Other default colors to override
38 background = Color(0xFFFFFBFE),
39 surface = Color(0xFFFFFBFE),
40 onPrimary = Color.White,
41 onSecondary = Color.White,
42 onTertiary = Color.White,
43 onBackground = Color(0xFF1C1B1F),
44 onSurface = Color(0xFF1C1B1F),
45 */
46 )
47
48 @Composable
ActivityThemenull49 fun ActivityTheme(
50 darkTheme: Boolean = isSystemInDarkTheme(),
51 // Dynamic color is available on Android 12+
52 dynamicColor: Boolean = true,
53 content: @Composable () -> Unit,
54 ) {
55 val colorScheme =
56 when {
57 dynamicColor -> {
58 val context = LocalContext.current
59 if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
60 }
61
62 darkTheme -> DarkColorScheme
63 else -> LightColorScheme
64 }
65
66 MaterialTheme(colorScheme = colorScheme, typography = Typography, content = content)
67 }
68