Create sheetStateForPreview to avoid code duplication.

This commit is contained in:
Benoit Marty
2023-07-20 16:12:33 +02:00
committed by Benoit Marty
parent 5edcffca93
commit d84a9d5d24
2 changed files with 29 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* 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 io.element.android.libraries.designsystem.preview
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
@OptIn(ExperimentalMaterial3Api::class)
val sheetStateForPreview = SheetState(
skipPartiallyExpanded = true,
initialValue = SheetValue.Expanded,
)

View File

@@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.material3.contentColorFor
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
@@ -38,6 +37,7 @@ import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.preview.sheetStateForPreview
import io.element.android.libraries.theme.ElementTheme
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
@@ -100,10 +100,7 @@ private fun ContentToPreview() {
) {
ModalBottomSheet(
onDismissRequest = {},
sheetState = SheetState(
skipPartiallyExpanded = true,
initialValue = SheetValue.Expanded,
),
sheetState = sheetStateForPreview,
) {
Text(
text = "Sheet Content",