From 2ef2d5c95fc33f060f818c9a95e50a8508b1b382 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Fri, 23 Aug 2024 11:24:23 +1000 Subject: [PATCH] fix ban & delete toast --- .../Conversations/ConversationVC+Interaction.swift | 12 ++++++++---- Session/Shared/Types/NavigatableState.swift | 12 ++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 97c43b93d..2840185e1 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -2303,14 +2303,16 @@ extension ConversationVC: DispatchQueue.main.async { [weak self] in self?.viewModel.showToast( text: "banUserBanned".localized(), - backgroundColor: .backgroundSecondary + backgroundColor: .backgroundSecondary, + insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing ) } case .failure: DispatchQueue.main.async { [weak self] in self?.viewModel.showToast( text: "banErrorFailed".localized(), - backgroundColor: .backgroundSecondary + backgroundColor: .backgroundSecondary, + insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing ) } } @@ -2362,14 +2364,16 @@ extension ConversationVC: DispatchQueue.main.async { [weak self] in self?.viewModel.showToast( text: "banUserBanned".localized(), - backgroundColor: .backgroundSecondary + backgroundColor: .backgroundSecondary, + insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing ) } case .failure: DispatchQueue.main.async { [weak self] in self?.viewModel.showToast( text: "banErrorFailed".localized(), - backgroundColor: .backgroundSecondary + backgroundColor: .backgroundSecondary, + insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing ) } } diff --git a/Session/Shared/Types/NavigatableState.swift b/Session/Shared/Types/NavigatableState.swift index 7a55b3ec7..96fc97bc9 100644 --- a/Session/Shared/Types/NavigatableState.swift +++ b/Session/Shared/Types/NavigatableState.swift @@ -13,8 +13,8 @@ public protocol NavigatableStateHolder { } public extension NavigatableStateHolder { - func showToast(text: String, backgroundColor: ThemeValue = .backgroundPrimary) { - navigatableState._showToast.send((text, backgroundColor)) + func showToast(text: String, backgroundColor: ThemeValue = .backgroundPrimary, insect: CGFloat = Values.largeSpacing) { + navigatableState._showToast.send((text, backgroundColor, insect)) } func dismissScreen(type: DismissType = .auto) { @@ -29,13 +29,13 @@ public extension NavigatableStateHolder { // MARK: - NavigatableState public struct NavigatableState { - let showToast: AnyPublisher<(String, ThemeValue), Never> + let showToast: AnyPublisher<(String, ThemeValue, CGFloat), Never> let transitionToScreen: AnyPublisher<(UIViewController, TransitionType), Never> let dismissScreen: AnyPublisher // MARK: - Internal Variables - fileprivate let _showToast: PassthroughSubject<(String, ThemeValue), Never> = PassthroughSubject() + fileprivate let _showToast: PassthroughSubject<(String, ThemeValue, CGFloat), Never> = PassthroughSubject() fileprivate let _transitionToScreen: PassthroughSubject<(UIViewController, TransitionType), Never> = PassthroughSubject() fileprivate let _dismissScreen: PassthroughSubject = PassthroughSubject() @@ -55,11 +55,11 @@ public struct NavigatableState { ) { self.showToast .receive(on: DispatchQueue.main) - .sink { [weak viewController] text, color in + .sink { [weak viewController] text, color, insect in guard let view: UIView = viewController?.view else { return } let toastController: ToastController = ToastController(text: text, background: color) - toastController.presentToastView(fromBottomOfView: view, inset: Values.largeSpacing) + toastController.presentToastView(fromBottomOfView: view, inset: insect) } .store(in: &disposables)