diff --git a/lib/YearsPage.dart b/lib/YearsPage.dart index e01f5ac..b83e9e5 100644 --- a/lib/YearsPage.dart +++ b/lib/YearsPage.dart @@ -1,18 +1,40 @@ import 'package:flutter/material.dart'; +import 'package:numberpicker/numberpicker.dart'; +import 'package:ohthatsa/DayCalculator.dart'; + import 'AppDrawer.dart'; -class YearsPage extends StatelessWidget { +class YearsPage extends StatefulWidget { + @override + _YearsPageState createState() => _YearsPageState(); +} + +class _YearsPageState extends State { + int _year = new DateTime.now().year; @override Widget build(BuildContext context){ return Scaffold( - drawer: AppDrawer(), - appBar: AppBar( - title: Text("Overview"), - ), - body: Center( - child: Text("Years page") - ) + drawer: AppDrawer(), + appBar: AppBar( + title: Text("Overview"), + ), + body: Center( + child: new Column( + children: [ + new NumberPicker.integer( + initialValue: _year, // TODO set to current year + minValue: 1800, + maxValue: 2399, + onChanged: (newYear) => + setState(() => _year = newYear), + ), + new Text("You picked the year: $_year"), + new Text("The century code is: " + DayCalculator.getCenturyValue(_year).toString()), + new Text("Is this a leap year: " + DayCalculator.isLeapYear(_year).toString()), + ] + ) + ) ); } } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 2818e3e..15f31ac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ class OhThatsA extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: "OhThatsA", - initialRoute: '/monthValues', + initialRoute: '/years', routes: { '/monthValues': (context) => MonthValuesPage(), '/years': (context) => YearsPage(), diff --git a/pubspec.yaml b/pubspec.yaml index 94394c9..2f73c9f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ environment: dependencies: flutter: sdk: flutter + numberpicker: ^1.2.1 # The following adds the Cupertino Icons font to your application.