Skip to content

Commit 0a6c3ed

Browse files
authoredMar 19, 2025··
Use built-in labeled content view instead of horizontal stacks where appropriate (#1169)
1 parent 113bc0a commit 0a6c3ed

File tree

3 files changed

+6
-48
lines changed

3 files changed

+6
-48
lines changed
 

‎Demo/Resources/Localizable.xcstrings

-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
},
77
"-" : {
88

9-
},
10-
"%@, %@" : {
11-
"localizations" : {
12-
"en" : {
13-
"stringUnit" : {
14-
"state" : "new",
15-
"value" : "%1$@, %2$@"
16-
}
17-
}
18-
}
199
},
2010
"%g× %@" : {
2111
"extractionState" : "manual",

‎Demo/Sources/Metrics/MetricsView.swift

+3-21
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,10 @@ private struct InformationSectionContent: View {
4848
}
4949

5050
private func cell(_ name: LocalizedStringKey, value: String) -> some View {
51-
HStack {
52-
Text(name)
53-
Spacer()
51+
LabeledContent(name) {
5452
Text(value)
5553
.monospacedDigit()
56-
.lineLimit(1)
57-
.foregroundColor(.secondary)
5854
}
59-
.accessibilityElement()
60-
.accessibilityLabel("\(Text(name)), \(value)")
6155
}
6256
}
6357

@@ -109,16 +103,10 @@ private struct ExperienceStartupTimesSectionContent: View {
109103
}
110104

111105
private func cell(_ name: LocalizedStringKey, value: String) -> some View {
112-
HStack {
113-
Text(name)
114-
Spacer()
106+
LabeledContent(name) {
115107
Text(value)
116108
.monospacedDigit()
117-
.lineLimit(1)
118-
.foregroundColor(.secondary)
119109
}
120-
.accessibilityElement()
121-
.accessibilityLabel("\(Text(name)), \(value)")
122110
}
123111
}
124112

@@ -146,16 +134,10 @@ private struct ServiceStartupTimesSectionContent: View {
146134
}
147135

148136
private func cell(_ name: LocalizedStringKey, value: String) -> some View {
149-
HStack {
150-
Text(name)
151-
Spacer()
137+
LabeledContent(name) {
152138
Text(value)
153139
.monospacedDigit()
154-
.lineLimit(1)
155-
.foregroundColor(.secondary)
156140
}
157-
.accessibilityElement()
158-
.accessibilityLabel("\(Text(name)), \(value)")
159141
}
160142
}
161143

‎Demo/Sources/Settings/SettingsView.swift

+3-17
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ private struct UrlCacheView: View {
1313
var body: some View {
1414
HStack {
1515
Button(action: clearUrlCache) {
16-
HStack {
17-
Text("Clear URL cache")
18-
Spacer()
16+
LabeledContent("Clear URL cache") {
1917
Text(urlCacheSize)
20-
.font(.footnote)
2118
.foregroundColor(.red)
2219
}
2320
}
@@ -52,16 +49,7 @@ private struct InfoCell: View {
5249
}
5350

5451
private func content() -> some View {
55-
HStack {
56-
Text(title)
57-
Spacer()
58-
Text(value)
59-
.foregroundColor(.secondary)
60-
.multilineTextAlignment(.trailing)
61-
.lineLimit(2)
62-
}
63-
.accessibilityElement()
64-
.accessibilityLabel("\(Text(title)), \(value)")
52+
LabeledContent(title, value: value)
6553
}
6654
}
6755

@@ -257,9 +245,7 @@ struct SettingsView: View {
257245
}
258246
}
259247
#else
260-
HStack {
261-
Text(key)
262-
Spacer()
248+
LabeledContent(key) {
263249
numberTextField(value: value)
264250
}
265251
#endif

0 commit comments

Comments
 (0)