mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Use Compound icons within the user indicators.
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Compound
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
enum UserIndicatorType: Equatable {
|
||||
case toast(progress: UserIndicator.Progress?)
|
||||
@@ -40,7 +42,7 @@ struct UserIndicator: Equatable, Identifiable {
|
||||
var type: UserIndicatorType = .toast
|
||||
var title: String
|
||||
var message: String?
|
||||
var iconName: String?
|
||||
var icon: KeyPath<CompoundIcons, Image>?
|
||||
var persistent = false
|
||||
|
||||
// MARK: - Associated values from the type
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserIndicatorModalView: View {
|
||||
@@ -23,9 +24,8 @@ struct UserIndicatorModalView: View {
|
||||
}
|
||||
|
||||
HStack(spacing: 8) {
|
||||
if let iconName = indicator.iconName {
|
||||
Image(systemName: iconName)
|
||||
.font(titleFont)
|
||||
if let icon = indicator.icon {
|
||||
CompoundIcon(icon, size: .medium, relativeTo: .compound.headingMDBold)
|
||||
.foregroundColor(.compound.iconPrimary)
|
||||
}
|
||||
|
||||
@@ -76,24 +76,24 @@ struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
|
||||
VStack(spacing: 0) {
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .published(CurrentValueSubject<Double, Never>(0.5).asCurrentValuePublisher()),
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none,
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
message: "You can now be happy.",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserIndicatorToastView: View {
|
||||
@@ -18,9 +19,8 @@ struct UserIndicatorToastView: View {
|
||||
.controlSize(.small)
|
||||
.tint(.compound.iconPrimary)
|
||||
}
|
||||
if let iconName = indicator.iconName {
|
||||
Image(systemName: iconName)
|
||||
.font(.compound.bodyMD)
|
||||
if let icon = indicator.icon {
|
||||
CompoundIcon(icon, size: .small, relativeTo: .compound.bodyMD)
|
||||
.foregroundColor(.compound.iconPrimary)
|
||||
}
|
||||
Text(indicator.title)
|
||||
@@ -48,7 +48,7 @@ struct UserIndicatorToastView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 30) {
|
||||
UserIndicatorToastView(indicator: UserIndicator(title: "Successfully logged in",
|
||||
iconName: "checkmark"))
|
||||
icon: \.check))
|
||||
|
||||
UserIndicatorToastView(indicator: UserIndicator(title: "Toast without icon"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user