Skip to content

Commit

Permalink
updated version to 0.0.8
Browse files Browse the repository at this point in the history
added temporary fix for supporting detents for ios bottomsheet
  • Loading branch information
Kashif-E committed Nov 7, 2024
1 parent 36bb6e9 commit 8799bf2
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 127 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mavenPublishing {
coordinates(
groupId = "io.github.kashif-mehmood-km",
artifactId = "common",
version = "0.0.7"
version = "0.0.8"
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.kashif.sample.voyager

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material.Colors
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.bottomSheet.LocalBottomSheetNavigator
import com.kashif.voyant.hideX
Expand All @@ -19,7 +25,7 @@ class SampleBottomSheet : Screen {

val bottomSheetNavigator = LocalBottomSheetNavigator.current
Column(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth().height(250.dp).border(1.dp, Color.Red),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ScreenC : Screen {
)

Button(
onClick = { bottomSheetNavigator.showX(SampleBottomSheet()) },
onClick = { bottomSheetNavigator.showX(SampleBottomSheet(), fixedHeight = 250.0) },
content = { Text("show bottom sheet") }
)
}
Expand Down
2 changes: 1 addition & 1 deletion navigationComposeX/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mavenPublishing {
coordinates(
groupId = "io.github.kashif-mehmood-km",
artifactId = "voyant-navigation-compose",
version = "0.0.7"
version = "0.0.8"
)


Expand Down
173 changes: 76 additions & 97 deletions voyagerX/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,132 +1,111 @@
import com.vanniktech.maven.publish.SonatypeHost

plugins {
alias(libs.plugins.multiplatform)
alias(libs.plugins.android.library)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
id("com.vanniktech.maven.publish") version "0.28.0"
kotlin("plugin.serialization") version "2.0.20"
alias(libs.plugins.multiplatform)
alias(libs.plugins.android.library)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
id("com.vanniktech.maven.publish") version "0.28.0"
kotlin("plugin.serialization") version "2.0.20"
}

group = "com.kashif.voyant.voyagerx"

version = "1.0"

kotlin {
jvmToolchain(11)
androidTarget {
publishLibraryVariants("release")
}
jvmToolchain(11)
androidTarget { publishLibraryVariants("release") }

jvm()
jvm()

wasmJs {
browser()
binaries.executable()
wasmJs {
browser()
binaries.executable()
}

listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
it.binaries.framework {
baseName = "voyagerX"
isStatic = true
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "voyagerX"
isStatic = true
}
sourceSets {
commonMain.dependencies {
api(projects.common)
api(libs.voyager.navigator)
api(libs.voyager.bottom.sheet.navigator)
}

sourceSets {
commonMain.dependencies {
api(projects.common)
api(libs.voyager.navigator)
api(libs.voyager.bottom.sheet.navigator)
}
commonTest.dependencies {}

commonTest.dependencies {
androidMain.dependencies {}

}
jvmMain.dependencies {}

androidMain.dependencies {
appleMain.dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") }
}

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

jvmMain.dependencies {
android {
namespace = "com.kashif.voyant.voyagerx"
compileSdk = 35

}
defaultConfig { minSdk = 21 }

publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}

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

}
}

android {
namespace = "com.kashif.voyant.voyagerx"
compileSdk = 35
dependencies { implementation(libs.androidx.core.ktx) }

defaultConfig {
minSdk = 21
mavenPublishing {
coordinates(
groupId = "io.github.kashif-mehmood-km", artifactId = "voyant-voyagerx", version = "0.0.8")

pom {
name.set("Voyant-VoyagerX")
description.set(
"Voyant is an extension library for Voyager and Navigation Compose to use native navigation on apple platforms..")
inceptionYear.set("2024")
url.set("https://github.com/kashif-e/voyant")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}


publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}

// For debug variant, we exclude Javadoc and sources to prevent conflicts
singleVariant("debug") {
// Exclude Javadoc and sources JARs for debug variant
}
developers {
developer {
id.set("Kashif-E")
name.set("Kashif")
email.set("[email protected]")
}
}
}
dependencies {
implementation(libs.androidx.core.ktx)
}

mavenPublishing {
coordinates(
groupId = "io.github.kashif-mehmood-km",
artifactId = "voyant-voyagerx",
version = "0.0.7"
)



pom {
name.set("Voyant-VoyagerX")
description.set("Voyant is an extension library for Voyager and Navigation Compose to use native navigation on apple platforms..")
inceptionYear.set("2024")
url.set("https://github.com/kashif-e/voyant")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("Kashif-E")
name.set("Kashif")
email.set("[email protected]")
}
}

scm {
url.set("https://github.com/kashif-e/voyant")
}
}
scm { url.set("https://github.com/kashif-e/voyant") }
}

// Configure publishing to Maven Central
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
// Configure publishing to Maven Central
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

// Enable GPG signing for all publications
signAllPublications()
// Enable GPG signing for all publications
signAllPublications()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator

actual fun Navigator.popX() {
pop()
pop()
}

actual fun Navigator.pushX(screen: Screen) {
push(screen)
push(screen)
}

actual fun Navigator.popUntilRootX() {
popUntilRoot()
popUntilRoot()
}

actual fun BottomSheetNavigator.showX(screen: Screen) {
show(screen)
actual fun BottomSheetNavigator.showX(
screen: Screen,
skipHalfExpanded: Boolean,
fixedHeight: Double
) {
show(screen)
}

actual fun BottomSheetNavigator.hideX() {
hide()
}
hide()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import com.kashif.voyant_common.extensions.UIViewControllerWrapper
import com.kashif.voyant_common.extensions.getNavigationController
import com.kashif.voyant_common.extensions.getTopViewController
import platform.Foundation.NSLog
import platform.UIKit.UIModalPresentationPageSheet
import platform.UIKit.UIModalTransitionStyleCoverVertical
import platform.UIKit.UISheetPresentationControllerDetent
import platform.UIKit.UIViewController
import platform.UIKit.hidesBottomBarWhenPushed
import platform.UIKit.sheetPresentationController

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

actual fun BottomSheetNavigator.showX(screen: Screen) {
val viewController = extendedComposeViewController(screen = screen)
val topVc = getTopViewController()
topVc?.presentViewController(viewController, animated = true, completion = null)
actual fun BottomSheetNavigator.showX(
screen: Screen,
skipHalfExpanded: Boolean,
fixedHeight: Double
) {

val viewController =
extendedComposeViewController(
screen = screen,
)
.apply {
modalPresentationStyle = UIModalPresentationPageSheet
modalTransitionStyle = UIModalTransitionStyleCoverVertical

sheetPresentationController?.detents =
when {
skipHalfExpanded -> listOf(UISheetPresentationControllerDetent.largeDetent())
fixedHeight > 0.0 ->
listOf(
UISheetPresentationControllerDetent.customDetentWithIdentifier(
identifier = "customDetent") { _,
->
fixedHeight
})
else -> listOf(UISheetPresentationControllerDetent.mediumDetent())
}

sheetPresentationController?.prefersGrabberVisible = true
}

getTopViewController()?.presentViewController(viewController, animated = true, completion = null)
?: run { NSLog("TopViewController is null") }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ expect fun Navigator.popUntilRootX()

expect fun BottomSheetNavigator.hideX()

expect fun BottomSheetNavigator.showX(screen: Screen)
/**
* fixed height and skip half expanded are only for ios bottomsheet
*/
expect fun BottomSheetNavigator.showX(
screen: Screen,
skipHalfExpanded: Boolean = false,
fixedHeight: Double = 0.0
)
Loading

0 comments on commit 8799bf2

Please sign in to comment.