Skip to content

Commit

Permalink
Patch 0.5.3
Browse files Browse the repository at this point in the history
fix:
- Fixed the problem with changing the screen orientation (#17)
  • Loading branch information
FulcrumOne committed May 21, 2024
1 parent 5590588 commit daa757f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
11 changes: 0 additions & 11 deletions Sources/Internal/Managers/ScreenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,3 @@ extension ScreenManager {
shared.safeArea.right = reader.safeAreaInsets.trailing
}
}

// MARK: - Orientation
extension ScreenManager {
var orientation: Orientation { switch size.width > size.height {
case true: .landscape
case false: .portrait
}}
}
extension ScreenManager { enum Orientation {
case portrait, landscape
}}
12 changes: 7 additions & 5 deletions Sources/Internal/Views/NavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import SwiftUI

struct NavigationView: View {
let config: NavigationGlobalConfig
@ObservedObject private var stack: NavigationManager = .shared
@ObservedObject private var screenManager: ScreenManager = .shared
@State private var temporaryViews: [AnyNavigatableView] = []
@State private var animatableData: AnimatableData = .init()
private let config: NavigationGlobalConfig


init(rootView: some NavigatableView, config: NavigationGlobalConfig?) { NavigationManager.setRoot(rootView); self.config = config ?? .init() }
var body: some View {
ZStack { ForEach(temporaryViews, id: \.id, content: createItem) }
.ignoresSafeArea(.container)
Expand All @@ -32,7 +31,7 @@ private extension NavigationView {
.padding(.top, getTopPadding(item))
.padding(.bottom, getBottomPadding(item))
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(getBackground(item))
.background(getBackground(item).compositingGroup())
.opacity(getOpacity(item))
.scaleEffect(getScale(item))
.offset(getOffset(item))
Expand Down Expand Up @@ -146,8 +145,11 @@ private extension NavigationView {
let rotationTranslation = calculateRotationTranslationValue(view)
return rotationTranslation
}
func getRotationAxis() -> (x: CGFloat, y: CGFloat, z: CGFloat) { (x: 0.000000001, y: 1, z: 0) }
func getRotationPerspective() -> CGFloat { 1.6 }
func getRotationAxis() -> (x: CGFloat, y: CGFloat, z: CGFloat) { (x: 0.00000001, y: 1, z: 0.00000001) }
func getRotationPerspective() -> CGFloat { switch screenManager.size.width > screenManager.size.height {
case true: 0.52
case false: 1
}}
}
private extension NavigationView {
func canCalculateRotation(_ view: AnyNavigatableView) -> Bool {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Public/Public+NavigatableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import SwiftUI

// MARK: - Initialising
public extension NavigatableView {
func implementNavigationView(config: NavigationGlobalConfig? = nil) -> some View { GeometryReader { reader in
NavigationView(rootView: self, config: config)
.onAppear { ScreenManager.update(reader) }
func implementNavigationView(config: NavigationGlobalConfig = .init()) -> some View { GeometryReader { reader in
NavigationView(config: config)
.onAppear { ScreenManager.update(reader); NavigationManager.setRoot(self) }
.onChange(of: reader.size) { _ in ScreenManager.update(reader) }
.onChange(of: reader.safeAreaInsets) { _ in ScreenManager.update(reader) }
}}
Expand Down

0 comments on commit daa757f

Please sign in to comment.