mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Coordinator stops (#207)
* Add `stop` method to `Coordinator` * Use new stop method to cleanup room screen * Call stop implicitly when removing a child coordinator * Revert placeholder avatar font change * Fix PR remarks
This commit is contained in:
parent
d7dad1353b
commit
b03a02351a
@ -105,6 +105,10 @@ class AppCoordinator: Coordinator {
|
||||
stateMachine.processEvent(userSessionStore.hasSessions ? .startWithExistingSession : .startWithAuthentication)
|
||||
}
|
||||
|
||||
func stop() {
|
||||
hideLoadingIndicator()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func setupLogging() {
|
||||
|
@ -36,6 +36,9 @@ protocol Coordinator: AnyObject {
|
||||
///
|
||||
/// - Parameter childCoordinator: Child coordinator to remove.
|
||||
func remove(childCoordinator: Coordinator)
|
||||
|
||||
/// Stops job of the coordinator. Can be used to clear some resources. Will be automatically called when the coordinator removed.
|
||||
func stop()
|
||||
}
|
||||
|
||||
// `Coordinator` default implementation
|
||||
@ -45,6 +48,7 @@ extension Coordinator {
|
||||
}
|
||||
|
||||
func remove(childCoordinator: Coordinator) {
|
||||
childCoordinator.stop()
|
||||
childCoordinators = childCoordinators.filter { $0 !== childCoordinator }
|
||||
}
|
||||
}
|
||||
|
@ -70,4 +70,6 @@ final class AnalyticsPromptCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController { analyticsPromptHostingController }
|
||||
|
||||
func stop() { }
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ class AuthenticationCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
navigationRouter.toPresentable()
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -99,6 +99,10 @@ final class LoginCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
loginHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -82,6 +82,10 @@ final class ServerSelectionCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
serverSelectionHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -108,6 +108,10 @@ final class SoftLogoutCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
softLogoutHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -77,6 +77,10 @@ final class BugReportCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
bugReportHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -79,6 +79,8 @@ final class HomeScreenCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
hostingController
|
||||
}
|
||||
|
||||
func stop() { }
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -58,4 +58,8 @@ final class RoomScreenCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
roomScreenHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
roomScreenViewModel.stop()
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ enum RoomScreenViewAction {
|
||||
case sendMessage
|
||||
case sendReaction(key: String, eventID: String)
|
||||
case cancelReply
|
||||
case viewDisappeared
|
||||
}
|
||||
|
||||
struct RoomScreenViewState: BindableState {
|
||||
|
@ -90,12 +90,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
MXLog.warning("React with \(key) failed. Not implemented.")
|
||||
case .cancelReply:
|
||||
state.composerMode = .default
|
||||
case .viewDisappeared:
|
||||
cancellables.forEach { $0.cancel() }
|
||||
cancellables.removeAll()
|
||||
state.contextMenuBuilder = nil
|
||||
}
|
||||
}
|
||||
|
||||
func stop() {
|
||||
cancellables.forEach { $0.cancel() }
|
||||
cancellables.removeAll()
|
||||
state.contextMenuBuilder = nil
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -19,4 +19,6 @@ import Foundation
|
||||
@MainActor
|
||||
protocol RoomScreenViewModelProtocol {
|
||||
var context: RoomScreenViewModelType.Context { get }
|
||||
|
||||
func stop()
|
||||
}
|
||||
|
@ -41,9 +41,6 @@ struct RoomScreen: View {
|
||||
}
|
||||
}
|
||||
.alert(item: $context.alertInfo) { $0.alert }
|
||||
.onDisappear {
|
||||
context.send(viewAction: .viewDisappeared)
|
||||
}
|
||||
}
|
||||
|
||||
private func sendMessage() {
|
||||
|
@ -26,7 +26,8 @@ struct PlaceholderAvatarImage: View {
|
||||
Text(textForImage)
|
||||
.padding(4)
|
||||
.foregroundColor(.white)
|
||||
.font(.title2.bold())
|
||||
.font(.system(size: 200).weight(.semibold))
|
||||
.minimumScaleFactor(0.001)
|
||||
}
|
||||
.aspectRatio(1, contentMode: .fill)
|
||||
}
|
||||
|
@ -63,4 +63,6 @@ final class SessionVerificationCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
sessionVerificationHostingController
|
||||
}
|
||||
|
||||
func stop() { }
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ final class SettingsCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
settingsHostingController
|
||||
}
|
||||
|
||||
func stop() { }
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
@ -60,6 +60,8 @@ class UITestsAppCoordinator: Coordinator {
|
||||
private func mockScreens() -> [MockScreen] {
|
||||
UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRouter: navigationRouter) }
|
||||
}
|
||||
|
||||
func stop() { }
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
@ -75,6 +75,10 @@ final class TemplateCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
templateHostingController
|
||||
}
|
||||
|
||||
func stop() {
|
||||
stopLoading()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user