From 836ed086f4870086e0a7879c9cecdb0ca109ac20 Mon Sep 17 00:00:00 2001 From: Kylmakalle Date: Fri, 2 May 2025 10:27:20 +0300 Subject: [PATCH] WatchOS keyboard allow emoji --- Telegram/Watch/Extension/TGInputController.h | 1 + Telegram/Watch/Extension/TGInputController.m | 9 +++++++++ Telegram/Watch/Extension/TGMessageViewController.m | 2 +- Telegram/Watch/Extension/TGNeoConversationController.m | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Telegram/Watch/Extension/TGInputController.h b/Telegram/Watch/Extension/TGInputController.h index 93008f96b5..d68ea2f1c5 100644 --- a/Telegram/Watch/Extension/TGInputController.h +++ b/Telegram/Watch/Extension/TGInputController.h @@ -5,6 +5,7 @@ @interface TGInputController : NSObject + (void)presentPlainInputControllerForInterfaceController:(TGInterfaceController *)interfaceController completion:(void (^)(NSString *))completion; ++ (void)presentInputControllerWithEmojisForInterfaceController:(TGInterfaceController *)interfaceController completion:(void (^)(NSString *))completion; + (void)presentInputControllerForInterfaceController:(TGInterfaceController *)interfaceController suggestionsForText:(NSString *)text completion:(void (^)(NSString *))completion; + (void)presentAudioControllerForInterfaceController:(TGInterfaceController *)interfaceController completion:(void (^)(int64_t uniqueId, int32_t duration, NSURL *url))completion; diff --git a/Telegram/Watch/Extension/TGInputController.m b/Telegram/Watch/Extension/TGInputController.m index 238d0ac387..b251aadf0c 100644 --- a/Telegram/Watch/Extension/TGInputController.m +++ b/Telegram/Watch/Extension/TGInputController.m @@ -20,6 +20,15 @@ }]; } ++ (void)presentInputControllerWithEmojisForInterfaceController:(TGInterfaceController *)interfaceController completion:(void (^)(NSString *))completion; +{ + [interfaceController presentTextInputControllerWithSuggestions:nil allowedInputMode:WKTextInputModeAllowEmoji completion:^(NSArray *results) + { + if (completion != nil && results.count > 0 && [results.firstObject isKindOfClass:[NSString class]]) + completion(results.firstObject); + }]; +} + + (void)presentInputControllerForInterfaceController:(TGInterfaceController *)interfaceController suggestionsForText:(NSString *)text completion:(void (^)(NSString *))completion { [interfaceController presentTextInputControllerWithSuggestions:[self suggestionsForText:text] allowedInputMode:WKTextInputModeAllowEmoji completion:^(NSArray *results) diff --git a/Telegram/Watch/Extension/TGMessageViewController.m b/Telegram/Watch/Extension/TGMessageViewController.m index c75b93f21f..cbbe91eb57 100644 --- a/Telegram/Watch/Extension/TGMessageViewController.m +++ b/Telegram/Watch/Extension/TGMessageViewController.m @@ -229,7 +229,7 @@ NSString *const TGMessageViewControllerIdentifier = @"TGMessageViewController"; if (strongSelf == nil) return; - [TGInputController presentPlainInputControllerForInterfaceController:strongSelf completion:^(NSString *text) + [TGInputController presentInputControllerWithEmojisForInterfaceController:strongSelf completion:^(NSString *text) { [strongSelf->_sendMessageDisposable setDisposable:[[TGBridgeSendMessageSignals sendMessageWithPeerId:strongSelf->_context.peerId text:text replyToMid:strongSelf->_context.message.identifier] startWithNext:^(TGBridgeMessage *message) { diff --git a/Telegram/Watch/Extension/TGNeoConversationController.m b/Telegram/Watch/Extension/TGNeoConversationController.m index de38075220..9b9d3d7d93 100644 --- a/Telegram/Watch/Extension/TGNeoConversationController.m +++ b/Telegram/Watch/Extension/TGNeoConversationController.m @@ -1238,7 +1238,7 @@ const NSInteger TGNeoConversationControllerInitialRenderCount = 4 * 2; if (strongSelf == nil) return; - [TGInputController presentPlainInputControllerForInterfaceController:strongSelf completion:^(NSString *text) + [TGInputController presentInputControllerWithEmojisForInterfaceController:strongSelf completion:^(NSString *text) { [strongSelf sendMessageWithText:text]; }];