-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: create separate class to simplify KeyboardMovementObserver …
…implementation
- Loading branch information
1 parent
3846dc8
commit 1d87523
Showing
2 changed files
with
38 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// KeyboardEventsIgnorer.swift | ||
// Pods | ||
// | ||
// Created by Kiryl Ziusko on 24/11/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
class KeyboardEventsIgnorer { | ||
var shouldIgnoreKeyboardEvents = false | ||
|
||
init() { | ||
NotificationCenter.default.addObserver( | ||
self, | ||
selector: #selector(handleIgnoreKeyboardEventsNotification), | ||
name: .shouldIgnoreKeyboardEvents, | ||
object: nil | ||
) | ||
} | ||
|
||
@objc private func handleIgnoreKeyboardEventsNotification(_ notification: Notification) { | ||
if let userInfo = notification.userInfo, let value = userInfo["ignore"] as? Bool { | ||
shouldIgnoreKeyboardEvents = value | ||
} | ||
} | ||
|
||
deinit { | ||
NotificationCenter.default.removeObserver(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters