-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use bottom sheets on non-android (#19)
The skiko/native implementation is... bad, and super janky, and crashes.
- Loading branch information
Showing
12 changed files
with
139 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/androidMain/kotlin/dev/zacsweers/fieldspottr/util/platform.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2024 Zac Sweers | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package dev.zacsweers.fieldspottr.util | ||
|
||
actual val CurrentPlatform: Platform = Platform.Android |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/commonMain/kotlin/dev/zacsweers/fieldspottr/ScaffoldScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (C) 2024 Zac Sweers | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package dev.zacsweers.fieldspottr | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.CenterAlignedTopAppBar | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import com.slack.circuit.foundation.CircuitContent | ||
import com.slack.circuit.runtime.CircuitUiState | ||
import com.slack.circuit.runtime.Navigator | ||
import com.slack.circuit.runtime.screen.Screen | ||
import dev.zacsweers.fieldspottr.parcel.CommonParcelize | ||
|
||
@CommonParcelize | ||
data class ScaffoldScreen(val title: String = "Field Spottr", val contentScreen: Screen) : Screen { | ||
data class State(val title: String, val contentScreen: Screen, val onBackPressed: () -> Unit) : | ||
CircuitUiState | ||
} | ||
|
||
@Composable | ||
fun ScaffoldPresenter(screen: ScaffoldScreen, navigator: Navigator): ScaffoldScreen.State { | ||
return ScaffoldScreen.State(screen.title, screen.contentScreen, navigator::pop) | ||
} | ||
|
||
@Composable | ||
fun ScaffoldScreenContent(state: ScaffoldScreen.State, modifier: Modifier = Modifier) { | ||
Scaffold( | ||
modifier = modifier, | ||
topBar = { | ||
CenterAlignedTopAppBar( | ||
title = { Text(state.title, fontWeight = FontWeight.Black, fontStyle = FontStyle.Italic) }, | ||
navigationIcon = { | ||
// TODO platform-default back button? | ||
IconButton(onClick = { state.onBackPressed() }) { | ||
Icon(Icons.AutoMirrored.Default.ArrowBack, contentDescription = "Close") | ||
} | ||
}, | ||
) | ||
}, | ||
) { innerPadding -> | ||
CircuitContent(state.contentScreen, modifier = Modifier.padding(innerPadding)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/commonMain/kotlin/dev/zacsweers/fieldspottr/util/platform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2024 Zac Sweers | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package dev.zacsweers.fieldspottr.util | ||
|
||
enum class Platform { | ||
Android, | ||
Jvm, | ||
Native, | ||
} | ||
|
||
expect val CurrentPlatform: Platform |
5 changes: 5 additions & 0 deletions
5
src/jvmMain/kotlin/dev/zacsweers/fieldspottr/util/platform.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2024 Zac Sweers | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package dev.zacsweers.fieldspottr.util | ||
|
||
actual val CurrentPlatform: Platform = Platform.Jvm |
5 changes: 5 additions & 0 deletions
5
src/nativeMain/kotlin/dev/zacsweers/fieldspottr/util/platform.native.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2024 Zac Sweers | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package dev.zacsweers.fieldspottr.util | ||
|
||
actual val CurrentPlatform: Platform = Platform.Native |