Skip to content

Commit 7a01b6b

Browse files
authored
Merge pull request #27 from noppefoxwolf/feature/visibility_observer
[Proposal] Add keyboard visibility observer.
2 parents 68f19a5 + f084bc6 commit 7a01b6b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/RxKeyboard.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public class RxKeyboard: NSObject {
2929
/// Same with `visibleHeight` but only emits values when keyboard is about to show. This is
3030
/// useful when adjusting scroll view content offset.
3131
public let willShowVisibleHeight: Driver<CGFloat>
32-
32+
33+
/// An observable visibility of keyboard. Emits keyboard visibility
34+
/// when changed keyboard show and hide.
35+
public let isHidden: Driver<Bool>
3336

3437
// MARK: Private
3538

@@ -55,7 +58,7 @@ public class RxKeyboard: NSObject {
5558
}
5659
.filter { state in state.isShowing }
5760
.map { state in state.visibleHeight }
58-
61+
self.isHidden = self.visibleHeight.map({ $0 == 0.0 }).distinctUntilChanged()
5962
super.init()
6063

6164
// keyboard will change frame

0 commit comments

Comments
 (0)