Skip to content

Commit

Permalink
Patch 0.4.1
Browse files Browse the repository at this point in the history
chore:
- Minor code refactoring
  • Loading branch information
FulcrumOne authored May 17, 2024
1 parent 5c569f7 commit 5eb08b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,12 @@ Navigattie is released under the MIT license. See [LICENSE][License] for details
# Our other open source SwiftUI libraries
[PopupView] - The most powerful popup library that allows you to present any popup
<br>
[CalendarView] - Create your own calendar object in no time
<br>
[GridView] - Lay out your data with no effort
<br>
[CameraView] - The most powerful CameraController. Designed for SwiftUI
<br>
[Timer] - Modern API for Timer


Expand All @@ -194,5 +198,7 @@ Navigattie is released under the MIT license. See [LICENSE][License] for details
[License]: https://github.com/Mijick/Navigattie/blob/main/LICENSE
[PopupView]: https://github.com/Mijick/PopupView
[CalendarView]: https://github.com/Mijick/CalendarView
[CameraView]: https://github.com/Mijick/CameraView
[GridView]: https://github.com/Mijick/GridView
[Timer]: https://github.com/Mijick/Timer
2 changes: 0 additions & 2 deletions Sources/Internal/Managers/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class NavigationManager: ObservableObject {
@Published private(set) var transitionsBlocked: Bool = false
private(set) var transitionType: TransitionType = .push
private(set) var transitionAnimation: TransitionAnimation = .no
private(set) var namespace: Namespace.ID?

static let shared: NavigationManager = .init()
private init() {}
Expand All @@ -49,7 +48,6 @@ private extension NavigationManager {
// MARK: - Setters
extension NavigationManager {
static func setRoot(_ rootView: some NavigatableView) { DispatchQueue.main.async { shared.views = [.init(rootView, .no)] }}
static func setNamespace(_ value: Namespace.ID) { if shared.namespace == nil { shared.namespace = value } }
static func blockTransitions(_ value: Bool) { shared.transitionsBlocked = value }
}

Expand Down
11 changes: 2 additions & 9 deletions Sources/Internal/Views/NavigationStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,14 @@ struct NavigationStackView: View {
private let config: NavigationGlobalConfig


init(namespace: Namespace.ID, config: NavigationGlobalConfig) { self._temporaryViews = .init(initialValue: NavigationManager.shared.views); self.config = config; NavigationManager.setNamespace(namespace) }
init(config: NavigationGlobalConfig) { self._temporaryViews = .init(initialValue: NavigationManager.shared.views); self.config = config }
var body: some View {
ZStack(content: createStack)
ZStack { ForEach(temporaryViews, id: \.id, content: createItem) }
.ignoresSafeArea(.container)
.onChange(of: stack.views, perform: onViewsChanged)
.onAnimationCompleted(for: animatableOpacity, perform: onAnimationCompleted)
}
}

private extension NavigationStackView {
func createStack() -> some View {
ForEach(temporaryViews, id: \.id, content: createItem)
}
}

private extension NavigationStackView {
func createItem(_ item: AnyNavigatableView) -> some View {
item
Expand Down
3 changes: 1 addition & 2 deletions Sources/Internal/Views/NavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import SwiftUI

struct NavigationView: View {
@Namespace var namespace
private let config: NavigationGlobalConfig


init(rootView: some NavigatableView, config: NavigationGlobalConfig?) { self.config = config ?? .init(); NavigationManager.setRoot(rootView) }
var body: some View { NavigationStackView(namespace: namespace, config: config) }
var body: some View { NavigationStackView(config: config) }
}

0 comments on commit 5eb08b2

Please sign in to comment.