Added leap year instruction page
This commit is contained in:
parent
5942ec9a73
commit
6e9f476017
2 changed files with 135 additions and 1 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/LeapInstructionPage.dart';
|
||||
import 'package:ohthatsa/pages/practice/instructions/MonthInstructionPage.dart';
|
||||
import 'package:ohthatsa/pages/practice/instructions/YearInstructionPage.dart';
|
||||
import 'package:ohthatsa/pages/practice/instructions/CenturyInstructionPage.dart';
|
||||
|
@ -140,7 +141,7 @@ class RouteGenerator {
|
|||
return MaterialPageRoute(builder: (context) => CenturyInstructionPage());
|
||||
}
|
||||
case "/instructions/leap": {
|
||||
return MaterialPageRoute(builder: (context) => YearInstructionPage());
|
||||
return MaterialPageRoute(builder: (context) => LeapInstructionPage());
|
||||
}
|
||||
case "/instructions/mod": {
|
||||
return MaterialPageRoute(builder: (context) => YearInstructionPage());
|
||||
|
|
133
lib/pages/practice/instructions/LeapInstructionPage.dart
Normal file
133
lib/pages/practice/instructions/LeapInstructionPage.dart
Normal file
|
@ -0,0 +1,133 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:numberpicker/numberpicker.dart';
|
||||
import 'package:ohthatsa/other/AppDrawer.dart';
|
||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||
import 'package:ohthatsa/util/Months.dart';
|
||||
|
||||
class LeapInstructionPage extends StatefulWidget {
|
||||
@override
|
||||
_LeapInstructionPageState createState() => _LeapInstructionPageState();
|
||||
}
|
||||
|
||||
class _LeapInstructionPageState extends State<LeapInstructionPage> {
|
||||
int year;
|
||||
bool isLeapYear;
|
||||
bool divBy4;
|
||||
bool divBy100;
|
||||
bool divBy400;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
this.setYear(DateTime.now().year);
|
||||
}
|
||||
|
||||
void setYear(int newYear){
|
||||
year = newYear;
|
||||
isLeapYear = DayCalculator.isLeapYear(year);
|
||||
divBy4 = (year % 4) == 0;
|
||||
divBy100 = (year % 100) == 0;
|
||||
divBy400 = (year % 400) == 0;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
static const textStyle = TextStyle(
|
||||
fontSize: 20
|
||||
);
|
||||
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("Leap Year Instructions")
|
||||
),
|
||||
|
||||
body: PageView(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(0, 50, 0, 10),
|
||||
child:Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("A year is a leap year if...", style: textStyle),
|
||||
Text("It is divisible by 4, unless...", style: textStyle),
|
||||
Text("It's also divisible by 100, unless...", style: textStyle),
|
||||
Text("It's divisible by 400", style: textStyle),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("1", style: pageNumCurrent),
|
||||
Text(" - ", style: pageNum),
|
||||
Text("2", style: pageNum),
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(0, 50, 0, 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
NumberPicker.integer(
|
||||
initialValue: year,
|
||||
minValue: 0,
|
||||
maxValue: 10000,
|
||||
onChanged: (newYear) => { this.setYear(newYear) }
|
||||
),
|
||||
Visibility(
|
||||
visible: divBy4,
|
||||
child: Text(year.toString() + " is divisible by 4", style: textStyle)
|
||||
),
|
||||
Visibility(
|
||||
visible: divBy100,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("But...", style: textStyle),
|
||||
Text(year.toString() + " is also divisible by 100", style: textStyle)
|
||||
],
|
||||
)
|
||||
),
|
||||
Visibility(
|
||||
visible: divBy400,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("But...", style: textStyle),
|
||||
Text(year.toString() + " is also divisible by 400", style: textStyle)
|
||||
],
|
||||
)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("So " + year.toString() + " is", style: textStyle),
|
||||
Text(this.isLeapYear ? " " : " not ", style: textStyle),
|
||||
Text("a leap year", style: textStyle)
|
||||
],
|
||||
),
|
||||
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