mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fix remaining retain cycles, allow coordinators to be weakly referenced and make sure the NavigationStackCoordinator cleans up after itself
This commit is contained in:
committed by
Stefan Ceriu
parent
93997efef9
commit
594f6f85dd
@@ -23,7 +23,7 @@ enum BugReportCoordinatorResult {
|
||||
|
||||
struct BugReportCoordinatorParameters {
|
||||
let bugReportService: BugReportServiceProtocol
|
||||
let userNotificationController: UserNotificationControllerProtocol
|
||||
weak var userNotificationController: UserNotificationControllerProtocol?
|
||||
let screenshot: UIImage?
|
||||
let isModallyPresented: Bool
|
||||
}
|
||||
@@ -76,17 +76,17 @@ final class BugReportCoordinator: CoordinatorProtocol {
|
||||
static let loadingIndicatorIdentifier = "BugReportLoading"
|
||||
|
||||
private func startLoading(label: String = ElementL10n.loading) {
|
||||
parameters.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
||||
type: .modal,
|
||||
title: label,
|
||||
persistent: true))
|
||||
parameters.userNotificationController?.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
||||
type: .modal,
|
||||
title: label,
|
||||
persistent: true))
|
||||
}
|
||||
|
||||
private func stopLoading() {
|
||||
parameters.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
||||
parameters.userNotificationController?.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
||||
}
|
||||
|
||||
private func showError(label: String) {
|
||||
parameters.userNotificationController.submitNotification(UserNotification(title: label))
|
||||
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ActivityCoordinator: CoordinatorProtocol {
|
||||
class ActivityCoordinator: CoordinatorProtocol {
|
||||
let items: [Any]
|
||||
|
||||
init(items: [Any]) {
|
||||
self.items = items
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(UIActivityViewControllerWrapper(activityItems: items)
|
||||
.presentationDetents([.medium])
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct InviteFriendsCoordinator: CoordinatorProtocol {
|
||||
class InviteFriendsCoordinator: CoordinatorProtocol {
|
||||
let userId: String
|
||||
|
||||
init(userId: String) {
|
||||
self.userId = userId
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
guard let permalink = try? PermalinkBuilder.permalinkTo(userIdentifier: userId).absoluteString else {
|
||||
return AnyView(EmptyView())
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SplashScreenCoordinator: CoordinatorProtocol {
|
||||
class SplashScreenCoordinator: CoordinatorProtocol {
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(
|
||||
ZStack {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsScreenCoordinatorParameters {
|
||||
let navigationStackCoordinator: NavigationStackCoordinator
|
||||
let userNotificationController: UserNotificationControllerProtocol
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
weak var userNotificationController: UserNotificationControllerProtocol?
|
||||
let userSession: UserSessionProtocol
|
||||
let bugReportService: BugReportServiceProtocol
|
||||
}
|
||||
@@ -88,10 +88,10 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
break
|
||||
}
|
||||
|
||||
self?.parameters.navigationStackCoordinator.pop()
|
||||
self?.parameters.navigationStackCoordinator?.pop()
|
||||
}
|
||||
|
||||
parameters.navigationStackCoordinator.push(coordinator)
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
|
||||
private func verifySession() {
|
||||
@@ -103,15 +103,15 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
let coordinator = SessionVerificationCoordinator(parameters: verificationParameters)
|
||||
|
||||
coordinator.callback = { [weak self] in
|
||||
self?.parameters.navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
self?.parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
||||
}
|
||||
|
||||
parameters.navigationStackCoordinator.setSheetCoordinator(coordinator) { [weak self] in
|
||||
self?.parameters.navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
parameters.navigationStackCoordinator?.setSheetCoordinator(coordinator) { [weak self] in
|
||||
self?.parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
||||
}
|
||||
}
|
||||
|
||||
private func showSuccess(label: String) {
|
||||
parameters.userNotificationController.submitNotification(UserNotification(title: label))
|
||||
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user