Skip to content

iDmitriyy/RxKeyboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

RxKeyboard

RxKeyboard provides a reactive way of handling standard keyboard events instead of using NotificationCenter.

There are totally 6 events: willBeShown/wasShown, willBeHidden/wasHidden, willChangeFrame/didChangeFrame

Every event contains additional UI information about Keyboard:

struct RxKeyboardAnimationParams {
    let initialFrame: CGRect
    let finalFrame: CGRect
    let animationTrait: RxKeyboardAnimationTrait
}

struct RxKeyboardAnimationTrait {
    let animationOptions: UIView.AnimationOptions
    let duration: TimeInterval
}

So if you need to change scrollView insets for example, it will be something like this:

rxKeyboard.willBeShown.emit(onNext: { [weak self] params in
    self?.setScrollViewBottomInset(params.finalFrame.size.height,
                                   duration: params.animationTrait.duration,
                                   animationOptions: params.animationTrait.animationOptions)
}).disposed(by: disposeBag)

If you need to get addtional values, such as 'currentFrame' or 'isVisible' for example, you can combine provided 6 events using Rx operators to achieve it.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages