2022-11-16 15:37:34 +02:00
|
|
|
//
|
2024-09-06 16:34:30 +03:00
|
|
|
// Copyright 2022-2024 New Vector Ltd.
|
2022-11-16 15:37:34 +02:00
|
|
|
//
|
2025-01-06 11:27:37 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2022-11-16 15:37:34 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
2023-02-14 11:09:55 +01:00
|
|
|
struct UserIndicatorPresenter: View {
|
|
|
|
@ObservedObject var userIndicatorController: UserIndicatorController
|
2022-11-16 15:37:34 +02:00
|
|
|
|
|
|
|
var body: some View {
|
2023-11-09 15:10:50 +02:00
|
|
|
indicatorViewFor(indicator: userIndicatorController.activeIndicator)
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
|
|
|
.animation(.elementDefault, value: userIndicatorController.activeIndicator)
|
2022-11-16 15:37:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
2023-02-14 11:09:55 +01:00
|
|
|
private func indicatorViewFor(indicator: UserIndicator?) -> some View {
|
2022-11-16 15:37:34 +02:00
|
|
|
ZStack { // Need a container to properly animate transitions
|
2023-02-14 11:09:55 +01:00
|
|
|
if let indicator {
|
|
|
|
switch indicator.type {
|
2022-11-16 15:37:34 +02:00
|
|
|
case .toast:
|
2023-02-14 11:09:55 +01:00
|
|
|
UserIndicatorToastView(indicator: indicator)
|
2022-11-16 15:37:34 +02:00
|
|
|
case .modal:
|
2023-02-14 11:09:55 +01:00
|
|
|
UserIndicatorModalView(indicator: indicator)
|
2022-11-16 15:37:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-14 16:24:10 +02:00
|
|
|
.alert(item: $userIndicatorController.alertInfo)
|
2022-11-16 15:37:34 +02:00
|
|
|
}
|
|
|
|
}
|