Add indicator after leaving a room (#981)

* Refactor UserIndicatorModalView to support no progress

* Add room left indicator in HomeScreenViewModel

* Apply PR suggestion
This commit is contained in:
Alfonso Grillo
2023-05-30 12:32:07 +02:00
committed by GitHub
parent 7c4d0631df
commit 5df4e32fef
4 changed files with 34 additions and 7 deletions

View File

@@ -24,10 +24,10 @@ struct UserIndicatorModalView: View {
var body: some View {
ZStack {
VStack(spacing: 12.0) {
if let progressFraction {
ProgressView(value: progressFraction)
} else {
if case .unknownProgress = indicator.loaderType {
ProgressView()
} else if case .progress = indicator.loaderType {
ProgressView(value: progressFraction)
}
HStack {
@@ -45,7 +45,7 @@ struct UserIndicatorModalView: View {
.background(Color.element.quinaryContent)
.clipShape(RoundedCornerShape(radius: 12.0, corners: .allCorners))
.shadow(color: .black.opacity(0.1), radius: 10.0, y: 4.0)
.onReceive(indicator.progressPublisher?.publisher ?? Empty().eraseToAnyPublisher()) { progress in
.onReceive(indicator.progressPublisher) { progress in
progressFraction = progress
}
.transition(.opacity)
@@ -68,9 +68,16 @@ struct UserIndicatorModalView_Previews: PreviewProvider {
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
title: "Successfully logged in",
iconName: "checkmark",
progressPublisher: ProgressTracker(initialValue: 0.5))
loaderType: .progress(ProgressTracker(initialValue: 0.5)))
)
.previewDisplayName("Progress Bar")
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
title: "Successfully logged in",
iconName: "checkmark",
loaderType: .none)
)
.previewDisplayName("No progress")
}
}
}