Add a message property to user indicator's and have it be rendered properly on modal indicator.s

This commit is contained in:
Stefan Ceriu
2025-09-12 15:10:56 +03:00
committed by Stefan Ceriu
parent d4506ef79c
commit 72b99d89dd
22 changed files with 37 additions and 54 deletions
@@ -24,11 +24,18 @@ struct UserIndicatorModalView: View {
HStack(spacing: 8) {
if let iconName = indicator.iconName {
Image(systemName: iconName)
.font(.compound.bodyLG)
.font(titleFont)
.foregroundColor(.compound.iconPrimary)
}
Text(indicator.title)
.font(.compound.bodyLG)
.font(titleFont)
.foregroundColor(.compound.textPrimary)
}
if let message = indicator.message {
Text(message)
.font(.compound.bodyMD)
.foregroundColor(.compound.textPrimary)
}
}
@@ -53,16 +60,23 @@ struct UserIndicatorModalView: View {
.ignoresSafeArea()
.interactiveDismissDisabled(indicator.interactiveDismissDisabled)
}
private var titleFont: Font {
if indicator.message != nil {
.compound.headingMDBold
} else {
.compound.bodyLG
}
}
}
struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
Group {
VStack(spacing: 0) {
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
title: "Successfully logged in",
iconName: "checkmark")
)
.previewDisplayName("Spinner")
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .published(CurrentValueSubject<Double, Never>(0.5).asCurrentValuePublisher()),
interactiveDismissDisabled: false,
@@ -70,7 +84,6 @@ struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
title: "Successfully logged in",
iconName: "checkmark")
)
.previewDisplayName("Progress Bar")
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none,
interactiveDismissDisabled: false,
@@ -78,7 +91,12 @@ struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
title: "Successfully logged in",
iconName: "checkmark")
)
.previewDisplayName("No progress")
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
title: "Successfully logged in",
message: "You can now be happy.",
iconName: "checkmark")
)
}
}
}