Skip to content

Commit f9e78da

Browse files
authored
Patch 1.1.3
fix: - Fixed a problem with text fields (#43)
1 parent d658e5d commit f9e78da

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

MijickNavigationView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Pod::Spec.new do |s|
55
NavigationView is a free and open-source library dedicated for SwiftUI that makes navigation easier and much cleaner.
66
DESC
77

8-
s.version = '1.1.2'
8+
s.version = '1.1.3'
99
s.ios.deployment_target = '15.0'
1010
s.swift_version = '5.0'
1111

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<p align="center">
2020
<a href="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/Mijick/NavigationView-Demo" rel="nofollow">Try demo we prepared</a>
2121
|
22-
<a href="https://github.com/orgs/Mijick/projects/5" rel="nofollow">Roadmap</a>
22+
<a href="https://mijick.notion.site/1308512b2a6c483fb9a7e6804530ef87?v=6b992a9f361047348dfd9cc94c954b67&pvs=74" rel="nofollow">Roadmap</a>
2323
|
2424
<a href="https://github.com/Mijick/NavigationView/issues/new" rel="nofollow">Propose a new feature</a>
2525
</p>

Sources/Internal/Extensions/Animation++.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
import SwiftUI
1313

1414
extension Animation {
15-
static var keyboard: Animation { .interpolatingSpring(mass: 3, stiffness: 1000, damping: 500, initialVelocity: 6.4) }
15+
static func keyboard(withDelay: Bool) -> Animation { .easeOut(duration: 0.25).delay(withDelay ? 0.1 : 0) }
1616
}

Sources/Internal/Managers/KeyboardManager.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import SwiftUI
1313
import Combine
1414

1515
class KeyboardManager: ObservableObject {
16-
@Published private(set) var isActive: Bool = false
16+
@Published private(set) var height: CGFloat = .zero
1717
private var subscription: [AnyCancellable] = []
1818

1919
static let shared: KeyboardManager = .init()
@@ -28,17 +28,18 @@ extension KeyboardManager {
2828
// MARK: - Show / Hide Events
2929
private extension KeyboardManager {
3030
func subscribeToKeyboardEvents() { Publishers.Merge(keyboardWillOpenPublisher, keyboardWillHidePublisher)
31-
.sink { self.isActive = $0 }
31+
.sink { self.height = $0 }
3232
.store(in: &subscription)
3333
}
3434
}
3535
private extension KeyboardManager {
36-
var keyboardWillOpenPublisher: Publishers.Map<NotificationCenter.Publisher, Bool> { NotificationCenter.default
37-
.publisher(for: UIResponder.keyboardDidShowNotification)
38-
.map { _ in true }
36+
var keyboardWillOpenPublisher: Publishers.CompactMap<NotificationCenter.Publisher, CGFloat> { NotificationCenter.default
37+
.publisher(for: UIResponder.keyboardWillShowNotification)
38+
.compactMap { $0.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect }
39+
.map { $0.height }
3940
}
40-
var keyboardWillHidePublisher: Publishers.Map<NotificationCenter.Publisher, Bool> { NotificationCenter.default
41+
var keyboardWillHidePublisher: Publishers.Map<NotificationCenter.Publisher, CGFloat> { NotificationCenter.default
4142
.publisher(for: UIResponder.keyboardWillHideNotification)
42-
.map { _ in false }
43+
.map { _ in .zero }
4344
}
4445
}

Sources/Internal/Managers/ScreenManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension ScreenManager {
3636
extension ScreenManager {
3737
func getSafeAreaValue(for edge: Edge.Set) -> CGFloat { switch edge {
3838
case .top: safeArea.top
39-
case .bottom: safeArea.bottom
39+
case .bottom: KeyboardManager.shared.height > 0 ? KeyboardManager.shared.height : safeArea.bottom
4040
case .leading: safeArea.left
4141
case .trailing: safeArea.right
4242
default: 0

Sources/Internal/Views/NavigationView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ struct NavigationView: View {
2424
var body: some View {
2525
ZStack { ForEach(temporaryViews, id: \.id, content: createItem) }
2626
.ignoresSafeArea()
27+
.frame(maxWidth: .infinity, maxHeight: .infinity)
2728
.gesture(createDragGesture())
2829
.onChange(of: stack.views, perform: onViewsChanged)
2930
.onChange(of: isGestureActive, perform: onDragGestureEnded)
3031
.onAnimationCompleted(for: animatableData.opacity, perform: onAnimationCompleted)
31-
.animation(.keyboard, value: keyboardManager.isActive)
32+
.animation(.keyboard(withDelay: isKeyboardVisible), value: isKeyboardVisible)
3233
}
3334
}
3435
private extension NavigationView {
@@ -105,8 +106,8 @@ private extension NavigationView {
105106
ignoredAreas.edges.isOne(of: .init(edge), .all)
106107
else { return screenManager.getSafeAreaValue(for: edge) }
107108

108-
if ignoredAreas.regions.isOne(of: .keyboard, .all) && keyboardManager.isActive { return 0 }
109-
if ignoredAreas.regions.isOne(of: .container, .all) && !keyboardManager.isActive { return 0 }
109+
if ignoredAreas.regions.isOne(of: .keyboard, .all) && isKeyboardVisible { return 0 }
110+
if ignoredAreas.regions.isOne(of: .container, .all) && !isKeyboardVisible { return 0 }
110111
return screenManager.getSafeAreaValue(for: edge)
111112
}
112113
func getBackground(_ item: AnyNavigatableView) -> Color { getConfig(item).backgroundColour ?? config.backgroundColour }
@@ -308,6 +309,7 @@ private extension NavigationView {
308309
// MARK: - Helpers
309310
private extension NavigationView {
310311
var gestureProgress: CGFloat { gestureData.translation / (stack.transitionAnimation == .verticalSlide ? screenManager.size.height : screenManager.size.width) }
312+
var isKeyboardVisible: Bool { keyboardManager.height > 0 }
311313
}
312314

313315
// MARK: - Configurables

0 commit comments

Comments
 (0)