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.systemui.touchpad.tutorial.ui.composable
18
19 import androidx.compose.runtime.Composable
20 import androidx.compose.runtime.remember
21 import com.airbnb.lottie.compose.rememberLottieDynamicProperties
22 import com.android.compose.theme.LocalAndroidColorScheme
23 import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
24 import com.android.systemui.inputdevice.tutorial.ui.composable.rememberColorFilterProperty
25 import com.android.systemui.res.R
26 import com.android.systemui.touchpad.tutorial.ui.viewmodel.EasterEggGestureViewModel
27 import com.android.systemui.touchpad.tutorial.ui.viewmodel.RecentAppsGestureScreenViewModel
28
29 @Composable
RecentAppsGestureTutorialScreennull30 fun RecentAppsGestureTutorialScreen(
31 viewModel: RecentAppsGestureScreenViewModel,
32 easterEggGestureViewModel: EasterEggGestureViewModel,
33 onDoneButtonClicked: () -> Unit,
34 onBack: () -> Unit,
35 ) {
36 val screenConfig =
37 TutorialScreenConfig(
38 colors = rememberScreenColors(),
39 strings =
40 TutorialScreenConfig.Strings(
41 titleResId = R.string.touchpad_recent_apps_gesture_action_title,
42 bodyResId = R.string.touchpad_recent_apps_gesture_guidance,
43 titleSuccessResId = R.string.touchpad_recent_apps_gesture_success_title,
44 bodySuccessResId = R.string.touchpad_recent_apps_gesture_success_body,
45 titleErrorResId = R.string.gesture_error_title,
46 bodyErrorResId = R.string.touchpad_recent_gesture_error_body,
47 ),
48 animations =
49 TutorialScreenConfig.Animations(educationResId = R.raw.trackpad_recent_apps_edu),
50 )
51 GestureTutorialScreen(
52 screenConfig = screenConfig,
53 tutorialStateFlow = viewModel.tutorialState,
54 motionEventConsumer = {
55 easterEggGestureViewModel.accept(it)
56 viewModel.handleEvent(it)
57 },
58 easterEggTriggeredFlow = easterEggGestureViewModel.easterEggTriggered,
59 onEasterEggFinished = easterEggGestureViewModel::onEasterEggFinished,
60 onDoneButtonClicked = onDoneButtonClicked,
61 onBack = onBack,
62 )
63 }
64
65 @Composable
rememberScreenColorsnull66 private fun rememberScreenColors(): TutorialScreenConfig.Colors {
67 val secondaryFixedDim = LocalAndroidColorScheme.current.secondaryFixedDim
68 val onSecondaryFixed = LocalAndroidColorScheme.current.onSecondaryFixed
69 val onSecondaryFixedVariant = LocalAndroidColorScheme.current.onSecondaryFixedVariant
70 val dynamicProperties =
71 rememberLottieDynamicProperties(
72 rememberColorFilterProperty(".secondaryFixedDim", secondaryFixedDim),
73 rememberColorFilterProperty(".onSecondaryFixed", onSecondaryFixed),
74 rememberColorFilterProperty(".onSecondaryFixedVariant", onSecondaryFixedVariant),
75 )
76 val screenColors =
77 remember(dynamicProperties) {
78 TutorialScreenConfig.Colors(
79 background = onSecondaryFixed,
80 title = secondaryFixedDim,
81 animationColors = dynamicProperties,
82 )
83 }
84 return screenColors
85 }
86