fix ban & delete toast

pull/1023/head
Ryan ZHAO 1 year ago
parent 5881b36384
commit 2ef2d5c95f

@ -2303,14 +2303,16 @@ extension ConversationVC:
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.viewModel.showToast( self?.viewModel.showToast(
text: "banUserBanned".localized(), text: "banUserBanned".localized(),
backgroundColor: .backgroundSecondary backgroundColor: .backgroundSecondary,
insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
) )
} }
case .failure: case .failure:
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.viewModel.showToast( self?.viewModel.showToast(
text: "banErrorFailed".localized(), 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 DispatchQueue.main.async { [weak self] in
self?.viewModel.showToast( self?.viewModel.showToast(
text: "banUserBanned".localized(), text: "banUserBanned".localized(),
backgroundColor: .backgroundSecondary backgroundColor: .backgroundSecondary,
insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
) )
} }
case .failure: case .failure:
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.viewModel.showToast( self?.viewModel.showToast(
text: "banErrorFailed".localized(), text: "banErrorFailed".localized(),
backgroundColor: .backgroundSecondary backgroundColor: .backgroundSecondary,
insect: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
) )
} }
} }

@ -13,8 +13,8 @@ public protocol NavigatableStateHolder {
} }
public extension NavigatableStateHolder { public extension NavigatableStateHolder {
func showToast(text: String, backgroundColor: ThemeValue = .backgroundPrimary) { func showToast(text: String, backgroundColor: ThemeValue = .backgroundPrimary, insect: CGFloat = Values.largeSpacing) {
navigatableState._showToast.send((text, backgroundColor)) navigatableState._showToast.send((text, backgroundColor, insect))
} }
func dismissScreen(type: DismissType = .auto) { func dismissScreen(type: DismissType = .auto) {
@ -29,13 +29,13 @@ public extension NavigatableStateHolder {
// MARK: - NavigatableState // MARK: - NavigatableState
public struct NavigatableState { public struct NavigatableState {
let showToast: AnyPublisher<(String, ThemeValue), Never> let showToast: AnyPublisher<(String, ThemeValue, CGFloat), Never>
let transitionToScreen: AnyPublisher<(UIViewController, TransitionType), Never> let transitionToScreen: AnyPublisher<(UIViewController, TransitionType), Never>
let dismissScreen: AnyPublisher<DismissType, Never> let dismissScreen: AnyPublisher<DismissType, Never>
// MARK: - Internal Variables // 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 _transitionToScreen: PassthroughSubject<(UIViewController, TransitionType), Never> = PassthroughSubject()
fileprivate let _dismissScreen: PassthroughSubject<DismissType, Never> = PassthroughSubject() fileprivate let _dismissScreen: PassthroughSubject<DismissType, Never> = PassthroughSubject()
@ -55,11 +55,11 @@ public struct NavigatableState {
) { ) {
self.showToast self.showToast
.receive(on: DispatchQueue.main) .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 } guard let view: UIView = viewController?.view else { return }
let toastController: ToastController = ToastController(text: text, background: color) let toastController: ToastController = ToastController(text: text, background: color)
toastController.presentToastView(fromBottomOfView: view, inset: Values.largeSpacing) toastController.presentToastView(fromBottomOfView: view, inset: insect)
} }
.store(in: &disposables) .store(in: &disposables)

Loading…
Cancel
Save