diff options
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/Color.kt | 32 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/common/shared/model/Color.kt | 31 |
2 files changed, 63 insertions, 0 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/Color.kt b/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/Color.kt new file mode 100644 index 000000000000..64b9f2df144b --- /dev/null +++ b/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/Color.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 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 + * + * http://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.android.systemui.common.ui.compose + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.ui.graphics.Color +import com.android.compose.theme.colorAttr + +/** Resolves [com.android.systemui.common.shared.model.Color] into [Color] */ +@Composable +@ReadOnlyComposable +fun com.android.systemui.common.shared.model.Color.toColor(): Color { + return when (this) { + is com.android.systemui.common.shared.model.Color.Attribute -> colorAttr(attribute) + is com.android.systemui.common.shared.model.Color.Loaded -> Color(color) + } +} diff --git a/packages/SystemUI/src/com/android/systemui/common/shared/model/Color.kt b/packages/SystemUI/src/com/android/systemui/common/shared/model/Color.kt new file mode 100644 index 000000000000..d235c95eb906 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/common/shared/model/Color.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 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 + * + * http://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.android.systemui.common.shared.model + +import android.annotation.AttrRes +import android.annotation.ColorInt + +/** + * Models a color that can be either a specific [Color.Loaded] value or a resolvable theme + * [Color.Attribute] + */ +sealed interface Color { + + data class Loaded(@ColorInt val color: Int) : Color + + data class Attribute(@AttrRes val attribute: Int) : Color +} |