Skip to content

Commit

Permalink
Merge pull request #27 from hrach/modal-sheet-fixes
Browse files Browse the repository at this point in the history
Fixes for ModalSheet
  • Loading branch information
hrach authored Jul 14, 2024
2 parents 105787c + 8bbc4de commit 74c1605
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 39 deletions.
3 changes: 2 additions & 1 deletion demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
defaultConfig {
applicationId = "dev.hrach.navigation.demo"
minSdk = 26
targetSdk = 34
targetSdk = 35
versionName = "1.0.0"
versionCode = 1
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -48,6 +48,7 @@ android {

lint {
disable.add("GradleDependency")
disable.add("OldTargetApi")
abortOnError = true
warningsAsErrors = true
}
Expand Down
3 changes: 2 additions & 1 deletion demo/src/main/kotlin/dev/hrach/navigation/demo/NavHost.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hrach.navigation.demo

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
Expand Down Expand Up @@ -34,6 +35,6 @@ internal fun NavHost(
modalSheet<Destinations.Modal2> { Modal2() }
bottomSheet<Destinations.BottomSheet> { BottomSheet(navController) }
}
ModalSheetHost(modalSheetNavigator)
ModalSheetHost(modalSheetNavigator, containerColor = MaterialTheme.colorScheme.background)
BottomSheetHost(bottomSheetNavigator)
}
29 changes: 16 additions & 13 deletions demo/src/main/kotlin/dev/hrach/navigation/demo/screens/Modal1.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package dev.hrach.navigation.demo.screens

import android.annotation.SuppressLint
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -42,19 +42,22 @@ private fun Modal1(
navigate: (Any) -> Unit,
bottomSheetResult: Int,
) {
Column(
Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.surface)
.windowInsetsPadding(WindowInsets.systemBars),
Surface(
color = MaterialTheme.colorScheme.inverseSurface,
) {
Text("Modal 1")
OutlinedButton(onClick = { navigate(Destinations.Modal2) }) {
Text("Modal 2")
Column(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.systemBars),
) {
Text("Modal 1")
OutlinedButton(onClick = { navigate(Destinations.Modal2) }) {
Text("Modal 2")
}
OutlinedButton(onClick = { navigate(Destinations.BottomSheet) }) {
Text("BottomSheet")
}
Text("BottomSheetResult: $bottomSheetResult")
}
OutlinedButton(onClick = { navigate(Destinations.BottomSheet) }) {
Text("BottomSheet")
}
Text("BottomSheetResult: $bottomSheetResult")
}
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin-serialization-core = "org.jetbrains.kotlinx:kotlinx-serialization-core:1.
kotlin-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
appcompat = "androidx.appcompat:appcompat:1.6.1"
androidx-lifecycle-runtime = "androidx.lifecycle:lifecycle-runtime:2.8.1"
compose-foundation = "androidx.compose.foundation:foundation:1.6.8"
compose-material3 = "androidx.compose.material3:material3:1.3.0-beta04"
navigation-compose = "androidx.navigation:navigation-compose:2.8.0-beta04"
junit = { module = "junit:junit", version = "4.13.2" }
1 change: 1 addition & 0 deletions modalsheet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ kotlinter {

dependencies {
implementation(libs.appcompat)
implementation(libs.compose.foundation)
implementation(libs.navigation.compose)

testImplementation(libs.junit)
Expand Down
Loading

0 comments on commit 74c1605

Please sign in to comment.