Skip to content

Commit cdf268a

Browse files
authored
refactor: checkbox component API to split two-values and three-values states components (#497) (#506)
Now checkbox component, with its selector only and control item variants, has two API: one with a binding of boolean an another with a binding of enum with the three possible states Closes #497 Acked-by: Ludovic Pinel <[email protected]> Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent fd92bca commit cdf268a

File tree

2,069 files changed

+1245
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,069 files changed

+1245
-206
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Changed
1717

18+
- [Library] Split checkbox component API for two-values and three-values states ([#497](https://github.com/Orange-OpenSource/ouds-ios/issues/497))
1819
- [Library] Rename *selector* to *indicator* for control item absed components ([#496](https://github.com/Orange-OpenSource/ouds-ios/issues/496))
1920
- [Library] Checkbox component v2 ([#486](https://github.com/Orange-OpenSource/ouds-ios/issues/486))
2021
- [Library] Group components by category in documentation ([#484](https://github.com/Orange-OpenSource/ouds-ios/issues/484))

DesignToolbox/DesignToolbox.xcodeproj/project.pbxproj

+42
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@
190190
51BD762A2C466FCF0033365D /* DesignToolbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51BD761E2C466FCF0033365D /* DesignToolbox.swift */; };
191191
51BD762B2C466FCF0033365D /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51BD761F2C466FCF0033365D /* MainView.swift */; };
192192
51D6D5832D883D50009CD879 /* OUDSRadioButtonUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5822D883D50009CD879 /* OUDSRadioButtonUITests.swift */; };
193+
51D6D5852D887E36009CD879 /* CheckboxIndeterminateElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5842D887E36009CD879 /* CheckboxIndeterminateElement.swift */; };
194+
51D6D5862D887E36009CD879 /* CheckboxIndeterminateElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5842D887E36009CD879 /* CheckboxIndeterminateElement.swift */; };
195+
51D6D5882D887E55009CD879 /* CheckboxItemIndeterminateElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5872D887E55009CD879 /* CheckboxItemIndeterminateElement.swift */; };
196+
51D6D5892D887E55009CD879 /* CheckboxItemIndeterminateElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5872D887E55009CD879 /* CheckboxItemIndeterminateElement.swift */; };
197+
51D6D58B2D887E94009CD879 /* CheckboxIndeterminatePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D58A2D887E94009CD879 /* CheckboxIndeterminatePage.swift */; };
198+
51D6D58C2D887E94009CD879 /* CheckboxIndeterminatePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D58A2D887E94009CD879 /* CheckboxIndeterminatePage.swift */; };
199+
51D6D58E2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D58D2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift */; };
200+
51D6D58F2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D58D2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift */; };
201+
51D6D5912D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5902D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift */; };
202+
51D6D5922D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5902D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift */; };
203+
51D6D5942D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5932D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift */; };
204+
51D6D5952D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5932D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift */; };
205+
51D6D5972D8881A6009CD879 /* CheckboxLayouts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5962D8881A0009CD879 /* CheckboxLayouts.swift */; };
206+
51D6D5982D8881A6009CD879 /* CheckboxLayouts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6D5962D8881A0009CD879 /* CheckboxLayouts.swift */; };
193207
51EE2C682C5BF5DE00F634EC /* OUDSThemesOrange in Frameworks */ = {isa = PBXBuildFile; productRef = 51EE2C672C5BF5DE00F634EC /* OUDSThemesOrange */; };
194208
6D17A22B2CCBF0E200C00512 /* ColorTokenPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 075114DF2CB7FDC200B8B759 /* ColorTokenPage.swift */; };
195209
6D17A22C2CCBF12B00C00512 /* NamedColor+Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0765B4952CC159F600E69359 /* NamedColor+Action.swift */; };
@@ -376,6 +390,13 @@
376390
51BD761E2C466FCF0033365D /* DesignToolbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DesignToolbox.swift; sourceTree = "<group>"; };
377391
51BD761F2C466FCF0033365D /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
378392
51D6D5822D883D50009CD879 /* OUDSRadioButtonUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OUDSRadioButtonUITests.swift; sourceTree = "<group>"; };
393+
51D6D5842D887E36009CD879 /* CheckboxIndeterminateElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxIndeterminateElement.swift; sourceTree = "<group>"; };
394+
51D6D5872D887E55009CD879 /* CheckboxItemIndeterminateElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxItemIndeterminateElement.swift; sourceTree = "<group>"; };
395+
51D6D58A2D887E94009CD879 /* CheckboxIndeterminatePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxIndeterminatePage.swift; sourceTree = "<group>"; };
396+
51D6D58D2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxItemIndeterminatePage.swift; sourceTree = "<group>"; };
397+
51D6D5902D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxIndeterminateConfiguration.swift; sourceTree = "<group>"; };
398+
51D6D5932D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxItemIndeterminateConfiguration.swift; sourceTree = "<group>"; };
399+
51D6D5962D8881A0009CD879 /* CheckboxLayouts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxLayouts.swift; sourceTree = "<group>"; };
379400
51E3FF0A2CAFD9AE00F1BC59 /* DesignToolboxElementPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesignToolboxElementPage.swift; sourceTree = "<group>"; };
380401
6DCC57E12CEB984D000F35F8 /* DesignToolboxCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesignToolboxCode.swift; sourceTree = "<group>"; };
381402
6DFC208A2CDE669500F2EC33 /* AccessibilityStatementPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityStatementPage.swift; sourceTree = "<group>"; };
@@ -750,18 +771,25 @@
750771
isa = PBXGroup;
751772
children = (
752773
513441FD2D75B880000B5DE4 /* CheckboxConfiguration.swift */,
774+
51D6D5902D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift */,
753775
513441FE2D75B880000B5DE4 /* CheckboxElement.swift */,
776+
51D6D5842D887E36009CD879 /* CheckboxIndeterminateElement.swift */,
754777
513441FF2D75B880000B5DE4 /* CheckboxPage.swift */,
778+
51D6D58A2D887E94009CD879 /* CheckboxIndeterminatePage.swift */,
755779
);
756780
path = Checkbox;
757781
sourceTree = "<group>";
758782
};
759783
513442042D75B880000B5DE4 /* CheckboxItem */ = {
760784
isa = PBXGroup;
761785
children = (
786+
51D6D5962D8881A0009CD879 /* CheckboxLayouts.swift */,
762787
513442012D75B880000B5DE4 /* CheckboxItemElement.swift */,
788+
51D6D5872D887E55009CD879 /* CheckboxItemIndeterminateElement.swift */,
763789
513442022D75B880000B5DE4 /* CheckboxItemPage.swift */,
790+
51D6D58D2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift */,
764791
513442032D75B880000B5DE4 /* CheckboxItemConfiguration.swift */,
792+
51D6D5932D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift */,
765793
);
766794
path = CheckboxItem;
767795
sourceTree = "<group>";
@@ -1181,6 +1209,7 @@
11811209
51952AA22D3FA32E0068B807 /* GridTokenElement.swift in Sources */,
11821210
51952AA32D3FA32E0068B807 /* GrisTokenPage.swift in Sources */,
11831211
513442162D75B9E1000B5DE4 /* DesignToolboxBackgroundModifier.swift in Sources */,
1212+
51D6D5892D887E55009CD879 /* CheckboxItemIndeterminateElement.swift in Sources */,
11841213
51952AA42D3FA32E0068B807 /* TokensPage.swift in Sources */,
11851214
0745C1912D7A0596006B3A1F /* RadioPage.swift in Sources */,
11861215
0745C1922D7A0596006B3A1F /* RadioConfiguration.swift in Sources */,
@@ -1191,6 +1220,7 @@
11911220
0745C18A2D7A03B8006B3A1F /* RadioElements.swift in Sources */,
11921221
51952A922D3FA2720068B807 /* OUDSButtonUITests.swift in Sources */,
11931222
51952A7C2D3FA1510068B807 /* OUDSTokensBorderUITests.swift in Sources */,
1223+
51D6D5862D887E36009CD879 /* CheckboxIndeterminateElement.swift in Sources */,
11941224
6DED17EF2CD25B2200584BC9 /* SizeTokenElement.swift in Sources */,
11951225
6DED17EE2CD23E5400584BC9 /* CardIllustration.swift in Sources */,
11961226
6DED17ED2CD23D5200584BC9 /* DesignToolboxElementPage.swift in Sources */,
@@ -1210,6 +1240,7 @@
12101240
513442092D75B880000B5DE4 /* CheckboxItemPage.swift in Sources */,
12111241
5134420A2D75B880000B5DE4 /* CheckboxItemElement.swift in Sources */,
12121242
5134420B2D75B880000B5DE4 /* CheckboxConfiguration.swift in Sources */,
1243+
51D6D5982D8881A6009CD879 /* CheckboxLayouts.swift in Sources */,
12131244
514D02FC2D75F45F00622692 /* OUDSCheckboxUITests.swift in Sources */,
12141245
5134420C2D75B880000B5DE4 /* CheckboxElements.swift in Sources */,
12151246
5134420D2D75B880000B5DE4 /* CheckboxItemConfiguration.swift in Sources */,
@@ -1219,6 +1250,7 @@
12191250
6DB260DA2CD0EF9D0091F72E /* NamedSize+IconDecorative.swift in Sources */,
12201251
07AB458A2D50CB9B0001D237 /* DesignToolboxTextField.swift in Sources */,
12211252
51952A8C2D3FA22A0068B807 /* OUDSTokensFontUITests.swift in Sources */,
1253+
51D6D58C2D887E94009CD879 /* CheckboxIndeterminatePage.swift in Sources */,
12221254
6D17A2352CCF8DC300C00512 /* NamedColor.swift in Sources */,
12231255
6D17A22C2CCBF12B00C00512 /* NamedColor+Action.swift in Sources */,
12241256
6D17A22D2CCBF12B00C00512 /* NamedColor+Always.swift in Sources */,
@@ -1243,7 +1275,9 @@
12431275
6D8F9C542CC160660078A10E /* SpaceTokenPage.swift in Sources */,
12441276
07304A6A2D429F9F009320BA /* LinkConfiguration.swift in Sources */,
12451277
07304A6B2D429F9F009320BA /* LinkElement.swift in Sources */,
1278+
51D6D5952D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift in Sources */,
12461279
07304A6C2D429F9F009320BA /* LinkPage.swift in Sources */,
1280+
51D6D58F2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift in Sources */,
12471281
07D7E1982D035566006472EB /* ButtonConfiguration.swift in Sources */,
12481282
6D8F9C532CC160580078A10E /* SizeTokenPage.swift in Sources */,
12491283
6D8F9C522CC15F960078A10E /* ElevationTokenPage.swift in Sources */,
@@ -1253,6 +1287,7 @@
12531287
6D24658E2CBEAC750023E359 /* BorderTokenPage.swift in Sources */,
12541288
51952A8F2D3FA24C0068B807 /* OUDSTokensOpacityUITests.swift in Sources */,
12551289
07F0AFDF2CFDD1FD00D334DD /* ComponentsPage.swift in Sources */,
1290+
51D6D5922D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift in Sources */,
12561291
);
12571292
runOnlyForDeploymentPostprocessing = 0;
12581293
};
@@ -1262,6 +1297,7 @@
12621297
files = (
12631298
51952A672D3F9B9E0068B807 /* DesignToolboxConfiguration.swift in Sources */,
12641299
51952A682D3F9B9E0068B807 /* NamedColor+Opacity.swift in Sources */,
1300+
51D6D5972D8881A6009CD879 /* CheckboxLayouts.swift in Sources */,
12651301
07AB458B2D50CB9B0001D237 /* DesignToolboxTextField.swift in Sources */,
12661302
0745C1972D7A0823006B3A1F /* RaioItemElement.swift in Sources */,
12671303
0745C1982D7A0823006B3A1F /* RadiolItemConfiguration.swift in Sources */,
@@ -1282,9 +1318,12 @@
12821318
07F0AFD72CFDB3CC00D334DD /* ComponentPage.swift in Sources */,
12831319
077CCE592CB426090059CC28 /* DimensionTokenElement.swift in Sources */,
12841320
07CF42852CA45DA9000BD03E /* BorderTokenPage.swift in Sources */,
1321+
51D6D5882D887E55009CD879 /* CheckboxItemIndeterminateElement.swift in Sources */,
12851322
51952A722D3F9D720068B807 /* DesignToolboxTokenIllustration.swift in Sources */,
12861323
0765B4982CC15A4000E69359 /* NamedColor+Always.swift in Sources */,
12871324
07F75A392CC6462D0004F1AD /* NamedSpace+Fixed.swift in Sources */,
1325+
51D6D5852D887E36009CD879 /* CheckboxIndeterminateElement.swift in Sources */,
1326+
51D6D58B2D887E94009CD879 /* CheckboxIndeterminatePage.swift in Sources */,
12881327
07CF42842CA45DA9000BD03E /* BorderTokenElement.swift in Sources */,
12891328
07D7E1972D035566006472EB /* ButtonConfiguration.swift in Sources */,
12901329
07CF42802CA41325000BD03E /* OpacityTokenPage.swift in Sources */,
@@ -1298,11 +1337,13 @@
12981337
07CF42782CA3F4BE000BD03E /* ElevationTokenElement.swift in Sources */,
12991338
0765B4A42CC15C3E00E69359 /* NamedColor+Chart.swift in Sources */,
13001339
07CF42792CA3F4BE000BD03E /* ElevationTokenPage.swift in Sources */,
1340+
51D6D5912D887FA9009CD879 /* CheckboxIndeterminateConfiguration.swift in Sources */,
13011341
075114E12CB7FDC200B8B759 /* ColorTokenPage.swift in Sources */,
13021342
07F7533B2CC785620007450D /* DesignToolboxSectionHeaderStyle.swift in Sources */,
13031343
07F0AFDE2CFDD1FD00D334DD /* ComponentsPage.swift in Sources */,
13041344
07AB45882D4D08080001D237 /* DesignToolboxChoicePicker.swift in Sources */,
13051345
07B3CCB12D40E34700DBB10A /* LinkConfiguration.swift in Sources */,
1346+
51D6D5942D888159009CD879 /* CheckboxItemIndeterminateConfiguration.swift in Sources */,
13061347
07B3CCB22D40E34700DBB10A /* LinkElement.swift in Sources */,
13071348
07B3CCB32D40E34700DBB10A /* LinkPage.swift in Sources */,
13081349
070DF8B12CDD07F20043D558 /* GrisTokenPage.swift in Sources */,
@@ -1348,6 +1389,7 @@
13481389
513442112D75B880000B5DE4 /* CheckboxItemElement.swift in Sources */,
13491390
513442122D75B880000B5DE4 /* CheckboxConfiguration.swift in Sources */,
13501391
513442132D75B880000B5DE4 /* CheckboxElements.swift in Sources */,
1392+
51D6D58E2D887F04009CD879 /* CheckboxItemIndeterminatePage.swift in Sources */,
13511393
513442142D75B880000B5DE4 /* CheckboxItemConfiguration.swift in Sources */,
13521394
0784B2712CCB86C500299C10 /* NamedSize+IconWithTypography.swift in Sources */,
13531395
075C71332CEB743300B93FC3 /* SpaceTokenCommonIllustration.swift in Sources */,

DesignToolbox/DesignToolbox/Pages/Components/Checkbox/Checkbox/CheckboxConfiguration.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,39 @@ import SwiftUI
1717
// MARK: - Checkbox Configuration Model
1818

1919
/// The model shared between `CheckboxConfiguration` view and `CheckboxPage` view.
20+
/// Related to `OUDSCheckbox` (i.e. with 2 available values).
2021
final class CheckboxConfigurationModel: ComponentConfiguration {
2122

22-
// MARK: - Properties
23+
// MARK: Properties
2324

2425
@Published var enabled: Bool {
2526
didSet { updateCode() }
2627
}
2728

28-
@Published var indicatorState: OUDSCheckboxIndicatorState {
29+
@Published var indicatorState: Bool {
2930
didSet { updateCode() }
3031
}
3132

3233
@Published var isError: Bool {
3334
didSet { updateCode() }
3435
}
3536

36-
// MARK: - Initializer
37+
// MARK: Initializer
3738

3839
override init() {
39-
indicatorState = .selected
40+
indicatorState = true
4041
isError = false
4142
enabled = true
4243
}
4344

4445
deinit { }
4546

46-
// MARK: - Component Configuration
47+
// MARK: Component Configuration
4748

4849
override func updateCode() {
4950
code =
5051
"""
51-
OUDSCheckbox(selection: $selection\(isErrorPattern))
52+
OUDSCheckbox(isOn: $isOn\(isErrorPattern))
5253
\(disableCode)
5354
"""
5455
}
@@ -87,11 +88,10 @@ struct CheckboxConfiguration: View {
8788
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))
8889
.disabled(!model.enabled)
8990

90-
DesignToolboxChoicePicker(title: "app_components_checkbox_selection_label", selection: $model.indicatorState) {
91-
ForEach(OUDSCheckboxIndicatorState.allCases, id: \.id) { state in
92-
Text(LocalizedStringKey(state.description)).tag(state)
93-
}
94-
}
91+
Toggle("app_components_checkbox_selection_label", isOn: $model.indicatorState)
92+
.typeHeadingMedium(theme)
93+
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))
94+
.disabled(!model.enabled)
9595
}
9696
}
9797
}

