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 package com.android.avatarpicker.ui.details.items
17 
18 import androidx.compose.animation.AnimatedVisibility
19 import androidx.compose.animation.fadeIn
20 import androidx.compose.animation.fadeOut
21 import androidx.compose.foundation.background
22 import androidx.compose.foundation.layout.Box
23 import androidx.compose.foundation.layout.fillMaxSize
24 import androidx.compose.foundation.layout.padding
25 import androidx.compose.foundation.layout.size
26 import androidx.compose.foundation.shape.CircleShape
27 import androidx.compose.material.icons.Icons
28 import androidx.compose.material.icons.filled.Done
29 import androidx.compose.material3.Icon
30 import androidx.compose.material3.MaterialTheme
31 import androidx.compose.runtime.Composable
32 import androidx.compose.ui.Alignment
33 import androidx.compose.ui.Modifier
34 import androidx.compose.ui.unit.dp
35 
36 @Composable
SelectorWrappernull37 fun SelectorWrapper(isSelected: Boolean, content: @Composable () -> Unit) {
38     Box(Modifier.fillMaxSize()) {
39         content()
40         AnimatedVisibility(
41             isSelected,
42             Modifier.matchParentSize(),
43             enter = fadeIn(initialAlpha = .3f),
44             exit = fadeOut(targetAlpha = .3f)
45         ) {
46             Box(
47                 modifier = Modifier.matchParentSize()
48                     .background(MaterialTheme.colorScheme.scrim.copy(.32f), CircleShape),
49                 contentAlignment = Alignment.Center
50             ) {
51                 Icon(
52                     imageVector = Icons.Default.Done,
53                     contentDescription = null,
54                     modifier = Modifier.background(
55                         MaterialTheme.colorScheme.primaryContainer, CircleShape
56                     ).padding(8.dp).size(16.dp),
57                     tint = MaterialTheme.colorScheme.primary
58                 )
59             }
60         }
61     }
62 }