mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Permission and search UI improvements
This commit is contained in:
@@ -33,7 +33,7 @@ final class WebSearchControllerInteraction {
|
||||
let openResult: (ChatContextResult) -> Void
|
||||
let setSearchQuery: (String) -> Void
|
||||
let deleteRecentQuery: (String) -> Void
|
||||
let toggleSelection: (ChatContextResult, Bool) -> Void
|
||||
let toggleSelection: (ChatContextResult, Bool) -> Bool
|
||||
let sendSelected: (ChatContextResult?, Bool, Int32?) -> Void
|
||||
let schedule: () -> Void
|
||||
let avatarCompleted: (UIImage) -> Void
|
||||
@@ -41,7 +41,7 @@ final class WebSearchControllerInteraction {
|
||||
let editingState: TGMediaEditingContext
|
||||
var hiddenMediaId: String?
|
||||
|
||||
init(openResult: @escaping (ChatContextResult) -> Void, setSearchQuery: @escaping (String) -> Void, deleteRecentQuery: @escaping (String) -> Void, toggleSelection: @escaping (ChatContextResult, Bool) -> Void, sendSelected: @escaping (ChatContextResult?, Bool, Int32?) -> Void, schedule: @escaping () -> Void, avatarCompleted: @escaping (UIImage) -> Void, selectionState: TGMediaSelectionContext?, editingState: TGMediaEditingContext) {
|
||||
init(openResult: @escaping (ChatContextResult) -> Void, setSearchQuery: @escaping (String) -> Void, deleteRecentQuery: @escaping (String) -> Void, toggleSelection: @escaping (ChatContextResult, Bool) -> Bool, sendSelected: @escaping (ChatContextResult?, Bool, Int32?) -> Void, schedule: @escaping () -> Void, avatarCompleted: @escaping (UIImage) -> Void, selectionState: TGMediaSelectionContext?, editingState: TGMediaEditingContext) {
|
||||
self.openResult = openResult
|
||||
self.setSearchQuery = setSearchQuery
|
||||
self.deleteRecentQuery = deleteRecentQuery
|
||||
@@ -119,6 +119,8 @@ public final class WebSearchController: ViewController {
|
||||
|
||||
public var searchingUpdated: (Bool) -> Void = { _ in }
|
||||
|
||||
public var attemptItemSelection: (ChatContextResult) -> Bool = { _ in return true }
|
||||
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peer: EnginePeer?, chatLocation: ChatLocation?, configuration: EngineConfiguration.SearchBots, mode: WebSearchControllerMode) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
@@ -233,8 +235,14 @@ public final class WebSearchController: ViewController {
|
||||
}
|
||||
}, toggleSelection: { [weak self] result, value in
|
||||
if let strongSelf = self {
|
||||
if !strongSelf.attemptItemSelection(result) {
|
||||
return false
|
||||
}
|
||||
let item = LegacyWebSearchItem(result: result)
|
||||
strongSelf.controllerInteraction?.selectionState?.setItem(item, selected: value)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}, sendSelected: { [weak self] current, silently, scheduleTime in
|
||||
if let selectionState = selectionState, let results = self?.controllerNode.currentExternalResults {
|
||||
@@ -258,6 +266,18 @@ public final class WebSearchController: ViewController {
|
||||
}
|
||||
}, selectionState: selectionState, editingState: editingState)
|
||||
|
||||
selectionState?.attemptSelectingItem = { [weak self] item in
|
||||
guard let self else {
|
||||
return false
|
||||
}
|
||||
|
||||
if let item = item as? LegacyWebSearchItem {
|
||||
return self.attemptItemSelection(item.result)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
if let selectionState = selectionState {
|
||||
self.selectionDisposable = (selectionChangedSignal(selectionState: selectionState)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
|
||||
Reference in New Issue
Block a user