Skip to content

Commit 1d643d5

Browse files
committed
docs: update API, add references and improve code samples for controls and switch item Swift DocC
Signed-off-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com>
1 parent a3a1f67 commit 1d643d5

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +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, extraLabel: "The Beatles", description: "1967")
73+
/// OUDSSwitchItem("Lucy in the Sky with Diamonds", isOn: $isOn, description: "The Beatles")
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-
/// extraLabel: "The Beatles",
80-
/// description: "1967",
79+
/// description: "The Beatles",
8180
/// isReversed: true,
8281
/// icon: Image(decorative: "ic_heart"))
8382
///

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Some components can be used for **controls** and **inputs**.
3030

3131
The library proposes layout to add in your views some checkboxes components, even if this type of component is not iOS-native one.
3232
You can use a simple checkbox without any labels and images using ``OUDSCheckbox``.
33-
This checkbox can provide two values (selected and unselected) or three values (selected, unselected and indeterminate)
33+
This checkbox can provide two values (selected and unselected) or three values (selected, unselected and indeterminate) with ``OUDSCheckboxIndeterminate``.
3434

3535
@TabNavigator {
3636
@Tab("SwiftUI") {
@@ -91,14 +91,12 @@ It can be be used for two-states (``OUDSCheckboxItem``) or three-states manageme
9191
@Tab("SwiftUI") {
9292
```swift
9393
// A leading checkbox with a label, with only two states
94-
OUDSCheckboxItem(isOn: $isOn, label: "Hello world", target: self, action: action)
94+
OUDSCheckboxItem(isOn: $isOn, label: "Hello world")
9595

9696
// A leading checkbox with a label, an helper text, and exposing a three-values-based state with selection binding
9797
OUDSCheckboxItemIndeterminate(selection: $selection,
9898
label: "Dead Robot Zombie Cop",
99-
description: "from Outer Space II",
100-
target: self,
101-
action: action)
99+
description: "from Outer Space II")
102100

103101
// A trailing checkbox with a label, an helper text, an icon, a divider and is about an error
104102
// with a reversed layout, and exposing only two states through isOn binding
@@ -108,9 +106,7 @@ It can be be used for two-states (``OUDSCheckboxItem``) or three-states manageme
108106
icon: Image(decorative: "ic_heart"),
109107
isReversed: true,
110108
isError: true,
111-
hasDivider: true,
112-
target: self,
113-
action: action)
109+
hasDivider: true)
114110
```
115111
}
116112
@Tab("UIKit (experimental)") {
@@ -190,7 +186,7 @@ var someDataToPopulate: [OUDSCheckboxPickerData<String>] {
190186
// Use the data and the binding for the picker.
191187
@State var selections: [String] = ["Choice_1"] // or empty if nothing selected
192188
// Here the picker is vertical by default
193-
OUDSCheckboxPicker(selections: $selections, checkboxes: someDataToPopulate)
189+
OUDSCheckboxPicker(selections: $selections, checkboxes: someDataToPopulate)
194190

195191
// The picker can be vertical and have a root item with a label and a counter
196192
OUDSCheckboxPicker(selections: $selections,
@@ -277,7 +273,7 @@ The indicator can be leading or trailing.
277273
@Tab("SwiftUI") {
278274
```swift
279275
// A leading radio with a label
280-
OUDSRadioItem(isOn: $isOn, label: "Lucy in the Sky with Diamonds", target: target, action: action)
276+
OUDSRadioItem(isOn: $isOn, label: "Lucy in the Sky with Diamonds")
281277

282278
// A trailing radio with a label, an additional label, a descrption, an icon, a divider and is about an
283279
// error with a reversed layout
@@ -288,9 +284,7 @@ The indicator can be leading or trailing.
288284
icon: Image(decorative: "ic_heart"),
289285
isReversed: true,
290286
isError: true,
291-
hasDivider: true,
292-
target: target,
293-
action: action)
287+
hasDivider: true)
294288
```
295289
}
296290
@Tab("UIKit (experimental)") {
@@ -557,7 +551,7 @@ The library proposes suggestion (``OUDSSuggestionChip``) chip component to make
557551
}
558552
}
559553

560-
The library proposes filter chip component to make some filtering with selected or unselected options.
554+
The library proposes filter chip component (``OUDSFilterChip``) to make some filtering with selected or unselected options.
561555

562556
@TabNavigator {
563557
@Tab("SwiftUI") {
@@ -606,7 +600,7 @@ The library proposes filter chip component to make some filtering with selected
606600
}
607601
}
608602

609-
The library proposes a chip picker to make easily filtering with two kinds of selection:
603+
The library proposes a chip picker (``OUDSChipPicker``) to make easily filtering with two kinds of selection:
610604
- **single or none**: to select or unselect one option only
611605
- **single**: to select at least one option
612606
- **multiple**: to select several options
@@ -620,10 +614,10 @@ enum Drink: String, CaseIterable {
620614
var someDataToPopulate: [OUDSChipPickerData<Drink>] {
621615
[
622616
OUDSChipPickerData(tag: Drink.virginHolyLava,
623-
layout: .textAndIcon("Virgin Holy Lava", icon: Image(systemName: "flame")),
617+
layout: .textAndIcon("Virgin Holy Lava", icon: Image(systemName: "flame"))),
624618

625619
OUDSChipPickerData(tag: Dring.ipaBeer,
626-
layout: .textAndIcon("IPA Beer", icon: Image(systemName: "dog.fill")),
620+
layout: .textAndIcon("IPA Beer", icon: Image(systemName: "dog.fill"))),
627621

628622
OUDSChipPickerData(tag: Drink.mineralWater,
629623
layout: .textAndIcon("Mineral water", icon: Image(systemName: "waterbottle.fill")),
@@ -637,7 +631,7 @@ var someDataToPopulate: [OUDSChipPickerData<Drink>] {
637631
@State var selection: Drink? = .mineralWater
638632

639633
// Here the picker with title, selection and data
640-
OUDSChipPicker(title: Select a drink, selection: $selection, chips: someDataToPopulate)
634+
OUDSChipPicker(title: "Select a drink", selection: $selection, chips: someDataToPopulate)
641635

642636
// MARK: - Simple selection
643637

@@ -646,7 +640,7 @@ OUDSChipPicker(title: Select a drink, selection: $selection, chips: someDataToPo
646640
@State var selection: Drink = .mineralWater
647641

648642
// Here the picker with title, selection and data
649-
OUDSChipPicker(title: Select a drink, selection: $selection, chips: someDataToPopulate)
643+
OUDSChipPicker(title: "Select a drink", selection: $selection, chips: someDataToPopulate)
650644

651645
// MARK: - Multiple selection
652646

@@ -655,7 +649,7 @@ OUDSChipPicker(title: Select a drink, selection: $selection, chips: someDataToPo
655649
@State var selections: [Drink] = [.mineralWater]
656650

657651
// Here the picker with title, selection and data
658-
OUDSChipPicker(title: Select a drink, selections: $selections, chips: someDataToPopulate)
652+
OUDSChipPicker(title: "Select a drink", selections: $selections, chips: someDataToPopulate)
659653
```
660654

661655
### Text input
@@ -691,7 +685,7 @@ OUDSTextInput(label: "Email", text: $text, prefix: "Distance", suffix: "km")
691685
// Add a leading icon for more context
692686
OUDSTextInput(label: "Email", text: $text, placeholder: "firstName.lastName", suffix: "@orange.com", leadingIcon: Image(systemName: "envelope"))
693687

694-
// Add a trailing button with local image namde "ic_cross" for additional action
688+
// Add a trailing button with local image named "ic_cross" for additional action
695689
let trailingAction = OUDSTextInput.TrailingAction(icon: Image("ic_cross"), actionHint: "Delete") { text = "" }
696690
OUDSTextInput(label: "Email", text: $text, trailingAction: trailingAction)
697691

0 commit comments

Comments
 (0)