change emoji popup position when too low
This commit is contained in:
@@ -19,9 +19,19 @@ class EmojiPickerView: ExpoView, MCEmojiPickerDelegate {
|
|||||||
let reactRootVC = reactViewController()
|
let reactRootVC = reactViewController()
|
||||||
emojiPicker.sourceView = self
|
emojiPicker.sourceView = self
|
||||||
emojiPicker.delegate = self
|
emojiPicker.delegate = self
|
||||||
|
emojiPicker.arrowDirection = preferredArrowDirection()
|
||||||
reactRootVC?.present(emojiPicker, animated: true)
|
reactRootVC?.present(emojiPicker, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the trigger sits in the bottom third of the screen there isn't enough
|
||||||
|
/// room below it for a usable popover, so anchor the picker above instead.
|
||||||
|
private func preferredArrowDirection() -> MCPickerArrowDirection {
|
||||||
|
guard let window = self.window else { return .up }
|
||||||
|
let frameInWindow = self.convert(self.bounds, to: window)
|
||||||
|
let threshold = window.bounds.height * (2.0 / 3.0)
|
||||||
|
return frameInWindow.midY >= threshold ? .down : .up
|
||||||
|
}
|
||||||
|
|
||||||
func didGetEmoji(emoji: String) {
|
func didGetEmoji(emoji: String) {
|
||||||
onEmojiSelected([
|
onEmojiSelected([
|
||||||
"emoji": emoji
|
"emoji": emoji
|
||||||
|
|||||||
Reference in New Issue
Block a user