Changed instructions to a page instead of SimpleDialog, which was being annoying with state
This commit is contained in:
parent
0046da73a0
commit
1f5558bef4
4 changed files with 231 additions and 46 deletions
|
@ -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/YearInstructionPage.dart';
|
||||
import 'package:rxdart/subjects.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
@ -123,6 +124,9 @@ class RouteGenerator {
|
|||
case "/notifications": {
|
||||
return MaterialPageRoute(builder: (context) => NotificationsPage());
|
||||
}
|
||||
case "/instructions/year": {
|
||||
return MaterialPageRoute(builder: (context) => YearInstructionPage());
|
||||
}
|
||||
default: {
|
||||
return MaterialPageRoute(builder: (context) => YearsPage());
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
|||
);
|
||||
},
|
||||
onLongPress: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
child: this.getInstructionDialog(practiceType)
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/instructions/year'
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ohthatsa/util/Months.dart';
|
||||
|
||||
TableRow getMonthTableRow(MapEntry<String, Month> 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: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("Memorize these values for every month"),
|
||||
Table(
|
||||
children: Months.stringMap.entries.map(getMonthTableRow).toList()
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
224
lib/pages/practice/instructions/YearInstructionPage.dart
Normal file
224
lib/pages/practice/instructions/YearInstructionPage.dart
Normal file
|
@ -0,0 +1,224 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:numberpicker/numberpicker.dart';
|
||||
|
||||
import 'package:ohthatsa/other/AppDrawer.dart';
|
||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||
import 'package:term_glyph/term_glyph.dart' as glyph;
|
||||
|
||||
class YearInstructionPage extends StatefulWidget {
|
||||
@override
|
||||
_YearInstructionPageState createState() => _YearInstructionPageState();
|
||||
}
|
||||
|
||||
class _YearInstructionPageState extends State<YearInstructionPage> {
|
||||
int year;
|
||||
int yy;
|
||||
String centuriesString;
|
||||
String yyString;
|
||||
double yyDiv4;
|
||||
int yyDiv4Floored;
|
||||
int yearValue;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
this.setYearValues(DateTime.now().year);
|
||||
}
|
||||
void setYearValues(newYear){
|
||||
year = newYear;
|
||||
yy = year % 100;
|
||||
centuriesString = (year ~/ 100).toString();
|
||||
yyString = year.toString().substring(2);
|
||||
yyDiv4 = yy / 4;
|
||||
yyDiv4Floored = yyDiv4.floor();
|
||||
yearValue = DayCalculator.getYearValue(year);
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
static const formulaStyle = TextStyle(
|
||||
fontSize: 20
|
||||
);
|
||||
static const formulaStyleU = TextStyle(
|
||||
fontSize: 20,
|
||||
decoration: TextDecoration.underline
|
||||
);
|
||||
static const YYStyle = TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 20
|
||||
);
|
||||
static const YYStyleU = TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 20,
|
||||
decoration: TextDecoration.underline
|
||||
);
|
||||
static const pageNum = TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 20
|
||||
);
|
||||
static const pageNumCurrent = TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 20
|
||||
);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawer: AppDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text("Year Instructions")
|
||||
),
|
||||
body: PageView(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(0, 50, 0, 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"Take only the last two digits: ",
|
||||
style: TextStyle(fontSize: 25)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"YY",
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 25
|
||||
)
|
||||
),
|
||||
Text(
|
||||
"YY",
|
||||
style: YYStyle
|
||||
)
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"Calculate:",
|
||||
style: TextStyle(fontSize: 25)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"(",
|
||||
style: formulaStyle,
|
||||
),
|
||||
Text(
|
||||
"YY",
|
||||
style: YYStyle
|
||||
),
|
||||
Text(
|
||||
" + floor(",
|
||||
style: formulaStyle
|
||||
),
|
||||
Text(
|
||||
"YY",
|
||||
style: YYStyle
|
||||
),
|
||||
Text(
|
||||
" / 4)) % 7",
|
||||
style: formulaStyle
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("1", style: pageNumCurrent),
|
||||
Text(" - ", style: pageNum),
|
||||
Text("2", style: pageNum),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
NumberPicker.integer(
|
||||
initialValue: year,
|
||||
minValue: 1700,
|
||||
maxValue: 2399,
|
||||
onChanged: (newYear) => this.setYearValues(newYear)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("For ", style: formulaStyle),
|
||||
Text(centuriesString, style: formulaStyle),
|
||||
Text(year.toString().substring(2), style: YYStyle),
|
||||
Text(" our formula becomes: ", style: formulaStyle),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("(", style: formulaStyle),
|
||||
Text(yyString, style: YYStyle),
|
||||
Text(" + floor(", style: formulaStyle),
|
||||
Text(yyString, style: YYStyleU),
|
||||
Text(" / 4", style: formulaStyleU),
|
||||
Text(")) % 7", style: formulaStyle),
|
||||
],
|
||||
),
|
||||
Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("(", style: formulaStyle),
|
||||
Text(yyString, style: YYStyle),
|
||||
Text(" + ", style: formulaStyle),
|
||||
Text("floor(" + yyDiv4.toString() + ")", style: formulaStyleU),
|
||||
Text(") % 7", style: formulaStyle),
|
||||
],
|
||||
),
|
||||
Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("(", style: formulaStyleU),
|
||||
Text(yyString, style: YYStyleU),
|
||||
Text(" + " + yyDiv4Floored.toString() + ")", style: formulaStyleU),
|
||||
Text(" % 7", style: formulaStyle),
|
||||
],
|
||||
),
|
||||
Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text((yy + yyDiv4Floored).toString(), style: formulaStyleU),
|
||||
Text(" % 7", style: formulaStyleU),
|
||||
],
|
||||
),
|
||||
Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("So the year value of " + year.toString() + " is: ", style: formulaStyle),
|
||||
Text(yearValue.toString(), style: formulaStyleU),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("1", style: pageNum),
|
||||
Text(" - ", style: pageNum),
|
||||
Text("2", style: pageNumCurrent),
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue