From 034d7877313298cd2ee7ddd4bb9782d4cf9d0574 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Mon, 26 Oct 2020 17:51:53 +0100 Subject: [PATCH] Added a dialog popup when month practice is complete --- .../practice/month/MonthPracticePage.dart | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/pages/practice/month/MonthPracticePage.dart b/lib/pages/practice/month/MonthPracticePage.dart index c7392ea..6448168 100644 --- a/lib/pages/practice/month/MonthPracticePage.dart +++ b/lib/pages/practice/month/MonthPracticePage.dart @@ -157,6 +157,51 @@ class _MonthPracticeState extends State { ); } + Future _finishedPractice() { + showDialog( + context: context, + child: SimpleDialog( + title: Text("Practice Complete!"), + contentPadding: EdgeInsets.all(50), + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text("Rounds of Practice:"), + Text(_startCount.toString()) + ] + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text("Correct:"), + Text(_correct.toString()), + ] + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text("Incorrect:"), + Text(_incorrect.toString()), + ] + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + (_correct / _startCount * 100).round().toString() + "%", + style: TextStyle( + color: (_correct / _startCount * 100) > 70 ? Colors.green : Colors.red, + fontSize: 30, + ) + ), + ] + ), + ] + ) + ); + } + @override Widget build(BuildContext context) { PracticeSetup setup = ModalRoute.of(context).settings.arguments; @@ -217,6 +262,7 @@ class _MonthPracticeState extends State { _count += 1; answers.add(MonthPracticeAnswer(_month, answer)); if((_startCount - _count) == 0) { + _finishedPractice(); Navigator.pop(context); return; }