mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-06 12:28:29 +00:00
547 refactored userNotification into userIndicator
This commit is contained in:
@@ -101,13 +101,13 @@ class AppCoordinator: AppCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func toPresentable() -> AnyView {
|
func toPresentable() -> AnyView {
|
||||||
ServiceLocator.shared.userNotificationController.toPresentable()
|
ServiceLocator.shared.userIndicatorController.toPresentable()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private static func setupServiceLocator(navigationRootCoordinator: NavigationRootCoordinator) {
|
private static func setupServiceLocator(navigationRootCoordinator: NavigationRootCoordinator) {
|
||||||
ServiceLocator.shared.register(userNotificationController: UserNotificationController(rootCoordinator: navigationRootCoordinator))
|
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController(rootCoordinator: navigationRootCoordinator))
|
||||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||||
ServiceLocator.shared.register(networkMonitor: NetworkMonitor())
|
ServiceLocator.shared.register(networkMonitor: NetworkMonitor())
|
||||||
}
|
}
|
||||||
@@ -377,18 +377,18 @@ class AppCoordinator: AppCoordinatorProtocol {
|
|||||||
static let loadingIndicatorIdentifier = "AppCoordinatorLoading"
|
static let loadingIndicatorIdentifier = "AppCoordinatorLoading"
|
||||||
|
|
||||||
private func showLoadingIndicator() {
|
private func showLoadingIndicator() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
type: .modal,
|
type: .modal,
|
||||||
title: ElementL10n.loading,
|
title: ElementL10n.loading,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func hideLoadingIndicator() {
|
private func hideLoadingIndicator() {
|
||||||
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showLoginErrorToast() {
|
private func showLoginErrorToast() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: "Failed logging in"))
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: "Failed logging in"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Application State
|
// MARK: - Application State
|
||||||
@@ -447,11 +447,11 @@ class AppCoordinator: AppCoordinatorProtocol {
|
|||||||
MXLog.info("Reachability changed to \(reachable)")
|
MXLog.info("Reachability changed to \(reachable)")
|
||||||
|
|
||||||
if reachable {
|
if reachable {
|
||||||
ServiceLocator.shared.userNotificationController.retractNotificationWithId(reachabilityNotificationIdentifier)
|
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(reachabilityNotificationIdentifier)
|
||||||
} else {
|
} else {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(.init(id: reachabilityNotificationIdentifier,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationIdentifier,
|
||||||
title: ElementL10n.a11yPresenceOffline,
|
title: ElementL10n.a11yPresenceOffline,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
}
|
}
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ class ServiceLocator {
|
|||||||
|
|
||||||
private init() { }
|
private init() { }
|
||||||
|
|
||||||
private(set) var userNotificationController: UserNotificationControllerProtocol!
|
private(set) var userIndicatorController: UserIndicatorControllerProtocol!
|
||||||
|
|
||||||
func register(userNotificationController: UserNotificationControllerProtocol) {
|
func register(userIndicatorController: UserIndicatorControllerProtocol) {
|
||||||
self.userNotificationController = userNotificationController
|
self.userIndicatorController = userIndicatorController
|
||||||
}
|
}
|
||||||
|
|
||||||
private(set) var settings: AppSettings!
|
private(set) var settings: AppSettings!
|
||||||
|
|||||||
+4
-4
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class MockUserNotificationController: UserNotificationControllerProtocol {
|
class MockUserIndicatorController: UserIndicatorControllerProtocol {
|
||||||
func submitNotification(_ notification: UserNotification) { }
|
func submitIndicator(_ indicator: UserIndicator) { }
|
||||||
|
|
||||||
func retractNotificationWithId(_ id: String) { }
|
func retractIndicatorWithId(_ id: String) { }
|
||||||
|
|
||||||
func retractAllNotifications() { }
|
func retractAllIndicators() { }
|
||||||
}
|
}
|
||||||
+5
-5
@@ -14,15 +14,15 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import Foundation
|
||||||
|
|
||||||
enum UserNotificationType {
|
enum UserIndicatorType {
|
||||||
case toast
|
case toast
|
||||||
case modal
|
case modal
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UserNotification: Equatable, Identifiable {
|
struct UserIndicator: Equatable, Identifiable {
|
||||||
static func == (lhs: UserNotification, rhs: UserNotification) -> Bool {
|
static func == (lhs: UserIndicator, rhs: UserIndicator) -> Bool {
|
||||||
lhs.id == rhs.id &&
|
lhs.id == rhs.id &&
|
||||||
lhs.type == rhs.type &&
|
lhs.type == rhs.type &&
|
||||||
lhs.title == rhs.title &&
|
lhs.title == rhs.title &&
|
||||||
@@ -31,7 +31,7 @@ struct UserNotification: Equatable, Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var id: String = UUID().uuidString
|
var id: String = UUID().uuidString
|
||||||
var type = UserNotificationType.toast
|
var type = UserIndicatorType.toast
|
||||||
var title: String
|
var title: String
|
||||||
var iconName: String?
|
var iconName: String?
|
||||||
var persistent = false
|
var persistent = false
|
||||||
+20
-20
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
class UserNotificationController: ObservableObject, UserNotificationControllerProtocol, CustomStringConvertible {
|
class UserIndicatorController: ObservableObject, UserIndicatorControllerProtocol, CustomStringConvertible {
|
||||||
private let rootCoordinator: CoordinatorProtocol
|
private let rootCoordinator: CoordinatorProtocol
|
||||||
|
|
||||||
private var dismisalTimer: Timer?
|
private var dismisalTimer: Timer?
|
||||||
@@ -25,15 +25,15 @@ class UserNotificationController: ObservableObject, UserNotificationControllerPr
|
|||||||
var nonPersistentDisplayDuration = 2.5
|
var nonPersistentDisplayDuration = 2.5
|
||||||
var minimumDisplayDuration = 0.5
|
var minimumDisplayDuration = 0.5
|
||||||
|
|
||||||
@Published private(set) var activeNotification: UserNotification?
|
@Published private(set) var activeIndicator: UserIndicator?
|
||||||
private(set) var notificationQueue = [UserNotification]() {
|
private(set) var indicatorQueue = [UserIndicator]() {
|
||||||
didSet {
|
didSet {
|
||||||
activeNotification = notificationQueue.last
|
activeIndicator = indicatorQueue.last
|
||||||
|
|
||||||
if let activeNotification, !activeNotification.persistent {
|
if let activeIndicator, !activeIndicator.persistent {
|
||||||
dismisalTimer?.invalidate()
|
dismisalTimer?.invalidate()
|
||||||
dismisalTimer = Timer.scheduledTimer(withTimeInterval: nonPersistentDisplayDuration, repeats: false) { [weak self] _ in
|
dismisalTimer = Timer.scheduledTimer(withTimeInterval: nonPersistentDisplayDuration, repeats: false) { [weak self] _ in
|
||||||
self?.retractNotificationWithId(activeNotification.id)
|
self?.retractIndicatorWithId(activeIndicator.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,35 +45,35 @@ class UserNotificationController: ObservableObject, UserNotificationControllerPr
|
|||||||
|
|
||||||
func toPresentable() -> AnyView {
|
func toPresentable() -> AnyView {
|
||||||
AnyView(
|
AnyView(
|
||||||
UserNotificationPresenter(userNotificationController: self, rootView: rootCoordinator.toPresentable())
|
UserIndicatorPresenter(userIndicatorController: self, rootView: rootCoordinator.toPresentable())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func submitNotification(_ notification: UserNotification) {
|
func submitIndicator(_ indicator: UserIndicator) {
|
||||||
if let index = notificationQueue.firstIndex(where: { $0.id == notification.id }) {
|
if let index = indicatorQueue.firstIndex(where: { $0.id == indicator.id }) {
|
||||||
notificationQueue[index] = notification
|
indicatorQueue[index] = indicator
|
||||||
} else {
|
} else {
|
||||||
retractNotificationWithId(notification.id)
|
retractIndicatorWithId(indicator.id)
|
||||||
notificationQueue.append(notification)
|
indicatorQueue.append(indicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
displayTimes[notification.id] = .now
|
displayTimes[indicator.id] = .now
|
||||||
}
|
}
|
||||||
|
|
||||||
func retractAllNotifications() {
|
func retractAllIndicators() {
|
||||||
for notification in notificationQueue {
|
for indicator in indicatorQueue {
|
||||||
retractNotificationWithId(notification.id)
|
retractIndicatorWithId(indicator.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func retractNotificationWithId(_ id: String) {
|
func retractIndicatorWithId(_ id: String) {
|
||||||
guard let displayTime = displayTimes[id], abs(displayTime.timeIntervalSinceNow) <= minimumDisplayDuration else {
|
guard let displayTime = displayTimes[id], abs(displayTime.timeIntervalSinceNow) <= minimumDisplayDuration else {
|
||||||
notificationQueue.removeAll { $0.id == id }
|
indicatorQueue.removeAll { $0.id == id }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.scheduledTimer(withTimeInterval: minimumDisplayDuration, repeats: false) { [weak self] _ in
|
Timer.scheduledTimer(withTimeInterval: minimumDisplayDuration, repeats: false) { [weak self] _ in
|
||||||
self?.notificationQueue.removeAll { $0.id == id }
|
self?.indicatorQueue.removeAll { $0.id == id }
|
||||||
self?.displayTimes[id] = nil
|
self?.displayTimes[id] = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,6 +81,6 @@ class UserNotificationController: ObservableObject, UserNotificationControllerPr
|
|||||||
// MARK: - CustomStringConvertible
|
// MARK: - CustomStringConvertible
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
"UserNotificationController(\(String(describing: rootCoordinator)))"
|
"UserIndicatorController(\(String(describing: rootCoordinator)))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
protocol UserNotificationControllerProtocol: CoordinatorProtocol {
|
protocol UserIndicatorControllerProtocol: CoordinatorProtocol {
|
||||||
func submitNotification(_ notification: UserNotification)
|
func submitIndicator(_ indicator: UserIndicator)
|
||||||
func retractNotificationWithId(_ id: String)
|
func retractIndicatorWithId(_ id: String)
|
||||||
func retractAllNotifications()
|
func retractAllIndicators()
|
||||||
}
|
}
|
||||||
+14
-14
@@ -17,8 +17,8 @@
|
|||||||
import Combine
|
import Combine
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct UserNotificationModalView: View {
|
struct UserIndicatorModalView: View {
|
||||||
let notification: UserNotification
|
let indicator: UserIndicator
|
||||||
@State private var progressFraction: Double?
|
@State private var progressFraction: Double?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -31,10 +31,10 @@ struct UserNotificationModalView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
if let iconName = notification.iconName {
|
if let iconName = indicator.iconName {
|
||||||
Image(systemName: iconName)
|
Image(systemName: iconName)
|
||||||
}
|
}
|
||||||
Text(notification.title)
|
Text(indicator.title)
|
||||||
.font(.element.body)
|
.font(.element.body)
|
||||||
.foregroundColor(.element.primaryContent)
|
.foregroundColor(.element.primaryContent)
|
||||||
}
|
}
|
||||||
@@ -45,30 +45,30 @@ struct UserNotificationModalView: View {
|
|||||||
.background(Color.element.quinaryContent)
|
.background(Color.element.quinaryContent)
|
||||||
.clipShape(RoundedCornerShape(radius: 12.0, corners: .allCorners))
|
.clipShape(RoundedCornerShape(radius: 12.0, corners: .allCorners))
|
||||||
.shadow(color: .black.opacity(0.1), radius: 10.0, y: 4.0)
|
.shadow(color: .black.opacity(0.1), radius: 10.0, y: 4.0)
|
||||||
.onReceive(notification.progressPublisher?.publisher ?? Empty().eraseToAnyPublisher()) { progress in
|
.onReceive(indicator.progressPublisher?.publisher ?? Empty().eraseToAnyPublisher()) { progress in
|
||||||
progressFraction = progress
|
progressFraction = progress
|
||||||
}
|
}
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
.id(notification.id)
|
.id(indicator.id)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.background(.black.opacity(0.1))
|
.background(.black.opacity(0.1))
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UserNotificationModalView_Previews: PreviewProvider {
|
struct UserIndicatorModalView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
UserNotificationModalView(notification: UserNotification(type: .modal,
|
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||||
title: "Successfully logged in",
|
title: "Successfully logged in",
|
||||||
iconName: "checkmark")
|
iconName: "checkmark")
|
||||||
)
|
)
|
||||||
.previewDisplayName("Spinner")
|
.previewDisplayName("Spinner")
|
||||||
UserNotificationModalView(notification: UserNotification(type: .modal,
|
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||||
title: "Successfully logged in",
|
title: "Successfully logged in",
|
||||||
iconName: "checkmark",
|
iconName: "checkmark",
|
||||||
progressPublisher: ProgressTracker(initialValue: 0.5))
|
progressPublisher: ProgressTracker(initialValue: 0.5))
|
||||||
)
|
)
|
||||||
.previewDisplayName("Progress Bar")
|
.previewDisplayName("Progress Bar")
|
||||||
}
|
}
|
||||||
+9
-9
@@ -16,27 +16,27 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct UserNotificationPresenter: View {
|
struct UserIndicatorPresenter: View {
|
||||||
@ObservedObject var userNotificationController: UserNotificationController
|
@ObservedObject var userIndicatorController: UserIndicatorController
|
||||||
let rootView: AnyView
|
let rootView: AnyView
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
rootView
|
rootView
|
||||||
notificationViewFor(notification: userNotificationController.activeNotification)
|
indicatorViewFor(indicator: userIndicatorController.activeIndicator)
|
||||||
}
|
}
|
||||||
.animation(.elementDefault, value: userNotificationController.activeNotification)
|
.animation(.elementDefault, value: userIndicatorController.activeIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func notificationViewFor(notification: UserNotification?) -> some View {
|
private func indicatorViewFor(indicator: UserIndicator?) -> some View {
|
||||||
ZStack { // Need a container to properly animate transitions
|
ZStack { // Need a container to properly animate transitions
|
||||||
if let notification {
|
if let indicator {
|
||||||
switch notification.type {
|
switch indicator.type {
|
||||||
case .toast:
|
case .toast:
|
||||||
UserNotificationToastView(notification: notification)
|
UserIndicatorToastView(indicator: indicator)
|
||||||
case .modal:
|
case .modal:
|
||||||
UserNotificationModalView(notification: notification)
|
UserIndicatorModalView(indicator: indicator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-9
@@ -16,19 +16,19 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct UserNotificationToastView: View {
|
struct UserIndicatorToastView: View {
|
||||||
let notification: UserNotification
|
let indicator: UserIndicator
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
if let iconName = notification.iconName {
|
if let iconName = indicator.iconName {
|
||||||
Image(systemName: iconName)
|
Image(systemName: iconName)
|
||||||
}
|
}
|
||||||
Text(notification.title)
|
Text(indicator.title)
|
||||||
.font(.element.footnote)
|
.font(.element.footnote)
|
||||||
.foregroundColor(.element.primaryContent)
|
.foregroundColor(.element.primaryContent)
|
||||||
}
|
}
|
||||||
.id(notification.id)
|
.id(indicator.id)
|
||||||
.padding(.horizontal, 12.0)
|
.padding(.horizontal, 12.0)
|
||||||
.padding(.vertical, 10.0)
|
.padding(.vertical, 10.0)
|
||||||
.frame(minWidth: 150.0)
|
.frame(minWidth: 150.0)
|
||||||
@@ -46,13 +46,13 @@ struct UserNotificationToastView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UserNotificationToastView_Previews: PreviewProvider {
|
struct UserIndicatorToastView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
VStack {
|
VStack {
|
||||||
UserNotificationToastView(notification: UserNotification(title: "Successfully logged in",
|
UserIndicatorToastView(indicator: UserIndicator(title: "Successfully logged in",
|
||||||
iconName: "checkmark"))
|
iconName: "checkmark"))
|
||||||
|
|
||||||
UserNotificationToastView(notification: UserNotification(title: "Toast without icon"))
|
UserIndicatorToastView(indicator: UserIndicator(title: "Toast without icon"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ class AuthenticationCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
private func showServerSelectionScreen() {
|
private func showServerSelectionScreen() {
|
||||||
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
|
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
|
||||||
userNotificationController: ServiceLocator.shared.userNotificationController,
|
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||||
isModallyPresented: false)
|
isModallyPresented: false)
|
||||||
let coordinator = ServerSelectionCoordinator(parameters: parameters)
|
let coordinator = ServerSelectionCoordinator(parameters: parameters)
|
||||||
|
|
||||||
@@ -123,13 +123,13 @@ class AuthenticationCoordinator: CoordinatorProtocol {
|
|||||||
static let loadingIndicatorIdentifier = "AuthenticationCoordinatorLoading"
|
static let loadingIndicatorIdentifier = "AuthenticationCoordinatorLoading"
|
||||||
|
|
||||||
private func startLoading() {
|
private func startLoading() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
type: .modal,
|
type: .modal,
|
||||||
title: ElementL10n.loading,
|
title: ElementL10n.loading,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopLoading() {
|
private func stopLoading() {
|
||||||
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ final class LoginCoordinator: CoordinatorProtocol {
|
|||||||
static let loadingIndicatorIdentifier = "LoginCoordinatorLoading"
|
static let loadingIndicatorIdentifier = "LoginCoordinatorLoading"
|
||||||
|
|
||||||
private func startLoading(isInteractionBlocking: Bool) {
|
private func startLoading(isInteractionBlocking: Bool) {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
type: .modal,
|
type: .modal,
|
||||||
title: ElementL10n.loading,
|
title: ElementL10n.loading,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
|
|
||||||
if !isInteractionBlocking {
|
if !isInteractionBlocking {
|
||||||
viewModel.update(isLoading: true)
|
viewModel.update(isLoading: true)
|
||||||
@@ -104,15 +104,15 @@ final class LoginCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
private func stopLoading() {
|
private func stopLoading() {
|
||||||
viewModel.update(isLoading: false)
|
viewModel.update(isLoading: false)
|
||||||
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func indicateSuccess() {
|
private func indicateSuccess() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.dialogTitleSuccess))
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.dialogTitleSuccess))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func indicateFailure() {
|
private func indicateFailure() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.dialogTitleError))
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.dialogTitleError))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Processes an error to either update the flow or display it to the user.
|
/// Processes an error to either update the flow or display it to the user.
|
||||||
@@ -200,7 +200,7 @@ final class LoginCoordinator: CoordinatorProtocol {
|
|||||||
/// Presents the server selection screen as a modal.
|
/// Presents the server selection screen as a modal.
|
||||||
private func presentServerSelectionScreen() {
|
private func presentServerSelectionScreen() {
|
||||||
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
|
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
|
||||||
userNotificationController: ServiceLocator.shared.userNotificationController,
|
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||||
isModallyPresented: false)
|
isModallyPresented: false)
|
||||||
|
|
||||||
let coordinator = ServerSelectionCoordinator(parameters: parameters)
|
let coordinator = ServerSelectionCoordinator(parameters: parameters)
|
||||||
|
|||||||
+7
-7
@@ -19,7 +19,7 @@ import SwiftUI
|
|||||||
struct ServerSelectionCoordinatorParameters {
|
struct ServerSelectionCoordinatorParameters {
|
||||||
/// The service used to authenticate the user.
|
/// The service used to authenticate the user.
|
||||||
let authenticationService: AuthenticationServiceProxyProtocol
|
let authenticationService: AuthenticationServiceProxyProtocol
|
||||||
let userNotificationController: UserNotificationControllerProtocol
|
let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
/// Whether the screen is presented modally or within a navigation stack.
|
/// Whether the screen is presented modally or within a navigation stack.
|
||||||
let isModallyPresented: Bool
|
let isModallyPresented: Bool
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ enum ServerSelectionCoordinatorAction {
|
|||||||
|
|
||||||
final class ServerSelectionCoordinator: CoordinatorProtocol {
|
final class ServerSelectionCoordinator: CoordinatorProtocol {
|
||||||
private let parameters: ServerSelectionCoordinatorParameters
|
private let parameters: ServerSelectionCoordinatorParameters
|
||||||
private let userNotificationController: UserNotificationControllerProtocol
|
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
private var viewModel: ServerSelectionViewModelProtocol
|
private var viewModel: ServerSelectionViewModelProtocol
|
||||||
private var authenticationService: AuthenticationServiceProxyProtocol { parameters.authenticationService }
|
private var authenticationService: AuthenticationServiceProxyProtocol { parameters.authenticationService }
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ final class ServerSelectionCoordinator: CoordinatorProtocol {
|
|||||||
self.parameters = parameters
|
self.parameters = parameters
|
||||||
viewModel = ServerSelectionViewModel(homeserverAddress: parameters.authenticationService.homeserver.address,
|
viewModel = ServerSelectionViewModel(homeserverAddress: parameters.authenticationService.homeserver.address,
|
||||||
isModallyPresented: parameters.isModallyPresented)
|
isModallyPresented: parameters.isModallyPresented)
|
||||||
userNotificationController = parameters.userNotificationController
|
userIndicatorController = parameters.userIndicatorController
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Public
|
// MARK: - Public
|
||||||
@@ -70,13 +70,13 @@ final class ServerSelectionCoordinator: CoordinatorProtocol {
|
|||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func startLoading(label: String = ElementL10n.loading) {
|
private func startLoading(label: String = ElementL10n.loading) {
|
||||||
userNotificationController.submitNotification(UserNotification(type: .modal,
|
userIndicatorController.submitIndicator(UserIndicator(type: .modal,
|
||||||
title: label,
|
title: label,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopLoading() {
|
private func stopLoading() {
|
||||||
userNotificationController.retractAllNotifications()
|
userIndicatorController.retractAllIndicators()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the login flow using the supplied homeserver address, or shows an error when this isn't possible.
|
/// Updates the login flow using the supplied homeserver address, or shows an error when this isn't possible.
|
||||||
|
|||||||
@@ -99,15 +99,15 @@ final class SoftLogoutCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
/// Show an activity indicator whilst loading.
|
/// Show an activity indicator whilst loading.
|
||||||
@MainActor private func startLoading() {
|
@MainActor private func startLoading() {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
type: .modal,
|
type: .modal,
|
||||||
title: ElementL10n.loading,
|
title: ElementL10n.loading,
|
||||||
persistent: true))
|
persistent: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hide the currently displayed activity indicator.
|
/// Hide the currently displayed activity indicator.
|
||||||
@MainActor private func stopLoading() {
|
@MainActor private func stopLoading() {
|
||||||
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows the forgot password screen.
|
/// Shows the forgot password screen.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ enum BugReportCoordinatorResult {
|
|||||||
|
|
||||||
struct BugReportCoordinatorParameters {
|
struct BugReportCoordinatorParameters {
|
||||||
let bugReportService: BugReportServiceProtocol
|
let bugReportService: BugReportServiceProtocol
|
||||||
weak var userNotificationController: UserNotificationControllerProtocol?
|
weak var userIndicatorController: UserIndicatorControllerProtocol?
|
||||||
let screenshot: UIImage?
|
let screenshot: UIImage?
|
||||||
let isModallyPresented: Bool
|
let isModallyPresented: Bool
|
||||||
}
|
}
|
||||||
@@ -76,20 +76,20 @@ final class BugReportCoordinator: CoordinatorProtocol {
|
|||||||
static let loadingIndicatorIdentifier = "BugReportLoading"
|
static let loadingIndicatorIdentifier = "BugReportLoading"
|
||||||
|
|
||||||
private func startLoading(label: String = ElementL10n.loading, progressPublisher: ProgressPublisher) {
|
private func startLoading(label: String = ElementL10n.loading, progressPublisher: ProgressPublisher) {
|
||||||
parameters.userNotificationController?.submitNotification(
|
parameters.userIndicatorController?.submitIndicator(
|
||||||
UserNotification(id: Self.loadingIndicatorIdentifier,
|
UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
type: .modal,
|
type: .modal,
|
||||||
title: label,
|
title: label,
|
||||||
persistent: true,
|
persistent: true,
|
||||||
progressPublisher: progressPublisher)
|
progressPublisher: progressPublisher)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopLoading() {
|
private func stopLoading() {
|
||||||
parameters.userNotificationController?.retractNotificationWithId(Self.loadingIndicatorIdentifier)
|
parameters.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showError(label: String) {
|
private func showError(label: String) {
|
||||||
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
|
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ class RoomDetailsViewModel: RoomDetailsViewModelType, RoomDetailsViewModelProtoc
|
|||||||
private func copyRoomLink() {
|
private func copyRoomLink() {
|
||||||
if let roomLink = state.permalink {
|
if let roomLink = state.permalink {
|
||||||
UIPasteboard.general.url = roomLink
|
UIPasteboard.general.url = roomLink
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.linkCopiedToClipboard))
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.linkCopiedToClipboard))
|
||||||
} else {
|
} else {
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.unknownError))
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.unknownError))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
title: ElementL10n.dialogTitleError,
|
title: ElementL10n.dialogTitleError,
|
||||||
message: message)
|
message: message)
|
||||||
case .toast(let message):
|
case .toast(let message):
|
||||||
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Constants.toastErrorID,
|
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Constants.toastErrorID,
|
||||||
type: .toast,
|
type: .toast,
|
||||||
title: message,
|
title: message,
|
||||||
iconName: "xmark"))
|
iconName: "xmark"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import SwiftUI
|
|||||||
|
|
||||||
struct SettingsScreenCoordinatorParameters {
|
struct SettingsScreenCoordinatorParameters {
|
||||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||||
weak var userNotificationController: UserNotificationControllerProtocol?
|
weak var userIndicatorController: UserIndicatorControllerProtocol?
|
||||||
let userSession: UserSessionProtocol
|
let userSession: UserSessionProtocol
|
||||||
let bugReportService: BugReportServiceProtocol
|
let bugReportService: BugReportServiceProtocol
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
private func presentBugReportScreen() {
|
private func presentBugReportScreen() {
|
||||||
let params = BugReportCoordinatorParameters(bugReportService: parameters.bugReportService,
|
let params = BugReportCoordinatorParameters(bugReportService: parameters.bugReportService,
|
||||||
userNotificationController: parameters.userNotificationController,
|
userIndicatorController: parameters.userIndicatorController,
|
||||||
screenshot: nil,
|
screenshot: nil,
|
||||||
isModallyPresented: false)
|
isModallyPresented: false)
|
||||||
let coordinator = BugReportCoordinator(parameters: params)
|
let coordinator = BugReportCoordinator(parameters: params)
|
||||||
@@ -112,6 +112,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func showSuccess(label: String) {
|
private func showSuccess(label: String) {
|
||||||
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
|
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,10 +188,10 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
private func presentSettingsScreen() {
|
private func presentSettingsScreen() {
|
||||||
let settingsNavigationStackCoordinator = NavigationStackCoordinator()
|
let settingsNavigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let userNotificationController = UserNotificationController(rootCoordinator: settingsNavigationStackCoordinator)
|
let userIndicatorController = UserIndicatorController(rootCoordinator: settingsNavigationStackCoordinator)
|
||||||
|
|
||||||
let parameters = SettingsScreenCoordinatorParameters(navigationStackCoordinator: settingsNavigationStackCoordinator,
|
let parameters = SettingsScreenCoordinatorParameters(navigationStackCoordinator: settingsNavigationStackCoordinator,
|
||||||
userNotificationController: userNotificationController,
|
userIndicatorController: userIndicatorController,
|
||||||
userSession: userSession,
|
userSession: userSession,
|
||||||
bugReportService: bugReportService)
|
bugReportService: bugReportService)
|
||||||
let settingsScreenCoordinator = SettingsScreenCoordinator(parameters: parameters)
|
let settingsScreenCoordinator = SettingsScreenCoordinator(parameters: parameters)
|
||||||
@@ -208,7 +208,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
settingsNavigationStackCoordinator.setRootCoordinator(settingsScreenCoordinator)
|
settingsNavigationStackCoordinator.setRootCoordinator(settingsScreenCoordinator)
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(userNotificationController) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedSettingsScreen)
|
self?.stateMachine.processEvent(.dismissedSettingsScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,10 +238,10 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
private func presentFeedbackScreen(for image: UIImage? = nil) {
|
private func presentFeedbackScreen(for image: UIImage? = nil) {
|
||||||
let feedbackNavigationStackCoordinator = NavigationStackCoordinator()
|
let feedbackNavigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let userNotificationController = UserNotificationController(rootCoordinator: feedbackNavigationStackCoordinator)
|
let userIndicatorController = UserIndicatorController(rootCoordinator: feedbackNavigationStackCoordinator)
|
||||||
|
|
||||||
let parameters = BugReportCoordinatorParameters(bugReportService: bugReportService,
|
let parameters = BugReportCoordinatorParameters(bugReportService: bugReportService,
|
||||||
userNotificationController: userNotificationController,
|
userIndicatorController: userIndicatorController,
|
||||||
screenshot: image,
|
screenshot: image,
|
||||||
isModallyPresented: true)
|
isModallyPresented: true)
|
||||||
let coordinator = BugReportCoordinator(parameters: parameters)
|
let coordinator = BugReportCoordinator(parameters: parameters)
|
||||||
@@ -251,7 +251,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
feedbackNavigationStackCoordinator.setRootCoordinator(coordinator)
|
feedbackNavigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(userNotificationController) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedFeedbackScreen)
|
self?.stateMachine.processEvent(.dismissedFeedbackScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class UITestsAppCoordinator: AppCoordinatorProtocol {
|
|||||||
navigationRootCoordinator = NavigationRootCoordinator()
|
navigationRootCoordinator = NavigationRootCoordinator()
|
||||||
mockScreens = UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRootCoordinator: navigationRootCoordinator) }
|
mockScreens = UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRootCoordinator: navigationRootCoordinator) }
|
||||||
|
|
||||||
ServiceLocator.shared.register(userNotificationController: MockUserNotificationController())
|
ServiceLocator.shared.register(userIndicatorController: MockUserIndicatorController())
|
||||||
|
|
||||||
AppSettings.configureWithSuiteName("io.element.elementx.uitests")
|
AppSettings.configureWithSuiteName("io.element.elementx.uitests")
|
||||||
AppSettings.reset()
|
AppSettings.reset()
|
||||||
@@ -76,13 +76,13 @@ class MockScreen: Identifiable {
|
|||||||
case .serverSelection:
|
case .serverSelection:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let coordinator = ServerSelectionCoordinator(parameters: .init(authenticationService: MockAuthenticationServiceProxy(),
|
let coordinator = ServerSelectionCoordinator(parameters: .init(authenticationService: MockAuthenticationServiceProxy(),
|
||||||
userNotificationController: MockUserNotificationController(),
|
userIndicatorController: MockUserIndicatorController(),
|
||||||
isModallyPresented: true))
|
isModallyPresented: true))
|
||||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .serverSelectionNonModal:
|
case .serverSelectionNonModal:
|
||||||
return ServerSelectionCoordinator(parameters: .init(authenticationService: MockAuthenticationServiceProxy(),
|
return ServerSelectionCoordinator(parameters: .init(authenticationService: MockAuthenticationServiceProxy(),
|
||||||
userNotificationController: MockUserNotificationController(),
|
userIndicatorController: MockUserIndicatorController(),
|
||||||
isModallyPresented: false))
|
isModallyPresented: false))
|
||||||
case .analyticsPrompt:
|
case .analyticsPrompt:
|
||||||
return AnalyticsPromptCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@mock:client.com"),
|
return AnalyticsPromptCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@mock:client.com"),
|
||||||
@@ -119,7 +119,7 @@ class MockScreen: Identifiable {
|
|||||||
case .settings:
|
case .settings:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let coordinator = SettingsScreenCoordinator(parameters: .init(navigationStackCoordinator: navigationStackCoordinator,
|
let coordinator = SettingsScreenCoordinator(parameters: .init(navigationStackCoordinator: navigationStackCoordinator,
|
||||||
userNotificationController: nil,
|
userIndicatorController: nil,
|
||||||
userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@mock:client.com"),
|
userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@mock:client.com"),
|
||||||
mediaProvider: MockMediaProvider()),
|
mediaProvider: MockMediaProvider()),
|
||||||
bugReportService: MockBugReportService()))
|
bugReportService: MockBugReportService()))
|
||||||
@@ -128,7 +128,7 @@ class MockScreen: Identifiable {
|
|||||||
case .bugReport:
|
case .bugReport:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let coordinator = BugReportCoordinator(parameters: .init(bugReportService: MockBugReportService(),
|
let coordinator = BugReportCoordinator(parameters: .init(bugReportService: MockBugReportService(),
|
||||||
userNotificationController: nil,
|
userIndicatorController: nil,
|
||||||
screenshot: nil,
|
screenshot: nil,
|
||||||
isModallyPresented: true))
|
isModallyPresented: true))
|
||||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
@@ -136,7 +136,7 @@ class MockScreen: Identifiable {
|
|||||||
case .bugReportWithScreenshot:
|
case .bugReportWithScreenshot:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let coordinator = BugReportCoordinator(parameters: .init(bugReportService: MockBugReportService(),
|
let coordinator = BugReportCoordinator(parameters: .init(bugReportService: MockBugReportService(),
|
||||||
userNotificationController: nil,
|
userIndicatorController: nil,
|
||||||
screenshot: Asset.Images.appLogo.image,
|
screenshot: Asset.Images.appLogo.image,
|
||||||
isModallyPresented: false))
|
isModallyPresented: false))
|
||||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ import XCTest
|
|||||||
@testable import ElementX
|
@testable import ElementX
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class UserNotificationControllerTests: XCTestCase {
|
class UserIndicatorControllerTests: XCTestCase {
|
||||||
private var notificationController: UserNotificationController!
|
private var notificationController: UserIndicatorController!
|
||||||
|
|
||||||
override func setUp() {
|
override func setUp() {
|
||||||
notificationController = UserNotificationController(rootCoordinator: SplashScreenCoordinator())
|
notificationController = UserIndicatorController(rootCoordinator: SplashScreenCoordinator())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNotificationQueueing() {
|
func testNotificationQueueing() {
|
||||||
notificationController.minimumDisplayDuration = 0.0
|
notificationController.minimumDisplayDuration = 0.0
|
||||||
|
|
||||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
notificationController.submitIndicator(.init(id: "First", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
notificationController.submitIndicator(.init(id: "Second", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
notificationController.submitIndicator(.init(id: "Third", title: ""))
|
||||||
|
|
||||||
XCTAssertEqual(notificationController.notificationQueue.count, 3)
|
XCTAssertEqual(notificationController.notificationQueue.count, 3)
|
||||||
XCTAssertEqual(notificationController.notificationQueue[2].id, "Third")
|
XCTAssertEqual(notificationController.notificationQueue[2].id, "Third")
|
||||||
@@ -55,9 +55,9 @@ class UserNotificationControllerTests: XCTestCase {
|
|||||||
notificationController.minimumDisplayDuration = 0.25
|
notificationController.minimumDisplayDuration = 0.25
|
||||||
notificationController.nonPersistentDisplayDuration = 2.5
|
notificationController.nonPersistentDisplayDuration = 2.5
|
||||||
|
|
||||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
notificationController.submitIndicator(.init(id: "First", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
notificationController.submitIndicator(.init(id: "Second", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
notificationController.submitIndicator(.init(id: "Third", title: ""))
|
||||||
|
|
||||||
XCTAssertEqual(notificationController.activeNotification?.id, "Third")
|
XCTAssertEqual(notificationController.activeNotification?.id, "Third")
|
||||||
|
|
||||||
@@ -76,9 +76,9 @@ class UserNotificationControllerTests: XCTestCase {
|
|||||||
notificationController.minimumDisplayDuration = 0.25
|
notificationController.minimumDisplayDuration = 0.25
|
||||||
notificationController.nonPersistentDisplayDuration = 2.5
|
notificationController.nonPersistentDisplayDuration = 2.5
|
||||||
|
|
||||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
notificationController.submitIndicator(.init(id: "First", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
notificationController.submitIndicator(.init(id: "Second", title: ""))
|
||||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
notificationController.submitIndicator(.init(id: "Third", title: ""))
|
||||||
|
|
||||||
notificationController.retractNotificationWithId("Second")
|
notificationController.retractNotificationWithId("Second")
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Refactored UserNotification into UserIndicator.
|
||||||
Reference in New Issue
Block a user