[Chat] Fix unusably small emoji picker (#10591)
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
import ExpoModulesCore
|
import ExpoModulesCore
|
||||||
import WebKit
|
|
||||||
import MCEmojiPicker
|
import MCEmojiPicker
|
||||||
|
|
||||||
class EmojiPickerView: ExpoView, MCEmojiPickerDelegate {
|
class EmojiPickerView: ExpoView, MCEmojiPickerDelegate {
|
||||||
let onEmojiSelected = EventDispatcher()
|
let onEmojiSelected = EventDispatcher()
|
||||||
|
|
||||||
override func layoutSubviews() {
|
required init(appContext: AppContext? = nil) {
|
||||||
|
super.init(appContext: appContext)
|
||||||
|
|
||||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
|
||||||
self.addGestureRecognizer(tapGesture)
|
self.addGestureRecognizer(tapGesture)
|
||||||
}
|
}
|
||||||
@@ -19,9 +20,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