1 /* 2 * Copyright (C) 2023 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 18 package com.android.customization.picker.color.ui.viewmodel 19 20 import android.annotation.ColorInt 21 import com.android.customization.model.color.ColorOptionImpl 22 23 data class ColorOptionIconViewModel( 24 @ColorInt val lightThemeColor0: Int, 25 @ColorInt val lightThemeColor1: Int, 26 @ColorInt val lightThemeColor2: Int, 27 @ColorInt val lightThemeColor3: Int, 28 @ColorInt val darkThemeColor0: Int, 29 @ColorInt val darkThemeColor1: Int, 30 @ColorInt val darkThemeColor2: Int, 31 @ColorInt val darkThemeColor3: Int, 32 ) { 33 companion object { fromColorOptionnull34 fun fromColorOption(colorOption: ColorOptionImpl): ColorOptionIconViewModel { 35 val lightThemeColors = colorOption.previewInfo.resolveColors(/* darkTheme= */ false) 36 val darkThemeColors = colorOption.previewInfo.resolveColors(/* darkTheme= */ true) 37 return ColorOptionIconViewModel( 38 lightThemeColor0 = lightThemeColors[0], 39 lightThemeColor1 = lightThemeColors[1], 40 lightThemeColor2 = lightThemeColors[2], 41 lightThemeColor3 = lightThemeColors[3], 42 darkThemeColor0 = darkThemeColors[0], 43 darkThemeColor1 = darkThemeColors[1], 44 darkThemeColor2 = darkThemeColors[2], 45 darkThemeColor3 = darkThemeColors[3], 46 ) 47 } 48 } 49 } 50