修复LocationDetail的Sheet样式

This commit is contained in:
2024-07-16 03:12:27 +08:00
parent e2943a71e4
commit a3fba7d7e9
4 changed files with 28 additions and 35 deletions

1
.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
RiderPro

View File

@@ -4,29 +4,15 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-07-11T19:09:15.409616Z"> <DropdownSelection timestamp="2024-07-15T18:00:33.224509Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/Users/kevinlinpr/.android/avd/Pixel_8_Pro_API_34.avd" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=R5CX21KR1NR" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>
<DialogSelection /> <DialogSelection />
</SelectionState> </SelectionState>
<SelectionState runConfigName="GreetingPreview">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-06-13T20:34:51.683789Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/Users/kevinlinpr/.android/avd/Pixel_8_Pro_API_34.avd" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
<SelectionState runConfigName="LocationDetail">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates> </selectionStates>
</component> </component>
</project> </project>

2
.idea/vcs.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>

View File

@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
@@ -33,22 +34,34 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SheetValue
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.material3.rememberBottomSheetScaffoldState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import kotlinx.coroutines.launch
data class OfficialGalleryItem( data class OfficialGalleryItem(
val id: Int, val id: Int,
@@ -107,12 +120,10 @@ fun LocationDetail() {
val navController = LocalNavController.current val navController = LocalNavController.current
// 2/3 height of the screen // 2/3 height of the screen
fun getPeekHeight(): Dp { fun getPeekHeight(): Dp {
val screenHeight = configuration.screenHeightDp val screenHeight = configuration.screenHeightDp
val peekHeight = (screenHeight * 2 / 3).dp val peekHeight = (screenHeight * 2 / 3).dp
return peekHeight return peekHeight
} }
fun getNoPeekHeight(): Dp { fun getNoPeekHeight(): Dp {
val screenHeight = configuration.screenHeightDp val screenHeight = configuration.screenHeightDp
val peekHeight = (screenHeight * 1 / 3).dp val peekHeight = (screenHeight * 1 / 3).dp
@@ -121,26 +132,21 @@ fun LocationDetail() {
Box( Box(
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) { ) {
Box( Image(
painter = painterResource(id = R.drawable.default_moment_img),
contentDescription = "Location Image",
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(getNoPeekHeight() + 32.dp), .height(getNoPeekHeight() + 100.dp),
contentAlignment = Alignment.Center contentScale = ContentScale.Crop
) { )
Image( val bottomSheetScaffoldState = rememberBottomSheetScaffoldState()
painter = painterResource(id = R.drawable.default_moment_img),
contentDescription = "Location Image",
modifier = Modifier
.fillMaxWidth()
.height(getNoPeekHeight() + 32.dp),
contentScale = ContentScale.Crop
)
}
BottomSheetScaffold( BottomSheetScaffold(
scaffoldState = scaffoldState, scaffoldState = scaffoldState,
sheetPeekHeight = getPeekHeight(), sheetPeekHeight = getPeekHeight(),
sheetShadowElevation = 0.dp,
sheetContainerColor = Color.Transparent, sheetContainerColor = Color.Transparent,
sheetShape = RoundedCornerShape(16.dp), sheetShape = RoundedCornerShape(16.dp, 16.dp, 0.dp, 0.dp),
sheetDragHandle = null, sheetDragHandle = null,
sheetContent = { sheetContent = {
Column( Column(
@@ -341,8 +347,8 @@ fun LocationDetail() {
} }
} },
) { innerPadding -> ) {
} }
} }