Run SwiftFormat and fix SwiftLint.

This commit is contained in:
Doug
2025-09-28 15:25:05 +01:00
committed by Doug
parent ed73853c9b
commit 90eeabf9de
15 changed files with 54 additions and 46 deletions
@@ -18,13 +18,13 @@ struct ListInlinePicker<SelectedValue: Hashable>: View {
ListRow(label: .plain(title: item.title),
details: isWaiting ? .isWaiting(selection == item.tag) : nil,
kind: .selection(isSelected: !isWaiting ? selection == item.tag : false) {
var transaction = Transaction()
transaction.disablesAnimations = true
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
selection = item.tag
}
})
withTransaction(transaction) {
selection = item.tag
}
})
}
}
}
@@ -184,14 +184,14 @@ public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyV
// Custom row without a label or details label.
public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView {
init(kind: Kind<CustomContent, SelectionValue>) {
self.label = ListRowLabel()
self.details = nil
label = ListRowLabel()
details = nil
self.kind = kind
}
init(kind: Kind<CustomContent, SelectionValue>) where SelectionValue == String {
self.label = ListRowLabel()
self.details = nil
label = ListRowLabel()
details = nil
self.kind = kind
}
}
@@ -249,6 +249,7 @@ private extension Button {
// MARK: - Previews
// swiftlint:disable print_deprecation
public struct ListRow_Previews: PreviewProvider, TestablePreview {
public static var previews: some View {
Form {
@@ -348,14 +349,14 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
systemIcon: .squareDashed),
details: .title("Content"),
kind: .selection(isSelected: true) {
print("I was tapped!")
})
print("I was tapped!")
})
ListRow(label: .default(title: "Title",
systemIcon: .squareDashed),
details: .title("Content"),
kind: .selection(isSelected: true) {
print("I was tapped!")
})
print("I was tapped!")
})
ListRow(label: .plain(title: "Title"),
kind: .inlinePicker(selection: .constant("Item 1"),
@@ -375,7 +376,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
ListRow(label: .action(title: "Title",
systemIcon: .squareDashed),
kind: .button { print("I was tapped!") })
.disabled(true)
.disabled(true)
}
static var plainButton: some View {
@@ -401,7 +402,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
ListRow(label: .centeredAction(title: "Title",
systemIcon: .squareDashed),
kind: .button { print("I was tapped!") })
.disabled(true)
.disabled(true)
}
}
@@ -445,10 +446,10 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview {
})
ListRow(label: .plain(title: "Placeholder"),
kind: .textField(text: .constant("This is a disabled text field")))
.disabled(true)
.disabled(true)
ListRow(label: .plain(title: "Placeholder"),
kind: .textField(text: .constant(""), axis: .vertical))
.lineLimit(4...)
.lineLimit(4...)
ListRow(label: .plain(title: "Password"),
kind: .secureField(text: .constant("p4ssw0rd")))
}
@@ -474,3 +475,5 @@ struct ListRowLoadingSelection_Previews: PreviewProvider, TestablePreview {
.compoundList()
}
}
// swiftlint:enable print_deprecation
@@ -26,17 +26,17 @@ public struct ListRowAccessory: View {
/// A chevron to indicate that the button pushes another screen.
public static var navigationLink: Self {
Self.init(kind: .navigationLink)
Self(kind: .navigationLink)
}
/// A checkmark (or reserved space) to indicate that the row is selected.
public static func selection(_ isSelected: Bool) -> Self {
Self.init(kind: isSelected ? .selected : .unselected)
Self(kind: isSelected ? .selected : .unselected)
}
/// A circular checkmark (or empty circle) to indicate that the row is one of multiple selected.
public static func multiSelection(_ isSelected: Bool) -> Self {
Self.init(kind: isSelected ? .multiSelected : .multiUnselected)
Self(kind: isSelected ? .multiSelected : .multiUnselected)
}
let kind: Kind
@@ -61,7 +61,7 @@ public struct ListRowDetails<Icon: View> {
public static func icon(_ icon: KeyPath<CompoundIcons, Image>,
counter: Int? = nil,
isWaiting: Bool = false) -> Self where Icon == CompoundIcon {
ListRowDetails(icon:CompoundIcon(icon),
ListRowDetails(icon: CompoundIcon(icon),
counter: counter,
isWaiting: isWaiting)
}
@@ -68,7 +68,7 @@ public struct ListRowLabel<Icon: View>: View {
}
var iconAlignment: VerticalAlignment = .center
var hideIconBackground: Bool = false
var hideIconBackground = false
enum Layout { case `default`, centered, avatar }
var layout: Layout = .default
@@ -77,6 +77,7 @@ public struct ListRowLabel<Icon: View>: View {
guard isEnabled else { return .compound.textDisabled }
return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary
}
var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit }
var statusColor: Color {
@@ -86,6 +87,7 @@ public struct ListRowLabel<Icon: View>: View {
var descriptionColor: Color {
isEnabled ? .compound.textSecondary : .compound.textDisabled
}
var descriptionLineLimit: Int? {
guard layout == .avatar else { return lineLimit }
return role != .error ? 1 : lineLimit