Skip to content

Commit 9ee4ec7

Browse files
authored
Pass TextStyle to showConfirmationDialog/showModalActionSheet (#124)
2 parents eb2c009 + 594571c commit 9ee4ec7

File tree

7 files changed

+60
-3
lines changed

7 files changed

+60
-3
lines changed

example/lib/pages/alert_page.dart

+23
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,29 @@ class AlertPage extends StatelessWidget {
267267
logger.info(result);
268268
},
269269
),
270+
ListTile(
271+
title: const Text(
272+
'showConfirmationDialog (custom TextStyle)',
273+
),
274+
onTap: () async {
275+
final result = await showConfirmationDialog(
276+
context: context,
277+
title: 'Title',
278+
message: 'This is message.',
279+
actions: [
280+
const AlertDialogAction(
281+
key: 'a',
282+
label: 'A',
283+
textStyle: TextStyle(
284+
color: Colors.yellow,
285+
fontSize: 50,
286+
),
287+
),
288+
],
289+
);
290+
logger.info(result);
291+
},
292+
),
270293
],
271294
),
272295
);

example/lib/pages/sheet_page.dart

+23
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,29 @@ class SheetPage extends StatelessWidget {
204204
logger.info(result);
205205
},
206206
),
207+
ListTile(
208+
title: const Text(
209+
'showModalActionSheet (custom TextStyle)',
210+
),
211+
onTap: () async {
212+
final result = await showModalActionSheet(
213+
context: context,
214+
title: 'Title',
215+
message: 'This is message.',
216+
actions: [
217+
const SheetAction(
218+
key: 'a',
219+
label: 'A',
220+
textStyle: TextStyle(
221+
color: Colors.yellow,
222+
fontSize: 50,
223+
),
224+
),
225+
],
226+
);
227+
logger.info(result);
228+
},
229+
),
207230
],
208231
),
209232
);

lib/src/alert_dialog/alert_dialog_action.dart

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extension AlertDialogActionListEx<T> on List<AlertDialogAction<T>> {
8787
label: a.label,
8888
isDefaultAction: a.isDefaultAction,
8989
isDestructiveAction: a.isDestructiveAction,
90+
textStyle: a.textStyle,
9091
),
9192
)
9293
.toList();

lib/src/alert_dialog/show_confirmation_dialog.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ class _ConfirmationMaterialDialogState<T>
179179
children: widget.actions
180180
.map(
181181
(action) => RadioListTile<T>(
182-
title: Text(action.label),
182+
title: Text(
183+
action.label,
184+
style: action.textStyle,
185+
),
183186
value: action.key,
184187
groupValue: _selectedKey,
185188
onChanged: (value) {

lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class CupertinoModalActionSheet<T> extends StatelessWidget {
5858
isDestructiveAction: a.isDestructiveAction,
5959
isDefaultAction: a.isDefaultAction,
6060
onPressed: () => onPressed(a.key),
61-
child: Text(a.label),
61+
child: Text(
62+
a.label,
63+
style: a.textStyle,
64+
),
6265
),
6366
)
6467
.toList(),

lib/src/modal_action_sheet/material_modal_action_sheet.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:adaptive_dialog/src/action_callback.dart';
22
import 'package:flutter/material.dart';
3+
34
import 'modal_action_sheet.dart';
45

56
class MaterialModalActionSheet<T> extends StatelessWidget {
@@ -62,7 +63,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
6263
a.label,
6364
style: TextStyle(
6465
color: color,
65-
),
66+
).merge(a.textStyle),
6667
),
6768
onTap: () => onPressed(a.key),
6869
);

lib/src/modal_action_sheet/sheet_action.dart

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart';
55
class SheetAction<T> {
66
const SheetAction({
77
required this.label,
8+
this.textStyle = const TextStyle(),
89
this.key,
910
this.icon,
1011
this.isDefaultAction = false,
@@ -24,4 +25,6 @@ class SheetAction<T> {
2425

2526
/// Make font color to destructive/error color(red).
2627
final bool isDestructiveAction;
28+
29+
final TextStyle textStyle;
2730
}

0 commit comments

Comments
 (0)