Skip to content

Commit a844c3a

Browse files
committed
feat(alert-message): add rounded corner config
1 parent 1a21e18 commit a844c3a

16 files changed

Lines changed: 223 additions & 104 deletions

app/lib/l10n/gen/ouds_flutter_app_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ abstract class AppLocalizations {
277277
/// **'Rounded corner text inputs'**
278278
String get app_themeSettingsDialog_roundedCornerTextInputs_label;
279279

280+
/// No description provided for @app_themeSettingsDialog_roundedCornerAlertMessage_label.
281+
///
282+
/// In en, this message translates to:
283+
/// **'Rounded corner alert message'**
284+
String get app_themeSettingsDialog_roundedCornerAlertMessage_label;
285+
280286
/// No description provided for @app_tokens_viewCodeExample_label.
281287
///
282288
/// In en, this message translates to:

app/lib/l10n/gen/ouds_flutter_app_localizations_ar.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class AppLocalizationsAr extends AppLocalizations {
101101
String get app_themeSettingsDialog_roundedCornerTextInputs_label =>
102102
'حقول إدخال نص بزوايا مستديرة';
103103

104+
@override
105+
String get app_themeSettingsDialog_roundedCornerAlertMessage_label =>
106+
'رسالة تنبيه بزوايا مستديرة';
107+
104108
@override
105109
String get app_tokens_viewCodeExample_label => 'عرض مثال على كود الرمز';
106110

app/lib/l10n/gen/ouds_flutter_app_localizations_en.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class AppLocalizationsEn extends AppLocalizations {
101101
String get app_themeSettingsDialog_roundedCornerTextInputs_label =>
102102
'Rounded corner text inputs';
103103

104+
@override
105+
String get app_themeSettingsDialog_roundedCornerAlertMessage_label =>
106+
'Rounded corner alert message';
107+
104108
@override
105109
String get app_tokens_viewCodeExample_label => 'View token code example';
106110

app/lib/l10n/gen/ouds_flutter_app_localizations_fr.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class AppLocalizationsFr extends AppLocalizations {
102102
String get app_themeSettingsDialog_roundedCornerTextInputs_label =>
103103
'Text Inputs avec coins arrondis';
104104

105+
@override
106+
String get app_themeSettingsDialog_roundedCornerAlertMessage_label =>
107+
'Message d’alerte à coins arrondis';
108+
105109
@override
106110
String get app_tokens_viewCodeExample_label =>
107111
'Voir l\'exemple de code du token';

app/lib/l10n/ouds_flutter_ar.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"app_themeSettingsDialog_label": "تغيير إعدادات السمة",
3737
"app_themeSettingsDialog_roundedCornerButtons_label" :"زر بزوايا مستديرة",
3838
"app_themeSettingsDialog_roundedCornerTextInputs_label" :"حقول إدخال نص بزوايا مستديرة",
39+
"app_themeSettingsDialog_roundedCornerAlertMessage_label" :"رسالة تنبيه بزوايا مستديرة",
3940

4041
"@_tokens": {},
4142
"app_tokens_viewCodeExample_label": "عرض مثال على كود الرمز",

app/lib/l10n/ouds_flutter_en.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"app_themeSettingsDialog_label": "Change theme settings",
3939
"app_themeSettingsDialog_roundedCornerButtons_label" :"Rounded corner button",
4040
"app_themeSettingsDialog_roundedCornerTextInputs_label" :"Rounded corner text inputs",
41+
"app_themeSettingsDialog_roundedCornerAlertMessage_label" :"Rounded corner alert message",
4142

4243
"@_tokens": {},
4344
"app_tokens_viewCodeExample_label": "View token code example",

app/lib/l10n/ouds_flutter_fr.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"app_themeSettingsDialog_label": "Changer les réglages du thème",
3939
"app_themeSettingsDialog_roundedCornerButtons_label" :"Buttons avec coins arrondis",
4040
"app_themeSettingsDialog_roundedCornerTextInputs_label" :"Text Inputs avec coins arrondis",
41+
"app_themeSettingsDialog_roundedCornerAlertMessage_label" :"Message d’alerte à coins arrondis",
4142

4243
"@_tokens": {},
4344
"app_tokens_viewCodeExample_label": "Voir l'exemple de code du token",

app/lib/main.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'package:ouds_core/l10n/gen/ouds_localizations.dart';
1717
import 'package:ouds_flutter_demo/l10n/gen/ouds_flutter_app_localizations.dart';
1818
import 'package:ouds_flutter_demo/ui/main_screen.dart';
1919
import 'package:ouds_flutter_demo/ui/theme/theme_controller.dart';
20+
import 'package:ouds_theme_contract/config/component/ouds_alert_message_config_border.dart';
2021
import 'package:ouds_theme_contract/config/component/ouds_button_config.dart';
2122
import 'package:ouds_theme_contract/config/component/ouds_text_input_config.dart';
2223
import 'package:ouds_theme_contract/config/ouds_theme_config_model.dart';
@@ -79,11 +80,19 @@ class _OudsApplicationState extends State<OudsApplication> {
7980
builder: (context, child) {
8081
return Directionality(
8182
textDirection: Directionality.of(context) == TextDirection.rtl
82-
? TextDirection.rtl // If the language is RTL, use TextDirection.rtl
83+
? TextDirection
84+
.rtl // If the language is RTL, use TextDirection.rtl
8385
: TextDirection.ltr, // Otherwise, use TextDirection.ltr
8486
child: OudsThemeConfigModel(
85-
button: OudsButtonConfig(rounded: themeController.onBorderRadiusButtonState),
86-
textInput: OudsTextInputConfig(rounded: themeController.onBorderRadiusTextInputState),
87+
button: OudsButtonConfig(
88+
rounded: themeController.onBorderRadiusButtonState,
89+
),
90+
textInput: OudsTextInputConfig(
91+
rounded: themeController.onBorderRadiusTextInputState,
92+
),
93+
alertMessage: OudsAlertMessageConfig(
94+
rounded: themeController.onBorderRadiusAlertMessageState,
95+
),
8796
child: OudsTheme(
8897
themeContract: themeController.currentTheme,
8998
themeMode: themeController.themeMode,

app/lib/ui/components/button/button_customization.dart

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import 'package:ouds_flutter_demo/ui/utilities/customizable/customizable_widget_
44

55
/// Section for InheritedWidget to pass data down the widget tree
66
class _ButtonCustomization extends InheritedWidget {
7-
const _ButtonCustomization({
8-
required super.child,
9-
required this.data,
10-
});
7+
const _ButtonCustomization({required super.child, required this.data});
118

129
final ButtonCustomizationState data;
1310

@@ -17,26 +14,24 @@ class _ButtonCustomization extends InheritedWidget {
1714

1815
/// Main Widget class for button customization
1916
class ButtonCustomization extends StatefulWidget {
20-
const ButtonCustomization({
21-
super.key,
22-
required this.child,
23-
});
17+
const ButtonCustomization({super.key, required this.child});
2418

2519
final Widget child;
2620

2721
@override
2822
ButtonCustomizationState createState() => ButtonCustomizationState();
2923

3024
static ButtonCustomizationState? of(BuildContext context) {
31-
return (context.dependOnInheritedWidgetOfExactType<_ButtonCustomization>())?.data;
25+
return (context.dependOnInheritedWidgetOfExactType<_ButtonCustomization>())
26+
?.data;
3227
}
3328
}
3429

3530
/// Button customization state management
36-
class ButtonCustomizationState extends CustomizationWidgetState<ButtonCustomization> {
31+
class ButtonCustomizationState
32+
extends CustomizationWidgetState<ButtonCustomization> {
3733
late final AppearanceState appearanceState;
3834
late final LayoutState layoutState;
39-
late final RoundedCornerState roundedCornerState;
4035
late final LoaderState loaderState;
4136
late final FullWidthState fullWidthState;
4237

@@ -46,7 +41,6 @@ class ButtonCustomizationState extends CustomizationWidgetState<ButtonCustomizat
4641
appearanceState = AppearanceState(setState, onColoredBoxState);
4742
loaderState = LoaderState(setState, enabledState);
4843
layoutState = LayoutState(setState);
49-
roundedCornerState = RoundedCornerState(setState);
5044
fullWidthState = FullWidthState(setState);
5145
}
5246

@@ -62,14 +56,12 @@ class ButtonCustomizationState extends CustomizationWidgetState<ButtonCustomizat
6256

6357
// Proxy getters and setters to expose state values directly
6458
ButtonEnumAppearance get selectedAppearance => appearanceState.selected;
65-
set selectedAppearance(ButtonEnumAppearance value) => appearanceState.selected = value;
59+
set selectedAppearance(ButtonEnumAppearance value) =>
60+
appearanceState.selected = value;
6661

6762
ButtonEnumLayout get selectedLayout => layoutState.selected;
6863
set selectedLayout(ButtonEnumLayout value) => layoutState.selected = value;
6964

70-
bool get hasRoundedCorner => roundedCornerState.value;
71-
set hasRoundedCorner(bool value) => roundedCornerState.value = value;
72-
7365
bool get hasLoader => loaderState.value;
7466
set hasLoader(bool value) => loaderState.value = value;
7567

@@ -78,10 +70,7 @@ class ButtonCustomizationState extends CustomizationWidgetState<ButtonCustomizat
7870

7971
@override
8072
Widget build(BuildContext context) {
81-
return _ButtonCustomization(
82-
data: this,
83-
child: widget.child,
84-
);
73+
return _ButtonCustomization(data: this, child: widget.child);
8574
}
8675
}
8776

@@ -99,7 +88,8 @@ class AppearanceState {
9988
ButtonEnumAppearance.minimal,
10089
ButtonEnumAppearance.negative,
10190
];
102-
ButtonEnumAppearance _selectedAppearance = ButtonEnumAppearance.defaultAppearance;
91+
ButtonEnumAppearance _selectedAppearance =
92+
ButtonEnumAppearance.defaultAppearance;
10393

10494
List<ButtonEnumAppearance> get list => _appearance;
10595
set list(List<ButtonEnumAppearance> newList) {
@@ -158,21 +148,6 @@ class LoaderState {
158148
}
159149
}
160150

161-
/// RoundedCorner State Management
162-
class RoundedCornerState {
163-
RoundedCornerState(this._setState);
164-
165-
final void Function(void Function()) _setState;
166-
bool _hasRoundedCorner = false;
167-
168-
bool get value => _hasRoundedCorner;
169-
set value(bool newValue) {
170-
_setState(() {
171-
_hasRoundedCorner = newValue;
172-
});
173-
}
174-
}
175-
176151
/// FullWidth State Management
177152
class FullWidthState {
178153
FullWidthState(this._setState);
@@ -192,12 +167,16 @@ class FullWidthState {
192167
class ButtonErrorCases {
193168
// OnColoredBox behavior: Disable if appearance is 'Negative'
194169
static bool isOnColoredBoxDisabled(ButtonEnumAppearance appearance) {
195-
return appearance == ButtonEnumAppearance.negative || appearance == ButtonEnumAppearance.brand;
170+
return appearance == ButtonEnumAppearance.negative ||
171+
appearance == ButtonEnumAppearance.brand;
196172
}
197173

198174
// OnColoredBox management: Disable when "Negative" appearance is selected
199-
static bool shouldDisableOnColoredBox(ButtonEnumAppearance selectedAppearance) {
200-
return selectedAppearance == ButtonEnumAppearance.negative || selectedAppearance == ButtonEnumAppearance.brand;
175+
static bool shouldDisableOnColoredBox(
176+
ButtonEnumAppearance selectedAppearance,
177+
) {
178+
return selectedAppearance == ButtonEnumAppearance.negative ||
179+
selectedAppearance == ButtonEnumAppearance.brand;
201180
}
202181

203182
// Enabled behavior: Disable if Loader is not null

app/lib/ui/theme/theme_controller.dart

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
2525
bool _onColoredSurface = false;
2626
bool _onBorderRadiusButtonState = false;
2727
bool _onBorderRadiusTextInputState = false;
28+
bool _onBorderRadiusAlertMessageState = false;
2829

2930
/// Getter to access the current theme
3031
OudsThemeContract get currentTheme => _currentTheme;
@@ -38,6 +39,7 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
3839
/// Getter to know if we are on a border state
3940
bool get onBorderRadiusButtonState => _onBorderRadiusButtonState;
4041
bool get onBorderRadiusTextInputState => _onBorderRadiusTextInputState;
42+
bool get onBorderRadiusAlertMessageState => _onBorderRadiusAlertMessageState;
4143

4244
ThemeController(this.fontFamily) {
4345
/// Initialize the theme based on the system's current brightness setting
@@ -65,10 +67,13 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
6567

6668
/// Updates the theme mode based on the platform's brightness setting (light/dark)
6769
void _updateThemeForSystemMode() {
68-
final systemBrightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
70+
final systemBrightness =
71+
WidgetsBinding.instance.platformDispatcher.platformBrightness;
6972

7073
/// Set the theme mode to dark or light based on the platform's brightness
71-
setThemeMode(systemBrightness == Brightness.dark ? ThemeMode.dark : ThemeMode.light);
74+
setThemeMode(
75+
systemBrightness == Brightness.dark ? ThemeMode.dark : ThemeMode.light,
76+
);
7277
}
7378

7479
/// Changes the current theme to the provided theme
@@ -126,14 +131,23 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
126131
}
127132
}
128133

134+
void setOnBorderRadiusAlertMessageState(bool? value) {
135+
bool newValue = value ?? false;
136+
if (_onBorderRadiusAlertMessageState != newValue) {
137+
_onBorderRadiusAlertMessageState = newValue;
138+
notifyListeners();
139+
}
140+
}
141+
129142
/// Returns the ThemeData based on the current theme mode (light or dark)
130143
ThemeData get themeData {
131144
return isDarkTheme ? _currentTheme.darkThemeData : _currentTheme.themeData;
132145
}
133146

134147
bool get isDarkTheme {
135148
if (themeMode == ThemeMode.system) {
136-
final Brightness brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
149+
final Brightness brightness =
150+
WidgetsBinding.instance.platformDispatcher.platformBrightness;
137151
return brightness == Brightness.dark;
138152
} else {
139153
return themeMode == ThemeMode.dark;
@@ -142,7 +156,8 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
142156

143157
bool get isInverseDarkTheme {
144158
if (themeMode == ThemeMode.system) {
145-
final Brightness brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
159+
final Brightness brightness =
160+
WidgetsBinding.instance.platformDispatcher.platformBrightness;
146161
return brightness == Brightness.light;
147162
} else {
148163
return themeMode == ThemeMode.light;
@@ -180,8 +195,10 @@ class ThemeController extends ChangeNotifier with WidgetsBindingObserver {
180195
// Get the current theme name
181196
// replace white space by _
182197
// convert it to lowercase
183-
final themeName = themeController.currentTheme.name.replaceAll(' ', '_').toLowerCase();
198+
final themeName = themeController.currentTheme.name
199+
.replaceAll(' ', '_')
200+
.toLowerCase();
184201
// Build and return the corresponding asset path
185202
return 'assets/$themeName/';
186203
}
187-
}
204+
}

0 commit comments

Comments
 (0)