Skip to content

Commit 49464c9

Browse files
committed
Select any month in fishes/bugs of the month + minor
1 parent 13550f0 commit 49464c9

File tree

6 files changed

+171
-84
lines changed

6 files changed

+171
-84
lines changed

‎lib/misc/io_manager.dart‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class IOManager
104104
}
105105
}
106106
}
107-
print(completedTasks);
108107
User.completedBugs = completedTasks;
109108

110109

@@ -123,8 +122,6 @@ class IOManager
123122
}
124123
}
125124
User.completedFossils = completedTasks;
126-
127-
128125
}
129126
catch (e)
130127
{

‎lib/pages/menu_page.dart‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:animal_crossing_completion/misc/custom_icons.dart';
33
import 'package:animal_crossing_completion/pages/todo_list_page/month_bug.dart';
44
import 'package:animal_crossing_completion/pages/todo_list_page/month_fish.dart';
55
import 'package:animal_crossing_completion/pages/todo_list_page/tasks_section.dart';
6+
import 'package:animal_crossing_completion/pages/todo_list_page/todo_list_page.dart';
67
import 'package:flutter/material.dart';
78
import '../user.dart';
89
import 'onboard_page.dart';
@@ -75,7 +76,10 @@ class _MenuPageState extends State<MenuPage> {
7576
fontSize: 40.0,
7677
fontWeight: FontWeight.w500)),
7778
new Text(
78-
(User.completedFish.length + User.completedBugs.length + User.completedFossils.length).toString() +
79+
(User.completedFish.length +
80+
User.completedBugs.length +
81+
User.completedFossils.length)
82+
.toString() +
7983
' completed tasks out of ' +
8084
(TasksList.tasks.length +
8185
TasksList.taskde.length +
@@ -176,10 +180,20 @@ class _MenuPageState extends State<MenuPage> {
176180
await User.prefs.commit();
177181

178182
setState(() => User.hemisphere = !User.hemisphere);
179-
Navigator.of(context).popAndPushNamed('/');
183+
Navigator.of(context).popAndPushNamed(TodoListPage.routeName);
180184
},
181185
child: new ListTile(
182-
subtitle: User.hemisphere ? Text("Currently on North hemisphere") : Text("Currently on South hemisphere"),
186+
subtitle: User.hemisphere
187+
? Text("Currently on North hemisphere",
188+
style: new TextStyle(
189+
color: User.darkKnightMode
190+
? textDarkTheme
191+
: Colors.black))
192+
: Text("Currently on South hemisphere",
193+
style: new TextStyle(
194+
color: User.darkKnightMode
195+
? textDarkTheme
196+
: Colors.black)),
183197
title: new Text("Change hemisphere",
184198
style: new TextStyle(
185199
color:
@@ -190,6 +204,9 @@ class _MenuPageState extends State<MenuPage> {
190204
color: User.darkKnightMode ? textDarkTheme : Colors.black),
191205
),
192206
),
207+
Container(
208+
margin: EdgeInsets.symmetric(horizontal: 100),
209+
child: Divider(thickness: 3, color: User.darkKnightMode ? textDarkTheme : Colors.black,)),
193210
new FlatButton(
194211
onPressed: () {
195212
showAboutDialog(

‎lib/pages/todo_list_page/month_bug.dart‎

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,77 @@ class BugMonth extends StatefulWidget {
1414
}
1515

1616
class _BugMonthState extends State<BugMonth> {
17+
String dropdownValue = getMonthTitle();
18+
1719
@override
1820
Widget build(BuildContext context) {
1921
return Scaffold(
20-
appBar: AppBar(backgroundColor: User.darkKnightMode ? veryDarkTheme : acTheme,
21-
title: Text(getMonthTitle()),),
22-
body: Container(
23-
child: new Builder(
24-
builder: (BuildContext context) {
25-
return new CustomScrollView(
26-
scrollDirection: Axis.vertical,
27-
slivers: <Widget>[
28-
new SliverList(
29-
delegate: new SliverChildListDelegate(<Widget>[
30-
DecoratedBox(
31-
decoration: BoxDecoration(color: User.darkKnightMode ? menuDarkTheme : acTheme),
32-
child: new SizedBox(height: 20,)),
33-
new BuilderTaskType(this, 5),
34-
DecoratedBox(
35-
decoration: BoxDecoration(color: User.darkKnightMode ? menuDarkTheme : acTheme),
36-
child: new SizedBox(height: 60,))
37-
]))
38-
],
39-
);
40-
},
22+
appBar: AppBar(
23+
backgroundColor: User.darkKnightMode ? veryDarkTheme : acTheme,
24+
title: DropdownButton<String>(
25+
value: dropdownValue,
26+
items: <String>[
27+
'January',
28+
'February',
29+
'March',
30+
'April',
31+
'May',
32+
'June',
33+
'July',
34+
'August',
35+
'September',
36+
'October',
37+
'November',
38+
'December'
39+
].map((String value) {
40+
return new DropdownMenuItem<String>(
41+
value: value,
42+
child: new Text(
43+
value,
4144
),
42-
),);
43-
44-
}
45-
46-
String getMonthTitle() {
47-
var now = new DateTime.now();
48-
final monthName = DateFormat.MMMM().format(now);
45+
);
46+
}).toList(),
47+
onChanged: (String newValue) {
48+
setState(() {
49+
dropdownValue = newValue;
50+
});
51+
},
52+
),
53+
),
54+
body: Container(
55+
child: new Builder(
56+
builder: (BuildContext context) {
57+
return new CustomScrollView(
58+
scrollDirection: Axis.vertical,
59+
slivers: <Widget>[
60+
new SliverList(
61+
delegate: new SliverChildListDelegate(<Widget>[
62+
DecoratedBox(
63+
decoration: BoxDecoration(
64+
color: User.darkKnightMode ? menuDarkTheme : acTheme),
65+
child: new SizedBox(
66+
height: 20,
67+
)),
68+
new BuilderTaskType(this, 5, dropdownValue),
69+
DecoratedBox(
70+
decoration: BoxDecoration(
71+
color: User.darkKnightMode ? menuDarkTheme : acTheme),
72+
child: new SizedBox(
73+
height: 60,
74+
))
75+
]))
76+
],
77+
);
78+
},
79+
),
80+
),
81+
);
82+
}
83+
84+
static String getMonthTitle() {
85+
var now = new DateTime.now();
86+
final monthName = DateFormat.MMMM().format(now);
4987

50-
return monthName;
51-
}
52-
}
88+
return monthName;
89+
}
90+
}

‎lib/pages/todo_list_page/month_fish.dart‎

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,77 @@ class FishMonth extends StatefulWidget {
1414
}
1515

1616
class _FishMonthState extends State<FishMonth> {
17+
String dropdownValue = getMonthTitle();
18+
1719
@override
1820
Widget build(BuildContext context) {
1921
return Scaffold(
20-
appBar: AppBar(backgroundColor: User.darkKnightMode ? veryDarkTheme : acTheme,
21-
title: Text(getMonthTitle()),),
22-
body: Container(
23-
child: new Builder(
24-
builder: (BuildContext context) {
25-
return new CustomScrollView(
26-
scrollDirection: Axis.vertical,
27-
slivers: <Widget>[
28-
new SliverList(
29-
delegate: new SliverChildListDelegate(<Widget>[
30-
DecoratedBox(
31-
decoration: BoxDecoration(color: User.darkKnightMode ? menuDarkTheme : acTheme),
32-
child: new SizedBox(height: 20,)),
33-
new BuilderTaskType(this, 4),
34-
DecoratedBox(
35-
decoration: BoxDecoration(color: User.darkKnightMode ? menuDarkTheme : acTheme),
36-
child: new SizedBox(height: 60,))
37-
]))
38-
],
39-
);
40-
},
22+
appBar: AppBar(
23+
backgroundColor: User.darkKnightMode ? veryDarkTheme : acTheme,
24+
title: DropdownButton<String>(
25+
value: dropdownValue,
26+
items: <String>[
27+
'January',
28+
'February',
29+
'March',
30+
'April',
31+
'May',
32+
'June',
33+
'July',
34+
'August',
35+
'September',
36+
'October',
37+
'November',
38+
'December'
39+
].map((String value) {
40+
return new DropdownMenuItem<String>(
41+
value: value,
42+
child: new Text(
43+
value,
4144
),
42-
),);
43-
44-
}
45-
46-
String getMonthTitle() {
47-
var now = new DateTime.now();
48-
final monthName = DateFormat.MMMM().format(now);
45+
);
46+
}).toList(),
47+
onChanged: (String newValue) {
48+
setState(() {
49+
dropdownValue = newValue;
50+
});
51+
},
52+
),
53+
),
54+
body: Container(
55+
child: new Builder(
56+
builder: (BuildContext context) {
57+
return new CustomScrollView(
58+
scrollDirection: Axis.vertical,
59+
slivers: <Widget>[
60+
new SliverList(
61+
delegate: new SliverChildListDelegate(<Widget>[
62+
DecoratedBox(
63+
decoration: BoxDecoration(
64+
color: User.darkKnightMode ? menuDarkTheme : acTheme),
65+
child: new SizedBox(
66+
height: 20,
67+
)),
68+
new BuilderTaskType(this, 4, dropdownValue),
69+
DecoratedBox(
70+
decoration: BoxDecoration(
71+
color: User.darkKnightMode ? menuDarkTheme : acTheme),
72+
child: new SizedBox(
73+
height: 60,
74+
))
75+
]))
76+
],
77+
);
78+
},
79+
),
80+
),
81+
);
82+
}
83+
84+
static String getMonthTitle() {
85+
var now = new DateTime.now();
86+
final monthName = DateFormat.MMMM().format(now);
4987

50-
return monthName;
51-
}
52-
}
88+
return monthName;
89+
}
90+
}

‎lib/pages/todo_list_page/tasks_section.dart‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:intl/intl.dart';
32
import '../../logic/task.dart';
43
import '../../misc/tasks_list.dart';
54
import '../../user.dart';
@@ -10,8 +9,9 @@ class BuilderTaskType extends StatefulWidget {
109

1110
State state;
1211
int position;
12+
String listMonthName;
1313

14-
BuilderTaskType(this.state, this.position);
14+
BuilderTaskType(this.state, this.position, [this.listMonthName]);
1515

1616
@override
1717
_BuilderTaskTypeState createState() => _BuilderTaskTypeState();
@@ -25,11 +25,11 @@ class _BuilderTaskTypeState extends State<BuilderTaskType> {
2525
(
2626
mainAxisAlignment: MainAxisAlignment.start,
2727
crossAxisAlignment: CrossAxisAlignment.start,
28-
children: returnRightList(widget.position)
28+
children: returnRightList(widget.position, listMonthName: widget.listMonthName)
2929
);
3030
}
3131

32-
List<Widget> returnRightList(int position) {
32+
List<Widget> returnRightList(int position, {listMonthName}) {
3333
switch (position) {
3434
case 0: {
3535
if (User.hemisphere) {
@@ -50,9 +50,8 @@ class _BuilderTaskTypeState extends State<BuilderTaskType> {
5050
} break;
5151
case 4: {
5252
if (User.hemisphere) {
53-
return TasksList.tasks.where((task) {
54-
var now = new DateTime.now();
55-
final monthName = DateFormat.MMMM().format(now);
53+
return TasksList.tasks.where((task) {
54+
final monthName = listMonthName;
5655

5756
var returnValue = false;
5857
if (task.jan == true && monthName == 'January') {
@@ -85,9 +84,8 @@ class _BuilderTaskTypeState extends State<BuilderTaskType> {
8584
}
8685
).map<Widget>((Task task) => new TodoCard(checkIfDone(task, User.completedFish), widget.state, 1)).toList();
8786
} else {
88-
return TasksList.tasks_south.where((task) {
89-
var now = new DateTime.now();
90-
final monthName = DateFormat.MMMM().format(now);
87+
return TasksList.tasks_south.where((task) {
88+
final monthName = listMonthName;
9189

9290
var returnValue = false;
9391
if (task.jan == true && monthName == 'January') {
@@ -124,9 +122,8 @@ class _BuilderTaskTypeState extends State<BuilderTaskType> {
124122
}
125123
case 5: {
126124
if (User.hemisphere) {
127-
return TasksList.taskde.where((task) {
128-
var now = new DateTime.now();
129-
final monthName = DateFormat.MMMM().format(now);
125+
return TasksList.taskde.where((task) {
126+
final monthName = listMonthName;
130127

131128
var returnValue = false;
132129
if (task.jan == true && monthName == 'January') {
@@ -159,9 +156,8 @@ class _BuilderTaskTypeState extends State<BuilderTaskType> {
159156
}
160157
).map<Widget>((Task task) => new TodoCard(checkIfDone(task, User.completedBugs), widget.state, 2)).toList();
161158
} else {
162-
return TasksList.taskde_south.where((task) {
163-
var now = new DateTime.now();
164-
final monthName = DateFormat.MMMM().format(now);
159+
return TasksList.taskde_south.where((task) {
160+
final monthName = listMonthName;
165161

166162
var returnValue = false;
167163
if (task.jan == true && monthName == 'January') {

‎lib/pages/todo_list_page/todo_list_page.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import '../menu_page.dart';
1313
class TodoListPage extends StatefulWidget {
1414
bool showSmallProgressBar = false;
1515
bool resetState = false;
16+
static const String routeName = '/todolist';
1617

1718
@override
1819
TodoListPageState createState() => new TodoListPageState();

0 commit comments

Comments
 (0)