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.scene.ui.composable.transitions
18
19 import androidx.compose.animation.core.tween
20 import com.android.compose.animation.scene.Edge
21 import com.android.compose.animation.scene.TransitionBuilder
22 import com.android.systemui.notifications.ui.composable.Notifications
23 import com.android.systemui.qs.ui.composable.QuickSettings
24 import com.android.systemui.shade.ui.composable.ShadeHeader
25 import kotlin.time.Duration.Companion.milliseconds
26
TransitionBuildernull27 fun TransitionBuilder.toQuickSettingsTransition(
28 durationScale: Double = 1.0,
29 ) {
30 spec = tween(durationMillis = (DefaultDuration * durationScale).inWholeMilliseconds.toInt())
31
32 translate(
33 ShadeHeader.Elements.ExpandedContent,
34 y = -(ShadeHeader.Dimensions.ExpandedHeight - ShadeHeader.Dimensions.CollapsedHeight)
35 )
36 translate(ShadeHeader.Elements.Clock, y = -ShadeHeader.Dimensions.CollapsedHeight)
37 translate(ShadeHeader.Elements.ShadeCarrierGroup, y = -ShadeHeader.Dimensions.CollapsedHeight)
38
39 fractionRange(start = .58f) {
40 fade(ShadeHeader.Elements.ExpandedContent)
41 fade(ShadeHeader.Elements.Clock)
42 fade(ShadeHeader.Elements.ShadeCarrierGroup)
43 }
44
45 translate(QuickSettings.Elements.Content, y = -ShadeHeader.Dimensions.ExpandedHeight * .66f)
46 translate(Notifications.Elements.NotificationScrim, Edge.Top, false)
47 }
48
49 private val DefaultDuration = 500.milliseconds
50