Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-10-28 16:37:34 +04:00
parent 83e17029fc
commit d80ead5f67
7 changed files with 111 additions and 27 deletions

View File

@ -245,6 +245,16 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
}
self.dismissButton.addTarget(self, action: #selector(self.dismissPressed), forControlEvents: .touchUpInside)
self.containerNode.shouldBegin = { [weak self] point in
guard let strongSelf = self else {
return false
}
if strongSelf.addButton.frame.contains(point) || strongSelf.dismissButton.frame.contains(point) {
return false
}
return true
}
self.containerNode.activated = { [weak self] gesture, _ in
guard let strongSelf = self, let item = strongSelf.layoutParams?.0, let _ = item.importer, let contextAction = item.contextAction else {
gesture.cancel()

View File

@ -168,7 +168,7 @@ class ItemListPeerActionItemNode: ListViewItemNode {
case .generic:
verticalInset = 11.0
verticalOffset = 0.0
leftInset = (item.icon == nil ? 16.0 : 59.0) + params.leftInset
leftInset = (item.icon == nil ? 16.0 : 65.0) + params.leftInset
case .peerList:
verticalInset = 14.0
verticalOffset = 0.0

View File

@ -222,7 +222,7 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
case let .exceptionsHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .addException(theme, text):
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.addPersonIcon(theme), title: text, sectionId: self.section, height: .generic, color: .accent, editing: false, action: {
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.plusIconImage(theme), title: text, sectionId: self.section, height: .generic, color: .accent, editing: false, action: {
arguments.addException()
})
case let .exception(_, _, _, dateTimeFormat, nameDisplayOrder, peer, description, _, editing, revealed):

View File

@ -18,6 +18,7 @@ import StickerResources
import AnimatedStickerNode
import TelegramAnimatedStickerNode
import AvatarNode
import UndoUI
private func closeButtonImage(theme: PresentationTheme) -> UIImage? {
return generateImage(CGSize(width: 30.0, height: 30.0), contextGenerator: { size, context in
@ -391,6 +392,74 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
}
}
override func didLoad() {
super.didLoad()
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
self.wrappingScrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture)))
let titleGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleTitleLongPress(_:)))
self.titleNode.view.addGestureRecognizer(titleGestureRecognizer)
let deviceGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleDeviceLongPress(_:)))
self.deviceValueNode.view.addGestureRecognizer(deviceGestureRecognizer)
let locationGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLocationLongPress(_:)))
self.locationValueNode.view.addGestureRecognizer(locationGestureRecognizer)
let ipGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleIpLongPress(_:)))
self.ipValueNode.view.addGestureRecognizer(ipGestureRecognizer)
}
@objc private func handleTitleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
if gestureRecognizer.state == .began {
self.displayCopyContextMenu(self.titleNode, self.titleNode.attributedText?.string ?? "")
}
}
@objc private func handleDeviceLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
if gestureRecognizer.state == .began {
self.displayCopyContextMenu(self.deviceValueNode, self.deviceValueNode.attributedText?.string ?? "")
}
}
@objc private func handleLocationLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
if gestureRecognizer.state == .began {
self.displayCopyContextMenu(self.locationValueNode, self.locationValueNode.attributedText?.string ?? "")
}
}
@objc private func handleIpLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
if gestureRecognizer.state == .began {
self.displayCopyContextMenu(self.ipValueNode, self.ipValueNode.attributedText?.string ?? "")
}
}
private func displayCopyContextMenu(_ node: ASDisplayNode, _ string: String) {
if !string.isEmpty {
var actions: [ContextMenuAction] = []
actions.append(ContextMenuAction(content: .text(title: self.presentationData.strings.Conversation_ContextMenuCopy, accessibilityLabel: self.presentationData.strings.Conversation_ContextMenuCopy), action: { [weak self] in
UIPasteboard.general.string = string
if let strongSelf = self {
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
strongSelf.controller?.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
}
}))
let contextMenuController = ContextMenuController(actions: actions)
self.controller?.present(contextMenuController, in: .window(.root), with: ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
if let strongSelf = self {
return (node, node.bounds.insetBy(dx: 0.0, dy: -2.0), strongSelf, strongSelf.view.bounds)
} else {
return nil
}
}))
}
}
func updatePresentationData(_ presentationData: PresentationData) {
guard !self.animatedOut else {
return
@ -427,16 +496,6 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.cancelButton.setImage(closeButtonImage(theme: self.presentationData.theme), for: .normal)
self.terminateButton.updateTheme(SolidRoundedButtonTheme(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: self.presentationData.theme.list.itemDestructiveColor))
}
override func didLoad() {
super.didLoad()
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
self.wrappingScrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture)))
}
@objc func cancelButtonPressed() {
self.animateOut()
@ -486,6 +545,13 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
offsetCompleted = true
internalCompletion()
})
self.controller?.window?.forEachController { c in
if let c = c as? UndoOverlayController {
c.dismiss()
}
}
}
var passthroughHitTestImpl: ((CGPoint) -> UIView?)?

