Skip to content

Commit dcb7b32

Browse files
committed
Add new list action button views
1 parent dda69c2 commit dcb7b32

5 files changed

Lines changed: 83 additions & 74 deletions

File tree

RELEASE_NOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ These release notes cover the current major version. See older versions for olde
1111

1212

1313

14+
## 6.2
15+
16+
This version adds a `ListActionButton` and `ListActionButtonGroup`.
17+
18+
The old `ListButtonGroup` view has been deprecated.
19+
20+
21+
1422
## 6.1.1
1523

1624
This version renames the `onMultilineSubmit` view extension.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// ListActionButton.swift
3+
// Vinylsamlaren
4+
//
5+
// Created by Daniel Saidi on 2026-05-26.
6+
//
7+
8+
import SwiftUI
9+
10+
/// This view can be used in a ``ListActionButtonGroup``.
11+
@available(iOS 26.0, *)
12+
public struct ListActionButton: View {
13+
14+
public init(
15+
title: LocalizedStringResource,
16+
icon: Image,
17+
action: @escaping () -> Void
18+
) {
19+
self.title = title
20+
self.icon = icon
21+
self.action = action
22+
}
23+
24+
let title: LocalizedStringResource
25+
let icon: Image
26+
let action: () -> Void
27+
28+
public var body: some View {
29+
Button(action: action) {
30+
VStack(spacing: 6) {
31+
icon
32+
Text(title)
33+
.font(.caption)
34+
.fontWeight(.medium)
35+
}
36+
.frame(maxWidth: .infinity)
37+
}
38+
}
39+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// ListActionButtonGroup.swift
3+
// Vinylsamlaren
4+
//
5+
// Created by Daniel Saidi on 2026-05-26.
6+
//
7+
8+
import SwiftUI
9+
10+
/// This view renders a horizontal list action buttons list.
11+
@available(iOS 26.0, *)
12+
public struct ListActionButtonGroup<Content: View>: View {
13+
14+
public init(
15+
@ViewBuilder content: @escaping () -> Content
16+
) {
17+
self.content = content
18+
}
19+
20+
private let content: () -> Content
21+
22+
public var body: some View {
23+
HStack(spacing: 10) {
24+
Group {
25+
content()
26+
}
27+
.tint(.accentColor)
28+
.buttonStyle(.bordered)
29+
.buttonBorderShape(.roundedRectangle)
30+
}
31+
.listRowBackground(Color.clear)
32+
.listRowInsets(.init(top: 16, leading: 0, bottom: 16, trailing: 0))
33+
}
34+
}

Sources/SwiftUIKit/Lists/ListButtonGroup.swift

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
#if os(iOS)
1010
import SwiftUI
1111

12-
/// This group applies zero insets and a clear background to render buttons in the
13-
/// content as a horizontal group.
14-
///
15-
/// You can style the view with `.listButtonGroupStyle(...)`.
12+
@available(*, deprecated, renamed: "ListActionButtonGroup")
1613
public struct ListButtonGroup<Content: View>: View {
1714

1815
/// Create a form button group section.
@@ -39,72 +36,4 @@ public struct ListButtonGroup<Content: View>: View {
3936
.listRowBackground(Color.clear)
4037
}
4138
}
42-
43-
#Preview {
44-
45-
struct PreviewList: View {
46-
47-
var body: some View {
48-
List {
49-
"Add something".previewButton(.add)
50-
51-
ListButtonGroup {
52-
HStack {
53-
"Bug".previewButton(.bug)
54-
"Camera".previewButton(.camera).disabled(true)
55-
"Photos".previewButton(.camera).opacity(0.5)
56-
"Feedback".previewButton(.feedback)
57-
}
58-
}
59-
60-
Section {
61-
Text("Preview.Row")
62-
}
63-
}
64-
}
65-
}
66-
67-
return VStack(spacing: 0) {
68-
PreviewList()
69-
Divider()
70-
PreviewList()
71-
.listButtonGroupStyle(.swedish)
72-
Divider()
73-
PreviewList()
74-
.environment(\.colorScheme, .dark)
75-
}
76-
.frame(maxHeight: .infinity)
77-
.background(Color.black.opacity(0.08).ignoresSafeArea())
78-
}
79-
80-
private extension ButtonStyle where Self == ListButtonGroupStyle {
81-
82-
static var swedish: Self {
83-
.init(
84-
backgroundColor: .blue,
85-
labelStyle: .init(color: .yellow)
86-
)
87-
}
88-
}
89-
90-
@MainActor
91-
private extension String {
92-
93-
func previewButton(_ icon: Image) -> some View {
94-
Button {} label: { Label(LocalizedStringKey(self), icon) }
95-
}
96-
}
97-
98-
private extension Image {
99-
100-
static let add = systemImage("plus")
101-
static let bug = systemImage("ladybug")
102-
static let camera = systemImage("camera")
103-
static let feedback = systemImage("envelope")
104-
static let photoLibrary = systemImage("photo.on.rectangle.angled")
105-
106-
static func systemImage(_ name: String) -> Image {
107-
Image(systemName: name)
108-
}
109-
}
11039
#endif

Sources/SwiftUIKit/Lists/ListButtonGroupStyle.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#if os(iOS)
1010
import SwiftUI
1111

12-
/// This button style can generate inline button groups that mimics the look of the
13-
/// topmost iOS Contact button group.
12+
@available(*, deprecated, renamed: "ListActionButtonGroup")
1413
public struct ListButtonGroupStyle: ButtonStyle {
1514

1615
/// Create a custom form group button style.

0 commit comments

Comments
 (0)