mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Small bug fixes
This commit is contained in:
parent
d624e5b5a9
commit
97c2d9fc91
@ -1136,35 +1136,42 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
|
|||||||
guard let strongSelf = self, let featuredState = featuredState else {
|
guard let strongSelf = self, let featuredState = featuredState else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.processedFeaturedFilters = true
|
|
||||||
if !featuredState.isSeen && !featuredState.filters.isEmpty {
|
let _ = (currentChatListFilters(postbox: strongSelf.context.account.postbox)
|
||||||
let _ = (currentChatListFilters(postbox: strongSelf.context.account.postbox)
|
|> deliverOnMainQueue).start(next: { filters in
|
||||||
|> deliverOnMainQueue).start(next: { filters in
|
guard let strongSelf = self else {
|
||||||
guard let strongSelf = self else {
|
return
|
||||||
return
|
}
|
||||||
}
|
strongSelf.processedFeaturedFilters = true
|
||||||
let hasFilters = !filters.isEmpty
|
if !featuredState.isSeen && !featuredState.filters.isEmpty && filters.isEmpty {
|
||||||
if let _ = strongSelf.validLayout, let parentController = strongSelf.parent as? TabBarController, let sourceFrame = parentController.frameForControllerTab(controller: strongSelf) {
|
let _ = (currentChatListFilters(postbox: strongSelf.context.account.postbox)
|
||||||
let absoluteFrame = sourceFrame
|
|> deliverOnMainQueue).start(next: { filters in
|
||||||
//TODO:localize
|
guard let strongSelf = self else {
|
||||||
let text: String
|
return
|
||||||
if hasFilters {
|
|
||||||
text = "Hold on 'Chats' to edit folders and switch between views."
|
|
||||||
} else {
|
|
||||||
text = "Hold to organize your chats with folders."
|
|
||||||
}
|
}
|
||||||
parentController.present(TooltipScreen(text: text, location: CGPoint(x: absoluteFrame.midX - 14.0, y: absoluteFrame.minY - 8.0), shouldDismissOnTouch: { point in
|
let hasFilters = !filters.isEmpty
|
||||||
guard let strongSelf = self, let parentController = strongSelf.parent as? TabBarController else {
|
if let _ = strongSelf.validLayout, let parentController = strongSelf.parent as? TabBarController, let sourceFrame = parentController.frameForControllerTab(controller: strongSelf) {
|
||||||
|
let absoluteFrame = sourceFrame
|
||||||
|
//TODO:localize
|
||||||
|
let text: String
|
||||||
|
if hasFilters {
|
||||||
|
text = "Hold on 'Chats' to edit folders and switch between views."
|
||||||
|
} else {
|
||||||
|
text = "Hold to organize your chats with folders."
|
||||||
|
}
|
||||||
|
parentController.present(TooltipScreen(text: text, location: CGPoint(x: absoluteFrame.midX - 14.0, y: absoluteFrame.minY - 8.0), shouldDismissOnTouch: { point in
|
||||||
|
guard let strongSelf = self, let parentController = strongSelf.parent as? TabBarController else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if parentController.isPointInsideContentArea(point: point) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}), in: .current)
|
||||||
if parentController.isPointInsideContentArea(point: point) {
|
}
|
||||||
return false
|
})
|
||||||
}
|
}
|
||||||
return true
|
})
|
||||||
}), in: .current)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -720,9 +720,21 @@ final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
func updateAvailableFilters(_ availableFilters: [ChatListContainerNodeFilter]) {
|
func updateAvailableFilters(_ availableFilters: [ChatListContainerNodeFilter]) {
|
||||||
if self.availableFilters != availableFilters {
|
if self.availableFilters != availableFilters {
|
||||||
self.availableFilters = availableFilters
|
let apply: () -> Void = { [weak self] in
|
||||||
if let (layout, navigationBarHeight, visualNavigationHeight, cleanNavigationBarHeight, isReorderingFilters, isEditing) = self.validLayout {
|
guard let strongSelf = self else {
|
||||||
self.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, isReorderingFilters: isReorderingFilters, isEditing: isEditing, transition: .immediate)
|
return
|
||||||
|
}
|
||||||
|
strongSelf.availableFilters = availableFilters
|
||||||
|
if let (layout, navigationBarHeight, visualNavigationHeight, cleanNavigationBarHeight, isReorderingFilters, isEditing) = strongSelf.validLayout {
|
||||||
|
strongSelf.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, isReorderingFilters: isReorderingFilters, isEditing: isEditing, transition: .immediate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !availableFilters.contains(where: { $0.id == self.selectedId }) {
|
||||||
|
self.switchToFilter(id: .all, completion: {
|
||||||
|
apply()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
|||||||
case let .nameHeader(title):
|
case let .nameHeader(title):
|
||||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section)
|
return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section)
|
||||||
case let .name(placeholder, value):
|
case let .name(placeholder, value):
|
||||||
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(), text: value, placeholder: placeholder, type: .regular(capitalization: true, autocorrection: false), clearType: .always, sectionId: self.section, textUpdated: { value in
|
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(), text: value, placeholder: placeholder, type: .regular(capitalization: true, autocorrection: false), clearType: .always, maxLength: 20, sectionId: self.section, textUpdated: { value in
|
||||||
arguments.updateState { current in
|
arguments.updateState { current in
|
||||||
var state = current
|
var state = current
|
||||||
state.name = value
|
state.name = value
|
||||||
@ -968,7 +968,7 @@ func chatListFilterPresetController(context: AccountContext, currentPreset: Chat
|
|||||||
applyImpl?()
|
applyImpl?()
|
||||||
})
|
})
|
||||||
|
|
||||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(currentPreset != nil ? "Folder" : "Create Folder"), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(currentPreset != nil ? "Edit Folder" : "Create Folder"), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: chatListFilterPresetControllerEntries(presentationData: presentationData, isNewFilter: currentPreset == nil, state: state, includePeers: includePeers, excludePeers: excludePeers), style: .blocks, emptyStateItem: nil, animateChanges: !skipStateAnimation)
|
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: chatListFilterPresetControllerEntries(presentationData: presentationData, isNewFilter: currentPreset == nil, state: state, includePeers: includePeers, excludePeers: excludePeers), style: .blocks, emptyStateItem: nil, animateChanges: !skipStateAnimation)
|
||||||
skipStateAnimation = false
|
skipStateAnimation = false
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ private func chatListFilterPresetListControllerEntries(presentationData: Present
|
|||||||
entries.append(.listFooter("Tap \"Edit\" to change the order or delete folders."))
|
entries.append(.listFooter("Tap \"Edit\" to change the order or delete folders."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filteredSuggestedFilters.isEmpty {
|
if !filteredSuggestedFilters.isEmpty && filters.count < 10 {
|
||||||
entries.append(.suggestedListHeader("RECOMMENDED FOLDERS"))
|
entries.append(.suggestedListHeader("RECOMMENDED FOLDERS"))
|
||||||
for filter in filteredSuggestedFilters {
|
for filter in filteredSuggestedFilters {
|
||||||
entries.append(.suggestedPreset(index: PresetIndex(value: entries.count), title: filter.title, label: filter.description, preset: filter.data))
|
entries.append(.suggestedPreset(index: PresetIndex(value: entries.count), title: filter.title, label: filter.description, preset: filter.data))
|
||||||
@ -492,4 +492,3 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
|||||||
|
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public class ItemListSingleLineInputItem: ListViewItem, ItemListItem {
|
|||||||
let returnKeyType: UIReturnKeyType
|
let returnKeyType: UIReturnKeyType
|
||||||
let spacing: CGFloat
|
let spacing: CGFloat
|
||||||
let clearType: ItemListSingleLineInputClearType
|
let clearType: ItemListSingleLineInputClearType
|
||||||
|
let maxLength: Int
|
||||||
let enabled: Bool
|
let enabled: Bool
|
||||||
public let sectionId: ItemListSectionId
|
public let sectionId: ItemListSectionId
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
@ -48,7 +49,7 @@ public class ItemListSingleLineInputItem: ListViewItem, ItemListItem {
|
|||||||
let cleared: (() -> Void)?
|
let cleared: (() -> Void)?
|
||||||
public let tag: ItemListItemTag?
|
public let tag: ItemListItemTag?
|
||||||
|
|
||||||
public init(presentationData: ItemListPresentationData, title: NSAttributedString, text: String, placeholder: String, type: ItemListSingleLineInputItemType = .regular(capitalization: true, autocorrection: true), returnKeyType: UIReturnKeyType = .`default`, spacing: CGFloat = 0.0, clearType: ItemListSingleLineInputClearType = .none, enabled: Bool = true, tag: ItemListItemTag? = nil, sectionId: ItemListSectionId, textUpdated: @escaping (String) -> Void, shouldUpdateText: @escaping (String) -> Bool = { _ in return true }, processPaste: ((String) -> String)? = nil, updatedFocus: ((Bool) -> Void)? = nil, action: @escaping () -> Void, cleared: (() -> Void)? = nil) {
|
public init(presentationData: ItemListPresentationData, title: NSAttributedString, text: String, placeholder: String, type: ItemListSingleLineInputItemType = .regular(capitalization: true, autocorrection: true), returnKeyType: UIReturnKeyType = .`default`, spacing: CGFloat = 0.0, clearType: ItemListSingleLineInputClearType = .none, maxLength: Int = 0, enabled: Bool = true, tag: ItemListItemTag? = nil, sectionId: ItemListSectionId, textUpdated: @escaping (String) -> Void, shouldUpdateText: @escaping (String) -> Bool = { _ in return true }, processPaste: ((String) -> String)? = nil, updatedFocus: ((Bool) -> Void)? = nil, action: @escaping () -> Void, cleared: (() -> Void)? = nil) {
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
self.title = title
|
self.title = title
|
||||||
self.text = text
|
self.text = text
|
||||||
@ -57,6 +58,7 @@ public class ItemListSingleLineInputItem: ListViewItem, ItemListItem {
|
|||||||
self.returnKeyType = returnKeyType
|
self.returnKeyType = returnKeyType
|
||||||
self.spacing = spacing
|
self.spacing = spacing
|
||||||
self.clearType = clearType
|
self.clearType = clearType
|
||||||
|
self.maxLength = maxLength
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.sectionId = sectionId
|
self.sectionId = sectionId
|
||||||
@ -441,6 +443,9 @@ public class ItemListSingleLineInputItemNode: ListViewItemNode, UITextFieldDeleg
|
|||||||
if !item.shouldUpdateText(newText) {
|
if !item.shouldUpdateText(newText) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if item.maxLength != 0 && newText.count > item.maxLength {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if string.count > 1, let item = self.item, let processPaste = item.processPaste {
|
if string.count > 1, let item = self.item, let processPaste = item.processPaste {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user