View File

@ -14,17 +14,6 @@ import SearchBarNode
import SearchUI
import ChatListSearchItemHeader
/*extension NavigationBarSearchContentNode: ItemListControllerSearchNavigationContentNode {
public func activate() {
}
public func deactivate() {
}
public func setQueryUpdated(_ f: @escaping (String) -> Void) {
}
}*/
extension SettingsSearchableItemIcon {
func image() -> UIImage? {
switch self {
@ -298,8 +287,14 @@ private enum SettingsSearchRecentEntry: Comparable, Identifiable {
func item(account: Account, theme: PresentationTheme, strings: PresentationStrings, interaction: SettingsSearchInteraction) -> ListViewItem {
switch self {
case let .recent(_, item, header), let .faq(_, item, header):
return SettingsSearchRecentItem(account: account, theme: theme, strings: strings, title: item.title, breadcrumbs: item.breadcrumbs, action: {
case let .recent(_, item, header):
return SettingsSearchRecentItem(account: account, theme: theme, strings: strings, title: item.title, breadcrumbs: item.breadcrumbs, isFaq: false, action: {
interaction.openItem(item)
}, deleted: {
interaction.deleteRecentItem(item.id)
}, header: header)
case let .faq(_, item, header):
return SettingsSearchRecentItem(account: account, theme: theme, strings: strings, title: item.title, breadcrumbs: item.breadcrumbs, isFaq: true, action: {
interaction.openItem(item)
}, deleted: {
interaction.deleteRecentItem(item.id)

View File

@ -19,17 +19,19 @@ class SettingsSearchRecentItem: ListViewItem {
let account: Account
let title: String
let breadcrumbs: [String]
let isFaq: Bool
let action: () -> Void
let deleted: () -> Void
let header: ListViewItemHeader?
init(account: Account, theme: PresentationTheme, strings: PresentationStrings, title: String, breadcrumbs: [String], action: @escaping () -> Void, deleted: @escaping () -> Void, header: ListViewItemHeader) {
init(account: Account, theme: PresentationTheme, strings: PresentationStrings, title: String, breadcrumbs: [String], isFaq: Bool, action: @escaping () -> Void, deleted: @escaping () -> Void, header: ListViewItemHeader) {
self.theme = theme
self.strings = strings
self.account = account
self.title = title
self.breadcrumbs = breadcrumbs
self.isFaq = isFaq
self.action = action
self.deleted = deleted
self.header = header
@ -227,7 +229,12 @@ class SettingsSearchRecentItemNode: ItemListRevealOptionsItemNode {
strongSelf.updateLayout(size: nodeLayout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
strongSelf.setRevealOptions((left: [], right: [ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: item.strings.Common_Delete, icon: .none, color: item.theme.list.itemDisclosureActions.destructive.fillColor, textColor: item.theme.list.itemDisclosureActions.destructive.foregroundColor)]))
var revealOptions: [ItemListRevealOption] = []
if item.isFaq {
} else {
revealOptions.append(ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: item.strings.Common_Delete, icon: .none, color: item.theme.list.itemDisclosureActions.destructive.fillColor, textColor: item.theme.list.itemDisclosureActions.destructive.foregroundColor))
}
strongSelf.setRevealOptions((left: [], right: revealOptions))
}
})
})

View File

@ -5959,6 +5959,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
}
if self.isSettings {
(self.controller?.parent as? TabBarController)?.updateIsTabBarHidden(true, transition: .animated(duration: 0.3, curve: .linear))
if let settings = self.data?.globalSettings {
self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, mode: .list, placeholder: self.presentationData.strings.Settings_Search, hasBackground: true, hasSeparator: true, contentNode: SettingsSearchContainerNode(context: self.context, openResult: { [weak self] result in
if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
@ -6038,6 +6040,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
self.searchDisplayController = nil
searchDisplayController.deactivate(placeholder: nil)
if self.isSettings {
(self.controller?.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: .animated(duration: 0.3, curve: .linear))
}
let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .easeInOut)
if let navigationBar = self.controller?.navigationBar {
transition.updateAlpha(node: navigationBar, alpha: 1.0)