chat selecting fixes

This commit is contained in:
overtake 2019-06-26 15:58:13 +02:00
parent a0f2dc92b9
commit c27c6977a4
10 changed files with 50 additions and 26 deletions

View File

@ -490,9 +490,9 @@ open class NavigationController: UINavigationController, ContainableController,
controller.navigationBar?.previousItem = .item(viewControllers[i - 1].navigationItem)
}
if i < self._viewControllers.count - 1 {
controller.navigationCustomData = (viewControllers[i + 1] as? ViewController)?.customData
controller.updateNavigationCustomData((viewControllers[i + 1] as? ViewController)?.customData, progress: 1.0, transition: transition)
} else {
controller.navigationCustomData = nil
controller.updateNavigationCustomData(nil, progress: 1.0, transition: transition)
}
}
viewControllers[i].navigation_setNavigationController(self)
@ -840,13 +840,27 @@ open class NavigationController: UINavigationController, ContainableController,
bottomController.displayNode.recursivelyEnsureDisplaySynchronously(true)
}
let navigationTransitionCoordinator = NavigationTransitionCoordinator(transition: .Pop, container: self.controllerView.containerView, topView: topView, topNavigationBar: (topController as? ViewController)?.navigationBar, bottomView: bottomView, bottomNavigationBar: (bottomController as? ViewController)?.navigationBar)
let navigationTransitionCoordinator = NavigationTransitionCoordinator(transition: .Pop, container: self.controllerView.containerView, topView: topView, topNavigationBar: (topController as? ViewController)?.navigationBar, bottomView: bottomView, bottomNavigationBar: (bottomController as? ViewController)?.navigationBar, didUpdateProgress: { [weak self] progress in
if let strongSelf = self {
for i in 0 ..< strongSelf._viewControllers.count {
if let controller = strongSelf._viewControllers[i].controller as? ViewController {
if i < strongSelf._viewControllers.count - 1 {
controller.updateNavigationCustomData((strongSelf.viewControllers[i + 1] as? ViewController)?.customData, progress: 1.0 - progress, transition: .immediate)
} else {
controller.updateNavigationCustomData(nil, progress: 1.0 - progress, transition: .immediate)
}
}
}
}
})
self.navigationTransitionCoordinator = navigationTransitionCoordinator
}
case UIGestureRecognizerState.changed:
if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion {
let translation = recognizer.translation(in: self.view).x
navigationTransitionCoordinator.progress = max(0.0, min(1.0, translation / self.view.frame.width))
let progress = max(0.0, min(1.0, translation / self.view.frame.width))
navigationTransitionCoordinator.progress = progress
}
case UIGestureRecognizerState.ended:
if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion {

View File

@ -39,10 +39,11 @@ class NavigationTransitionCoordinator {
private(set) var animatingCompletion = false
private var currentCompletion: (() -> Void)?
init(transition: NavigationTransition, container: UIView, topView: UIView, topNavigationBar: NavigationBar?, bottomView: UIView, bottomNavigationBar: NavigationBar?) {
private var didUpdateProgress:((CGFloat)->Void)?
init(transition: NavigationTransition, container: UIView, topView: UIView, topNavigationBar: NavigationBar?, bottomView: UIView, bottomNavigationBar: NavigationBar?, didUpdateProgress: ((CGFloat) -> Void)? = nil) {
self.transition = transition
self.container = container
self.didUpdateProgress = didUpdateProgress
self.topView = topView
switch transition {
case .Push:
@ -109,6 +110,8 @@ class NavigationTransitionCoordinator {
self.bottomView.frame = CGRect(origin: CGPoint(x: ((position - 1.0) * containerSize.width * 0.3), y: 0.0), size: containerSize)
self.updateNavigationBarTransition()
self.didUpdateProgress?(self.progress)
}
func updateNavigationBarTransition() {

View File

@ -73,14 +73,13 @@ open class TabBarController: ViewController {
}
}
open override var navigationCustomData: Any? {
didSet {
for controller in controllers {
controller.navigationCustomData = navigationCustomData
}
open override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
for controller in controllers {
controller.updateNavigationCustomData(data, progress: progress, transition: transition)
}
}
public private(set) var controllers: [ViewController] = []
private let _ready = Promise<Bool>()

View File

@ -206,7 +206,10 @@ open class ViewControllerPresentationArguments {
public var scrollToTopWithTabBar: (() -> Void)?
public var longTapWithTabBar: (() -> Void)?
open var navigationCustomData: Any?
open func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
}
open var customData: Any? {
get {
return nil

View File

@ -96,12 +96,11 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
private var searchContentNode: NavigationBarSearchContentNode?
public override var navigationCustomData: Any? {
didSet {
self.chatListDisplayNode.chatListNode.updateSelectedChatLocation(self.navigationCustomData as? ChatLocation, progress: 1, transition: .immediate)
}
public override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
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
@ -1121,11 +1120,13 @@ public class ChatListController: TelegramController, UIViewControllerPreviewingD
editItem.accessibilityLabel = self.presentationData.strings.Common_Done
if case .root = self.groupId {
self.navigationItem.leftBarButtonItem = editItem
(self.navigationController as? NavigationController)?.updateMasterDetailsBlackout(.details, transition: .animated(duration: 0.5, curve: .spring))
} else {
self.navigationItem.rightBarButtonItem = editItem
(self.navigationController as? NavigationController)?.updateMasterDetailsBlackout(.master, transition: .animated(duration: 0.5, curve: .spring))
}
self.searchContentNode?.setIsEnabled(false, animated: true)
(self.navigationController as? NavigationController)?.updateMasterDetailsBlackout(.details, transition: .animated(duration: 0.5, curve: .spring))
self.chatListDisplayNode.chatListNode.updateState { state in
var state = state
state.editing = true

View File

@ -519,6 +519,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
func updateIsHighlighted(transition: ContainedViewLayoutTransition) {
let highlightProgress: CGFloat = self.item?.interaction.highlightedChatLocation?.progress ?? 1.0
if reallyHighlighted {
if self.highlightedBackgroundNode.supernode == nil {
@ -526,14 +527,14 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
self.highlightedBackgroundNode.alpha = 0.0
}
self.highlightedBackgroundNode.layer.removeAllAnimations()
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: 1.0)
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: highlightProgress)
if let item = self.item {
self.onlineNode.setImage(PresentationResourcesChatList.recentStatusOnlineIcon(item.presentationData.theme, state: .highlighted))
}
} else {
if self.highlightedBackgroundNode.supernode != nil {
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: 0.0, completion: { [weak self] completed in
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: highlightProgress, completion: { [weak self] completed in
if let strongSelf = self {
if completed {
strongSelf.highlightedBackgroundNode.removeFromSupernode()

View File

@ -1427,7 +1427,7 @@ final class ChatListNode: ListView {
}
if let chatLocation = chatLocation {
interaction.highlightedChatLocation = ChatListHighlightedLocation(location: chatLocation, progress: 1.0)
interaction.highlightedChatLocation = ChatListHighlightedLocation(location: chatLocation, progress: progress)
} else {
interaction.highlightedChatLocation = nil
}

View File

@ -99,6 +99,7 @@ private enum ContactListNodeEntryId: Hashable {
final class ContactItemHighlighting {
var chatLocation: ChatLocation?
var progress: CGFloat = 1.0
init(chatLocation: ChatLocation? = nil) {
self.chatLocation = chatLocation
}
@ -1343,6 +1344,7 @@ final class ContactListNode: ASDisplayNode {
func updateSelectedChatLocation(_ chatLocation: ChatLocation?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
self.interaction?.itemHighlighting.chatLocation = chatLocation
self.interaction?.itemHighlighting.progress = progress
self.listNode.forEachItemNode { itemNode in
if let itemNode = itemNode as? ContactsPeerItemNode {

View File

@ -77,12 +77,12 @@ public class ContactsController: ViewController {
var switchToChatsController: (() -> Void)?
public override var navigationCustomData: Any? {
didSet {
self.contactsNode.contactListNode.updateSelectedChatLocation(self.navigationCustomData as? ChatLocation, progress: 1, transition: .immediate)
}
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

View File

@ -401,6 +401,7 @@ class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
func updateIsHighlighted(transition: ContainedViewLayoutTransition) {
var reallyHighlighted = self.isHighlighted
var highlightProgress: CGFloat = self.item?.itemHighlighting?.progress ?? 1.0
if let item = self.item {
switch item.peer {
case let .peer(_, chatPeer):
@ -420,10 +421,10 @@ class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
self.highlightedBackgroundNode.alpha = 0.0
}
self.highlightedBackgroundNode.layer.removeAllAnimations()
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: 1.0)
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: highlightProgress)
} else {
if self.highlightedBackgroundNode.supernode != nil {
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: 0.0, completion: { [weak self] completed in
transition.updateAlpha(layer: self.highlightedBackgroundNode.layer, alpha: highlightProgress, completion: { [weak self] completed in
if let strongSelf = self {
if completed {
strongSelf.highlightedBackgroundNode.removeFromSupernode()