Loading packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class CredentialManagerRepo( requestInfo = intent.extras?.getParcelable( RequestInfo.EXTRA_REQUEST_INFO, RequestInfo::class.java ) ?: testCreatePasswordRequestInfo() ) ?: testGetRequestInfo() providerEnabledList = when (requestInfo.type) { RequestInfo.TYPE_CREATE -> Loading packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt +76 −47 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.offset import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface Loading @@ -40,6 +41,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape Loading Loading @@ -339,6 +341,25 @@ fun ModalBottomSheetLayout( visible = sheetState.targetValue != Hidden ) } // For large screen, allow enough horizontal scrim space. // Manually calculate the > compact width due to lack of corresponding jetpack dependency. val maxSheetContentWidth: Dp = if (maxWidth >= ModalBottomSheetDefaults.MaxCompactWidth && maxWidth <= ModalBottomSheetDefaults.MaxCompactWidth + ModalBottomSheetDefaults.StartPadding + ModalBottomSheetDefaults.EndPadding ) (maxWidth - ModalBottomSheetDefaults.StartPadding - ModalBottomSheetDefaults.EndPadding) else ModalBottomSheetDefaults.MaxSheetWidth val maxSheetContentHeight = maxHeight - ModalBottomSheetDefaults.MinScrimHeight Box( Modifier.sizeIn( maxWidth = maxSheetContentWidth, // Allow enough vertical scrim space. maxHeight = maxSheetContentHeight ).align(Alignment.TopCenter) ) { Surface( Modifier .fillMaxWidth() Loading Loading @@ -387,7 +408,10 @@ fun ModalBottomSheetLayout( color = sheetBackgroundColor, contentColor = sheetContentColor ) { Column(content = sheetContent) Column( content = sheetContent ) } } } } Loading Loading @@ -465,6 +489,11 @@ private fun Scrim( * Contains useful Defaults for [ModalBottomSheetLayout]. */ object ModalBottomSheetDefaults { val MaxCompactWidth = 600.dp val MaxSheetWidth = 640.dp val MinScrimHeight = 56.dp val StartPadding = 56.dp val EndPadding = 56.dp /** * The default elevation used by [ModalBottomSheetLayout]. Loading packages/CredentialManager/src/com/android/credentialmanager/common/ui/BottomSheet.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.credentialmanager.common.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.ColumnScope import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import com.android.credentialmanager.common.material.ModalBottomSheetLayout import com.android.credentialmanager.common.material.ModalBottomSheetValue import com.android.credentialmanager.common.material.rememberModalBottomSheetState import com.android.credentialmanager.ui.theme.EntryShape /** Draws a modal bottom sheet with the same styles and effects shared by various flows. */ @Composable fun ModalBottomSheet( sheetContent: @Composable ColumnScope.() -> Unit, onDismiss: () -> Unit ) { val state = rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Expanded, skipHalfExpanded = true ) ModalBottomSheetLayout( sheetBackgroundColor = MaterialTheme.colorScheme.surface, modifier = Modifier.background(Color.Transparent), sheetState = state, sheetContent = sheetContent, scrimColor = MaterialTheme.colorScheme.scrim.copy(alpha = 0.8f), sheetShape = EntryShape.TopRoundedCorner, ) {} LaunchedEffect(state.currentValue) { if (state.currentValue == ModalBottomSheetValue.Hidden) { onDismiss() } } } No newline at end of file packages/CredentialManager/src/com/android/credentialmanager/common/ui/Cards.kt +2 −3 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ package com.android.credentialmanager.common.ui import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier Loading @@ -30,7 +30,6 @@ import androidx.compose.ui.graphics.Shape * By default the card is filled with surfaceVariant color. This container card instead fills the * background color with surface corlor. */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun ContainerCard( modifier: Modifier = Modifier, Loading @@ -39,7 +38,7 @@ fun ContainerCard( content: @Composable ColumnScope.() -> Unit, ) { Card( modifier = modifier, modifier = modifier.fillMaxWidth(), shape = shape, border = border, colors = CardDefaults.cardColors( Loading packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt +4 −19 Original line number Diff line number Diff line Loading @@ -45,18 +45,15 @@ import androidx.core.graphics.drawable.toBitmap import com.android.credentialmanager.R import com.android.credentialmanager.common.CredentialType import com.android.credentialmanager.common.ProviderActivityState import com.android.credentialmanager.common.material.ModalBottomSheetLayout import com.android.credentialmanager.common.material.ModalBottomSheetValue import com.android.credentialmanager.common.material.rememberModalBottomSheetState import com.android.credentialmanager.common.ui.ActionButton import com.android.credentialmanager.common.ui.ConfirmButton import com.android.credentialmanager.common.ui.Entry import com.android.credentialmanager.common.ui.ModalBottomSheet import com.android.credentialmanager.common.ui.TextOnSurface import com.android.credentialmanager.common.ui.TextSecondary import com.android.credentialmanager.common.ui.TextOnSurfaceVariant import com.android.credentialmanager.common.ui.ContainerCard import com.android.credentialmanager.common.ui.ToggleVisibilityButton import com.android.credentialmanager.ui.theme.EntryShape import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme @OptIn(ExperimentalMaterial3Api::class) Loading @@ -65,13 +62,7 @@ fun CreateCredentialScreen( viewModel: CreateCredentialViewModel, providerActivityLauncher: ManagedActivityResultLauncher<IntentSenderRequest, ActivityResult> ) { val state = rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Expanded, skipHalfExpanded = true ) ModalBottomSheetLayout( sheetBackgroundColor = MaterialTheme.colorScheme.surface, sheetState = state, ModalBottomSheet( sheetContent = { val uiState = viewModel.uiState // Hide the sheet content as opposed to the whole bottom sheet to maintain the scrim Loading Loading @@ -153,14 +144,8 @@ fun CreateCredentialScreen( } } }, scrimColor = MaterialTheme.colorScheme.scrim.copy(alpha = 0.8f), sheetShape = EntryShape.TopRoundedCorner, ) {} LaunchedEffect(state.currentValue) { if (state.currentValue == ModalBottomSheetValue.Hidden) { viewModel.onCancel() } } onDismiss = viewModel::onCancel ) } @OptIn(ExperimentalMaterial3Api::class) Loading Loading
packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class CredentialManagerRepo( requestInfo = intent.extras?.getParcelable( RequestInfo.EXTRA_REQUEST_INFO, RequestInfo::class.java ) ?: testCreatePasswordRequestInfo() ) ?: testGetRequestInfo() providerEnabledList = when (requestInfo.type) { RequestInfo.TYPE_CREATE -> Loading
packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt +76 −47 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.offset import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface Loading @@ -40,6 +41,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape Loading Loading @@ -339,6 +341,25 @@ fun ModalBottomSheetLayout( visible = sheetState.targetValue != Hidden ) } // For large screen, allow enough horizontal scrim space. // Manually calculate the > compact width due to lack of corresponding jetpack dependency. val maxSheetContentWidth: Dp = if (maxWidth >= ModalBottomSheetDefaults.MaxCompactWidth && maxWidth <= ModalBottomSheetDefaults.MaxCompactWidth + ModalBottomSheetDefaults.StartPadding + ModalBottomSheetDefaults.EndPadding ) (maxWidth - ModalBottomSheetDefaults.StartPadding - ModalBottomSheetDefaults.EndPadding) else ModalBottomSheetDefaults.MaxSheetWidth val maxSheetContentHeight = maxHeight - ModalBottomSheetDefaults.MinScrimHeight Box( Modifier.sizeIn( maxWidth = maxSheetContentWidth, // Allow enough vertical scrim space. maxHeight = maxSheetContentHeight ).align(Alignment.TopCenter) ) { Surface( Modifier .fillMaxWidth() Loading Loading @@ -387,7 +408,10 @@ fun ModalBottomSheetLayout( color = sheetBackgroundColor, contentColor = sheetContentColor ) { Column(content = sheetContent) Column( content = sheetContent ) } } } } Loading Loading @@ -465,6 +489,11 @@ private fun Scrim( * Contains useful Defaults for [ModalBottomSheetLayout]. */ object ModalBottomSheetDefaults { val MaxCompactWidth = 600.dp val MaxSheetWidth = 640.dp val MinScrimHeight = 56.dp val StartPadding = 56.dp val EndPadding = 56.dp /** * The default elevation used by [ModalBottomSheetLayout]. Loading
packages/CredentialManager/src/com/android/credentialmanager/common/ui/BottomSheet.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.credentialmanager.common.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.ColumnScope import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import com.android.credentialmanager.common.material.ModalBottomSheetLayout import com.android.credentialmanager.common.material.ModalBottomSheetValue import com.android.credentialmanager.common.material.rememberModalBottomSheetState import com.android.credentialmanager.ui.theme.EntryShape /** Draws a modal bottom sheet with the same styles and effects shared by various flows. */ @Composable fun ModalBottomSheet( sheetContent: @Composable ColumnScope.() -> Unit, onDismiss: () -> Unit ) { val state = rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Expanded, skipHalfExpanded = true ) ModalBottomSheetLayout( sheetBackgroundColor = MaterialTheme.colorScheme.surface, modifier = Modifier.background(Color.Transparent), sheetState = state, sheetContent = sheetContent, scrimColor = MaterialTheme.colorScheme.scrim.copy(alpha = 0.8f), sheetShape = EntryShape.TopRoundedCorner, ) {} LaunchedEffect(state.currentValue) { if (state.currentValue == ModalBottomSheetValue.Hidden) { onDismiss() } } } No newline at end of file
packages/CredentialManager/src/com/android/credentialmanager/common/ui/Cards.kt +2 −3 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ package com.android.credentialmanager.common.ui import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier Loading @@ -30,7 +30,6 @@ import androidx.compose.ui.graphics.Shape * By default the card is filled with surfaceVariant color. This container card instead fills the * background color with surface corlor. */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun ContainerCard( modifier: Modifier = Modifier, Loading @@ -39,7 +38,7 @@ fun ContainerCard( content: @Composable ColumnScope.() -> Unit, ) { Card( modifier = modifier, modifier = modifier.fillMaxWidth(), shape = shape, border = border, colors = CardDefaults.cardColors( Loading
packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt +4 −19 Original line number Diff line number Diff line Loading @@ -45,18 +45,15 @@ import androidx.core.graphics.drawable.toBitmap import com.android.credentialmanager.R import com.android.credentialmanager.common.CredentialType import com.android.credentialmanager.common.ProviderActivityState import com.android.credentialmanager.common.material.ModalBottomSheetLayout import com.android.credentialmanager.common.material.ModalBottomSheetValue import com.android.credentialmanager.common.material.rememberModalBottomSheetState import com.android.credentialmanager.common.ui.ActionButton import com.android.credentialmanager.common.ui.ConfirmButton import com.android.credentialmanager.common.ui.Entry import com.android.credentialmanager.common.ui.ModalBottomSheet import com.android.credentialmanager.common.ui.TextOnSurface import com.android.credentialmanager.common.ui.TextSecondary import com.android.credentialmanager.common.ui.TextOnSurfaceVariant import com.android.credentialmanager.common.ui.ContainerCard import com.android.credentialmanager.common.ui.ToggleVisibilityButton import com.android.credentialmanager.ui.theme.EntryShape import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme @OptIn(ExperimentalMaterial3Api::class) Loading @@ -65,13 +62,7 @@ fun CreateCredentialScreen( viewModel: CreateCredentialViewModel, providerActivityLauncher: ManagedActivityResultLauncher<IntentSenderRequest, ActivityResult> ) { val state = rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Expanded, skipHalfExpanded = true ) ModalBottomSheetLayout( sheetBackgroundColor = MaterialTheme.colorScheme.surface, sheetState = state, ModalBottomSheet( sheetContent = { val uiState = viewModel.uiState // Hide the sheet content as opposed to the whole bottom sheet to maintain the scrim Loading Loading @@ -153,14 +144,8 @@ fun CreateCredentialScreen( } } }, scrimColor = MaterialTheme.colorScheme.scrim.copy(alpha = 0.8f), sheetShape = EntryShape.TopRoundedCorner, ) {} LaunchedEffect(state.currentValue) { if (state.currentValue == ModalBottomSheetValue.Hidden) { viewModel.onCancel() } } onDismiss = viewModel::onCancel ) } @OptIn(ExperimentalMaterial3Api::class) Loading