From a9712a3923d4604ac693d80344eb8a1c90762a63 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 26 Jun 2019 17:10:05 +0200 Subject: [PATCH] Fixed chat input field placeholder --- .../TelegramUI/ChatListController.swift | 1 - .../TelegramUI/ChatTextInputPanelNode.swift | 21 +++++++++++++++++-- .../TelegramUI/ContactsController.swift | 2 -- .../TelegramUI/DeviceLocationManager.swift | 2 +- .../TelegramUI/SettingsController.swift | 8 +------ 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/submodules/TelegramUI/TelegramUI/ChatListController.swift b/submodules/TelegramUI/TelegramUI/ChatListController.swift index eef178f947..ed89128a31 100644 --- a/submodules/TelegramUI/TelegramUI/ChatListController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatListController.swift @@ -100,7 +100,6 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD self.chatListDisplayNode.chatListNode.updateSelectedChatLocation(data as? ChatLocation, progress: progress, transition: transition) } - public init(context: AccountContext, groupId: PeerGroupId, controlsHistoryPreload: Bool, hideNetworkActivityStatus: Bool = false) { self.context = context self.controlsHistoryPreload = controlsHistoryPreload diff --git a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift index c39d0610f9..a034a11d85 100644 --- a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift @@ -230,6 +230,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { private var currentPlaceholder: String? private var presentationInterfaceState: ChatPresentationInterfaceState? + private var initializedPlaceholder = false private var keepSendButtonEnabled = false private var extendedSearchLayout = false @@ -684,7 +685,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } } - if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated { + if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated || !self.initializedPlaceholder { + self.initializedPlaceholder = true + let placeholder: String if let channel = peer as? TelegramChannel, case .broadcast = channel.info { if interfaceState.interfaceState.silentPosting { @@ -1342,7 +1345,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } else { return ASEditableTextNodeTargetForAction(target: nil) } - } else if action == #selector(self.formatAttributesBold(_:)) || action == #selector(self.formatAttributesItalic(_:)) || action == #selector(self.formatAttributesMonospace(_:)) || action == #selector(self.formatAttributesLink(_:)) { + } else if action == #selector(self.formatAttributesBold(_:)) || action == #selector(self.formatAttributesItalic(_:)) || action == #selector(self.formatAttributesMonospace(_:)) || action == #selector(self.formatAttributesLink(_:)) || action == #selector(self.formatAttributesStrikethrough(_:)) || action == #selector(self.formatAttributesUnderline(_:)) { if case .format = self.inputMenu.state { return ASEditableTextNodeTargetForAction(target: self) } else { @@ -1385,6 +1388,20 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { self.interfaceInteraction?.openLinkEditing() } + @objc func formatAttributesStrikethrough(_ sender: Any) { + self.inputMenu.back() + self.interfaceInteraction?.updateTextInputStateAndMode { current, inputMode in + return (chatTextInputAddFormattingAttribute(current, attribute: ChatTextInputAttributes.strikethrough), inputMode) + } + } + + @objc func formatAttributesUnderline(_ sender: Any) { + self.inputMenu.back() + self.interfaceInteraction?.updateTextInputStateAndMode { current, inputMode in + return (chatTextInputAddFormattingAttribute(current, attribute: ChatTextInputAttributes.underline), inputMode) + } + } + @objc func editableTextNode(_ editableTextNode: ASEditableTextNode, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { self.updateActivity() var cleanText = text diff --git a/submodules/TelegramUI/TelegramUI/ContactsController.swift b/submodules/TelegramUI/TelegramUI/ContactsController.swift index da1ca2ee0b..9b9cd026b9 100644 --- a/submodules/TelegramUI/TelegramUI/ContactsController.swift +++ b/submodules/TelegramUI/TelegramUI/ContactsController.swift @@ -77,12 +77,10 @@ public class ContactsController: ViewController { var switchToChatsController: (() -> Void)? - public override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) { self.contactsNode.contactListNode.updateSelectedChatLocation(data as? ChatLocation, progress: progress, transition: transition) } - public init(context: AccountContext) { self.context = context diff --git a/submodules/TelegramUI/TelegramUI/DeviceLocationManager.swift b/submodules/TelegramUI/TelegramUI/DeviceLocationManager.swift index b909b83a5c..4099490a9f 100644 --- a/submodules/TelegramUI/TelegramUI/DeviceLocationManager.swift +++ b/submodules/TelegramUI/TelegramUI/DeviceLocationManager.swift @@ -54,7 +54,7 @@ final class DeviceLocationManager: NSObject, CLLocationManagerDelegate { } self.manager.delegate = self self.manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters - self.manager.distanceFilter = 20.0 + self.manager.distanceFilter = 10.0 self.manager.activityType = .other self.manager.pausesLocationUpdatesAutomatically = false } diff --git a/submodules/TelegramUI/TelegramUI/SettingsController.swift b/submodules/TelegramUI/TelegramUI/SettingsController.swift index a669aedec3..724bd660ff 100644 --- a/submodules/TelegramUI/TelegramUI/SettingsController.swift +++ b/submodules/TelegramUI/TelegramUI/SettingsController.swift @@ -1347,15 +1347,9 @@ public func settingsController(context: AccountContext, accountManager: AccountM context.sharedContext.switchToAccount(id: id) }) } - var didAppear = false - controller.didAppear = { [weak controller] _ in + controller.didAppear = { _ in updatePassport() updateNotifyExceptions() - - if !didAppear { - (controller?.displayNode as? ItemListControllerNode)?.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: ListViewScrollToItem(index: 0, position: .top(-navigationBarSearchContentHeight), animated: false, curve: .Default(duration: 0.0), directionHint: .Up), updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) - didAppear = true - } } controller.previewItemWithTag = { tag in if let tag = tag as? SettingsEntryTag, case let .account(id) = tag {