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.statusbar.notification.stack.ui.viewmodel 19 20 import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor 21 import javax.inject.Inject 22 import kotlinx.coroutines.flow.Flow 23 import kotlinx.coroutines.flow.distinctUntilChanged 24 import kotlinx.coroutines.flow.map 25 26 /** View-model for the shared notification container */ 27 class SharedNotificationContainerViewModel 28 @Inject 29 constructor( 30 interactor: SharedNotificationContainerInteractor, 31 ) { 32 val configurationBasedDimensions: Flow<ConfigurationBasedDimensions> = 33 interactor.configurationBasedDimensions 34 .map { 35 ConfigurationBasedDimensions( 36 marginStart = if (it.useSplitShade) 0 else it.marginHorizontal, 37 marginEnd = it.marginHorizontal, 38 marginBottom = it.marginBottom, 39 marginTop = 40 if (it.useLargeScreenHeader) it.marginTopLargeScreen else it.marginTop, 41 useSplitShade = it.useSplitShade, 42 ) 43 } 44 .distinctUntilChanged() 45 46 data class ConfigurationBasedDimensions( 47 val marginStart: Int, 48 val marginTop: Int, 49 val marginEnd: Int, 50 val marginBottom: Int, 51 val useSplitShade: Boolean, 52 ) 53 } 54