mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 03:40:18 +00:00
Use reloadInputViews to update keyboard appearance
This commit is contained in:
parent
ab3f224d56
commit
f3120007e5
@ -142,7 +142,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
||||||
|
|
||||||
|
- (void)resetInitialPrimaryLanguage;
|
||||||
- (void)dropAutocorrection;
|
- (void)dropAutocorrection;
|
||||||
|
- (bool)isCurrentlyEmoji;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,6 @@
|
|||||||
@interface ASPanningOverriddenUITextView : ASTextKitComponentsTextView
|
@interface ASPanningOverriddenUITextView : ASTextKitComponentsTextView
|
||||||
{
|
{
|
||||||
BOOL _shouldBlockPanGesture;
|
BOOL _shouldBlockPanGesture;
|
||||||
BOOL _initializedPrimaryInputLanguage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, copy) bool (^shouldCopy)();
|
@property (nonatomic, copy) bool (^shouldCopy)();
|
||||||
@ -93,6 +92,7 @@
|
|||||||
@property (nonatomic, copy) void (^backspaceWhileEmpty)();
|
@property (nonatomic, copy) void (^backspaceWhileEmpty)();
|
||||||
|
|
||||||
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
||||||
|
@property (nonatomic) bool initializedPrimaryInputLanguage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -200,6 +200,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UIKeyboardAppearance)keyboardAppearance {
|
||||||
|
return [super keyboardAppearance];
|
||||||
|
}
|
||||||
|
|
||||||
- (UITextInputMode *)textInputMode {
|
- (UITextInputMode *)textInputMode {
|
||||||
if (!_initializedPrimaryInputLanguage) {
|
if (!_initializedPrimaryInputLanguage) {
|
||||||
_initializedPrimaryInputLanguage = true;
|
_initializedPrimaryInputLanguage = true;
|
||||||
@ -642,6 +646,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setInitialPrimaryLanguage:(NSString *)initialPrimaryLanguage {
|
||||||
|
((ASPanningOverriddenUITextView *)_textKitComponents.textView).initialPrimaryLanguage = initialPrimaryLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)resetInitialPrimaryLanguage {
|
||||||
|
((ASPanningOverriddenUITextView *)_textKitComponents.textView).initializedPrimaryInputLanguage = false;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dropAutocorrection {
|
- (void)dropAutocorrection {
|
||||||
_isPreservingSelection = YES; // Used in -textViewDidChangeSelection: to avoid informing our delegate about our preservation.
|
_isPreservingSelection = YES; // Used in -textViewDidChangeSelection: to avoid informing our delegate about our preservation.
|
||||||
_isPreservingText = YES;
|
_isPreservingText = YES;
|
||||||
@ -664,6 +676,15 @@
|
|||||||
_isPreservingText = NO;
|
_isPreservingText = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (bool)isCurrentlyEmoji {
|
||||||
|
NSString *value = [[UITextInputMode currentInputMode] primaryLanguage];
|
||||||
|
if ([value isEqualToString:@"emoji"]) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Core
|
#pragma mark - Core
|
||||||
- (void)_updateDisplayingPlaceholder
|
- (void)_updateDisplayingPlaceholder
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,14 +11,8 @@ public class EditableTextNode: ASEditableTextNode {
|
|||||||
guard newValue != self.keyboardAppearance else {
|
guard newValue != self.keyboardAppearance else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let resigning = self.isFirstResponder()
|
|
||||||
if resigning {
|
|
||||||
self.resignFirstResponder()
|
|
||||||
}
|
|
||||||
super.keyboardAppearance = newValue
|
super.keyboardAppearance = newValue
|
||||||
if resigning {
|
self.textView.reloadInputViews()
|
||||||
self.becomeFirstResponder()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -645,8 +645,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
|
|
||||||
let keyboardAppearance = interfaceState.theme.chat.inputPanel.keyboardColor.keyboardAppearance
|
let keyboardAppearance = interfaceState.theme.chat.inputPanel.keyboardColor.keyboardAppearance
|
||||||
if let textInputNode = self.textInputNode, textInputNode.keyboardAppearance != keyboardAppearance, textInputNode.isFirstResponder() {
|
if let textInputNode = self.textInputNode, textInputNode.keyboardAppearance != keyboardAppearance, textInputNode.isFirstResponder() {
|
||||||
textInputNode.resignFirstResponder()
|
if textInputNode.isCurrentlyEmoji() {
|
||||||
textInputNode.becomeFirstResponder()
|
textInputNode.initialPrimaryLanguage = "emoji"
|
||||||
|
textInputNode.resetInitialPrimaryLanguage()
|
||||||
|
}
|
||||||
textInputNode.keyboardAppearance = keyboardAppearance
|
textInputNode.keyboardAppearance = keyboardAppearance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user