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.systemui.keyguard.ui.viewmodel
19 
20 import com.android.systemui.res.R
21 import com.android.systemui.common.shared.model.Icon
22 import com.android.systemui.common.shared.model.Text
23 import com.android.systemui.keyguard.domain.interactor.KeyguardLongPressInteractor
24 import javax.inject.Inject
25 import kotlinx.coroutines.flow.Flow
26 
27 /** Models the UI state of a keyguard settings popup menu. */
28 class KeyguardSettingsMenuViewModel
29 @Inject
30 constructor(
31     private val interactor: KeyguardLongPressInteractor,
32 ) {
33     val isVisible: Flow<Boolean> = interactor.isMenuVisible
34     val shouldOpenSettings: Flow<Boolean> = interactor.shouldOpenSettings
35 
36     val icon: Icon =
37         Icon.Resource(
38             res = R.drawable.ic_palette,
39             contentDescription = null,
40         )
41 
42     val text: Text =
43         Text.Resource(
44             res = R.string.lock_screen_settings,
45         )
46 
onTouchGestureStartednull47     fun onTouchGestureStarted() {
48         interactor.onMenuTouchGestureStarted()
49     }
50 
onTouchGestureEndednull51     fun onTouchGestureEnded(isClick: Boolean) {
52         interactor.onMenuTouchGestureEnded(
53             isClick = isClick,
54         )
55     }
56 
onSettingsShownnull57     fun onSettingsShown() {
58         interactor.onSettingsShown()
59     }
60 }
61