@@ -2,22 +2,24 @@ import 'package:flutter/material.dart';
22import 'package:osam_common_module_flutter/src/model/language.dart' ;
33import 'package:osam_common_module_flutter/src/model/version.dart' ;
44import 'package:osam_common_module_flutter/src/model/version_control_response.dart' ;
5+ import 'package:osam_common_module_flutter/src/model/version_control_result.dart' ;
56
67class UIHelper {
78 static const Color veryDarkGrey = Color (0xFF1C1C1C );
89 static const Color mediumLightGrey = Color (0xFFB0B0B0 );
910
10- static Future <VersionControlResponse ?> showVersionDialog ({
11+ static Future <VersionControlResult ?> showVersionDialog ({
1112 required BuildContext context,
1213 required Version version,
1314 required Language language,
1415 bool showNegative = true ,
1516 bool showClose = true ,
1617 bool showCheckBox = true ,
1718 bool isDarkMode = false ,
19+ bool applyComModStyles = false ,
1820 Widget ? appIcon,
1921 }) {
20- return showDialog <VersionControlResponse >(
22+ return showDialog <VersionControlResult >(
2123 context: context,
2224 barrierDismissible: showClose,
2325 builder: (BuildContext context) {
@@ -28,6 +30,7 @@ class UIHelper {
2830 showClose: showClose,
2931 showCheckBox: showCheckBox,
3032 isDarkMode: isDarkMode,
33+ applyComModStyles: applyComModStyles,
3134 appIcon: appIcon,
3235 );
3336 },
@@ -42,6 +45,7 @@ class OSAMDialog extends StatefulWidget {
4245 final bool showClose;
4346 final bool showCheckBox;
4447 final bool isDarkMode;
48+ final bool applyComModStyles;
4549 final Widget ? appIcon;
4650
4751 const OSAMDialog ({
@@ -52,6 +56,7 @@ class OSAMDialog extends StatefulWidget {
5256 required this .showClose,
5357 required this .showCheckBox,
5458 required this .isDarkMode,
59+ this .applyComModStyles = false ,
5560 this .appIcon,
5661 });
5762
@@ -64,13 +69,45 @@ class _OSAMDialogState extends State<OSAMDialog> {
6469
6570 @override
6671 Widget build (BuildContext context) {
67- final Color backgroundColor =
68- widget.isDarkMode ? UIHelper .veryDarkGrey : Colors .white;
69- final Color textColor = widget.isDarkMode ? Colors .white : Colors .black;
70- final Color primaryButtonColor =
71- widget.isDarkMode ? Colors .white : UIHelper .veryDarkGrey;
72- final Color primaryButtonTextColor =
73- widget.isDarkMode ? UIHelper .veryDarkGrey : Colors .white;
72+ final Color backgroundColor;
73+ final Color textColor;
74+ final Color primaryButtonColor;
75+ final Color primaryButtonTextColor;
76+ final Color secondaryButtonTextColor;
77+ final BorderSide ? secondaryButtonBorder;
78+ final Color checkboxActiveColor;
79+ final Color checkboxCheckColor;
80+ final Color closeIconColor;
81+
82+ if (widget.applyComModStyles) {
83+ backgroundColor =
84+ widget.isDarkMode ? UIHelper .veryDarkGrey : Colors .white;
85+ textColor = widget.isDarkMode ? Colors .white : Colors .black;
86+ primaryButtonColor =
87+ widget.isDarkMode ? Colors .white : UIHelper .veryDarkGrey;
88+ primaryButtonTextColor =
89+ widget.isDarkMode ? UIHelper .veryDarkGrey : Colors .white;
90+ secondaryButtonTextColor =
91+ widget.isDarkMode ? Colors .white : UIHelper .veryDarkGrey;
92+ secondaryButtonBorder = BorderSide (
93+ color: widget.isDarkMode ? Colors .white : UIHelper .mediumLightGrey,
94+ );
95+ checkboxActiveColor =
96+ widget.isDarkMode ? Colors .white : UIHelper .veryDarkGrey;
97+ checkboxCheckColor =
98+ widget.isDarkMode ? UIHelper .veryDarkGrey : Colors .white;
99+ closeIconColor = widget.isDarkMode ? Colors .white : Colors .black;
100+ } else {
101+ backgroundColor = widget.isDarkMode ? Colors .black : Colors .white;
102+ textColor = widget.isDarkMode ? Colors .white : Colors .black;
103+ primaryButtonColor = Colors .transparent;
104+ primaryButtonTextColor = Colors .grey[800 ]! ; // Approx DKGRAY
105+ secondaryButtonTextColor = Colors .grey[800 ]! ;
106+ secondaryButtonBorder = null ;
107+ checkboxActiveColor = Theme .of (context).primaryColor;
108+ checkboxCheckColor = Colors .white;
109+ closeIconColor = Colors .grey[800 ]! ;
110+ }
74111
75112 return Dialog (
76113 backgroundColor: backgroundColor,
@@ -91,11 +128,15 @@ class _OSAMDialogState extends State<OSAMDialog> {
91128 constraints: const BoxConstraints (),
92129 icon: Icon (
93130 Icons .close,
94- color: widget.isDarkMode ? Colors .white : Colors .black ,
131+ color: closeIconColor ,
95132 size: 24 ,
96133 ),
97- onPressed: () => Navigator .of (context)
98- .pop (VersionControlResponse .CANCELLED ),
134+ onPressed: () => Navigator .of (context).pop (
135+ VersionControlResult (
136+ response: VersionControlResponse .CANCELLED ,
137+ isCheckBoxChecked: _dontShowAgain,
138+ ),
139+ ),
99140 ),
100141 ),
101142 if (widget.appIcon != null )
@@ -109,14 +150,17 @@ class _OSAMDialogState extends State<OSAMDialog> {
109150 ),
110151 Padding (
111152 padding: const EdgeInsets .only (top: 16.0 ),
112- child: Text (
113- widget.version.title.localize (widget.language),
114- style: TextStyle (
115- fontSize: 22 ,
116- fontWeight: FontWeight .w600,
117- color: textColor,
153+ child: Semantics (
154+ header: true ,
155+ child: Text (
156+ widget.version.title.localize (widget.language),
157+ style: TextStyle (
158+ fontSize: 22 ,
159+ fontWeight: FontWeight .w600,
160+ color: textColor,
161+ ),
162+ textAlign: TextAlign .center,
118163 ),
119- textAlign: TextAlign .center,
120164 ),
121165 ),
122166 Padding (
@@ -144,12 +188,8 @@ class _OSAMDialogState extends State<OSAMDialog> {
144188 ),
145189 child: Checkbox (
146190 value: _dontShowAgain,
147- activeColor: widget.isDarkMode
148- ? Colors .white
149- : UIHelper .veryDarkGrey,
150- checkColor: widget.isDarkMode
151- ? UIHelper .veryDarkGrey
152- : Colors .white,
191+ activeColor: checkboxActiveColor,
192+ checkColor: checkboxCheckColor,
153193 onChanged: (value) {
154194 setState (() {
155195 _dontShowAgain = value ?? false ;
@@ -172,22 +212,42 @@ class _OSAMDialogState extends State<OSAMDialog> {
172212 child: SizedBox (
173213 width: double .infinity,
174214 height: 48 ,
175- child: ElevatedButton (
176- onPressed: () => Navigator .of (context)
177- .pop (VersionControlResponse .ACCEPTED ),
178- style: ElevatedButton .styleFrom (
179- backgroundColor: primaryButtonColor,
180- foregroundColor: primaryButtonTextColor,
181- shape: RoundedRectangleBorder (
182- borderRadius: BorderRadius .circular (28 ),
183- ),
184- elevation: 0 ,
185- ),
186- child: Text (
187- widget.version.ok.localize (widget.language),
188- style: const TextStyle (fontSize: 16 ),
189- ),
190- ),
215+ child: widget.applyComModStyles
216+ ? ElevatedButton (
217+ onPressed: () => Navigator .of (context).pop (
218+ VersionControlResult (
219+ response: VersionControlResponse .ACCEPTED ,
220+ isCheckBoxChecked: _dontShowAgain,
221+ ),
222+ ),
223+ style: ElevatedButton .styleFrom (
224+ backgroundColor: primaryButtonColor,
225+ foregroundColor: primaryButtonTextColor,
226+ shape: RoundedRectangleBorder (
227+ borderRadius: BorderRadius .circular (28 ),
228+ ),
229+ elevation: 0 ,
230+ ),
231+ child: Text (
232+ widget.version.ok.localize (widget.language),
233+ style: const TextStyle (fontSize: 16 ),
234+ ),
235+ )
236+ : TextButton (
237+ onPressed: () => Navigator .of (context).pop (
238+ VersionControlResult (
239+ response: VersionControlResponse .ACCEPTED ,
240+ isCheckBoxChecked: _dontShowAgain,
241+ ),
242+ ),
243+ style: TextButton .styleFrom (
244+ foregroundColor: primaryButtonTextColor,
245+ ),
246+ child: Text (
247+ widget.version.ok.localize (widget.language),
248+ style: const TextStyle (fontSize: 16 ),
249+ ),
250+ ),
191251 ),
192252 ),
193253 if (widget.showNegative)
@@ -196,25 +256,41 @@ class _OSAMDialogState extends State<OSAMDialog> {
196256 child: SizedBox (
197257 width: double .infinity,
198258 height: 48 ,
199- child: OutlinedButton (
200- onPressed: () => Navigator .of (context)
201- .pop (VersionControlResponse .CANCELLED ),
202- style: OutlinedButton .styleFrom (
203- side: BorderSide (
204- color: widget.isDarkMode
205- ? Colors .white
206- : UIHelper .mediumLightGrey,
207- ),
208- shape: RoundedRectangleBorder (
209- borderRadius: BorderRadius .circular (28 ),
210- ),
211- foregroundColor: textColor,
212- ),
213- child: Text (
214- widget.version.cancel.localize (widget.language),
215- style: const TextStyle (fontSize: 16 ),
216- ),
217- ),
259+ child: widget.applyComModStyles
260+ ? OutlinedButton (
261+ onPressed: () => Navigator .of (context).pop (
262+ VersionControlResult (
263+ response: VersionControlResponse .CANCELLED ,
264+ isCheckBoxChecked: _dontShowAgain,
265+ ),
266+ ),
267+ style: OutlinedButton .styleFrom (
268+ side: secondaryButtonBorder,
269+ shape: RoundedRectangleBorder (
270+ borderRadius: BorderRadius .circular (28 ),
271+ ),
272+ foregroundColor: secondaryButtonTextColor,
273+ ),
274+ child: Text (
275+ widget.version.cancel.localize (widget.language),
276+ style: const TextStyle (fontSize: 16 ),
277+ ),
278+ )
279+ : TextButton (
280+ onPressed: () => Navigator .of (context).pop (
281+ VersionControlResult (
282+ response: VersionControlResponse .CANCELLED ,
283+ isCheckBoxChecked: _dontShowAgain,
284+ ),
285+ ),
286+ style: TextButton .styleFrom (
287+ foregroundColor: secondaryButtonTextColor,
288+ ),
289+ child: Text (
290+ widget.version.cancel.localize (widget.language),
291+ style: const TextStyle (fontSize: 16 ),
292+ ),
293+ ),
218294 ),
219295 ),
220296 ],
0 commit comments