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)
|
stateMachine.processEvent(userSessionStore.hasSessions ? .startWithExistingSession : .startWithAuthentication)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
hideLoadingIndicator()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func setupLogging() {
|
private func setupLogging() {
|
||||||
|
@ -36,6 +36,9 @@ protocol Coordinator: AnyObject {
|
|||||||
///
|
///
|
||||||
/// - Parameter childCoordinator: Child coordinator to remove.
|
/// - Parameter childCoordinator: Child coordinator to remove.
|
||||||
func remove(childCoordinator: Coordinator)
|
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
|
// `Coordinator` default implementation
|
||||||
@ -45,6 +48,7 @@ extension Coordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func remove(childCoordinator: Coordinator) {
|
func remove(childCoordinator: Coordinator) {
|
||||||
|
childCoordinator.stop()
|
||||||
childCoordinators = childCoordinators.filter { $0 !== childCoordinator }
|
childCoordinators = childCoordinators.filter { $0 !== childCoordinator }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,4 +70,6 @@ final class AnalyticsPromptCoordinator: Coordinator, Presentable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func toPresentable() -> UIViewController { analyticsPromptHostingController }
|
func toPresentable() -> UIViewController { analyticsPromptHostingController }
|
||||||
|
|
||||||
|
func stop() { }
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,10 @@ class AuthenticationCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
navigationRouter.toPresentable()
|
navigationRouter.toPresentable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -99,6 +99,10 @@ final class LoginCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
loginHostingController
|
loginHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -82,6 +82,10 @@ final class ServerSelectionCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
serverSelectionHostingController
|
serverSelectionHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -108,6 +108,10 @@ final class SoftLogoutCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
softLogoutHostingController
|
softLogoutHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ final class BugReportCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
bugReportHostingController
|
bugReportHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ final class HomeScreenCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
hostingController
|
hostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() { }
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -58,4 +58,8 @@ final class RoomScreenCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
roomScreenHostingController
|
roomScreenHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
roomScreenViewModel.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ enum RoomScreenViewAction {
|
|||||||
case sendMessage
|
case sendMessage
|
||||||
case sendReaction(key: String, eventID: String)
|
case sendReaction(key: String, eventID: String)
|
||||||
case cancelReply
|
case cancelReply
|
||||||
case viewDisappeared
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RoomScreenViewState: BindableState {
|
struct RoomScreenViewState: BindableState {
|
||||||
|
@ -90,12 +90,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
MXLog.warning("React with \(key) failed. Not implemented.")
|
MXLog.warning("React with \(key) failed. Not implemented.")
|
||||||
case .cancelReply:
|
case .cancelReply:
|
||||||
state.composerMode = .default
|
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
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -19,4 +19,6 @@ import Foundation
|
|||||||
@MainActor
|
@MainActor
|
||||||
protocol RoomScreenViewModelProtocol {
|
protocol RoomScreenViewModelProtocol {
|
||||||
var context: RoomScreenViewModelType.Context { get }
|
var context: RoomScreenViewModelType.Context { get }
|
||||||
|
|
||||||
|
func stop()
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,6 @@ struct RoomScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $context.alertInfo) { $0.alert }
|
.alert(item: $context.alertInfo) { $0.alert }
|
||||||
.onDisappear {
|
|
||||||
context.send(viewAction: .viewDisappeared)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func sendMessage() {
|
private func sendMessage() {
|
||||||
|
@ -26,7 +26,8 @@ struct PlaceholderAvatarImage: View {
|
|||||||
Text(textForImage)
|
Text(textForImage)
|
||||||
.padding(4)
|
.padding(4)
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.font(.title2.bold())
|
.font(.system(size: 200).weight(.semibold))
|
||||||
|
.minimumScaleFactor(0.001)
|
||||||
}
|
}
|
||||||
.aspectRatio(1, contentMode: .fill)
|
.aspectRatio(1, contentMode: .fill)
|
||||||
}
|
}
|
||||||
|
@ -63,4 +63,6 @@ final class SessionVerificationCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
sessionVerificationHostingController
|
sessionVerificationHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() { }
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,8 @@ final class SettingsCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
settingsHostingController
|
settingsHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() { }
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ class UITestsAppCoordinator: Coordinator {
|
|||||||
private func mockScreens() -> [MockScreen] {
|
private func mockScreens() -> [MockScreen] {
|
||||||
UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRouter: navigationRouter) }
|
UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRouter: navigationRouter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
@ -75,6 +75,10 @@ final class TemplateCoordinator: Coordinator, Presentable {
|
|||||||
func toPresentable() -> UIViewController {
|
func toPresentable() -> UIViewController {
|
||||||
templateHostingController
|
templateHostingController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stop() {
|
||||||
|
stopLoading()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user