Created
May 30, 2019 12:23
-
-
Save marinat/5d37b838ede1a1fbbdbd86b3c6806116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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