Skip to content

Commit

Permalink
refactor(material_buttons): migrated to the new specification
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Jan 24, 2021
1 parent c3d8003 commit e0e649f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
26 changes: 20 additions & 6 deletions lib/widgets/layout/danger_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,42 @@ class DangerAlertDialog extends StatelessWidget {

@override
Widget build(BuildContext context) {
const buttonPadding =
EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0);

return AlertDialog(
title: Text(title),
content: Text(content),
actionsPadding: const EdgeInsets.all(8.0),
actions: [
FlatButton(
TextButton(
style: TextButton.styleFrom(
padding: buttonPadding,
),
onPressed: () {
Navigator.of(context).pop(false);
},
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0),
child: Text(
(cancelText ?? MaterialLocalizations.of(context).cancelButtonLabel)
.toUpperCase(),
),
),
FlatButton(
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
},
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0),
hoverColor: Colors.red.withOpacity(0.1),
splashColor: Colors.red.withOpacity(0.15),
style: ButtonStyle(
padding: MaterialStateProperty.all(buttonPadding),
overlayColor: MaterialStateProperty.resolveWith<Color>((states) {
if (states.contains(MaterialState.hovered)) {
return Colors.red.withOpacity(0.1);
} else if (states.contains(MaterialState.pressed)) {
return Colors.red.withOpacity(0.15);
}

return null;
}),
),
child: Text(
(okText ?? MaterialLocalizations.of(context).deleteButtonTooltip)
.toUpperCase(),
Expand Down
6 changes: 4 additions & 2 deletions lib/widgets/layout/day_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class DayNavigation extends StatelessWidget {
builder: (context, dayHandler, child) {
return Row(
children: [
FlatButton(
padding: const EdgeInsets.symmetric(vertical: 18.0),
TextButton(
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16.0),
),
onPressed: () => dayHandler.changeToNow(),
child: Text(appLocalizations.today),
),
Expand Down
19 changes: 11 additions & 8 deletions lib/widgets/layout/radio_button_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ class _RadioButtonListState extends State<RadioButtonList> {
Padding(
padding:
EdgeInsets.only(bottom: i == widget._lastLoopIndex ? 0.0 : 4.0),
child: FlatButton(
color: _selectedIndex == i
? theme.colorScheme.secondaryVariant
: null,
textTheme: ButtonTextTheme.primary,
textColor: _selectedIndex == i ? null : theme.hintColor,
padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: TextButton(
style: ElevatedButton.styleFrom(
primary: _selectedIndex == i
? theme.colorScheme.secondaryVariant
: null,
onPrimary: _selectedIndex == i ? Colors.white : theme.hintColor,
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
),
),
onPressed: () {
if (i != _selectedIndex) {
setState(() => _selectedIndex = i);
Expand Down

0 comments on commit e0e649f

Please sign in to comment.