Skip to content

Commit 7523b45

Browse files
committed
refactor: additional label now extra label for control item (#1139)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 0b66f56 commit 7523b45

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

OUDS/Core/Components/Sources/Controls/Checkbox/OUDSCheckboxItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public struct OUDSCheckboxItem: View {
214214
_isOn = isOn
215215
layoutData = .init(
216216
label: label.localized(),
217-
additionalLabel: nil,
217+
extraLabel: nil,
218218
description: description?.localized(),
219219
icon: icon,
220220
flipIcon: flipIcon,

OUDS/Core/Components/Sources/Controls/Checkbox/OUDSCheckboxItemIndeterminate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public struct OUDSCheckboxItemIndeterminate: View {
213213
self.action = action
214214
layoutData = .init(
215215
label: label.localized(),
216-
additionalLabel: nil,
216+
extraLabel: nil,
217217
description: description?.localized(),
218218
icon: icon,
219219
flipIcon: flipIcon,

OUDS/Core/Components/Sources/Controls/CheckboxPicker/OUDSCheckboxPicker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import SwiftUI
4444
/// [
4545
/// OUDSCheckboxPickerData<String>(tag: "Choice_1",
4646
/// label: "Virgin Holy Lava",
47-
/// additionalLabel: "Very spicy",
47+
/// extraLabel: "Very spicy",
4848
/// helper: "No alcohol, only tasty flavors",
4949
/// icon: Image(systemName: "flame")),
5050
///

OUDS/Core/Components/Sources/Controls/Radio/OUDSRadioItem.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ import SwiftUI
7777
///
7878
/// // A leading radio with a label, and an additional label but without text.
7979
/// // The default layout will be used here.
80-
/// OUDSRadioItem(isOn: $selection, label: "Lucy in the Sky with Diamonds", additionalLabel: "The Beatles")
80+
/// OUDSRadioItem(isOn: $selection, label: "Lucy in the Sky with Diamonds", extraLabel: "The Beatles")
8181
///
8282
/// // A leading radio with an additional label.
8383
/// // The default layout will be used here.
84-
/// OUDSRadioItem(isOn: $selection, label: "Lucy in the Sky with Diamonds", additionalLabel: "The Beatles", description: "1967")
84+
/// OUDSRadioItem(isOn: $selection, label: "Lucy in the Sky with Diamonds", extraLabel: "The Beatles", description: "1967")
8585
///
8686
/// // A trailing radio with a label, a description, an icon, a divider and is about an error.
8787
/// // The reversed layout will be used here.
@@ -166,7 +166,7 @@ public struct OUDSRadioItem: View {
166166
/// ```swift
167167
/// OUDSRadioItem(isOn: $selection,
168168
/// label: "Virgin Holy Lava",
169-
/// additionalLabel: "Very spicy",
169+
/// extraLabel: "Very spicy",
170170
/// description: "No alcohol, only tasty flavors",
171171
/// icon: Image(systemName: "flame")
172172
/// ```
@@ -176,7 +176,7 @@ public struct OUDSRadioItem: View {
176176
/// - Parameters:
177177
/// - isOn: A binding to a property that determines whether the toggle is on or off.
178178
/// - label: The main label text of the radio.
179-
/// - additionalLabel: An additional label text of the radio, default set to `nil`
179+
/// - extraLabel: An additional label text of the radio, default set to `nil`
180180
/// - description: An description, like an helper text, should not be empty, default set to `nil`
181181
/// - icon: An optional icon, default set to `nil`
182182
/// - flipIcon: Default set to `false`, set to true to reverse the image (i.e. flip vertically)
@@ -195,7 +195,7 @@ public struct OUDSRadioItem: View {
195195
/// provide the localized string if key is stored in another bundle.**
196196
public init(isOn: Binding<Bool>,
197197
label: String,
198-
additionalLabel: String? = nil,
198+
extraLabel: String? = nil,
199199
description: String? = nil,
200200
icon: Image? = nil,
201201
flipIcon: Bool = false,
@@ -215,8 +215,8 @@ public struct OUDSRadioItem: View {
215215
OL.warning("Description text given to an OUDSRadioItem is defined but empty, is it expected? Prefer use of `nil` value instead")
216216
}
217217

218-
if let additionalLabel, additionalLabel.isEmpty {
219-
OL.warning("Additional label text given to an OUDSRadioItem is defined but empty, is it expected? Prefer use of `nil` value instead")
218+
if let extraLabel, extraLabel.isEmpty {
219+
OL.warning("Extra label text given to an OUDSRadioItem is defined but empty, is it expected? Prefer use of `nil` value instead")
220220
}
221221

222222
// swiftlint:disable force_unwrapping
@@ -228,7 +228,7 @@ public struct OUDSRadioItem: View {
228228
_isOn = isOn
229229
layoutData = .init(
230230
label: label.localized(),
231-
additionalLabel: additionalLabel?.localized(),
231+
extraLabel: extraLabel?.localized(),
232232
description: description?.localized(),
233233
icon: icon,
234234
flipIcon: flipIcon,
@@ -267,7 +267,7 @@ public struct OUDSRadioItem: View {
267267
}
268268
let radioA11yTrait = "core_radio_trait_a11y".localized() // Fake trait for Voice Over vocalization
269269

270-
let result = "\(stateDescription), \(layoutData.label), \(layoutData.additionalLabel ?? ""), \(layoutData.description ?? "") \(errorDescription), \(radioA11yTrait)"
270+
let result = "\(stateDescription), \(layoutData.label), \(layoutData.extraLabel ?? ""), \(layoutData.description ?? "") \(errorDescription), \(radioA11yTrait)"
271271
return result
272272
}
273273

OUDS/Core/Components/Sources/Controls/RadioPicker/OUDSRadioPicker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import SwiftUI
4343
/// [
4444
/// OUDSRadioPickerData<String>(tag: "Choice_1",
4545
/// label: "Virgin Holy Lava",
46-
/// additionalLabel: "Very spicy",
46+
/// extraLabel: "Very spicy",
4747
/// description: "No alcohol, only tasty flavors",
4848
/// icon: Image(systemName: "flame")),
4949
///
@@ -200,7 +200,7 @@ public struct OUDSRadioPicker<Tag>: View where Tag: Hashable {
200200
private func content(for radio: OUDSRadioPickerData<Tag>, noDivider: Bool) -> some View {
201201
OUDSRadioItem(isOn: selection.wrappedValue == radio.tag ? .constant(true) : .constant(false),
202202
label: radio.label,
203-
additionalLabel: radio.additionalLabel,
203+
extraLabel: radio.extraLabel,
204204
description: radio.description,
205205
icon: radio.icon,
206206
isOutlined: isOutlined ? true : radio.isOutlined,

OUDS/Core/Components/Sources/Controls/RadioPicker/OUDSRadioPickerData.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct OUDSRadioPickerData<Tag> where Tag: Hashable {
2828
let label: String
2929

3030
/// An optional additional label the ``OUDSRadioItem`` can have
31-
let additionalLabel: String?
31+
let extraLabel: String?
3232

3333
/// A description the ``OUDSRadioItem`` can have
3434
let description: String?
@@ -60,7 +60,7 @@ public struct OUDSRadioPickerData<Tag> where Tag: Hashable {
6060
/// - Parameters:
6161
/// - tag: a value to discriminate one radio to another
6262
/// - label: the mandatory text to add to ``OUDSRadioItem``
63-
/// - additionalLabel: An optional additinal text, default set to nil
63+
/// - extraLabel: An optional additinal text, default set to nil
6464
/// - description: Another optional text, a description, default set to nil
6565
/// - icon: An optional image, default set to nil
6666
/// - isOutlined: True to outline the ``OUDSRadioItem``, false otherwise (default)
@@ -70,11 +70,11 @@ public struct OUDSRadioPickerData<Tag> where Tag: Hashable {
7070
/// - hasDivider: True if a divider must be added for the current ``OUDSRadioItem``, false otherwise (default)
7171
/// - accessibilityIdentifier: The accessibility identifier to add to the item, nil by default
7272
///
73-
/// **Remark: If `label`, `additionalLabel` and `helper` strings are wording keys from strings catalog stored in `Bundle.main`, they are
73+
/// **Remark: If `label`, `extraLabel` and `helper` strings are wording keys from strings catalog stored in `Bundle.main`, they are
7474
/// automatically localized. Else, prefer to provide the localized string if key is stored in another bundle.**
7575
public init(tag: Tag,
7676
label: String,
77-
additionalLabel: String? = nil,
77+
extraLabel: String? = nil,
7878
description: String? = nil,
7979
icon: Image? = nil,
8080
isOutlined: Bool = false,
@@ -86,7 +86,7 @@ public struct OUDSRadioPickerData<Tag> where Tag: Hashable {
8686
{
8787
self.tag = tag
8888
self.label = label
89-
self.additionalLabel = additionalLabel
89+
self.extraLabel = extraLabel
9090
self.description = description
9191
self.icon = icon
9292
self.isOutlined = isOutlined

OUDS/Core/Components/Sources/Controls/Switch/OUDSSwitchItem.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ import SwiftUI
7070
///
7171
/// // A leading switch with an additional label.
7272
/// // The default layout will be used here.
73-
/// OUDSSwitchItem("Lucy in the Sky with Diamonds", isOn: $isOn, additionalLabel: "The Beatles", description: "1967")
73+
/// OUDSSwitchItem("Lucy in the Sky with Diamonds", isOn: $isOn, extraLabel: "The Beatles", description: "1967")
7474
///
7575
/// // A trailing switch with a label, an additonal label, a description text and an icon.
7676
/// // The inverse layout will be used here.
7777
/// OUDSSwitchItem("Lucy in the Sky with Diamonds",
7878
/// isOn: $isOn,
79-
/// additionalLabel: "The Beatles",
79+
/// extraLabel: "The Beatles",
8080
/// description: "1967",
8181
/// isReversed: true,
8282
/// icon: Image(decorative: "ic_heart"))
@@ -200,7 +200,7 @@ public struct OUDSSwitchItem: View {
200200

201201
layoutData = .init(
202202
label: label.localized(),
203-
additionalLabel: nil,
203+
extraLabel: nil,
204204
description: description?.localized(),
205205
icon: icon,
206206
flipIcon: flipIcon,
@@ -240,7 +240,7 @@ public struct OUDSSwitchItem: View {
240240

241241
let switchA11yTrait = "core_switch_trait_a11y".localized() // Fake trait for Voice Over vocalization
242242

243-
let result = "\(stateDescription), \(layoutData.label), \(layoutData.additionalLabel ?? ""), \(layoutData.description ?? ""), \(errorDescription), \(switchA11yTrait)"
243+
let result = "\(stateDescription), \(layoutData.label), \(layoutData.extraLabel ?? ""), \(layoutData.description ?? ""), \(errorDescription), \(switchA11yTrait)"
244244
return result
245245
}
246246

OUDS/Core/Components/Sources/_/Internal/ControlItem/ControlItemLabel.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct ControlItemLabel: View {
3232
/// Gathers any details and content to add in the ``ControlItemLabel``
3333
struct LayoutData {
3434
let label: String
35-
let additionalLabel: String?
35+
let extraLabel: String?
3636
let description: String?
3737
let icon: Image?
3838
let flipIcon: Bool
@@ -62,11 +62,11 @@ struct ControlItemLabel: View {
6262
.oudsForegroundStyle(labelColor)
6363
.frame(maxWidth: .infinity, alignment: .leading)
6464

65-
if let additionalLabel = layoutData.additionalLabel, !additionalLabel.isEmpty {
66-
Text(additionalLabel)
65+
if let extraLabel = layoutData.extraLabel, !extraLabel.isEmpty {
66+
Text(extraLabel)
6767
.labelStrongMedium(theme)
6868
.multilineTextAlignment(.leading)
69-
.oudsForegroundStyle(additionalLabelColor)
69+
.oudsForegroundStyle(extraLabelColor)
7070
}
7171

7272
if let description = layoutData.description, !description.isEmpty {
@@ -113,7 +113,7 @@ struct ControlItemLabel: View {
113113
}
114114
}
115115

116-
private var additionalLabelColor: MultipleColorSemanticTokens {
116+
private var extraLabelColor: MultipleColorSemanticTokens {
117117
interactionState == .disabled ? theme.colors.contentDisabled : theme.colors.contentDefault
118118
}
119119
}

OUDS/Core/Components/Sources/_OUDSComponents.docc/Controls.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ The indicator can be leading or trailing.
283283
// error with a reversed layout
284284
OUDSRadioItem(isOn: $isOn,
285285
label: "Lucy in the Sky with Diamonds",
286-
additionalLabel: "The Beatles"
286+
extraLabel: "The Beatles"
287287
description: "1967",
288288
icon: Image(decorative: "ic_heart"),
289289
isReversed: true,
@@ -306,7 +306,7 @@ The indicator can be leading or trailing.
306306
// A trailing radio with a label, an additional label, a description, an icon, a divider and is about an rror with a reversed layout
307307
OUDSUIKit.createRadioItem(isOn: isOn,
308308
label: "Lucy in the Sky with Diamonds",
309-
additionalLabel: "The Beatles"
309+
extraLabel: "The Beatles"
310310
description: "1967",
311311
icon: Image(decorative: "ic_heart"),
312312
isReversed: true,
@@ -343,7 +343,7 @@ var someDataToPopulate: [OUDSRadioPickerData<String>] {
343343
[
344344
OUDSRadioPickerData<String>(tag: "Choice_1",
345345
label: "Virgin Holy Lava",
346-
additionalLabel: "Very spicy",
346+
extraLabel: "Very spicy",
347347
description: "No alcohol, only tasty flavors",
348348
icon: Image(systemName: "flame")),
349349

0 commit comments

Comments
 (0)