• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright (C) 2025 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.wallpaper.customization.ui.compose
18 
19 import androidx.compose.foundation.layout.Arrangement
20 import androidx.compose.foundation.layout.Box
21 import androidx.compose.foundation.layout.Column
22 import androidx.compose.foundation.layout.PaddingValues
23 import androidx.compose.foundation.layout.Spacer
24 import androidx.compose.foundation.layout.fillMaxSize
25 import androidx.compose.foundation.layout.fillMaxWidth
26 import androidx.compose.foundation.layout.height
27 import androidx.compose.foundation.layout.padding
28 import androidx.compose.foundation.layout.size
29 import androidx.compose.foundation.lazy.LazyRow
30 import androidx.compose.foundation.lazy.items
31 import androidx.compose.foundation.shape.CircleShape
32 import androidx.compose.foundation.shape.RoundedCornerShape
33 import androidx.compose.material3.MaterialTheme
34 import androidx.compose.material3.Text
35 import androidx.compose.runtime.Composable
36 import androidx.compose.runtime.mutableStateListOf
37 import androidx.compose.runtime.remember
38 import androidx.compose.ui.Modifier
39 import androidx.compose.ui.draw.clip
40 import androidx.compose.ui.draw.drawBehind
41 import androidx.compose.ui.graphics.Color
42 import androidx.compose.ui.res.dimensionResource
43 import androidx.compose.ui.res.stringResource
44 import androidx.compose.ui.tooling.preview.Preview
45 import androidx.compose.ui.unit.dp
46 import com.android.compose.theme.PlatformTheme
47 import com.android.themepicker.R
48 
49 @Preview
50 @Composable
51 fun ColorFloatingSheet() {
52     // TODO (b/391927276): figure out how to animate color scheme changes
53     PlatformTheme {
54         val colorScheme = MaterialTheme.colorScheme
55         // TODO (b/391927276): replace placeholder colors with actual values
56         val colorsList = remember {
57             mutableStateListOf(
58                 Color.Red,
59                 Color.Green,
60                 Color.Blue,
61                 Color.Cyan,
62                 Color.Magenta,
63                 Color.Yellow,
64                 Color.Black,
65             )
66         }
67         Box(
68             modifier =
69                 Modifier.fillMaxWidth()
70                     .padding(horizontal = 16.dp)
71                     .clip(shape = RoundedCornerShape(28.dp))
72                     .drawBehind { drawRect(colorScheme.surfaceBright) }
73         ) {
74             Column(modifier = Modifier.padding(vertical = 20.dp)) {
75                 Text(
76                     modifier = Modifier.padding(horizontal = 20.dp),
77                     text = stringResource(R.string.wallpaper_color_subheader),
78                     color = colorScheme.onSurface,
79                 )
80 
81                 Spacer(modifier = Modifier.height(16.dp))
82 
83                 LazyRow(
84                     contentPadding = PaddingValues(horizontal = 20.dp),
85                     horizontalArrangement = Arrangement.spacedBy(4.dp),
86                 ) {
87                     items(colorsList) { color ->
88                         Box(
89                             modifier =
90                                 Modifier.size(
91                                     dimensionResource(R.dimen.floating_sheet_color_option_size)
92                                 )
93                         ) {
94                             ColorOptionIcon(color)
95                         }
96                     }
97                 }
98             }
99         }
100     }
101 }
102 
103 @Composable
ColorOptionIconnull104 fun ColorOptionIcon(color: Color) {
105     Box(modifier = Modifier.clip(CircleShape).fillMaxSize().drawBehind { drawRect(color) })
106 }
107