Skip to content

Commit 74c1605

Browse files
authored
Merge pull request #27 from hrach/modal-sheet-fixes
Fixes for ModalSheet
2 parents 105787c + 8bbc4de commit 74c1605

File tree

8 files changed

+259
-39
lines changed

8 files changed

+259
-39
lines changed

demo/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
defaultConfig {
1717
applicationId = "dev.hrach.navigation.demo"
1818
minSdk = 26
19-
targetSdk = 34
19+
targetSdk = 35
2020
versionName = "1.0.0"
2121
versionCode = 1
2222
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -48,6 +48,7 @@ android {
4848

4949
lint {
5050
disable.add("GradleDependency")
51+
disable.add("OldTargetApi")
5152
abortOnError = true
5253
warningsAsErrors = true
5354
}

demo/src/main/kotlin/dev/hrach/navigation/demo/NavHost.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.hrach.navigation.demo
22

3+
import androidx.compose.material3.MaterialTheme
34
import androidx.compose.runtime.Composable
45
import androidx.navigation.NavHostController
56
import androidx.navigation.compose.NavHost
@@ -34,6 +35,6 @@ internal fun NavHost(
3435
modalSheet<Destinations.Modal2> { Modal2() }
3536
bottomSheet<Destinations.BottomSheet> { BottomSheet(navController) }
3637
}
37-
ModalSheetHost(modalSheetNavigator)
38+
ModalSheetHost(modalSheetNavigator, containerColor = MaterialTheme.colorScheme.background)
3839
BottomSheetHost(bottomSheetNavigator)
3940
}

demo/src/main/kotlin/dev/hrach/navigation/demo/screens/Modal1.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package dev.hrach.navigation.demo.screens
22

33
import android.annotation.SuppressLint
4-
import androidx.compose.foundation.background
54
import androidx.compose.foundation.layout.Column
65
import androidx.compose.foundation.layout.WindowInsets
76
import androidx.compose.foundation.layout.fillMaxSize
87
import androidx.compose.foundation.layout.systemBars
98
import androidx.compose.foundation.layout.windowInsetsPadding
109
import androidx.compose.material3.MaterialTheme
1110
import androidx.compose.material3.OutlinedButton
11+
import androidx.compose.material3.Surface
1212
import androidx.compose.material3.Text
1313
import androidx.compose.runtime.Composable
1414
import androidx.compose.runtime.getValue
@@ -42,19 +42,22 @@ private fun Modal1(
4242
navigate: (Any) -> Unit,
4343
bottomSheetResult: Int,
4444
) {
45-
Column(
46-
Modifier
47-
.fillMaxSize()
48-
.background(MaterialTheme.colorScheme.surface)
49-
.windowInsetsPadding(WindowInsets.systemBars),
45+
Surface(
46+
color = MaterialTheme.colorScheme.inverseSurface,
5047
) {
51-
Text("Modal 1")
52-
OutlinedButton(onClick = { navigate(Destinations.Modal2) }) {
53-
Text("Modal 2")
48+
Column(
49+
modifier = Modifier
50+
.fillMaxSize()
51+
.windowInsetsPadding(WindowInsets.systemBars),
52+
) {
53+
Text("Modal 1")
54+
OutlinedButton(onClick = { navigate(Destinations.Modal2) }) {
55+
Text("Modal 2")
56+
}
57+
OutlinedButton(onClick = { navigate(Destinations.BottomSheet) }) {
58+
Text("BottomSheet")
59+
}
60+
Text("BottomSheetResult: $bottomSheetResult")
5461
}
55-
OutlinedButton(onClick = { navigate(Destinations.BottomSheet) }) {
56-
Text("BottomSheet")
57-
}
58-
Text("BottomSheetResult: $bottomSheetResult")
5962
}
6063
}

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ kotlin-serialization-core = "org.jetbrains.kotlinx:kotlinx-serialization-core:1.
99
kotlin-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
1010
appcompat = "androidx.appcompat:appcompat:1.6.1"
1111
androidx-lifecycle-runtime = "androidx.lifecycle:lifecycle-runtime:2.8.1"
12+
compose-foundation = "androidx.compose.foundation:foundation:1.6.8"
1213
compose-material3 = "androidx.compose.material3:material3:1.3.0-beta04"
1314
navigation-compose = "androidx.navigation:navigation-compose:2.8.0-beta04"
1415
junit = { module = "junit:junit", version = "4.13.2" }

modalsheet/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ kotlinter {
5555

5656
dependencies {
5757
implementation(libs.appcompat)
58+
implementation(libs.compose.foundation)
5859
implementation(libs.navigation.compose)
5960

6061
testImplementation(libs.junit)

0 commit comments

Comments
 (0)