From 4d4ca47bfe9ac03bd68abfe28063022b6f7b1e2d Mon Sep 17 00:00:00 2001 From: Kashif Mehmood Date: Sat, 28 Sep 2024 17:04:16 +0500 Subject: [PATCH] removed dead code --- .../com/kashif/voyant/Extensions.apple.kt | 7 ++- .../extensions/UIVIewControllerExtensions.kt | 29 +---------- .../extensions/UIViewControllerWrapper.kt | 52 +++---------------- 3 files changed, 15 insertions(+), 73 deletions(-) diff --git a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/Extensions.apple.kt b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/Extensions.apple.kt index 4baa30b..0b8aeac 100644 --- a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/Extensions.apple.kt +++ b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/Extensions.apple.kt @@ -7,9 +7,12 @@ import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator import com.kashif.voyant.extensions.extendedComposeViewController import com.kashif.voyant.extensions.getTopViewController import platform.Foundation.NSLog +import platform.UIKit.UIApplication +import platform.UIKit.UIApplicationDelegateProtocol import platform.UIKit.UIGestureRecognizerDelegateProtocol import platform.UIKit.UINavigationController import platform.UIKit.UINavigationControllerDelegateProtocol +import platform.UIKit.UIResponder import platform.UIKit.hidesBottomBarWhenPushed import platform.UIKit.navigationController @@ -25,7 +28,6 @@ actual fun Navigator.pushX(screen: Screen) { val navigationController = getNavigationController() navigationController?.let { navController -> navController.pushViewController(viewController, animated = true) - // Enable the gesture recognizer after pushing and set its delegate navController.interactivePopGestureRecognizer?.setEnabled(true) navController.interactivePopGestureRecognizer?.delegate = viewController as? UIGestureRecognizerDelegateProtocol } ?: run { @@ -84,4 +86,5 @@ actual fun BottomSheetNavigator.showX(screen: Screen) { topVc?.presentViewController(viewController, animated = true, completion = null) ?: run { NSLog("TopViewController is null") } -} \ No newline at end of file +} + diff --git a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIVIewControllerExtensions.kt b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIVIewControllerExtensions.kt index 55986c8..32c2a9a 100644 --- a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIVIewControllerExtensions.kt +++ b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIVIewControllerExtensions.kt @@ -1,18 +1,10 @@ package com.kashif.voyant.extensions -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.asPaddingValues -import androidx.compose.foundation.layout.imePadding -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.safeDrawing import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.ExperimentalComposeApi import androidx.compose.ui.Modifier -import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.uikit.OnFocusBehavior -import androidx.compose.ui.unit.dp import androidx.compose.ui.window.ComposeUIViewController import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.Navigator @@ -92,25 +84,8 @@ fun extendedComposeViewController( onFocusBehavior = OnFocusBehavior.DoNothing opaque = isOpaque }) { - - Box(modifier = modifier.imePadding() - .padding(top = WindowInsets.safeDrawing.asPaddingValues().calculateTopPadding()) - .pointerInput(Unit) { - awaitPointerEventScope { - while (true) { - val event = awaitPointerEvent() - val position = event.changes.first().position - // Don't consume events within 50.dp from the left edge - if (position.x > 50.dp.toPx()) { - event.changes.forEach { it.consume() } - } - } - } - } - ) { - BottomSheetNavigator { - Navigator(screen = screen) - } + BottomSheetNavigator { + Navigator(screen = screen) } } diff --git a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIViewControllerWrapper.kt b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIViewControllerWrapper.kt index 840d161..4912d70 100644 --- a/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIViewControllerWrapper.kt +++ b/voyagerX/src/appleMain/kotlin/com/kashif/voyant/extensions/UIViewControllerWrapper.kt @@ -50,13 +50,12 @@ class UIViewControllerWrapper( /** * Called after the view has been loaded. - * Sets the delegate for the interactive pop gesture recognizer and adds swipe gesture recognizers - * for left and right swipe directions. + * Sets the delegate for the interactive pop gesture recognizer */ - @OptIn(ExperimentalForeignApi::class) override fun viewDidLoad() { super.viewDidLoad() navigationController?.interactivePopGestureRecognizer?.delegate = this + controller.navigationController?.interactivePopGestureRecognizer?.delegate = this } /** @@ -73,63 +72,28 @@ class UIViewControllerWrapper( /** - * Determines whether the gesture recognizer should receive an object representing a touch. - * Always returns `true`. + * Called when the view controller is about to be displayed. + * Enables the interactive pop gesture recognizer. * - * @param gestureRecognizer The `UIGestureRecognizer` that is asking whether it should receive the touch. - * @param shouldReceiveTouch The `UITouch` object representing the touch. - * @return `true` to allow the gesture recognizer to receive the touch. - */ - override fun gestureRecognizer( - gestureRecognizer: UIGestureRecognizer, - shouldReceiveEvent: UIEvent - ): Boolean { - println("gestureRecognizer shouldReceiveEvent") - return true - } - - /** - * This method is called for press events + * @param navigationController The navigation controller that will display the view controller. + * @param willShowViewController The view controller that will be displayed. + * @param animated A flag indicating whether the transition will be animated. */ - override fun gestureRecognizer( - gestureRecognizer: UIGestureRecognizer, - shouldReceivePress: UIPress - ): Boolean { - println("gestureRecognizer shouldReceivePress") - return true - } - override fun navigationController( navigationController: UINavigationController, willShowViewController: UIViewController, animated: Boolean ) { - // Enable the gesture recognizer when pushing or popping view controllers - navigationController.interactivePopGestureRecognizer?.setEnabled(navigationController.viewControllers.size > 1) + navigationController.interactivePopGestureRecognizer?.setEnabled(true) } override fun gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer): Boolean { println("gestureRecognizerShouldBegin") - if (gestureRecognizer == navigationController?.interactivePopGestureRecognizer) { - return navigationController?.viewControllers?.size ?: 0 > 1 - } - return true - } - override fun gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch: UITouch): Boolean { - println("gestureRecognizer shouldReceiveTouch") return true } - override fun gestureRecognizer( - gestureRecognizer: UIGestureRecognizer, - shouldRequireFailureOfGestureRecognizer: UIGestureRecognizer - ): Boolean { - println("gestureRecognizer shouldRequireFailureOfGestureRecognizer") - // Change this to return true for the navigation gesture - return gestureRecognizer == navigationController?.interactivePopGestureRecognizer - } } \ No newline at end of file