Added simple scroller (NumberPicker) to select year and some text that gives the century value and if it's a leap year
This commit is contained in:
parent
9a6afcb2a8
commit
a59836153f
3 changed files with 32 additions and 9 deletions
|
@ -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<YearsPage> {
|
||||
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: <Widget>[
|
||||
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()),
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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(),
|
||||
|
|
|
@ -23,6 +23,7 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
numberpicker: ^1.2.1
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
|
|
Loading…
Add table
Reference in a new issue