From 40e51fb1576444cd1a6cd84ea93871459d43dda8 Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Mon, 20 Jun 2022 13:06:29 +0300 Subject: [PATCH] Auto dismiss bug report when completed (#83) * #76 Show success indicator on settings coordinator when bug report completed * #76 Add changelog * #76 remove unused method * #76 Rename `errorIndicator`s to `statusIndicator`s --- ElementX/Sources/AppCoordinator.swift | 6 +++--- .../Screens/BugReport/BugReportCoordinator.swift | 13 +++---------- .../Sources/Screens/BugReport/BugReportModels.swift | 2 -- .../Screens/BugReport/BugReportViewModel.swift | 2 -- .../Screens/Settings/SettingsCoordinator.swift | 7 +++++++ changelog.d/76.change | 1 + 6 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 changelog.d/76.change diff --git a/ElementX/Sources/AppCoordinator.swift b/ElementX/Sources/AppCoordinator.swift index 4f057c1dc..11c855e78 100644 --- a/ElementX/Sources/AppCoordinator.swift +++ b/ElementX/Sources/AppCoordinator.swift @@ -29,7 +29,7 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator { private var indicatorPresenter: UserIndicatorTypePresenterProtocol private var loadingIndicator: UserIndicator? - private var errorIndicator: UserIndicator? + private var statusIndicator: UserIndicator? var childCoordinators: [Coordinator] = [] @@ -281,11 +281,11 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator { } private func showLoginErrorToast() { - errorIndicator = indicatorPresenter.present(.error(label: "Failed logging in")) + statusIndicator = indicatorPresenter.present(.error(label: "Failed logging in")) } private func showLogoutErrorToast() { - errorIndicator = indicatorPresenter.present(.success(label: "Failed logging out")) + statusIndicator = indicatorPresenter.present(.error(label: "Failed logging out")) } private func showCrashPopup() { diff --git a/ElementX/Sources/Screens/BugReport/BugReportCoordinator.swift b/ElementX/Sources/Screens/BugReport/BugReportCoordinator.swift index 2d3b0b224..379cee45f 100644 --- a/ElementX/Sources/Screens/BugReport/BugReportCoordinator.swift +++ b/ElementX/Sources/Screens/BugReport/BugReportCoordinator.swift @@ -33,7 +33,7 @@ final class BugReportCoordinator: Coordinator, Presentable { private var indicatorPresenter: UserIndicatorTypePresenterProtocol private var loadingIndicator: UserIndicator? - private var errorIndicator: UserIndicator? + private var statusIndicator: UserIndicator? // MARK: Public @@ -67,12 +67,10 @@ final class BugReportCoordinator: Coordinator, Presentable { self.startLoading() case .submitFinished: self.stopLoading() - self.showSuccess(label: ElementL10n.done) + self.completion?() case .submitFailed(let error): self.stopLoading() self.showError(label: error.localizedDescription) - case .cancel: - self.completion?() } } } @@ -97,13 +95,8 @@ final class BugReportCoordinator: Coordinator, Presentable { loadingIndicator = nil } - /// Show success indicator - private func showSuccess(label: String) { - errorIndicator = indicatorPresenter.present(.success(label: label)) - } - /// Show error indicator private func showError(label: String) { - errorIndicator = indicatorPresenter.present(.error(label: label)) + statusIndicator = indicatorPresenter.present(.error(label: label)) } } diff --git a/ElementX/Sources/Screens/BugReport/BugReportModels.swift b/ElementX/Sources/Screens/BugReport/BugReportModels.swift index 2403df0e1..a23b129bf 100644 --- a/ElementX/Sources/Screens/BugReport/BugReportModels.swift +++ b/ElementX/Sources/Screens/BugReport/BugReportModels.swift @@ -25,7 +25,6 @@ enum BugReportViewModelAction { case submitStarted case submitFinished case submitFailed(error: Error) - case cancel } // MARK: View @@ -42,7 +41,6 @@ struct BugReportViewStateBindings { enum BugReportViewAction { case submit - case cancel case toggleSendLogs case removeScreenshot } diff --git a/ElementX/Sources/Screens/BugReport/BugReportViewModel.swift b/ElementX/Sources/Screens/BugReport/BugReportViewModel.swift index 143935e85..73e62e991 100644 --- a/ElementX/Sources/Screens/BugReport/BugReportViewModel.swift +++ b/ElementX/Sources/Screens/BugReport/BugReportViewModel.swift @@ -76,8 +76,6 @@ class BugReportViewModel: BugReportViewModelType, BugReportViewModelProtocol { switch viewAction { case .submit: await submitBugReport() - case .cancel: - callback?(.cancel) case .toggleSendLogs: context.sendingLogsEnabled.toggle() case .removeScreenshot: diff --git a/ElementX/Sources/Screens/Settings/SettingsCoordinator.swift b/ElementX/Sources/Screens/Settings/SettingsCoordinator.swift index 3e278fe79..e82a83cc3 100644 --- a/ElementX/Sources/Screens/Settings/SettingsCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/SettingsCoordinator.swift @@ -33,6 +33,7 @@ final class SettingsCoordinator: Coordinator, Presentable { private var indicatorPresenter: UserIndicatorTypePresenterProtocol private var loadingIndicator: UserIndicator? + private var statusIndicator: UserIndicator? // MARK: Public @@ -96,6 +97,7 @@ final class SettingsCoordinator: Coordinator, Presentable { guard let self = self, let coordinator = coordinator else { return } self.parameters.navigationRouter.popModule(animated: true) self.remove(childCoordinator: coordinator) + self.showSuccess(label: ElementL10n.done) } add(childCoordinator: coordinator) @@ -106,4 +108,9 @@ final class SettingsCoordinator: Coordinator, Presentable { self.remove(childCoordinator: coordinator) } } + + /// Show success indicator + private func showSuccess(label: String) { + statusIndicator = indicatorPresenter.present(.success(label: label)) + } } diff --git a/changelog.d/76.change b/changelog.d/76.change new file mode 100644 index 000000000..d0a1e6870 --- /dev/null +++ b/changelog.d/76.change @@ -0,0 +1 @@ +Settings: Auto dismiss bug report screen and show a success indicator when bug report completed.