16
16
17
17
package com.example.compose.snippets.designsystems
18
18
19
+ import androidx.compose.foundation.isSystemInDarkTheme
19
20
import androidx.compose.foundation.layout.RowScope
20
21
import androidx.compose.foundation.shape.RoundedCornerShape
21
22
import androidx.compose.foundation.shape.ZeroCornerSize
22
- import androidx.compose.material.Colors
23
- import androidx.compose.material.ContentAlpha
24
23
import androidx.compose.material3.Button
25
24
import androidx.compose.material3.ButtonDefaults
25
+ import androidx.compose.material3.ColorScheme
26
26
import androidx.compose.material3.MaterialTheme
27
27
import androidx.compose.material3.ProvideTextStyle
28
28
import androidx.compose.material3.Shapes
@@ -38,28 +38,13 @@ import androidx.compose.ui.text.TextStyle
38
38
import androidx.compose.ui.unit.Dp
39
39
import androidx.compose.ui.unit.dp
40
40
import androidx.compose.ui.unit.sp
41
- import com.example.compose.snippets.designsystems.FullyCustomDesignSystem.CustomTheme.elevation
42
41
43
- /*
44
- * Copyright 2022 The Android Open Source Project
45
- *
46
- * Licensed under the Apache License, Version 2.0 (the "License");
47
- * you may not use this file except in compliance with the License.
48
- * You may obtain a copy of the License at
49
- *
50
- * http://www.apache.org/licenses/LICENSE-2.0
51
- *
52
- * Unless required by applicable law or agreed to in writing, software
53
- * distributed under the License is distributed on an "AS IS" BASIS,
54
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
- * See the License for the specific language governing permissions and
56
- * limitations under the License.
57
- */
58
42
private object CustomDesignSystemExtend {
59
43
// [START android_compose_designsystems_custom_extend]
60
- // Use with MaterialTheme.colors.snackbarAction
61
- val Colors .snackbarAction: Color
62
- get() = if (isLight) Red300 else Red700
44
+ // Use with MaterialTheme.colorScheme.snackbarAction
45
+ val ColorScheme .snackbarAction: Color
46
+ @Composable
47
+ get() = if (isSystemInDarkTheme()) Red300 else Red700
63
48
64
49
// Use with MaterialTheme.typography.textFieldInput
65
50
val Typography .textFieldInput: TextStyle
@@ -78,14 +63,14 @@ private object CustomDesignSystemExtendTheme {
78
63
// [START android_compose_designsystems_custom_extend_theme]
79
64
@Immutable
80
65
data class ExtendedColors (
81
- val tertiary : Color ,
82
- val onTertiary : Color
66
+ val caution : Color ,
67
+ val onCaution : Color
83
68
)
84
69
85
70
val LocalExtendedColors = staticCompositionLocalOf {
86
71
ExtendedColors (
87
- tertiary = Color .Unspecified ,
88
- onTertiary = Color .Unspecified
72
+ caution = Color .Unspecified ,
73
+ onCaution = Color .Unspecified
89
74
)
90
75
}
91
76
@@ -95,8 +80,8 @@ private object CustomDesignSystemExtendTheme {
95
80
content : @Composable () -> Unit
96
81
) {
97
82
val extendedColors = ExtendedColors (
98
- tertiary = Color (0xFFA8EFF0 ),
99
- onTertiary = Color (0xFF002021 )
83
+ caution = Color (0xFFFFCC02 ),
84
+ onCaution = Color (0xFF2C2D30 )
100
85
)
101
86
CompositionLocalProvider (LocalExtendedColors provides extendedColors) {
102
87
MaterialTheme (
@@ -106,7 +91,7 @@ private object CustomDesignSystemExtendTheme {
106
91
}
107
92
}
108
93
109
- // Use with eg. ExtendedTheme.colors.tertiary
94
+ // Use with eg. ExtendedTheme.colors.caution
110
95
object ExtendedTheme {
111
96
val colors: ExtendedColors
112
97
@Composable
@@ -123,8 +108,8 @@ private object CustomDesignSystemExtendTheme {
123
108
) {
124
109
Button (
125
110
colors = ButtonDefaults .buttonColors(
126
- containerColor = ExtendedTheme .colors.tertiary ,
127
- contentColor = ExtendedTheme .colors.onTertiary
111
+ containerColor = ExtendedTheme .colors.caution ,
112
+ contentColor = ExtendedTheme .colors.onCaution
128
113
/* Other colors use values from MaterialTheme */
129
114
),
130
115
onClick = onClick,
@@ -340,7 +325,7 @@ object FullyCustomDesignSystem {
340
325
.copy(alpha = 0.12f )
341
326
.compositeOver(CustomTheme .colors.component),
342
327
disabledContentColor = CustomTheme .colors.content
343
- .copy(alpha = ContentAlpha .disabled )
328
+ .copy(alpha = 0.38f )
344
329
),
345
330
shape = ButtonShape ,
346
331
elevation = ButtonDefaults .elevatedButtonElevation(
0 commit comments