1
+ // Software Name: OUDS Flutter
2
+ // SPDX-FileCopyrightText: Copyright (c) Orange SA
3
+ // SPDX-License-Identifier: MIT
4
+ //
5
+ // This software is distributed under the MIT license,
6
+ // the text of which is available at https://opensource.org/license/MIT/
7
+ // or see the "LICENSE" file for more details.
8
+ //
9
+ // Software description: Flutter library of reusable graphical components
10
+ //
11
+
1
12
import 'package:flutter/material.dart' ;
2
13
import 'package:flutter_svg/flutter_svg.dart' ;
3
14
import 'package:ouds_core/components/control/internal/controller/ouds_interaction_state_controller.dart' ;
@@ -8,6 +19,12 @@ import 'package:ouds_core/components/control/internal/modifier/ouds_control_text
8
19
import 'package:ouds_core/components/control/internal/ouds_control_state.dart' ;
9
20
import 'package:ouds_theme_contract/ouds_theme.dart' ;
10
21
22
+ enum OudsControlItemType {
23
+ switchButton,
24
+ checkbox,
25
+ radio,
26
+ }
27
+
11
28
/// Refactor of controls for [Checkbox] , [Switch] , and [RadioButton] .
12
29
/// This implementation provides a customizable control item with properties such as text, icon, and interaction states.
13
30
/// It manages its own interaction state and can respond to tap events if not in read-only mode.
@@ -22,7 +39,7 @@ class OudsControlItem extends StatefulWidget {
22
39
final bool readOnly;
23
40
final bool error;
24
41
final String errorComponentName;
25
- final String componentName ;
42
+ final OudsControlItemType componentType ;
26
43
final Widget Function () indicator;
27
44
final String ? additionalText;
28
45
@@ -32,7 +49,7 @@ class OudsControlItem extends StatefulWidget {
32
49
super .key,
33
50
required this .text,
34
51
required this .errorComponentName,
35
- required this .componentName ,
52
+ required this .componentType ,
36
53
required this .indicator,
37
54
this .helperText,
38
55
this .icon,
@@ -187,8 +204,12 @@ class OudsControlItemState extends State<OudsControlItem> {
187
204
),
188
205
alignment: Alignment .center,
189
206
child: SizedBox (
190
- height: widget.componentName != "OudsSwitchButtonItem" ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader : null ,
191
- width: widget.componentName != "OudsSwitchButtonItem" ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader : null ,
207
+ height: widget.componentType != OudsControlItemType .switchButton
208
+ ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader
209
+ : null ,
210
+ width: widget.componentType != OudsControlItemType .switchButton
211
+ ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader
212
+ : null ,
192
213
child: widget.indicator (),
193
214
),
194
215
),
@@ -249,8 +270,12 @@ class OudsControlItemState extends State<OudsControlItem> {
249
270
),
250
271
alignment: Alignment .center,
251
272
child: SizedBox (
252
- height: widget.componentName != "OudsSwitchButtonItem" ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader : null ,
253
- width: widget.componentName != "OudsSwitchButtonItem" ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader : null ,
273
+ height: widget.componentType != OudsControlItemType .switchButton
274
+ ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader
275
+ : null ,
276
+ width: widget.componentType != OudsControlItemType .switchButton
277
+ ? OudsTheme .of (context).componentsTokens (context).controlItem.sizeLoader
278
+ : null ,
254
279
child: widget.indicator (),
255
280
),
256
281
),
@@ -265,39 +290,33 @@ class OudsControlItemState extends State<OudsControlItem> {
265
290
final List <Widget > columnChildren = [
266
291
Text (
267
292
widget.text,
268
- style: TextStyle (
269
- fontSize: OudsTheme .of (context).fontTokens.sizeLabelLarge,
270
- letterSpacing: OudsTheme .of (context).fontTokens.letterSpacingLabelLarge,
271
- fontWeight: OudsTheme .of (context).fontTokens.weightLabelDefault,
272
- color: controlItemTextModifier.getTextColor (controlItemState, widget.error),
273
- ),
293
+ style: OudsTheme .of (context).typographyTokens.typeLabelDefaultLarge (context).copyWith (
294
+ color: controlItemTextModifier.getTextColor (controlItemState, widget.error),
295
+ ),
274
296
),
275
297
];
276
-
277
298
if (hasAdditionalText) {
278
299
columnChildren.add (SizedBox (height: OudsTheme .of (context).componentsTokens (context).controlItem.spaceRowGap));
279
- columnChildren.add (Text (
280
- widget.additionalText! ,
281
- style: TextStyle (
282
- fontSize: OudsTheme .of (context).fontTokens.sizeLabelMedium,
283
- letterSpacing: OudsTheme .of (context).fontTokens.letterSpacingLabelMedium,
284
- fontWeight: OudsTheme .of (context).fontTokens.weightStrong,
285
- color: controlItemTextModifier.getAdditionalTextColor (controlItemState),
300
+ columnChildren.add (
301
+ Text (
302
+ widget.additionalText! ,
303
+ style: OudsTheme .of (context).typographyTokens.typeLabelStrongMedium (context).copyWith (
304
+ color: controlItemTextModifier.getAdditionalTextColor (controlItemState),
305
+ ),
286
306
),
287
- )) ;
307
+ );
288
308
}
289
309
290
310
if (hasHelperText) {
291
311
columnChildren.add (SizedBox (height: OudsTheme .of (context).componentsTokens (context).controlItem.spaceRowGap));
292
- columnChildren.add (Text (
293
- widget.helperText! ,
294
- style: TextStyle (
295
- fontSize: OudsTheme .of (context).fontTokens.sizeLabelMedium,
296
- letterSpacing: OudsTheme .of (context).fontTokens.letterSpacingLabelMedium,
297
- fontWeight: OudsTheme .of (context).fontTokens.weightBodyDefault,
298
- color: controlItemTextModifier.getHelperTextColor (controlItemState),
312
+ columnChildren.add (
313
+ Text (
314
+ widget.helperText! ,
315
+ style: OudsTheme .of (context).typographyTokens.typeLabelDefaultMedium (context).copyWith (
316
+ color: controlItemTextModifier.getHelperTextColor (controlItemState),
317
+ ),
299
318
),
300
- )) ;
319
+ );
301
320
}
302
321
303
322
return Expanded (
0 commit comments