Skip to content

Instantly share code, notes, and snippets.

@marinat
Created May 30, 2019 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinat/5d37b838ede1a1fbbdbd86b3c6806116 to your computer and use it in GitHub Desktop.
Save marinat/5d37b838ede1a1fbbdbd86b3c6806116 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:gusli_flutter/utils/gusli_icons.dart';
class IconDialog extends StatelessWidget {
final String titleText;
final Icon icon;
final Widget content;
final String positiveButton;
final Function positiveClick;
final String negativeButton;
final Function negativeClick;
final String neutralButton;
final Function neutralClick;
IconDialog(
{Key key,
@required this.titleText,
@required this.icon,
this.content,
@required this.positiveButton,
this.positiveClick,
this.negativeButton,
this.negativeClick,
this.neutralButton,
this.neutralClick})
: super(key: key);
@override
Widget build(BuildContext context) {
List<Widget> actions = [];
if (negativeButton != null) {
actions.add(FlatButton(
onPressed: () {
Navigator.pop(context);
if (negativeClick != null) negativeClick();
},
child: Text(
negativeButton,
style: TextStyle(
color: Theme.of(context).primaryColorLight, fontSize: 17.0),
),
));
}
if (neutralButton != null) {
actions.add(FlatButton(
onPressed: () {
Navigator.pop(context);
if (neutralClick != null) neutralClick();
},
child: Text(
neutralButton,
style:
TextStyle(color: Theme.of(context).accentColor, fontSize: 17.0),
),
));
}
actions.add(RaisedButton(
color: Theme.of(context).accentColor,
onPressed: () {
Navigator.pop(context);
if (positiveClick != null) positiveClick();
},
child: Text(
positiveButton,
style: TextStyle(fontSize: 17.0, color: Colors.white),
),
));
return AlertDialog(
title: Center(
child: Column(
children: <Widget>[
icon,
Padding(
padding: EdgeInsets.only(top: 16.0),
child: Text(titleText),
)
],
),
),
backgroundColor: Theme.of(context).primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(15))),
content: content,
actions: actions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment