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 e7ff429ee3
commit 409fbe1ea4
22 changed files with 37 additions and 54 deletions

View File

@@ -33,6 +33,7 @@ struct UserIndicator: Equatable, Identifiable {
var id: String = UUID().uuidString
var type: UserIndicatorType = .toast
var title: String
var message: String?
var iconName: String?
var persistent = false

View File

@@ -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")
)
}
}
}

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d681ba65fbd9d56483b2fd90f87de7a5234cbb5510c22be154093354aabbb8c7
size 90434

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d681ba65fbd9d56483b2fd90f87de7a5234cbb5510c22be154093354aabbb8c7
size 90434

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71c1e2e09b6212572ca3f443f9bb4ebeb2e4cf2182d818702fd11cb1587db9a0
size 42593

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71c1e2e09b6212572ca3f443f9bb4ebeb2e4cf2182d818702fd11cb1587db9a0
size 42593

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:46ae1f8079fb0d6fecf0f06c47f61c2f37d014f0d615aab79fd7c75639c5415f
size 91303

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:46ae1f8079fb0d6fecf0f06c47f61c2f37d014f0d615aab79fd7c75639c5415f
size 91303

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:57244d7c4e1affdbd4c25aeca1df48d547cb640a95a0262d45fa1384d6cdc260
size 42509

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:57244d7c4e1affdbd4c25aeca1df48d547cb640a95a0262d45fa1384d6cdc260
size 42509

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f6a2f85477fa536362b84331e745b5c84853f45cd3d21b74d4cba470aebc75b3
size 92654

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f6a2f85477fa536362b84331e745b5c84853f45cd3d21b74d4cba470aebc75b3
size 92654

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9d526453ba493b0723873363408a530c42ae1511dcb9af505f3aaf5a9c1d9953
size 43297

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9d526453ba493b0723873363408a530c42ae1511dcb9af505f3aaf5a9c1d9953
size 43297