• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.mechanics.demo
18 
19 import androidx.compose.foundation.layout.Box
20 import androidx.compose.foundation.layout.fillMaxSize
21 import androidx.compose.foundation.layout.systemBarsPadding
22 import androidx.compose.runtime.Composable
23 import androidx.compose.ui.Modifier
24 import androidx.navigation.compose.NavHost
25 import androidx.navigation.compose.rememberNavController
26 import com.android.mechanics.demo.demos.MagneticOverviewDismiss
27 import com.android.mechanics.demo.demos.MaterialFadeThrough
28 import com.android.mechanics.demo.presentation.DirectionChangeDemo
29 import com.android.mechanics.demo.presentation.DirectionSpecDemo
30 import com.android.mechanics.demo.presentation.GuaranteeBoxDemo
31 import com.android.mechanics.demo.presentation.GuaranteeFadeDemo
32 import com.android.mechanics.demo.presentation.PracticalDemoDetach
33 import com.android.mechanics.demo.presentation.SpecDemo
34 
35 object DemoScreens {
36 
37     private val MotionMechanicsPresentation =
38         ParentScreen(
39             "mm_preso_jan_21",
40             mapOf(
41                 "S06 - Expandable Drag Container" to DemoScreen(MaterialFadeThrough),
42                 //                "S08 - Predefined Motion" to DemoScreen(MaterialFadeThrough),
43                 //                "S09 - Dynamic Motion" to DemoScreen(MaterialFadeThrough),
44                 //                "S10 - Continuous Motion" to DemoScreen(MaterialFadeThrough),
45                 "S17 - Motion Spec" to DemoScreen(SpecDemo),
46                 "S22 - Directionality Hysteresis" to DemoScreen(DirectionChangeDemo),
47                 "S23 - Directionality Effects" to DemoScreen(DirectionSpecDemo),
48                 "S24 - Guaranteed Fade" to DemoScreen(GuaranteeFadeDemo),
49                 "S25 - Guaranteed Size" to DemoScreen(GuaranteeBoxDemo),
50                 //                "Extra - Appear" to DemoScreen(PracticalDemoAppear),
51                 "Extra - Magnetic Detach" to DemoScreen(PracticalDemoDetach),
52                 //                "S25 - Magnetic Detach" to DemoScreen(MaterialFadeThrough),
53                 //                "Motion Mechanics Presentation" to MotionMechanicsPresentation,
54                 "Extra - Magnetic Card Dismiss" to DemoScreen(MagneticOverviewDismiss),
55                 //                "Material Fade Through" to DemoScreen(MaterialFadeThrough),
56                 //                "Extra - Tactile Surface Reveal" to
57                 // DemoScreen(TactileSurfaceReveal),
58             ),
59         )
60 
61     val Home =
62         ParentScreen(
63             "home",
64             mapOf(
65                 "MM Presentation" to MotionMechanicsPresentation,
66                 "Magnetic Card Dismiss" to DemoScreen(MagneticOverviewDismiss),
67                 "Material Fade Through" to DemoScreen(MaterialFadeThrough),
68             ),
69         )
70 }
71 
72 @Composable
MechanicsDemonull73 fun MechanicsDemo() {
74     val rootScreen = DemoScreens.Home
75 
76     Box(Modifier.fillMaxSize().systemBarsPadding()) {
77         val navController = rememberNavController()
78         NavHost(navController = navController, startDestination = rootScreen.identifier) {
79             screen(rootScreen, navController)
80         }
81     }
82 }
83