Skip to content

Commit a60cd40

Browse files
committed
Adjust version validation script
1 parent 9d14d6b commit a60cd40

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

Sources/SwiftUIKit/Lists/ListAction.swift

+34-13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public enum ListAction {
2929

3030
public extension ListAction {
3131

32+
var accessibilityLabel: String {
33+
switch self {
34+
case .call(let url): "Call \(url)"
35+
case .copy(let text): "Copy \(text.prefix(10))"
36+
case .copyImage: "Copy Image"
37+
case .email(let addr): "Email \(addr)"
38+
case .openUrl(let url): "Open \(url)"
39+
}
40+
}
41+
3242
@ViewBuilder
3343
var button: some View {
3444
button {
@@ -41,16 +51,11 @@ public extension ListAction {
4151
@ViewBuilder content: @escaping () -> Content
4252
) -> some View {
4353
switch self {
44-
case .call(let url):
45-
link(url: .init(string: "tel:\(url)"), content: content)
46-
case .copy(let text):
47-
button(action: { copy(text) }, content: content)
48-
case .copyImage(let image):
49-
button(action: { copy(image) }, content: content)
50-
case .email(let url):
51-
link(url: .init(string: "mailto:\(url)"), content: content)
52-
case .openUrl(let url):
53-
link(url: .init(string: url), content: content)
54+
case .call(let url): link(for: calllUrl(for: url), content)
55+
case .copy(let text): button({ copy(text) }, content: content)
56+
case .copyImage(let img): button({ copy(img) }, content: content)
57+
case .email(let addr): link(for: emailUrl(for: addr), content)
58+
case .openUrl(let str): link(for: url(for: str), content)
5459
}
5560
}
5661

@@ -64,21 +69,37 @@ public extension ListAction {
6469
}
6570
}
6671

72+
private extension ListAction {
73+
74+
func emailUrl(for url: String) -> URL? {
75+
.init(string: "mailto:\(url)")
76+
}
77+
78+
func calllUrl(for url: String) -> URL? {
79+
.init(string: "tel:\(url)")
80+
}
81+
82+
func url(for url: String) -> URL? {
83+
.init(string: url)
84+
}
85+
}
86+
6787
private extension ListAction {
6888

6989
func button<Content: View>(
70-
action: @escaping () -> Void,
90+
_ action: @escaping () -> Void,
7191
@ViewBuilder content: @escaping () -> Content
7292
) -> some View {
7393
Button(action: action) {
7494
content()
7595
}
96+
.accessibilityHint(Text(accessibilityLabel))
7697
}
7798

7899
@ViewBuilder
79100
func link<Content: View>(
80-
url: URL?,
81-
@ViewBuilder content: @escaping () -> Content
101+
for url: URL?,
102+
@ViewBuilder _ content: @escaping () -> Content
82103
) -> some View {
83104
if let url {
84105
Link(destination: url) {

Sources/SwiftUIKit/Lists/ListActionRow.swift

+5-10
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99
#if os(iOS)
1010
import SwiftUI
1111

12-
/**
13-
This view can be used to present action rows in a `List`.
14-
15-
If `hideIfEmpty` is `true` and the text is empty, this view
16-
is rendered as an `EmptyView`.
17-
*/
12+
/// This view can be used to present action rows in a `List`.
1813
public struct ListActionRow: View {
1914

2015
/// Create a list action row with a custom trailing view.
2116
///
2217
/// - Parameters:
2318
/// - title: The row title, if any.
2419
/// - text: The row text.
25-
/// - action: The ``ListAction`` to use.
26-
/// - trailingView: An optional trailing view to apply to the view.
20+
/// - bundle: The bundle to use for localization, if any.
21+
/// - action: The ``ListAction`` to use, if any.
2722
public init(
2823
title: LocalizedStringKey? = nil,
2924
text: LocalizedStringKey,
@@ -80,9 +75,9 @@ public struct ListActionRow: View {
8075

8176
ListActionRow(
8277
text: "Preview.Text.\(2) Preview.Text.\(2) Preview.Text.\(2) Preview.Text.\(2) Preview.Text.\(2) Preview.Text.\(2) Preview.Text.\(2) ",
83-
bundle: .module
78+
bundle: .module,
79+
action: .email(address: "")
8480
)
85-
.font(.footnote)
8681

8782
ListActionRow(
8883
title: "Preview.Title.\(3)",

scripts/version_validate_git.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
3333
fi
3434

3535
# Check for uncommitted changes
36-
if ! git diff-index --quiet HEAD --; then
36+
if [ -n "$(git status --porcelain)" ]; then
3737
echo "Error: Git repository is dirty. There are uncommitted changes."
3838
exit 1
3939
fi

0 commit comments

Comments
 (0)