Skip to content

Commit 7902f2f

Browse files
committed
chore: clean API (#1364)
Signed-off-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com>
1 parent ef35cec commit 7902f2f

File tree

14 files changed

+59
-46
lines changed

14 files changed

+59
-46
lines changed

OUDS/Core/Components/Sources/Actions/Button/OUDSButton.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ import SwiftUI
5959
///
6060
/// // Text and icon with strong appearance and button taking full width
6161
/// OUDSButton(text: "Validate", icon: Image("ic_heart"), appearance: .strong, isFullWidth: true) { /* the action to process */ }
62+
///
63+
/// // Localizable from bundle can also be used
64+
/// OUDSButton(LocalizedStringKey("validate_button"), bundle: Bundle.module, appearance: .strong) { }
6265
/// ```
6366
///
6467
/// If you need to flip your icon depending to the layout direction or not (e.g. if RTL mode lose semantics / meanings):
@@ -182,7 +185,6 @@ public struct OUDSButton: View {
182185
/// - appearance: The button appearance, default set to `.default`
183186
/// - style: The button style, default set to `.default`
184187
/// - isFullWidth: Flag to let button take all the screen width, set to *false* by default.
185-
/// - action: The action to perform when the user triggers the button
186188
public init(text: String,
187189
icon: Image,
188190
flipIcon: Bool = false,
@@ -199,17 +201,19 @@ public struct OUDSButton: View {
199201
isHover = false
200202
}
201203

202-
/// Creates a button with a localized text and icon, looking up the key in the given bundle.
204+
// swiftlint:disable function_default_parameter_at_end
205+
/// Creates a button with a localized text and icon, looking up the key in the given bundle..
206+
/// A raw string can also be given to be displayed.
203207
///
204208
/// ```swift
209+
/// // Use localizable
205210
/// OUDSButton(LocalizedStringKey("validate_button"), bundle: Bundle.module, icon: Image("ic_checkmark"), appearance: .strong) { }
206211
/// ```
207212
///
208213
/// - Parameters:
209-
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
214+
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle, or a raw `String` to display
210215
/// - tableName: The name of the `.strings` file, or `nil` for the default
211216
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
212-
/// - comment: An optional comment for translators, does not affect the resolved value
213217
/// - icon: An image which shoud contains an icon
214218
/// - flipIcon: Default set to `false`, set to `true` to reverse the image (i.e. flip vertically)
215219
/// - appearance: The button appearance, default set to `.default`
@@ -219,7 +223,6 @@ public struct OUDSButton: View {
219223
public init(_ key: LocalizedStringKey,
220224
tableName: String? = nil,
221225
bundle: Bundle = .main,
222-
comment: StaticString? = nil,
223226
icon: Image,
224227
flipIcon: Bool = false,
225228
appearance: Appearance = .default,
@@ -236,6 +239,8 @@ public struct OUDSButton: View {
236239
isHover = false
237240
}
238241

242+
// swiftlint:enable function_default_parameter_at_end
243+
239244
/// Creates a button with an icon only.
240245
///
241246
/// - Parameters:
@@ -294,15 +299,13 @@ public struct OUDSButton: View {
294299
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
295300
/// - tableName: The name of the `.strings` file, or `nil` for the default
296301
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
297-
/// - comment: An optional comment for translators, does not affect the resolved value
298302
/// - appearance: The button appearance, default set to `.default`
299303
/// - style: The button style, default set to `.default`
300304
/// - isFullWidth: Flag to let button take all the screen width, set to *false* by default.
301305
/// - action: The action to perform when the user triggers the button
302306
public init(_ key: LocalizedStringKey,
303307
tableName: String? = nil,
304308
bundle: Bundle = .main,
305-
comment: StaticString? = nil,
306309
appearance: Appearance = .default,
307310
style: Style = .default,
308311
isFullWidth: Bool = false,

OUDS/Core/Components/Sources/ContentDisplay/BulletList/OUDSBulletList.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ public struct OUDSBulletList: View {
206206
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
207207
/// - tableName: The name of the `.strings` file, or `nil` for the default
208208
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
209-
/// - comment: An optional comment for translators, does not affect the resolved value
210209
/// - subListType: The specific `OUDSBulletList.Type` for the nested sub-list, if any. If `nil`,
211210
/// the type is inherited from the parent list.
212211
/// - subListTextStyle: The specific `OUDSBulletList.TextStyle` for the nested sub-list, if any. If
@@ -217,7 +216,6 @@ public struct OUDSBulletList: View {
217216
public init(_ key: LocalizedStringKey,
218217
tableName: String? = nil,
219218
bundle: Bundle = .main,
220-
comment: StaticString? = nil,
221219
subListType: OUDSBulletList.`Type`? = nil,
222220
subListTextStyle: OUDSBulletList.TextStyle? = nil,
223221
subListHasBoldText: Bool? = nil,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ import SwiftUI
7070
/// // The default layout will be used here.
7171
/// OUDSCheckboxItem("Hello world", isOn: $isOn)
7272
///
73+
/// // Localizable from bundle can also be used
74+
/// OUDSCheckboxItem(LocalizedStringKey("agree_terms"), bundle: Bundle.module, isOn: $isOn)
75+
///
7376
/// // A leading checkbox with a label, but in read only mode (user cannot interact yet, but not disabled).
7477
/// // The default layout will be used here.
7578
/// OUDSCheckboxItem("Hello world", isOn: $isOn, isReadOnly: true)
@@ -294,6 +297,7 @@ public struct OUDSCheckboxItem: View {
294297
self.action = action
295298
}
296299

300+
// swiftlint:disable function_default_parameter_at_end
297301
/// Creates a checkbox with a localized label, looking up the key in the given bundle.
298302
///
299303
/// ```swift
@@ -306,7 +310,6 @@ public struct OUDSCheckboxItem: View {
306310
/// - key: A `LocalizedStringKey` used to look up the label in the given bundle
307311
/// - tableName: The name of the `.strings` file, or `nil` for the default
308312
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
309-
/// - comment: An optional comment for translators, does not affect the resolved value
310313
/// - isOn: A binding to a property that determines whether the indicator is ticked (selected) or not (unselected)
311314
/// - description: An additional helper text, a description, which should not be empty, default set to `nil`
312315
/// - icon: An optional icon, default set to `nil`
@@ -321,7 +324,6 @@ public struct OUDSCheckboxItem: View {
321324
public init(_ key: LocalizedStringKey,
322325
tableName: String? = nil,
323326
bundle: Bundle = .main,
324-
comment: StaticString? = nil,
325327
isOn: Binding<Bool>,
326328
description: String? = nil,
327329
icon: Image? = nil,
@@ -348,6 +350,8 @@ public struct OUDSCheckboxItem: View {
348350
action: action)
349351
}
350352

353+
// swiftlint:enable function_default_parameter_at_end
354+
351355
// MARK: Body
352356

353357
public var body: some View {

OUDS/Core/Components/Sources/Controls/Chip/OUDSFilterChip.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import SwiftUI
2727
/// // Text only as not selected (default unselected)
2828
/// OUDSFilterChip(text: "Label") { /* the action to process */ }
2929
///
30+
/// // Text from a localizable and a bundle
31+
/// OUDSFilterChip(LocalizedStringKey("category_filter"), bundle: Bundle.module) { }
32+
///
3033
/// // Text and icon as selected
3134
/// OUDSFilterChip(icon: Image("ic_heart"), text: "Label", selected: true) { /* the action to process */ }
3235
/// ```
@@ -93,14 +96,12 @@ public struct OUDSFilterChip: View {
9396
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
9497
/// - tableName: The name of the `.strings` file, or `nil` for the default
9598
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
96-
/// - comment: An optional comment for translators, does not affect the resolved value
9799
/// - selected: Flag to know if chip is selected, by default is unselected
98100
/// - action: The action to perform when the user triggers the chip
99101
public init(icon: Image,
100102
_ key: LocalizedStringKey,
101103
tableName: String? = nil,
102104
bundle: Bundle = .main,
103-
comment: StaticString? = nil,
104105
selected: Bool = false,
105106
action: @escaping () -> Void)
106107
{
@@ -147,20 +148,18 @@ public struct OUDSFilterChip: View {
147148
/// Creates a filter chip with a localized text only, looking up the key in the given bundle.
148149
///
149150
/// ```swift
150-
/// OUDSFilterChip(LocalizedStringKey("category_filter"), bundle: Bundle.module, selected: false) { }
151+
/// OUDSFilterChip(LocalizedStringKey("category_filter"), bundle: Bundle.module) { }
151152
/// ```
152153
///
153154
/// - Parameters:
154155
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
155156
/// - tableName: The name of the `.strings` file, or `nil` for the default
156157
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
157-
/// - comment: An optional comment for translators, does not affect the resolved value
158158
/// - selected: Flag to know if chip is selected, by default is unselected
159159
/// - action: The action to perform when the user triggers the chip
160160
public init(_ key: LocalizedStringKey,
161161
tableName: String? = nil,
162162
bundle: Bundle = .main,
163-
comment: StaticString? = nil,
164163
selected: Bool = false,
165164
action: @escaping () -> Void)
166165
{

OUDS/Core/Components/Sources/Controls/Chip/OUDSSuggestionChip.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import SwiftUI
3434
/// // Text only
3535
/// OUDSSuggestionChip(text: "Heart") { /* the action to process */ }
3636
///
37+
/// // Text from a localizable and a bundle
38+
/// OUDSSuggestionChip(LocalizedStringKey("category_chip"), bundle: Bundle.module) { }
39+
///
3740
/// // Text and icon
3841
/// OUDSSuggestionChip(icon: Image("ic_heart"), text: "Heart") { /* the action to process */ }
3942
/// ```
@@ -100,13 +103,11 @@ public struct OUDSSuggestionChip: View {
100103
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
101104
/// - tableName: The name of the `.strings` file, or `nil` for the default
102105
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
103-
/// - comment: An optional comment for translators, does not affect the resolved value
104106
/// - action: The action to perform when the user triggers the chip
105107
public init(icon: Image,
106108
_ key: LocalizedStringKey,
107109
tableName: String? = nil,
108110
bundle: Bundle = .main,
109-
comment: StaticString? = nil,
110111
action: @escaping () -> Void)
111112
{
112113
let resolvedText = key.resolved(tableName: tableName, bundle: bundle)
@@ -154,12 +155,10 @@ public struct OUDSSuggestionChip: View {
154155
/// - key: A `LocalizedStringKey` used to look up the text in the given bundle
155156
/// - tableName: The name of the `.strings` file, or `nil` for the default
156157
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
157-
/// - comment: An optional comment for translators, does not affect the resolved value
158158
/// - action: The action to perform when the user triggers the chip
159159
public init(_ key: LocalizedStringKey,
160160
tableName: String? = nil,
161161
bundle: Bundle = .main,
162-
comment: StaticString? = nil,
163162
action: @escaping () -> Void)
164163
{
165164
let resolvedText = key.resolved(tableName: tableName, bundle: bundle)

OUDS/Core/Components/Sources/Controls/ChipPicker/OUDSChipPicker.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,12 @@ public struct OUDSChipPicker<Tag: Hashable>: View {
153153
/// - title: A `LocalizedStringKey` for the picker title, or `nil` if no title
154154
/// - tableName: The name of the `.strings` file, or `nil` for the default
155155
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
156-
/// - comment: An optional comment for translators, does not affect the resolved value
157156
/// - selection: The current selected value
158157
/// - chips: The raw data to wrap in ``OUDSFilterChip`` for display
159158
/// - itemsSpacing: The custom spacing to apply between items, default set to *nl*. If *nil* token *theme.spaces.fixedNone* will be used.
160159
public init(title: LocalizedStringKey?,
161160
tableName: String? = nil,
162161
bundle: Bundle = .main,
163-
comment: StaticString? = nil,
164162
selection: Binding<Tag?>,
165163
chips: [OUDSChipPickerData<Tag>],
166164
itemsSpacing: SpaceSemanticToken? = nil)
@@ -203,14 +201,12 @@ public struct OUDSChipPicker<Tag: Hashable>: View {
203201
/// - title: A `LocalizedStringKey` for the picker title, or `nil` if no title
204202
/// - tableName: The name of the `.strings` file, or `nil` for the default
205203
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
206-
/// - comment: An optional comment for translators, does not affect the resolved value
207204
/// - selection: The current selected value
208205
/// - chips: The raw data to wrap in ``OUDSFilterChip`` for display
209206
/// - itemsSpacing: The custom spacing to apply between items, default set to *nl*. If *nil* token *theme.spaces.fixedNone* will be used.
210207
public init(title: LocalizedStringKey?,
211208
tableName: String? = nil,
212209
bundle: Bundle = .main,
213-
comment: StaticString? = nil,
214210
selection: Binding<Tag>,
215211
chips: [OUDSChipPickerData<Tag>],
216212
itemsSpacing: SpaceSemanticToken? = nil)
@@ -253,14 +249,12 @@ public struct OUDSChipPicker<Tag: Hashable>: View {
253249
/// - title: A `LocalizedStringKey` for the picker title, or `nil` if no title
254250
/// - tableName: The name of the `.strings` file, or `nil` for the default
255251
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
256-
/// - comment: An optional comment for translators, does not affect the resolved value
257252
/// - selections: Current selected values
258253
/// - chips: The raw data to wrap in ``OUDSFilterChip`` for display
259254
/// - itemsSpacing: The custom spacing to apply between items, default set to *nl*. If *nil* token *theme.spaces.fixedNone* will be used.
260255
public init(title: LocalizedStringKey?,
261256
tableName: String? = nil,
262257
bundle: Bundle = .main,
263-
comment: StaticString? = nil,
264258
selections: Binding<[Tag]>,
265259
chips: [OUDSChipPickerData<Tag>],
266260
itemsSpacing: SpaceSemanticToken? = nil)

OUDS/Core/Components/Sources/Controls/PasswordInput/OUDSPasswordInput.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import SwiftUI
4141
/// ```swift
4242
/// // An outlined text input
4343
/// OUDSPasswordInput(label: "Your password", password: $password, isOutlined: true)
44+
///
45+
/// // With a localizable from a bundle
46+
/// OUDSPasswordInput(LocalizedStringKey("password_label"), bundle: Bundle.module, password: $password)
4447
/// ```
4548
///
4649
/// ### Rounded layout
@@ -166,6 +169,7 @@ public struct OUDSPasswordInput: View {
166169
self.constrainedMaxWidth = constrainedMaxWidth
167170
}
168171

172+
// swiftlint:disable function_default_parameter_at_end
169173
/// Creates a password input with a localized label, looking up the key in the given bundle.
170174
///
171175
/// ```swift
@@ -176,7 +180,6 @@ public struct OUDSPasswordInput: View {
176180
/// - key: A `LocalizedStringKey` used to look up the label in the given bundle
177181
/// - tableName: The name of the `.strings` file, or `nil` for the default
178182
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
179-
/// - comment: An optional comment for translators, does not affect the resolved value
180183
/// - password: The pasword to display and edit
181184
/// - isHiddenPassword: Flag to hide or show the password, By default set to `true`
182185
/// - placeholder: The text displayed when the password input is empty, by default is *nil*
@@ -189,7 +192,6 @@ public struct OUDSPasswordInput: View {
189192
public init(_ key: LocalizedStringKey,
190193
tableName: String? = nil,
191194
bundle: Bundle = .main,
192-
comment: StaticString? = nil,
193195
password: Binding<String>,
194196
isHiddenPassword: Binding<Bool> = .constant(true),
195197
placeholder: String? = nil,
@@ -212,6 +214,8 @@ public struct OUDSPasswordInput: View {
212214
status: status)
213215
}
214216

217+
// swiftlint:enable function_default_parameter_at_end
218+
215219
// MARK: Body
216220

217221
public var body: some View {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ import SwiftUI
7171
/// // The default layout will be used here.
7272
/// OUDSRadioItem("Lucy in the Sky with Diamonds", isOn: $selection)
7373
///
74+
/// // Localizable from bundle can also be used
75+
/// OUDSRadioItem(LocalizedStringKey("option_label"), bundle: Bundle.module, isOn: $selection)
76+
///
7477
/// // A leading radio with a label, but in read only mode (user cannot interact yet, but not disabled).
7578
/// // The default layout will be used here.
7679
/// OUDSRadioItem("Lucy in the Sky with Diamonds", isOn: $selection, isReadOnly: true)
@@ -318,6 +321,7 @@ public struct OUDSRadioItem: View {
318321
self.action = action
319322
}
320323

324+
// swiftlint:disable function_default_parameter_at_end
321325
/// Creates a radio with a localized label, looking up the key in the given bundle.
322326
///
323327
/// ```swift
@@ -330,7 +334,6 @@ public struct OUDSRadioItem: View {
330334
/// - key: A `LocalizedStringKey` used to look up the label in the given bundle
331335
/// - tableName: The name of the `.strings` file, or `nil` for the default
332336
/// - bundle: The bundle in which to look up the localized string. Defaults to `Bundle.main`.
333-
/// - comment: An optional comment for translators, does not affect the resolved value
334337
/// - isOn: A binding to a property that determines whether the toggle is on or off
335338
/// - extraLabel: An additional label text of the radio, default set to `nil`
336339
/// - description: A description, like an helper text, should not be empty, default set to `nil`
@@ -347,7 +350,6 @@ public struct OUDSRadioItem: View {
347350
public init(_ key: LocalizedStringKey,
348351
tableName: String? = nil,
349352
bundle: Bundle = .main,
350-
comment: StaticString? = nil,
351353
isOn: Binding<Bool>,
352354
extraLabel: String? = nil,
353355
description: String? = nil,
@@ -378,6 +380,8 @@ public struct OUDSRadioItem: View {
378380
action: action)
379381
}
380382

383+
// swiftlint:enable function_default_parameter_at_end
384+
381385
// MARK: Body
382386

383387
public var body: some View {

0 commit comments

Comments
 (0)