Skip to content

Commit

Permalink
Merge pull request #36 from canopas/fix-multiple-pop-issue
Browse files Browse the repository at this point in the history
Fix multiple pop issue and bump version to 2.0.2
  • Loading branch information
jimmy0251 authored Nov 23, 2022
2 parents bd3c0fc + f0291b6 commit 33b8123
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import PackageDescription
let package = Package(
name: "UIPilot",
platforms: [
.macOS(.v11),
.iOS(.v14),
.tvOS(.v14),
.watchOS(.v7)
],
products: [
.library(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Once you have your Swift package set up, adding UIPilot as a dependency is as ea

```swift
dependencies: [
.package(url: "https://github.com/canopas/UIPilot.git", .upToNextMajor(from: "2.0.1"))
.package(url: "https://github.com/canopas/UIPilot.git", .upToNextMajor(from: "2.0.2"))
]
```

Expand All @@ -51,7 +51,7 @@ dependencies: [
[CocoaPods][] is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate UIPilot into your Xcode project using CocoaPods, specify it in your Podfile:

target 'YourAppName' do
pod 'UIPilot', '~> 2.0.1'
pod 'UIPilot', '~> 2.0.2'
end

[CocoaPods]: https://cocoapods.org
Expand Down
13 changes: 7 additions & 6 deletions Sources/UIPilot/UIPilot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ struct NavigationControllerHost<T: Equatable, Screen: View>: UIViewControllerRep
navigation.popHandler = {
uipilot.onSystemPop()
}
navigation.stackSizeProvider = {
uipilot.routes.count
}

for path in uipilot.routes {
navigation.pushViewController(
Expand Down Expand Up @@ -154,6 +157,7 @@ struct NavigationControllerHost<T: Equatable, Screen: View>: UIViewControllerRep
class PopAwareUINavigationController: UINavigationController, UINavigationControllerDelegate
{
var popHandler: (() -> Void)?
var stackSizeProvider: (() -> Int)?

var popGestureBeganController: UIViewController?

Expand All @@ -163,16 +167,13 @@ class PopAwareUINavigationController: UINavigationController, UINavigationContro
}

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
if let coordinator = viewController.transitionCoordinator {
if let dismissedViewController = coordinator.viewController(forKey: .from),
!navigationController.viewControllers.contains(dismissedViewController) {
self.popHandler?()
}

if let stackSizeProvider = stackSizeProvider, stackSizeProvider() > navigationController.viewControllers.count {
self.popHandler?()
}
}
}


extension View {
public func uipNavigationBarHidden(_ hidden: Bool) -> some View {
return modifier(NavHiddenModifier(isHidden: hidden))
Expand Down
5 changes: 1 addition & 4 deletions UIPilot.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "UIPilot"
s.version = "2.0.1"
s.version = "2.0.2"
s.summary = "The missing type-safe, SwiftUI navigation library."

s.description = <<-DESC
Expand All @@ -21,7 +21,4 @@ Pod::Spec.new do |s|
s.preserve_paths = 'README.md'

s.ios.deployment_target = '14.0'
s.tvos.deployment_target = '14.0'
s.osx.deployment_target = '11.0'
s.watchos.deployment_target = '7.0'
end
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Once you have your Swift package set up, adding UIPilot as a dependency is as ea

```swift
dependencies: [
.package(url: "https://github.com/canopas/UIPilot.git", .upToNextMajor(from: "2.0.1"))
.package(url: "https://github.com/canopas/UIPilot.git", .upToNextMajor(from: "2.0.2"))
]
```

Expand All @@ -331,7 +331,7 @@ dependencies: [
[CocoaPods][] is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate UIPilot into your Xcode project using CocoaPods, specify it in your Podfile:

target 'YourAppName' do
pod 'UIPilot', '~> 2.0.1'
pod 'UIPilot', '~> 2.0.2'
end

[CocoaPods]: https://cocoapods.org
Expand Down

0 comments on commit 33b8123

Please sign in to comment.