mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fixes #954 - Implement media upload cancelling
This commit is contained in:
committed by
Stefan Ceriu
parent
d9e608a1e0
commit
ce7ca32efc
@@ -19,10 +19,10 @@ import Foundation
|
||||
|
||||
enum UserIndicatorType: Equatable {
|
||||
case toast(progress: UserIndicator.Progress?)
|
||||
case modal(progress: UserIndicator.Progress?, interactiveDismissDisabled: Bool)
|
||||
case modal(progress: UserIndicator.Progress?, interactiveDismissDisabled: Bool, allowsInteraction: Bool)
|
||||
|
||||
static var toast: Self { .toast(progress: .none) }
|
||||
static var modal: Self { .modal(progress: .indeterminate, interactiveDismissDisabled: false) }
|
||||
static var modal: Self { .modal(progress: .indeterminate, interactiveDismissDisabled: false, allowsInteraction: false) }
|
||||
}
|
||||
|
||||
struct UserIndicator: Equatable, Identifiable {
|
||||
@@ -50,13 +50,13 @@ struct UserIndicator: Equatable, Identifiable {
|
||||
var progress: Progress? {
|
||||
switch type {
|
||||
case .toast(let progress): return progress
|
||||
case .modal(let progress, _): return progress
|
||||
case .modal(let progress, _, _): return progress
|
||||
}
|
||||
}
|
||||
|
||||
var progressPublisher: CurrentValuePublisher<Double, Never> {
|
||||
switch type {
|
||||
case .toast(let progress), .modal(let progress, _):
|
||||
case .toast(let progress), .modal(let progress, _, _):
|
||||
switch progress {
|
||||
case .none, .indeterminate:
|
||||
return CurrentValueSubject<Double, Never>(0.0).asCurrentValuePublisher()
|
||||
@@ -70,8 +70,17 @@ struct UserIndicator: Equatable, Identifiable {
|
||||
switch type {
|
||||
case .toast:
|
||||
return false
|
||||
case .modal(_, let interactiveDismissDisabled):
|
||||
case .modal(_, let interactiveDismissDisabled, _):
|
||||
return interactiveDismissDisabled
|
||||
}
|
||||
}
|
||||
|
||||
var allowsInteraction: Bool {
|
||||
switch type {
|
||||
case .toast:
|
||||
return true
|
||||
case .modal(_, _, let allowsInteraction):
|
||||
return allowsInteraction
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,11 @@ struct UserIndicatorModalView: View {
|
||||
}
|
||||
.id(indicator.id)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.black.opacity(0.1))
|
||||
.background {
|
||||
if !indicator.allowsInteraction {
|
||||
Color.black.opacity(0.1)
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.interactiveDismissDisabled(indicator.interactiveDismissDisabled)
|
||||
}
|
||||
@@ -70,13 +74,16 @@ struct UserIndicatorModalView_Previews: PreviewProvider {
|
||||
.previewDisplayName("Spinner")
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .published(CurrentValueSubject<Double, Never>(0.5).asCurrentValuePublisher()),
|
||||
interactiveDismissDisabled: false),
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
.previewDisplayName("Progress Bar")
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none, interactiveDismissDisabled: false),
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none,
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user