1 /*
2  * Copyright (C) 2024 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.avatarpicker.domain
18 
19 import android.multiuser.Flags
20 import androidx.compose.ui.Modifier
21 import androidx.compose.ui.semantics.isTraversalGroup
22 import androidx.compose.ui.semantics.role
23 import androidx.compose.ui.semantics.Role
24 import androidx.compose.ui.semantics.selected
25 import androidx.compose.ui.semantics.semantics
26 import androidx.compose.foundation.clickable
27 
applyReadBackOrdernull28 fun Modifier.applyReadBackOrder() =
29     if (Flags.fixAvatarPickerReadBackOrder()) this.semantics { isTraversalGroup = true } else this
30 
applySelectablenull31 fun Modifier.applySelectable(isSelected: Boolean, select:() ->Unit): Modifier {
32     if (Flags.fixAvatarPickerSelectedReadBack()) {
33         if (isSelected)
34             return this.semantics {
35                 selected = isSelected
36                 role = Role.Button
37             }
38         else
39             return this.semantics{}.clickable{select()}
40     }
41     return this.clickable{select()}
42 }