fix ban & delete toast

pull/1023/head
Ryan ZHAO 9 months ago
parent 5881b36384
commit 2ef2d5c95f

@ -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
)
}
}

@ -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<DismissType, Never>
// 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<DismissType, Never> = 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)

Loading…
Cancel
Save