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:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:numberpicker/numberpicker.dart';
|
||||||
|
import 'package:ohthatsa/DayCalculator.dart';
|
||||||
|
|
||||||
import 'AppDrawer.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
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
drawer: AppDrawer(),
|
drawer: AppDrawer(),
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Overview"),
|
title: Text("Overview"),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Text("Years page")
|
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) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: "OhThatsA",
|
title: "OhThatsA",
|
||||||
initialRoute: '/monthValues',
|
initialRoute: '/years',
|
||||||
routes: {
|
routes: {
|
||||||
'/monthValues': (context) => MonthValuesPage(),
|
'/monthValues': (context) => MonthValuesPage(),
|
||||||
'/years': (context) => YearsPage(),
|
'/years': (context) => YearsPage(),
|
||||||
|
|
|
@ -23,6 +23,7 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
numberpicker: ^1.2.1
|
||||||
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
|
|
Loading…
Add table
Reference in a new issue