Skip to content

Commit 1043de4

Browse files
author
Alberto Aguilar Garcia WORDLINE
committed
Merge branch 'OSAM-21579_version_control_popup_flexibility' into 'feat/OSAM_april_2026'
OSAM-21579_version_control_popup_flexibility See merge request osam/common_module_flutter!19
1 parent 5c90217 commit 1043de4

7 files changed

Lines changed: 229 additions & 63 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 8.1.4-dev
1+
## 8.1.5-dev
22

33
* IMPLEMENTED STYLES FLEXIBILITY FOR CUSTOM POPUPS
44
* Added a parameter when building the version control popup for adding foreign styles or keeping their own.

lib/osam_common_module_flutter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ export 'src/model/subscription_response.dart';
1010
export 'src/model/token_response.dart';
1111
export 'src/model/version.dart';
1212
export 'src/model/version_control_response.dart';
13+
export 'src/model/version_control_result.dart';
1314
export 'src/osam.dart';
15+
export 'src/ui/alert_wrapper.dart';
1416
export 'src/ui/ui_helper.dart';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:osam_common_module_flutter/src/model/version_control_response.dart';
2+
3+
/// Result of the version control dialog
4+
class VersionControlResult {
5+
/// The user action with the version control popup
6+
final VersionControlResponse response;
7+
8+
/// Whether the "Don't show again" checkbox was checked
9+
final bool isCheckBoxChecked;
10+
11+
VersionControlResult({
12+
required this.response,
13+
required this.isCheckBoxChecked,
14+
});
15+
}

lib/src/osam.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class OSAM {
143143
{
144144
'language': language.toLanguageCode(),
145145
'isDarkMode': isDarkMode,
146-
'applyComModStyles': applyComModStyles
146+
'applyComModStyles': applyComModStyles,
147147
},
148148
);
149149
return VersionControlResponseExtensions.fromString(response ?? '');

lib/src/ui/alert_wrapper.dart

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:osam_common_module_flutter/osam_common_module_flutter.dart';
3+
4+
/// A wrapper for showing different types of alerts
5+
class AlertWrapper {
6+
final BuildContext context;
7+
8+
AlertWrapper(this.context);
9+
10+
/// Shows a forced version control dialog (no close, no negative, no checkbox)
11+
Future<VersionControlResult?> showVersionControlForce({
12+
required Version version,
13+
required Language language,
14+
bool isDarkMode = false,
15+
bool applyComModStyles = false,
16+
}) {
17+
return UIHelper.showVersionDialog(
18+
context: context,
19+
version: version,
20+
language: language,
21+
showNegative: false,
22+
showClose: false,
23+
showCheckBox: false,
24+
isDarkMode: isDarkMode,
25+
applyComModStyles: applyComModStyles,
26+
);
27+
}
28+
29+
/// Shows a lazy version control dialog (with close, negative, and checkbox)
30+
Future<VersionControlResult?> showVersionControlLazy({
31+
required Version version,
32+
required Language language,
33+
bool isDarkMode = false,
34+
bool applyComModStyles = false,
35+
}) {
36+
return UIHelper.showVersionDialog(
37+
context: context,
38+
version: version,
39+
language: language,
40+
isDarkMode: isDarkMode,
41+
applyComModStyles: applyComModStyles,
42+
);
43+
}
44+
45+
/// Shows an info version control dialog (with close, but no negative)
46+
Future<VersionControlResult?> showVersionControlInfo({
47+
required Version version,
48+
required Language language,
49+
bool isDarkMode = false,
50+
bool applyComModStyles = false,
51+
}) {
52+
return UIHelper.showVersionDialog(
53+
context: context,
54+
version: version,
55+
language: language,
56+
showNegative: false,
57+
isDarkMode: isDarkMode,
58+
applyComModStyles: applyComModStyles,
59+
);
60+
}
61+
62+
/// Triggers the rating popup flow
63+
Future<RatingControlResponse> showRating({
64+
required OSAM osam,
65+
required Language language,
66+
bool isDarkMode = false,
67+
}) {
68+
return osam.rating(
69+
language: language,
70+
isDarkMode: isDarkMode,
71+
);
72+
}
73+
}

lib/src/ui/ui_helper.dart

Lines changed: 136 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ import 'package:flutter/material.dart';
22
import 'package:osam_common_module_flutter/src/model/language.dart';
33
import 'package:osam_common_module_flutter/src/model/version.dart';
44
import '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

67
class 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

Comments
 (0)