fix: custom emoji picker using compact default height on the iPad issue
This commit is contained in:
parent
a5938eb0e1
commit
02f9a15069
|
@ -12,7 +12,7 @@
|
||||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>15</integer>
|
<integer>16</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<key>NotificationService.xcscheme_^#shared#^_</key>
|
<key>NotificationService.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>16</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|
|
@ -141,8 +141,8 @@ extension ComposeStatusSection {
|
||||||
attribute.contentWarningContent.value = text
|
attribute.contentWarningContent.value = text
|
||||||
}
|
}
|
||||||
.store(in: &cell.disposeBag)
|
.store(in: &cell.disposeBag)
|
||||||
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplacableTextInput: cell.textEditorView, disposeBag: &cell.disposeBag)
|
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplaceableTextInput: cell.textEditorView, disposeBag: &cell.disposeBag)
|
||||||
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplacableTextInput: cell.statusContentWarningEditorView.textView, disposeBag: &cell.disposeBag)
|
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplaceableTextInput: cell.statusContentWarningEditorView.textView, disposeBag: &cell.disposeBag)
|
||||||
|
|
||||||
return cell
|
return cell
|
||||||
case .attachment(let attachmentService):
|
case .attachment(let attachmentService):
|
||||||
|
@ -228,7 +228,7 @@ extension ComposeStatusSection {
|
||||||
.assign(to: \.value, on: attribute.option)
|
.assign(to: \.value, on: attribute.option)
|
||||||
.store(in: &cell.disposeBag)
|
.store(in: &cell.disposeBag)
|
||||||
cell.delegate = composeStatusPollOptionCollectionViewCellDelegate
|
cell.delegate = composeStatusPollOptionCollectionViewCellDelegate
|
||||||
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplacableTextInput: cell.pollOptionView.optionTextField, disposeBag: &cell.disposeBag)
|
ComposeStatusSection.configureCustomEmojiPicker(viewModel: customEmojiPickerInputViewModel, customEmojiReplaceableTextInput: cell.pollOptionView.optionTextField, disposeBag: &cell.disposeBag)
|
||||||
return cell
|
return cell
|
||||||
case .pollOptionAppendEntry:
|
case .pollOptionAppendEntry:
|
||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: ComposeStatusPollOptionAppendEntryCollectionViewCell.self), for: indexPath) as! ComposeStatusPollOptionAppendEntryCollectionViewCell
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: ComposeStatusPollOptionAppendEntryCollectionViewCell.self), for: indexPath) as! ComposeStatusPollOptionAppendEntryCollectionViewCell
|
||||||
|
@ -295,7 +295,7 @@ protocol CustomEmojiReplaceableTextInput: AnyObject {
|
||||||
var isFirstResponder: Bool { get }
|
var isFirstResponder: Bool { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomEmojiReplacableTextInputReference {
|
class CustomEmojiReplaceableTextInputReference {
|
||||||
weak var value: CustomEmojiReplaceableTextInput?
|
weak var value: CustomEmojiReplaceableTextInput?
|
||||||
|
|
||||||
init(value: CustomEmojiReplaceableTextInput? = nil) {
|
init(value: CustomEmojiReplaceableTextInput? = nil) {
|
||||||
|
@ -320,7 +320,7 @@ extension ComposeStatusSection {
|
||||||
|
|
||||||
static func configureCustomEmojiPicker(
|
static func configureCustomEmojiPicker(
|
||||||
viewModel: CustomEmojiPickerInputViewModel?,
|
viewModel: CustomEmojiPickerInputViewModel?,
|
||||||
customEmojiReplacableTextInput: CustomEmojiReplaceableTextInput,
|
customEmojiReplaceableTextInput: CustomEmojiReplaceableTextInput,
|
||||||
disposeBag: inout Set<AnyCancellable>
|
disposeBag: inout Set<AnyCancellable>
|
||||||
) {
|
) {
|
||||||
guard let viewModel = viewModel else { return }
|
guard let viewModel = viewModel else { return }
|
||||||
|
@ -328,9 +328,9 @@ extension ComposeStatusSection {
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak viewModel] isCustomEmojiComposing in
|
.sink { [weak viewModel] isCustomEmojiComposing in
|
||||||
guard let viewModel = viewModel else { return }
|
guard let viewModel = viewModel else { return }
|
||||||
customEmojiReplacableTextInput.inputView = isCustomEmojiComposing ? viewModel.customEmojiPickerInputView : nil
|
customEmojiReplaceableTextInput.inputView = isCustomEmojiComposing ? viewModel.customEmojiPickerInputView : nil
|
||||||
customEmojiReplacableTextInput.reloadInputViews()
|
customEmojiReplaceableTextInput.reloadInputViews()
|
||||||
viewModel.append(customEmojiReplacableTextInput: customEmojiReplacableTextInput)
|
viewModel.append(customEmojiReplaceableTextInput: customEmojiReplaceableTextInput)
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,8 @@ final class ComposeViewController: UIViewController, NeedsDependency {
|
||||||
var systemKeyboardHeight: CGFloat = .zero {
|
var systemKeyboardHeight: CGFloat = .zero {
|
||||||
didSet {
|
didSet {
|
||||||
// note: some system AutoLayout warning here
|
// note: some system AutoLayout warning here
|
||||||
customEmojiPickerInputView.frame.size.height = systemKeyboardHeight != .zero ? systemKeyboardHeight : 300
|
let height = max(300, systemKeyboardHeight)
|
||||||
|
customEmojiPickerInputView.frame.size.height = height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class CustomEmojiPickerInputViewModel {
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
private var customEmojiReplacableTextInputReferences: [CustomEmojiReplacableTextInputReference] = []
|
private var customEmojiReplaceableTextInputReferences: [CustomEmojiReplaceableTextInputReference] = []
|
||||||
|
|
||||||
// input
|
// input
|
||||||
weak var customEmojiPickerInputView: CustomEmojiPickerInputView?
|
weak var customEmojiPickerInputView: CustomEmojiPickerInputView?
|
||||||
|
@ -25,27 +25,27 @@ final class CustomEmojiPickerInputViewModel {
|
||||||
extension CustomEmojiPickerInputViewModel {
|
extension CustomEmojiPickerInputViewModel {
|
||||||
|
|
||||||
private func removeEmptyReferences() {
|
private func removeEmptyReferences() {
|
||||||
customEmojiReplacableTextInputReferences.removeAll(where: { element in
|
customEmojiReplaceableTextInputReferences.removeAll(where: { element in
|
||||||
element.value == nil
|
element.value == nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func append(customEmojiReplacableTextInput textInput: CustomEmojiReplaceableTextInput) {
|
func append(customEmojiReplaceableTextInput textInput: CustomEmojiReplaceableTextInput) {
|
||||||
removeEmptyReferences()
|
removeEmptyReferences()
|
||||||
|
|
||||||
let isContains = customEmojiReplacableTextInputReferences.contains(where: { element in
|
let isContains = customEmojiReplaceableTextInputReferences.contains(where: { element in
|
||||||
element.value === textInput
|
element.value === textInput
|
||||||
})
|
})
|
||||||
guard !isContains else {
|
guard !isContains else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
customEmojiReplacableTextInputReferences.append(CustomEmojiReplacableTextInputReference(value: textInput))
|
customEmojiReplaceableTextInputReferences.append(CustomEmojiReplaceableTextInputReference(value: textInput))
|
||||||
}
|
}
|
||||||
|
|
||||||
func insertText(_ text: String) -> CustomEmojiReplacableTextInputReference? {
|
func insertText(_ text: String) -> CustomEmojiReplaceableTextInputReference? {
|
||||||
removeEmptyReferences()
|
removeEmptyReferences()
|
||||||
|
|
||||||
for reference in customEmojiReplacableTextInputReferences {
|
for reference in customEmojiReplaceableTextInputReferences {
|
||||||
guard reference.value?.isFirstResponder == true else { continue }
|
guard reference.value?.isFirstResponder == true else { continue }
|
||||||
reference.value?.insertText(text)
|
reference.value?.insertText(text)
|
||||||
return reference
|
return reference
|
||||||
|
|
Loading…
Reference in New Issue