File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,12 @@ public class RxKeyboard: NSObject {
49
49
let frameVariable = Variable < CGRect > ( defaultFrame)
50
50
self . frame = frameVariable. asDriver ( ) . distinctUntilChanged ( )
51
51
self . visibleHeight = self . frame. map { UIScreen . main. bounds. height - $0. origin. y }
52
- self . willShowVisibleHeight = NotificationCenter . default. rx. notification ( . UIKeyboardWillShow)
53
- . map { notification -> CGFloat in
54
- let rectValue = notification. userInfo ? [ UIKeyboardFrameEndUserInfoKey] as? NSValue
55
- let keyboardFrame = rectValue? . cgRectValue ?? defaultFrame
56
- return UIScreen . main. bounds. height - keyboardFrame. origin. y
52
+ self . willShowVisibleHeight = self . visibleHeight
53
+ . scan ( ( visibleHeight: 0 , isShowing: false ) ) { lastState, newVisibleHeight in
54
+ return ( visibleHeight: newVisibleHeight, isShowing: lastState. visibleHeight == 0 )
57
55
}
58
- . asDriver { _ in . empty( ) }
56
+ . filter { state in state. isShowing }
57
+ . map { state in state. visibleHeight }
59
58
60
59
super. init ( )
61
60
You can’t perform that action at this time.
0 commit comments