DesignToolbox/DesignToolbox/Pages/Components/Checkbox/Checkbox/CheckboxElement.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
import SwiftUI
1515

16+
/// Related to `OUDSCheckbox` (i.e. with 2 available values).
1617
struct CheckboxElement: DesignToolboxElement {
1718
let name: String
1819
let image: Image
1920
let pageDescription: AnyView
2021

2122
init() {
22-
name = "app_components_checkbox_indicatorOnly_label"
23+
name = "app_components_checkbox_twoStates_indicatorOnly_label"
2324
image = Image(decorative: "il_component_checkbox").renderingMode(.template)
2425
pageDescription = AnyView(DesignToolboxElementPage(
2526
name: name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// Software Name: OUDS iOS
3+
// SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
// SPDX-License-Identifier: MIT
5+
//
6+
// This software is distributed under the MIT license,
7+
// the text of which is available at https://opensource.org/license/MIT/
8+
// or see the "LICENSE" file for more details.
9+
//
10+
// Authors: See CONTRIBUTORS.txt
11+
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
12+
//
13+
14+
import OUDSComponents
15+
import SwiftUI
16+
17+
// MARK: - Checkbox Configuration Model
18+
19+
/// The model shared between `CheckboxIndeterminateConfiguration` view and `CheckboxIndeterminatePage` view.
20+
/// Related to `OUDSCheckboxIndeterminate` (i.e. with 3 available values).
21+
final class CheckboxIndeterminateConfigurationModel: ComponentConfiguration {
22+
23+
// MARK: Properties
24+
25+
@Published var enabled: Bool {
26+
didSet { updateCode() }
27+
}
28+
29+
@Published var indicatorState: OUDSCheckboxIndicatorState {
30+
didSet { updateCode() }
31+
}
32+
33+
@Published var isError: Bool {
34+
didSet { updateCode() }
35+
}
36+
37+
// MARK: Initializer
38+
39+
override init() {
40+
indicatorState = .selected
41+
isError = false
42+
enabled = true
43+
}
44+
45+
deinit { }
46+
47+
// MARK: Component Configuration
48+
49+
override func updateCode() {
50+
code =
51+
"""
52+
OUDSCheckboxInterminate(selection: $selection\(isErrorPattern))
53+
\(disableCode)
54+
"""
55+
}
56+
57+
private var disableCode: String {
58+
".disable(\(enabled ? "false" : "true"))"
59+
}
60+
61+
private var isErrorPattern: String {
62+
if isError && enabled {
63+
return ", isError: true"
64+
} else {
65+
return ""
66+
}
67+
}
68+
}
69+
70+
// MARK: - Checkbox Indeterminate Configuration View
71+
72+
struct CheckboxIndeterminateConfiguration: View {
73+
74+
@ObservedObject var model: CheckboxIndeterminateConfigurationModel
75+
76+
@Environment(\.theme) private var theme
77+
@Environment(\.colorScheme) private var colorScheme
78+
79+
var body: some View {
80+
VStack(alignment: .leading, spacing: theme.spaces.spaceFixedMedium) {
81+
Toggle("app_common_enabled_label", isOn: $model.enabled)
82+
.typeHeadingMedium(theme)
83+
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))
84+
.disabled(model.isError)
85+
86+
Toggle("app_components_common_onError_label", isOn: $model.isError)
87+
.typeHeadingMedium(theme)
88+
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))
89+
.disabled(!model.enabled)
90+
91+
DesignToolboxChoicePicker(title: "app_components_checkbox_selection_label", selection: $model.indicatorState) {
92+
ForEach(OUDSCheckboxIndicatorState.allCases, id: \.id) { state in
93+
Text(LocalizedStringKey(state.description)).tag(state)
94+
}
95+
}
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)