From eac021d892db4fc96a0b9b3fb83b671e670444c1 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Mon, 27 Jun 2022 00:04:23 -0400 Subject: [PATCH] Add redesigned custom dialog (#90) --- lib/widgets/dialog.dart | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/widgets/dialog.dart diff --git a/lib/widgets/dialog.dart b/lib/widgets/dialog.dart new file mode 100644 index 00000000..aef89948 --- /dev/null +++ b/lib/widgets/dialog.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; + +/// A custom dialog that makes the title bold, puts the actions in a column, and adds a subtle border. +class FrostyDialog extends StatelessWidget { + final String title; + final Widget content; + final List? actions; + + const FrostyDialog({ + Key? key, + this.actions, + required this.title, + required this.content, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return AlertDialog( + titlePadding: const EdgeInsets.all(30.0), + contentPadding: const EdgeInsets.fromLTRB(30.0, 0.0, 30.0, 30.0), + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors.deepPurpleAccent.withOpacity(0.3), + width: 3.0, + ), + borderRadius: BorderRadius.circular(20.0), + ), + title: Text( + title, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + content: SingleChildScrollView( + child: Column(children: [ + content, + if (actions != null) ...[ + const SizedBox(height: 20.0), + ...?actions?.map( + (action) => Container( + width: double.infinity, + padding: const EdgeInsets.only(top: 10.0), + child: action, + ), + ), + ], + ]), + ), + ); + } +}