Skip to content

Commit

Permalink
bottom sheet width set to 60% in landscape mode and aligned center (#659
Browse files Browse the repository at this point in the history
)

* bottom sheet width set to 60% in landscape mode and aligned center

* changing default max landscape width to 1F

---------

Co-authored-by: Ayaan Shakil <[email protected]>
  • Loading branch information
ayanshakil and Ayaan Shakil authored Jun 14, 2024
1 parent 3377e4c commit c8e42d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ open class BottomSheetTokens : IControlToken, Parcelable {

@Composable
open fun scrimOpacity(bottomSheetInfo: BottomSheetInfo): Float = 0.32F

@Composable
open fun maxLandscapeWidth (bottomSheetInfo: BottomSheetInfo): Float = 1F
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.microsoft.fluentui.tokenized.bottomsheet

import android.content.res.Configuration
import android.view.*
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.foundation.*
Expand All @@ -29,6 +30,7 @@ import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.*
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -251,6 +253,7 @@ fun BottomSheet(
tokens.scrimColor(bottomSheetInfo).copy(alpha = scrimOpacity)

val scope = rememberCoroutineScope()
val maxLandscapeWidth :Float= tokens.maxLandscapeWidth(bottomSheetInfo)

BoxWithConstraints(modifier) {
val fullHeight = constraints.maxHeight.toFloat()
Expand All @@ -260,6 +263,7 @@ fun BottomSheet(
Box(
Modifier
.fillMaxSize()
.align(Alignment.Center)
.semantics {
if (!sheetState.isVisible) {
expand {
Expand Down Expand Up @@ -301,10 +305,14 @@ fun BottomSheet(
)
}
}
val configuration = LocalConfiguration.current

Box(
Modifier
.fillMaxWidth()
.fillMaxWidth(
if(configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)maxLandscapeWidth
else 1F
)
.nestedScroll(
if (!enableSwipeDismiss && sheetState.offset.value >= (fullHeight - dpToPx(
peekHeight
Expand Down

0 comments on commit c8e42d0

Please sign in to comment.