Skip to content

Commit 8799bf2

Browse files
committed
updated version to 0.0.8
added temporary fix for supporting detents for ios bottomsheet
1 parent 36bb6e9 commit 8799bf2

File tree

10 files changed

+162
-127
lines changed

10 files changed

+162
-127
lines changed

common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ mavenPublishing {
9393
coordinates(
9494
groupId = "io.github.kashif-mehmood-km",
9595
artifactId = "common",
96-
version = "0.0.7"
96+
version = "0.0.8"
9797
)
9898

9999

composeApp/src/commonMain/kotlin/com/kashif/sample/voyager/SampleBottomSheet.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package com.kashif.sample.voyager
22

3+
import androidx.compose.foundation.border
34
import androidx.compose.foundation.layout.Arrangement
45
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.fillMaxSize
57
import androidx.compose.foundation.layout.fillMaxWidth
8+
import androidx.compose.foundation.layout.height
9+
import androidx.compose.material.Colors
610
import androidx.compose.material3.Button
711
import androidx.compose.material3.MaterialTheme
812
import androidx.compose.material3.Text
913
import androidx.compose.runtime.Composable
1014
import androidx.compose.ui.Alignment
1115
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.graphics.Color
17+
import androidx.compose.ui.unit.dp
1218
import cafe.adriel.voyager.core.screen.Screen
1319
import cafe.adriel.voyager.navigator.bottomSheet.LocalBottomSheetNavigator
1420
import com.kashif.voyant.hideX
@@ -19,7 +25,7 @@ class SampleBottomSheet : Screen {
1925

2026
val bottomSheetNavigator = LocalBottomSheetNavigator.current
2127
Column(
22-
modifier = Modifier.fillMaxWidth(),
28+
modifier = Modifier.fillMaxWidth().height(250.dp).border(1.dp, Color.Red),
2329
verticalArrangement = Arrangement.Center,
2430
horizontalAlignment = Alignment.CenterHorizontally
2531
) {

composeApp/src/commonMain/kotlin/com/kashif/sample/voyager/ScreenC.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ScreenC : Screen {
4242
)
4343

4444
Button(
45-
onClick = { bottomSheetNavigator.showX(SampleBottomSheet()) },
45+
onClick = { bottomSheetNavigator.showX(SampleBottomSheet(), fixedHeight = 250.0) },
4646
content = { Text("show bottom sheet") }
4747
)
4848
}

navigationComposeX/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mavenPublishing {
8888
coordinates(
8989
groupId = "io.github.kashif-mehmood-km",
9090
artifactId = "voyant-navigation-compose",
91-
version = "0.0.7"
91+
version = "0.0.8"
9292
)
9393

9494

voyagerX/build.gradle.kts

Lines changed: 76 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,111 @@
11
import com.vanniktech.maven.publish.SonatypeHost
22

33
plugins {
4-
alias(libs.plugins.multiplatform)
5-
alias(libs.plugins.android.library)
6-
alias(libs.plugins.compose.compiler)
7-
alias(libs.plugins.compose)
8-
id("com.vanniktech.maven.publish") version "0.28.0"
9-
kotlin("plugin.serialization") version "2.0.20"
4+
alias(libs.plugins.multiplatform)
5+
alias(libs.plugins.android.library)
6+
alias(libs.plugins.compose.compiler)
7+
alias(libs.plugins.compose)
8+
id("com.vanniktech.maven.publish") version "0.28.0"
9+
kotlin("plugin.serialization") version "2.0.20"
1010
}
1111

1212
group = "com.kashif.voyant.voyagerx"
13+
1314
version = "1.0"
1415

1516
kotlin {
16-
jvmToolchain(11)
17-
androidTarget {
18-
publishLibraryVariants("release")
19-
}
17+
jvmToolchain(11)
18+
androidTarget { publishLibraryVariants("release") }
2019

21-
jvm()
20+
jvm()
2221

23-
wasmJs {
24-
browser()
25-
binaries.executable()
22+
wasmJs {
23+
browser()
24+
binaries.executable()
25+
}
26+
27+
listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
28+
it.binaries.framework {
29+
baseName = "voyagerX"
30+
isStatic = true
2631
}
32+
}
2733

28-
listOf(
29-
iosX64(),
30-
iosArm64(),
31-
iosSimulatorArm64()
32-
).forEach {
33-
it.binaries.framework {
34-
baseName = "voyagerX"
35-
isStatic = true
36-
}
34+
sourceSets {
35+
commonMain.dependencies {
36+
api(projects.common)
37+
api(libs.voyager.navigator)
38+
api(libs.voyager.bottom.sheet.navigator)
3739
}
3840

39-
sourceSets {
40-
commonMain.dependencies {
41-
api(projects.common)
42-
api(libs.voyager.navigator)
43-
api(libs.voyager.bottom.sheet.navigator)
44-
}
41+
commonTest.dependencies {}
4542

46-
commonTest.dependencies {
43+
androidMain.dependencies {}
4744

48-
}
45+
jvmMain.dependencies {}
4946

50-
androidMain.dependencies {
47+
appleMain.dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") }
48+
}
5149

52-
}
50+
// https://kotlinlang.org/docs/native-objc-interop.html#export-of-kdoc-comments-to-generated-objective-c-headers
51+
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
52+
compilations["main"].compilerOptions.options.freeCompilerArgs.add("-Xexport-kdoc")
53+
}
54+
}
5355

54-
jvmMain.dependencies {
56+
android {
57+
namespace = "com.kashif.voyant.voyagerx"
58+
compileSdk = 35
5559

56-
}
60+
defaultConfig { minSdk = 21 }
5761

62+
publishing {
63+
singleVariant("release") {
64+
withJavadocJar()
65+
withSourcesJar()
5866
}
5967

60-
//https://kotlinlang.org/docs/native-objc-interop.html#export-of-kdoc-comments-to-generated-objective-c-headers
61-
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
62-
compilations["main"].compilerOptions.options.freeCompilerArgs.add("-Xexport-kdoc")
68+
// For debug variant, we exclude Javadoc and sources to prevent conflicts
69+
singleVariant("debug") {
70+
// Exclude Javadoc and sources JARs for debug variant
6371
}
64-
72+
}
6573
}
6674

67-
android {
68-
namespace = "com.kashif.voyant.voyagerx"
69-
compileSdk = 35
75+
dependencies { implementation(libs.androidx.core.ktx) }
7076

71-
defaultConfig {
72-
minSdk = 21
77+
mavenPublishing {
78+
coordinates(
79+
groupId = "io.github.kashif-mehmood-km", artifactId = "voyant-voyagerx", version = "0.0.8")
80+
81+
pom {
82+
name.set("Voyant-VoyagerX")
83+
description.set(
84+
"Voyant is an extension library for Voyager and Navigation Compose to use native navigation on apple platforms..")
85+
inceptionYear.set("2024")
86+
url.set("https://github.com/kashif-e/voyant")
87+
88+
licenses {
89+
license {
90+
name.set("MIT")
91+
url.set("https://opensource.org/licenses/MIT")
92+
}
7393
}
7494

75-
76-
publishing {
77-
singleVariant("release") {
78-
withJavadocJar()
79-
withSourcesJar()
80-
}
81-
82-
// For debug variant, we exclude Javadoc and sources to prevent conflicts
83-
singleVariant("debug") {
84-
// Exclude Javadoc and sources JARs for debug variant
85-
}
95+
developers {
96+
developer {
97+
id.set("Kashif-E")
98+
name.set("Kashif")
99+
email.set("[email protected]")
100+
}
86101
}
87-
}
88-
dependencies {
89-
implementation(libs.androidx.core.ktx)
90-
}
91102

92-
mavenPublishing {
93-
coordinates(
94-
groupId = "io.github.kashif-mehmood-km",
95-
artifactId = "voyant-voyagerx",
96-
version = "0.0.7"
97-
)
98-
99-
100-
101-
pom {
102-
name.set("Voyant-VoyagerX")
103-
description.set("Voyant is an extension library for Voyager and Navigation Compose to use native navigation on apple platforms..")
104-
inceptionYear.set("2024")
105-
url.set("https://github.com/kashif-e/voyant")
106-
107-
licenses {
108-
license {
109-
name.set("MIT")
110-
url.set("https://opensource.org/licenses/MIT")
111-
}
112-
}
113-
114-
developers {
115-
developer {
116-
id.set("Kashif-E")
117-
name.set("Kashif")
118-
email.set("[email protected]")
119-
}
120-
}
121-
122-
scm {
123-
url.set("https://github.com/kashif-e/voyant")
124-
}
125-
}
103+
scm { url.set("https://github.com/kashif-e/voyant") }
104+
}
126105

127-
// Configure publishing to Maven Central
128-
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
106+
// Configure publishing to Maven Central
107+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
129108

130-
// Enable GPG signing for all publications
131-
signAllPublications()
109+
// Enable GPG signing for all publications
110+
signAllPublications()
132111
}

voyagerX/src/androidMain/kotlin/com/kashif/voyant/Extensions.android.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@ import cafe.adriel.voyager.navigator.Navigator
55
import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator
66

77
actual fun Navigator.popX() {
8-
pop()
8+
pop()
99
}
1010

1111
actual fun Navigator.pushX(screen: Screen) {
12-
push(screen)
12+
push(screen)
1313
}
1414

1515
actual fun Navigator.popUntilRootX() {
16-
popUntilRoot()
16+
popUntilRoot()
1717
}
1818

19-
actual fun BottomSheetNavigator.showX(screen: Screen) {
20-
show(screen)
19+
actual fun BottomSheetNavigator.showX(
20+
screen: Screen,
21+
skipHalfExpanded: Boolean,
22+
fixedHeight: Double
23+
) {
24+
show(screen)
2125
}
2226

2327
actual fun BottomSheetNavigator.hideX() {
24-
hide()
25-
}
28+
hide()
29+
}

voyagerX/src/appleMain/kotlin/com/kashif/voyant/Extensions.apple.kt

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import com.kashif.voyant_common.extensions.UIViewControllerWrapper
1212
import com.kashif.voyant_common.extensions.getNavigationController
1313
import com.kashif.voyant_common.extensions.getTopViewController
1414
import platform.Foundation.NSLog
15+
import platform.UIKit.UIModalPresentationPageSheet
16+
import platform.UIKit.UIModalTransitionStyleCoverVertical
17+
import platform.UIKit.UISheetPresentationControllerDetent
1518
import platform.UIKit.UIViewController
1619
import platform.UIKit.hidesBottomBarWhenPushed
20+
import platform.UIKit.sheetPresentationController
1721

1822
/**
1923
* Pushes a new screen onto the navigation stack.
@@ -54,10 +58,37 @@ actual fun BottomSheetNavigator.hideX() {
5458
topVc?.dismissViewControllerAnimated(true, null) ?: run { NSLog("TopViewController is null") }
5559
}
5660

57-
actual fun BottomSheetNavigator.showX(screen: Screen) {
58-
val viewController = extendedComposeViewController(screen = screen)
59-
val topVc = getTopViewController()
60-
topVc?.presentViewController(viewController, animated = true, completion = null)
61+
actual fun BottomSheetNavigator.showX(
62+
screen: Screen,
63+
skipHalfExpanded: Boolean,
64+
fixedHeight: Double
65+
) {
66+
67+
val viewController =
68+
extendedComposeViewController(
69+
screen = screen,
70+
)
71+
.apply {
72+
modalPresentationStyle = UIModalPresentationPageSheet
73+
modalTransitionStyle = UIModalTransitionStyleCoverVertical
74+
75+
sheetPresentationController?.detents =
76+
when {
77+
skipHalfExpanded -> listOf(UISheetPresentationControllerDetent.largeDetent())
78+
fixedHeight > 0.0 ->
79+
listOf(
80+
UISheetPresentationControllerDetent.customDetentWithIdentifier(
81+
identifier = "customDetent") { _,
82+
->
83+
fixedHeight
84+
})
85+
else -> listOf(UISheetPresentationControllerDetent.mediumDetent())
86+
}
87+
88+
sheetPresentationController?.prefersGrabberVisible = true
89+
}
90+
91+
getTopViewController()?.presentViewController(viewController, animated = true, completion = null)
6192
?: run { NSLog("TopViewController is null") }
6293
}
6394

voyagerX/src/commonMain/kotlin/com/kashif/voyant/Extensions.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ expect fun Navigator.popUntilRootX()
1212

1313
expect fun BottomSheetNavigator.hideX()
1414

15-
expect fun BottomSheetNavigator.showX(screen: Screen)
15+
/**
16+
* fixed height and skip half expanded are only for ios bottomsheet
17+
*/
18+
expect fun BottomSheetNavigator.showX(
19+
screen: Screen,
20+
skipHalfExpanded: Boolean = false,
21+
fixedHeight: Double = 0.0
22+
)

0 commit comments

Comments
 (0)