1 /*
2 * 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.systemui.touchpad.tutorial.ui.composable
18
19 import androidx.compose.material3.MaterialTheme
20 import androidx.compose.runtime.Composable
21 import androidx.compose.runtime.remember
22 import com.airbnb.lottie.compose.rememberLottieDynamicProperties
23 import com.android.compose.theme.LocalAndroidColorScheme
24 import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
25 import com.android.systemui.inputdevice.tutorial.ui.composable.rememberColorFilterProperty
26 import com.android.systemui.res.R
27 import com.android.systemui.touchpad.tutorial.ui.viewmodel.EasterEggGestureViewModel
28 import com.android.systemui.touchpad.tutorial.ui.viewmodel.SwitchAppsGestureScreenViewModel
29
30 @Composable
SwitchAppsGestureTutorialScreennull31 fun SwitchAppsGestureTutorialScreen(
32 viewModel: SwitchAppsGestureScreenViewModel,
33 easterEggGestureViewModel: EasterEggGestureViewModel,
34 onDoneButtonClicked: () -> Unit,
35 onBack: () -> Unit,
36 ) {
37 val screenConfig =
38 TutorialScreenConfig(
39 colors = rememberScreenColors(),
40 strings =
41 TutorialScreenConfig.Strings(
42 titleResId = R.string.touchpad_switch_apps_gesture_action_title,
43 bodyResId = R.string.touchpad_switch_apps_gesture_guidance,
44 titleSuccessResId = R.string.touchpad_switch_apps_gesture_success_title,
45 bodySuccessResId = R.string.touchpad_switch_apps_gesture_success_body,
46 titleErrorResId = R.string.gesture_error_title,
47 bodyErrorResId = R.string.touchpad_switch_gesture_error_body,
48 ),
49 animations =
50 TutorialScreenConfig.Animations(educationResId = R.raw.trackpad_switch_apps_edu),
51 )
52 GestureTutorialScreen(
53 screenConfig = screenConfig,
54 tutorialStateFlow = viewModel.tutorialState,
55 motionEventConsumer = {
56 easterEggGestureViewModel.accept(it)
57 viewModel.handleEvent(it)
58 },
59 easterEggTriggeredFlow = easterEggGestureViewModel.easterEggTriggered,
60 onEasterEggFinished = easterEggGestureViewModel::onEasterEggFinished,
61 onDoneButtonClicked = onDoneButtonClicked,
62 onBack = onBack,
63 )
64 }
65
66 @Composable
rememberScreenColorsnull67 private fun rememberScreenColors(): TutorialScreenConfig.Colors {
68 val onTertiary = MaterialTheme.colorScheme.onTertiary
69 val onTertiaryFixed = LocalAndroidColorScheme.current.onTertiaryFixed
70 val onTertiaryFixedVariant = LocalAndroidColorScheme.current.onTertiaryFixedVariant
71 val tertiaryFixedDim = LocalAndroidColorScheme.current.tertiaryFixedDim
72 val dynamicProperties =
73 rememberLottieDynamicProperties(
74 rememberColorFilterProperty(".tertiaryFixedDim", tertiaryFixedDim),
75 rememberColorFilterProperty(".onTertiaryFixed", onTertiaryFixed),
76 rememberColorFilterProperty(".onTertiary", onTertiary),
77 rememberColorFilterProperty(".onTertiaryFixedVariant", onTertiaryFixedVariant),
78 )
79 val screenColors =
80 remember(dynamicProperties) {
81 TutorialScreenConfig.Colors(
82 background = onTertiaryFixed,
83 title = tertiaryFixedDim,
84 animationColors = dynamicProperties,
85 )
86 }
87 return screenColors
88 }
89