From e957c0085ce3cb3dc277d570d1377a6d1b7bfedf Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 29 Nov 2019 09:59:56 +0200 Subject: [PATCH] Settings --- lib/ui/app/invoice/invoice_email_view.dart | 22 +++--- lib/ui/settings/templates_and_reminders.dart | 77 +++++++++++++------- 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/lib/ui/app/invoice/invoice_email_view.dart b/lib/ui/app/invoice/invoice_email_view.dart index e5d2ef299..51eee4f01 100644 --- a/lib/ui/app/invoice/invoice_email_view.dart +++ b/lib/ui/app/invoice/invoice_email_view.dart @@ -34,7 +34,8 @@ class _InvoiceEmailViewState extends State String _emailBody; String _lastSubject; String _lastBody; - String _templatePreview = ''; + String _bodyPreview = ''; + String _subjectPreview = ''; bool _isLoading = false; final _debouncer = Debouncer(); @@ -161,7 +162,8 @@ class _InvoiceEmailViewState extends State onComplete: (subject, body) { setState(() { _isLoading = false; - //_templatePreview = 'data:text/html;base64,$response'; + _subjectPreview = subject; + _bodyPreview = body; }); }); } @@ -170,6 +172,7 @@ class _InvoiceEmailViewState extends State final localization = AppLocalization.of(context); return Column( + mainAxisSize: MainAxisSize.max, children: [ Container( color: Theme.of(context).backgroundColor, @@ -210,17 +213,10 @@ class _InvoiceEmailViewState extends State ), ), Expanded( - child: Column( - children: [ - Expanded( - child: TemplatePreview(_templatePreview), - ), - if (_isLoading) - SizedBox( - height: 4.0, - child: LinearProgressIndicator(), - ) - ], + child: EmailPreview( + isLoading: _isLoading, + subject: _subjectPreview, + body: _bodyPreview, ), ), ], diff --git a/lib/ui/settings/templates_and_reminders.dart b/lib/ui/settings/templates_and_reminders.dart index 092278cff..71c53b8be 100644 --- a/lib/ui/settings/templates_and_reminders.dart +++ b/lib/ui/settings/templates_and_reminders.dart @@ -354,34 +354,10 @@ class _TemplatesAndRemindersState extends State ), ], ), - Container( - color: Colors.white, - //padding: const EdgeInsets.all(10), - child: Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - child: Text( - _subjectPreview, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 20, - ), - ), - padding: const EdgeInsets.only(left: 8, top: 12, bottom: 8, right: 8), - ), - Expanded( - child: TemplatePreview(_bodyPreview), - ), - if (_isLoading) - SizedBox( - height: 4.0, - child: LinearProgressIndicator(), - ) - ], - ), + EmailPreview( + isLoading: _isLoading, + subject: _subjectPreview, + body: _bodyPreview, ), ], ), @@ -578,3 +554,48 @@ class _TemplatePreviewState extends State ); } } + +class EmailPreview extends StatelessWidget { + const EmailPreview({ + @required this.subject, + @required this.body, + @required this.isLoading, + }); + + final String subject; + final String body; + final bool isLoading; + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: + const EdgeInsets.only(left: 8, top: 12, bottom: 8, right: 8), + child: Text( + subject, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), + ), + Expanded( + child: TemplatePreview(body), + ), + if (isLoading) + SizedBox( + height: 4.0, + child: LinearProgressIndicator(), + ) + ], + ), + ); + } +}