-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
common_bottom_sheet_buttons.dart
47 lines (41 loc) · 1.22 KB
/
common_bottom_sheet_buttons.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import 'package:flutter/material.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/shared/bottom_sheets/common_button_bar.dart';
class CommonButtonSheetButtons extends StatelessWidget {
final bool showCancelButton;
final bool showOkButton;
final VoidCallback? onOk;
final VoidCallback? onCancel;
final String? cancelText;
final String? okText;
const CommonButtonSheetButtons({
super.key,
this.showCancelButton = true,
this.showOkButton = true,
this.onOk,
this.onCancel,
this.cancelText,
this.okText,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final s = S.of(context);
final cancel = cancelText ?? s.cancel;
final ok = okText ?? s.ok;
return CommonButtonBar(
children: <Widget>[
if (showCancelButton)
OutlinedButton(
onPressed: () => onCancel != null ? onCancel!() : Navigator.pop(context),
child: Text(cancel, style: TextStyle(color: theme.primaryColor)),
),
if (showOkButton)
ElevatedButton(
onPressed: onOk != null ? () => onOk!() : null,
child: Text(ok),
)
],
);
}
}