Skip to content

Commit

Permalink
removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashif-E committed Sep 28, 2024
1 parent f847d02 commit 4d4ca47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -84,4 +86,5 @@ actual fun BottomSheetNavigator.showX(screen: Screen) {
topVc?.presentViewController(viewController, animated = true, completion = null) ?: run {
NSLog("TopViewController is null")
}
}
}

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand All @@ -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
}

}

0 comments on commit 4d4ca47

Please sign in to comment.