From 4638bd334efc80ba3ceec264e5688557d3ad27d5 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Mon, 21 Dec 2020 16:12:14 +0100 Subject: [PATCH] Switched month instructions to a page --- lib/main.dart | 20 +++++++++ lib/pages/practice/PracticeSetupPage.dart | 2 +- .../instructions/MonthInstructionDialog.dart | 43 ------------------ .../instructions/MonthInstructionPage.dart | 45 +++++++++++++++++++ 4 files changed, 66 insertions(+), 44 deletions(-) delete mode 100644 lib/pages/practice/instructions/MonthInstructionDialog.dart create mode 100644 lib/pages/practice/instructions/MonthInstructionPage.dart diff --git a/lib/main.dart b/lib/main.dart index b1371a6..d740656 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:ohthatsa/pages/practice/PracticePage.dart'; import 'package:ohthatsa/pages/MonthValuesPage.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; +import 'package:ohthatsa/pages/practice/instructions/MonthInstructionPage.dart'; import 'package:ohthatsa/pages/practice/instructions/YearInstructionPage.dart'; import 'package:rxdart/subjects.dart'; import 'package:flutter/services.dart'; @@ -101,6 +102,7 @@ class OhThatsA extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: "OhThatsA", + home: PracticeSetupPage(), onGenerateRoute: RouteGenerator.generateRoute, ); } @@ -109,6 +111,9 @@ class OhThatsA extends StatelessWidget { class RouteGenerator { static Route generateRoute(RouteSettings settings){ switch(settings.name){ + case "/": { + return MaterialPageRoute(builder: (context) => PracticeSetupPage()); + } case "/monthValues": { return MaterialPageRoute(builder: (context) => MonthValuesPage()); } @@ -124,9 +129,24 @@ class RouteGenerator { case "/notifications": { return MaterialPageRoute(builder: (context) => NotificationsPage()); } + case "/instructions/month": { + return MaterialPageRoute(builder: (context) => MonthInstructionPage()); + } case "/instructions/year": { return MaterialPageRoute(builder: (context) => YearInstructionPage()); } + case "/instructions/century": { + return MaterialPageRoute(builder: (context) => YearInstructionPage()); + } + case "/instructions/leap": { + return MaterialPageRoute(builder: (context) => YearInstructionPage()); + } + case "/instructions/mod": { + return MaterialPageRoute(builder: (context) => YearInstructionPage()); + } + case "/instructions/all": { + return MaterialPageRoute(builder: (context) => YearInstructionPage()); + } default: { return null; } diff --git a/lib/pages/practice/PracticeSetupPage.dart b/lib/pages/practice/PracticeSetupPage.dart index 05e8af6..b37f4eb 100644 --- a/lib/pages/practice/PracticeSetupPage.dart +++ b/lib/pages/practice/PracticeSetupPage.dart @@ -6,7 +6,7 @@ import 'package:ohthatsa/pages/practice/PracticeSetup.dart'; import 'package:ohthatsa/pages/practice/PracticeType.dart'; import 'package:ohthatsa/util/Extensions.dart'; -import 'instructions/MonthInstructionDialog.dart'; +import 'instructions/MonthInstructionPage.dart'; class PracticeSetupPage extends StatefulWidget { @override diff --git a/lib/pages/practice/instructions/MonthInstructionDialog.dart b/lib/pages/practice/instructions/MonthInstructionDialog.dart deleted file mode 100644 index d2f57ad..0000000 --- a/lib/pages/practice/instructions/MonthInstructionDialog.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:ohthatsa/util/Months.dart'; - -TableRow getMonthTableRow(MapEntry month) { - return TableRow( - children: [ - TableCell( - child: Text( - month.key, - style: TextStyle(fontSize: 25), - textAlign: TextAlign.right - ) - ), - TableCell( - child: Text( - month.value.value.toString(), - style: TextStyle(fontSize: 25), - textAlign: TextAlign.center - ) - ) - ] - ); -} - -SimpleDialog getMonthInstructionDialog(){ - return SimpleDialog( - title: Text( - "Month Instructions", - style: TextStyle(fontSize: 25, color: Colors.blue), - ), - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text("Memorize these values for every month"), - Table( - children: Months.stringMap.entries.map(getMonthTableRow).toList() - ) - ] - ) - ], - ); -} \ No newline at end of file diff --git a/lib/pages/practice/instructions/MonthInstructionPage.dart b/lib/pages/practice/instructions/MonthInstructionPage.dart new file mode 100644 index 0000000..898ff41 --- /dev/null +++ b/lib/pages/practice/instructions/MonthInstructionPage.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:ohthatsa/other/AppDrawer.dart'; +import 'package:ohthatsa/util/Months.dart'; + +class MonthInstructionPage extends StatelessWidget{ + TableRow getMonthTableRow(MapEntry month) { + return TableRow( + children: [ + TableCell( + child: Text( + month.key, + style: TextStyle(fontSize: 25), + textAlign: TextAlign.right + ) + ), + TableCell( + child: Text( + month.value.value.toString(), + style: TextStyle(fontSize: 25), + textAlign: TextAlign.center + ) + ) + ] + ); + } + + @override + Widget build(BuildContext context){ + return Scaffold( + drawer: AppDrawer(), + appBar: AppBar( + title: Text("Year Instructions") + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Memorize these values:", style: TextStyle(fontSize: 25, color: Colors.blue)), + Table( + children: Months.stringMap.entries.map(getMonthTableRow).toList() + ) + ] + ) + ); + } +} \ No newline at end of file