Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-03-15 04:44:34 +04:00
parent 40a3142765
commit 64b80e92b4
4 changed files with 60 additions and 10 deletions

View File

@ -31,6 +31,7 @@ swift_library(
"//submodules/OverlayStatusController:OverlayStatusController",
"//submodules/PhoneNumberFormat:PhoneNumberFormat",
"//submodules/SolidRoundedButtonNode:SolidRoundedButtonNode",
"//submodules/StickerResources:StickerResources",
],
visibility = [
"//visibility:public",

View File

@ -18,6 +18,7 @@ import ContactsPeerItem
import SearchUI
import TelegramPermissionsUI
import AppBundle
import StickerResources
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
if searchNode.expansionProgress > 0.0 && searchNode.expansionProgress < 1.0 {
@ -88,6 +89,9 @@ public class ContactsController: ViewController {
public var switchToChatsController: (() -> Void)?
private let preloadedSticker = Promise<TelegramMediaFile?>(nil)
private let preloadStickerDisposable = MetaDisposable()
public override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
if self.isNodeLoaded {
self.contactsNode.contactListNode.updateSelectedChatLocation(data as? ChatLocation, progress: progress, transition: transition)
@ -226,22 +230,30 @@ public class ContactsController: ViewController {
switch peer {
case let .peer(peer, _, _):
if let navigationController = strongSelf.navigationController as? NavigationController {
var scrollToEndIfExists = false
if let layout = strongSelf.validLayout, case .regular = layout.metrics.widthClass {
scrollToEndIfExists = true
}
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), purposefulAction: { [weak self] in
if fromSearch {
self?.deactivateSearch(animated: false)
self?.switchToChatsController?()
}
}, scrollToEndIfExists: scrollToEndIfExists, options: [.removeOnMasterDetails], completion: { [weak self] _ in
let _ = (strongSelf.preloadedSticker.get()
|> take(1)
|> deliverOnMainQueue).start(next: { [weak self] greetingSticker in
if let strongSelf = self {
strongSelf.contactsNode.contactListNode.listNode.clearHighlightAnimated(true)
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), purposefulAction: { [weak self] in
if fromSearch {
self?.deactivateSearch(animated: false)
self?.switchToChatsController?()
}
}, scrollToEndIfExists: scrollToEndIfExists, greetingData: greetingSticker.flatMap({ ChatGreetingData(sticker: $0) }), options: [.removeOnMasterDetails], completion: { [weak self] _ in
if let strongSelf = self {
strongSelf.contactsNode.contactListNode.listNode.clearHighlightAnimated(true)
}
}))
strongSelf.prepareRandomGreetingSticker()
}
}))
})
}
case let .deviceContact(id, _):
let _ = ((strongSelf.context.sharedContext.contactDataManager?.extendedData(stableId: id) ?? .single(nil))
@ -412,6 +424,14 @@ public class ContactsController: ViewController {
self.contactsNode.contactListNode.enableUpdates = false
}
public override func displayNodeDidLoad() {
super.displayNodeDidLoad()
Queue.mainQueue().after(1.0) {
self.prepareRandomGreetingSticker()
}
}
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
super.containerLayoutUpdated(layout, transition: transition)
@ -506,4 +526,27 @@ public class ContactsController: ViewController {
}
})
}
private func prepareRandomGreetingSticker() {
let context = self.context
self.preloadedSticker.set(.single(nil)
|> then(randomGreetingSticker(account: context.account)
|> map { item in
return item?.file
}))
self.preloadStickerDisposable.set((self.preloadedSticker.get()
|> mapToSignal { sticker -> Signal<Void, NoError> in
if let sticker = sticker {
let _ = freeMediaFileInteractiveFetched(account: context.account, fileReference: .standalone(media: sticker)).start()
return chatMessageAnimationData(postbox: context.account.postbox, resource: sticker.resource, fitzModifier: nil, width: 384, height: 384, synchronousLoad: false)
|> mapToSignal { _ -> Signal<Void, NoError> in
return .complete()
}
} else {
return .complete()
}
}).start())
}
}

View File

@ -1059,7 +1059,7 @@ static void setViewFrame(UIView *view, CGRect frame)
setViewFrame(_inputField, inputFieldFrame);
}
_doneButtonWrapper.frame = CGRectMake(self.frame.size.width - 47.0, CGRectGetMaxY(_fieldBackground.frame) - _doneButton.frame.size.height + 8.0, _doneButton.frame.size.width, _doneButton.frame.size.height);
_doneButtonWrapper.frame = CGRectMake(self.frame.size.width - 47.0, CGRectGetMaxY(_fieldBackground.frame) - _doneButton.frame.size.height + (TGIsPad() ? 7.0 : 8.0), _doneButton.frame.size.width, _doneButton.frame.size.height);
}
@end

View File

@ -115,6 +115,12 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode {
let isActiveUpdated = self.isActive != isActive
self.isActive = isActive
var isGestureEnabled = false
if [.mute, .voiceChat, .more].contains(icon) {
isGestureEnabled = true
}
self.containerNode.isGestureEnabled = isGestureEnabled
if isActiveUpdated, !self.containerNode.alpha.isZero {
if let snapshotView = self.backgroundNode.view.snapshotContentTree() {
snapshotView.frame = self.backgroundNode.view.frame