From a4c8aca9a1aacd92d51dc1b9fbe6bd3e19549a44 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 18 Jan 2019 00:54:51 +0400 Subject: [PATCH 1/3] UI fixes --- TelegramUI/ChatListController.swift | 1 + TelegramUI/ContactsController.swift | 25 ++++++ TelegramUI/QRCode.swift | 9 ++- TelegramUI/RadialDownloadContentNode.swift | 5 +- TelegramUI/TelegramRootController.swift | 88 ++++++++++----------- TelegramUI/WallpaperGalleryController.swift | 4 + 6 files changed, 83 insertions(+), 49 deletions(-) diff --git a/TelegramUI/ChatListController.swift b/TelegramUI/ChatListController.swift index 5d3f14c89a..389723fc31 100644 --- a/TelegramUI/ChatListController.swift +++ b/TelegramUI/ChatListController.swift @@ -251,6 +251,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: self.presentationData.strings.DialogList_SearchLabel, activate: { [weak self] in self?.activateSearch() }) + self.searchContentNode?.updateExpansionProgress(0.0) self.navigationBar?.setContentNode(self.searchContentNode, animated: false) } diff --git a/TelegramUI/ContactsController.swift b/TelegramUI/ContactsController.swift index fb78a5c68d..6a2ac19d46 100644 --- a/TelegramUI/ContactsController.swift +++ b/TelegramUI/ContactsController.swift @@ -20,6 +20,31 @@ private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBa listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: ListViewDeleteAndInsertOptions(), scrollToItem: scrollToItem, updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) return true + } else if searchNode.expansionProgress == 1.0 { + var sortItemNode: ListViewItemNode? + var nextItemNode: ListViewItemNode? + + listNode.forEachItemNode({ itemNode in + if sortItemNode == nil, let itemNode = itemNode as? ContactListActionItemNode { + sortItemNode = itemNode + } else if sortItemNode != nil && nextItemNode == nil { + nextItemNode = itemNode as? ListViewItemNode + } + }) + + if let sortItemNode = sortItemNode { + let itemFrame = sortItemNode.apparentFrame + if itemFrame.contains(CGPoint(x: 0.0, y: listNode.insets.top)) { + var scrollToItem: ListViewScrollToItem? + if itemFrame.minY + itemFrame.height * 0.6 < listNode.insets.top { + scrollToItem = ListViewScrollToItem(index: 0, position: .top(-50), animated: true, curve: .Default(duration: 0.3), directionHint: .Up) + } else { + scrollToItem = ListViewScrollToItem(index: 0, position: .top(0), animated: true, curve: .Default(duration: 0.3), directionHint: .Up) + } + listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: ListViewDeleteAndInsertOptions(), scrollToItem: scrollToItem, updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) + return true + } + } } return false } diff --git a/TelegramUI/QRCode.swift b/TelegramUI/QRCode.swift index 01ff2f20ed..09a14c348d 100644 --- a/TelegramUI/QRCode.swift +++ b/TelegramUI/QRCode.swift @@ -27,6 +27,8 @@ func qrCode(string: String, color: UIColor, backgroundColor: UIColor? = nil, sca let scale = arguments.drawingRect.size.width / inputImage.extent.width * context.scale let transformed = inputImage.transformed(by: CGAffineTransform.init(scaleX: scale, y: scale)) + let codeScale = 43.0 / inputImage.extent.width + let invertFilter = CIFilter(name: "CIColorInvert") invertFilter?.setValue(transformed, forKey: kCIInputImageKey) let alphaFilter = CIFilter(name: "CIMaskToAlpha") @@ -63,12 +65,11 @@ func qrCode(string: String, color: UIColor, backgroundColor: UIColor? = nil, sca c.setFillColor(UIColor.clear.cgColor) } - let clipOrigin = 93.0 * fittedRect.width / 267.0 - let clipSide = 81.0 * fittedRect.width / 267.0 - c.fill(CGRect(x: clipOrigin, y: clipOrigin, width: clipSide, height: clipSide)) + let clipSide = 81.0 * fittedRect.width / 267.0 * codeScale + c.fill(CGRect(x: fittedRect.midX - clipSide / 2.0, y: fittedRect.midY - clipSide / 2.0, width: clipSide, height: clipSide)) c.setBlendMode(.normal) - let iconScale = fittedRect.width / 308.0 + let iconScale = fittedRect.width / 308.0 * codeScale let iconSize = CGSize(width: 65.0 * iconScale, height: 79.0 * iconScale) let point = CGPoint(x: fittedRect.midX - iconSize.width / 2.0, y: fittedRect.midY - iconSize.height / 2.0) c.translateBy(x: point.x, y: point.y) diff --git a/TelegramUI/RadialDownloadContentNode.swift b/TelegramUI/RadialDownloadContentNode.swift index 28b3324352..5e57d59a87 100644 --- a/TelegramUI/RadialDownloadContentNode.swift +++ b/TelegramUI/RadialDownloadContentNode.swift @@ -154,7 +154,10 @@ final class RadialDownloadContentNode: RadialStatusContentNode { self.leftLine.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, delay: 0.07, removeOnCompletion: false) { finished in completion(0.0) } - self.rightLine.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, delay: 0.07, removeOnCompletion: false) + self.rightLine.animateAlpha(from: 1.0, to: 0.0, duration: 0.02, delay: 0.15, removeOnCompletion: false) { finished in + self.leftLine.strokeColor = UIColor.clear.cgColor + self.rightLine.strokeColor = UIColor.clear.cgColor + } } override func animateOut(to: RadialStatusNodeState, completion: @escaping () -> Void) { diff --git a/TelegramUI/TelegramRootController.swift b/TelegramUI/TelegramRootController.swift index e2c6fbf1f7..489fa6ab5e 100644 --- a/TelegramUI/TelegramRootController.swift +++ b/TelegramUI/TelegramRootController.swift @@ -76,50 +76,50 @@ public final class TelegramRootController: NavigationController { self.rootTabController = tabBarController self.pushViewController(tabBarController, animated: false) -// guard let controller = self.viewControllers.last as? ViewController else { -// return -// } -// -// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) { -// //(controller.navigationController as? NavigationController)?.pushViewController(ThemeGridController(account: self.account)) -// -// let wrapperNode = ASDisplayNode() -// let bounds = controller.displayNode.bounds -// wrapperNode.frame = bounds -// wrapperNode.backgroundColor = .gray -// controller.displayNode.addSubnode(wrapperNode) -// -// let radialStatusSize: CGFloat = 50.0 -// let statusNode = RadialStatusNode(backgroundNodeColor: UIColor(rgb: 0x000000, alpha: 0.6)) -// statusNode.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) -// wrapperNode.addSubnode(statusNode) -// -// let color = UIColor.white -// var smth = false -// let button = HighlightTrackingButtonNode() -// button.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) -// wrapperNode.addSubnode(button) -// button.highligthedChanged = { value in -// if value { -// if smth { -// smth = false -// //statusNode.transitionToState(.play(color), animated: true, completion: {}) -// statusNode.transitionToState(.download(.white), animated: true, completion: {}) -//// statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 1.0, cancelEnabled: true), animated: true, completion: {}) -//// statusNode.transitionToState(.none, animated: true, completion: { -//// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.85) { -//// statusNode.transitionToState(.download(.white), animated: true, completion: {}) -//// } -//// }) -// } else { -// smth = true -// statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 0.1, cancelEnabled: true), animated: true, completion: {}) -// } -// } -// } -// button.addTarget(self, action: #selector(self.mock), forControlEvents: .touchUpInside) -// statusNode.transitionToState(.download(.white), animated: false, completion: {}) -// } + guard let controller = self.viewControllers.last as? ViewController else { + return + } + + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) { + //(controller.navigationController as? NavigationController)?.pushViewController(ThemeGridController(account: self.account)) + + let wrapperNode = ASDisplayNode() + let bounds = controller.displayNode.bounds + wrapperNode.frame = bounds + wrapperNode.backgroundColor = .gray + controller.displayNode.addSubnode(wrapperNode) + + let radialStatusSize: CGFloat = 50.0 + let statusNode = RadialStatusNode(backgroundNodeColor: UIColor(rgb: 0x000000, alpha: 0.6)) + statusNode.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) + wrapperNode.addSubnode(statusNode) + + let color = UIColor.white + var smth = false + let button = HighlightTrackingButtonNode() + button.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) + wrapperNode.addSubnode(button) + button.highligthedChanged = { value in + if value { + if smth { + smth = false + //statusNode.transitionToState(.play(color), animated: true, completion: {}) + statusNode.transitionToState(.download(.white), animated: true, completion: {}) +// statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 1.0, cancelEnabled: true), animated: true, completion: {}) +// statusNode.transitionToState(.none, animated: true, completion: { +// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.85) { +// statusNode.transitionToState(.download(.white), animated: true, completion: {}) +// } +// }) + } else { + smth = true + statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 0.1, cancelEnabled: true), animated: true, completion: {}) + } + } + } + button.addTarget(self, action: #selector(self.mock), forControlEvents: .touchUpInside) + statusNode.transitionToState(.download(.white), animated: false, completion: {}) + } } @objc func mock() { diff --git a/TelegramUI/WallpaperGalleryController.swift b/TelegramUI/WallpaperGalleryController.swift index e15e892242..e717a72da1 100644 --- a/TelegramUI/WallpaperGalleryController.swift +++ b/TelegramUI/WallpaperGalleryController.swift @@ -257,6 +257,10 @@ class WallpaperGalleryController: ViewController { super.viewDidAppear(animated) self.galleryNode.modalAnimateIn() + + if let centralItemNode = self.galleryNode.pager.centralItemNode() as? WallpaperGalleryItemNode { + self.centralItemStatus.set(centralItemNode.status.get()) + } } override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { From 4bbda0846e5fdc0112e2c2bc7a25c93349ee6fc8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 18 Jan 2019 01:12:21 +0400 Subject: [PATCH 2/3] Remove test code --- TelegramUI/TelegramRootController.swift | 49 ------------------------- 1 file changed, 49 deletions(-) diff --git a/TelegramUI/TelegramRootController.swift b/TelegramUI/TelegramRootController.swift index 489fa6ab5e..7997c16ee3 100644 --- a/TelegramUI/TelegramRootController.swift +++ b/TelegramUI/TelegramRootController.swift @@ -75,55 +75,6 @@ public final class TelegramRootController: NavigationController { self.accountSettingsController = accountSettingsController self.rootTabController = tabBarController self.pushViewController(tabBarController, animated: false) - - guard let controller = self.viewControllers.last as? ViewController else { - return - } - - DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) { - //(controller.navigationController as? NavigationController)?.pushViewController(ThemeGridController(account: self.account)) - - let wrapperNode = ASDisplayNode() - let bounds = controller.displayNode.bounds - wrapperNode.frame = bounds - wrapperNode.backgroundColor = .gray - controller.displayNode.addSubnode(wrapperNode) - - let radialStatusSize: CGFloat = 50.0 - let statusNode = RadialStatusNode(backgroundNodeColor: UIColor(rgb: 0x000000, alpha: 0.6)) - statusNode.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) - wrapperNode.addSubnode(statusNode) - - let color = UIColor.white - var smth = false - let button = HighlightTrackingButtonNode() - button.frame = CGRect(origin: CGPoint(x: floor(bounds.midX - radialStatusSize / 2.0), y: floor(bounds.midY - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize)) - wrapperNode.addSubnode(button) - button.highligthedChanged = { value in - if value { - if smth { - smth = false - //statusNode.transitionToState(.play(color), animated: true, completion: {}) - statusNode.transitionToState(.download(.white), animated: true, completion: {}) -// statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 1.0, cancelEnabled: true), animated: true, completion: {}) -// statusNode.transitionToState(.none, animated: true, completion: { -// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.85) { -// statusNode.transitionToState(.download(.white), animated: true, completion: {}) -// } -// }) - } else { - smth = true - statusNode.transitionToState(.progress(color: color, lineWidth: nil, value: 0.1, cancelEnabled: true), animated: true, completion: {}) - } - } - } - button.addTarget(self, action: #selector(self.mock), forControlEvents: .touchUpInside) - statusNode.transitionToState(.download(.white), animated: false, completion: {}) - } - } - - @objc func mock() { - } public func updateRootControllers(showCallsTab: Bool) { From 3e64475b95347d38effd0241ac816e6765ea7f88 Mon Sep 17 00:00:00 2001 From: Peter Iakovlev Date: Fri, 18 Jan 2019 01:42:51 +0400 Subject: [PATCH 3/3] Fix auth layout --- .../AuthorizationSequencePasswordEntryControllerNode.swift | 2 +- TelegramUI/AuthorizationSequenceSignUpControllerNode.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TelegramUI/AuthorizationSequencePasswordEntryControllerNode.swift b/TelegramUI/AuthorizationSequencePasswordEntryControllerNode.swift index 54c6ad3edd..e4c2b549f2 100644 --- a/TelegramUI/AuthorizationSequencePasswordEntryControllerNode.swift +++ b/TelegramUI/AuthorizationSequencePasswordEntryControllerNode.swift @@ -104,7 +104,7 @@ final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UIT func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { self.layoutArguments = (layout, navigationBarHeight) - var insets = layout.insets(options: [.input]) + var insets = layout.insets(options: []) insets.top = navigationBarHeight if let inputHeight = layout.inputHeight { diff --git a/TelegramUI/AuthorizationSequenceSignUpControllerNode.swift b/TelegramUI/AuthorizationSequenceSignUpControllerNode.swift index b9ee941c47..20142f9455 100644 --- a/TelegramUI/AuthorizationSequenceSignUpControllerNode.swift +++ b/TelegramUI/AuthorizationSequenceSignUpControllerNode.swift @@ -197,7 +197,7 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { self.layoutArguments = (layout, navigationBarHeight) - var insets = layout.insets(options: [.statusBar, .input]) + var insets = layout.insets(options: [.statusBar]) if let inputHeight = layout.inputHeight { if abs(inputHeight - (layout.standardInputHeight - 44.0)) < 2.0 { insets.bottom += layout.standardInputHeight