Skip to content

Commit c87f270

Browse files
[fix] Fix window insets and navigation in FilePickerScreen and SubMediaScreen
1 parent 3909955 commit c87f270

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

shared/src/commonMain/kotlin/com/skyd/podaura/ui/screen/filepicker/FilePickerScreen.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import com.skyd.compone.component.ComponeTopBarStyle
4949
import com.skyd.compone.component.navigation.LocalNavBackStack
5050
import com.skyd.compone.component.navigation.LocalResultStore
5151
import com.skyd.compone.ext.onlyHorizontal
52-
import com.skyd.compone.ext.plus
52+
import com.skyd.compone.ext.withoutBottom
53+
import com.skyd.compone.ext.withoutTop
5354
import com.skyd.fundation.config.Const
5455
import com.skyd.fundation.config.DEFAULT_FILE_PICKER_PATH
5556
import com.skyd.fundation.ext.isDirectory
@@ -198,16 +199,17 @@ fun FilePickerScreen(
198199
PathLevelIndication(
199200
path = uiState.path,
200201
onRouteTo = { dispatch(FilePickerIntent.NewLocation(it)) },
202+
contentPadding = innerPadding.onlyHorizontal()
201203
)
202204
val resultStore = LocalResultStore.current
203205
LazyColumn(
204206
modifier = Modifier
205207
.fillMaxWidth()
206208
.weight(1f)
207209
.nestedScroll(scrollBehavior.nestedScrollConnection),
208-
contentPadding = innerPadding.onlyHorizontal() + PaddingValues(
209-
bottom = if (pickFolder) 0.dp else innerPadding.calculateBottomPadding(),
210-
),
210+
contentPadding = innerPadding.withoutTop().run {
211+
if (pickFolder) withoutBottom() else this
212+
}
211213
) {
212214
(uiState.fileListState as? FileListState.Success)?.list?.forEach { filePath ->
213215
item {
@@ -227,7 +229,7 @@ fun FilePickerScreen(
227229
result = filePath.toString(),
228230
)
229231
)
230-
navBackStack.removeFirstOrNull()
232+
navBackStack.removeLastOrNull()
231233
}
232234
}
233235
},
@@ -248,11 +250,8 @@ fun FilePickerScreen(
248250
if (pickFolder) {
249251
Button(
250252
modifier = Modifier
251-
.padding(
252-
top = 12.dp,
253-
bottom = 12.dp + innerPadding.calculateBottomPadding(),
254-
)
255-
.padding(horizontal = 16.dp)
253+
.padding(vertical = 12.dp, horizontal = 16.dp)
254+
.padding(innerPadding.withoutTop())
256255
.fillMaxWidth(),
257256
onClick = {
258257
resultStore.setResult(
@@ -265,7 +264,7 @@ fun FilePickerScreen(
265264
result = uiState.path,
266265
)
267266
)
268-
navBackStack.removeFirstOrNull()
267+
navBackStack.removeLastOrNull()
269268
},
270269
) {
271270
Text(text = stringResource(Res.string.file_picker_screen_pick))
@@ -283,7 +282,11 @@ fun FilePickerScreen(
283282
}
284283

285284
@Composable
286-
private fun PathLevelIndication(path: String, onRouteTo: (String) -> Unit) {
285+
private fun PathLevelIndication(
286+
path: String,
287+
onRouteTo: (String) -> Unit,
288+
contentPadding: PaddingValues = PaddingValues()
289+
) {
287290
val scrollState = rememberScrollState()
288291
LaunchedEffect(scrollState.maxValue) {
289292
if (scrollState.canScrollForward) {
@@ -294,6 +297,7 @@ private fun PathLevelIndication(path: String, onRouteTo: (String) -> Unit) {
294297
modifier = Modifier
295298
.horizontalScroll(scrollState)
296299
.padding(horizontal = 12.dp)
300+
.padding(contentPadding)
297301
.animateContentSize(),
298302
verticalAlignment = Alignment.CenterVertically,
299303
) {

shared/src/commonMain/kotlin/com/skyd/podaura/ui/screen/media/sub/SubMediaScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fun SubMediaScreenRoute(media: MediaBean?) {
6868
title = { Text(text = stringResource(Res.string.warning)) },
6969
text = { Text(text = stringResource(Res.string.sub_media_screen_path_illegal)) },
7070
confirmButton = {
71-
TextButton(onClick = { navBackStack.removeFirstOrNull() }) {
71+
TextButton(onClick = navBackStack::removeLastOrNull) {
7272
Text(text = stringResource(Res.string.exit))
7373
}
7474
},

0 commit comments

Comments
 (0)