Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plain can now include a description #45

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions Sources/Compound/List/ListLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ public struct ListLabel<Icon: View>: View {
}

public static func plain(title: String,
role: ButtonRole? = nil) -> ListLabel where Icon == EmptyView {
ListLabel(title: title, role: role, hideIconBackground: true)
description: String? = nil,
role: ButtonRole? = nil) -> ListLabel where Icon == EmptyView {
ListLabel(title: title, description: description, role: role, hideIconBackground: true)
}

public static func description(_ description: String) -> ListLabel where Icon == EmptyView {
Expand All @@ -205,32 +206,39 @@ struct ListLabel_Previews: PreviewProvider, PrefireProvider {
static var previews: some View {
Form {
Section {
ListLabel.default(title: "Person", icon: Image(systemName: "person"))

ListLabel.default(title: "Help",
description: "Supporting text",
systemIcon: .questionmarkCircle)

ListLabel.default(title: "Trash",
icon: Image(systemName: "trash"),
role: .destructive)

ListLabel.action(title: "Camera",
icon: Image(systemName: "camera"))

ListLabel.action(title: "Remove",
icon: Image(systemName: "person.badge.minus"),
role: .destructive)
Group {
ListLabel.default(title: "Person", icon: Image(systemName: "person"))

ListLabel.default(title: "Help",
description: "Supporting text",
systemIcon: .questionmarkCircle)

ListLabel.default(title: "Trash",
icon: Image(systemName: "trash"),
role: .destructive)
}

ListLabel.centeredAction(title: "Person",
icon: Image(systemName: "person"))
ListLabel.centeredAction(title: "Remove",
systemIcon: .personBadgeMinus,
role: .destructive)
Group {
ListLabel.action(title: "Camera",
icon: Image(systemName: "camera"))

ListLabel.action(title: "Remove",
icon: Image(systemName: "person.badge.minus"),
role: .destructive)

ListLabel.centeredAction(title: "Person",
icon: Image(systemName: "person"))
ListLabel.centeredAction(title: "Remove",
systemIcon: .personBadgeMinus,
role: .destructive)
}

ListLabel.plain(title: "Person")
ListLabel.plain(title: "Remove",
role: .destructive)
Group {
ListLabel.plain(title: "Person")
ListLabel.plain(title: "Remove",
role: .destructive)
ListLabel.plain(title: "Plain", description: "Description")
}

ListLabel.description("This is a row in the list, that only contains a description and doesn't have either an icon or a title.")
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/CompoundTests/__Snapshots__
Velin92 marked this conversation as resolved.
Show resolved Hide resolved