-
Notifications
You must be signed in to change notification settings - Fork 12
/
tasks_screen.dart
81 lines (75 loc) · 2.27 KB
/
tasks_screen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'package:flutter/material.dart';
import 'package:iamrick/utilities/constants.dart';
import 'package:iamrick/components/dashboard.dart';
import 'package:iamrick/components/task_list.dart';
import 'package:iamrick/screens/add_task_screen.dart';
import 'package:iamrick/models/task.dart';
// After Provider
//class TasksScreen extends StatelessWidget {
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// floatingActionButton: FloatingActionButton(
// backgroundColor: kColourPrimary,
// child: Icon(Icons.add, size: 36.0),
// onPressed: () {
// showModalBottomSheet(
// backgroundColor: Colors.transparent,
// isScrollControlled: true,
// context: context,
// builder: (context) => SingleChildScrollView(child: AddTaskScreen()),
// );
// },
// ),
// body: Column(
// children: <Widget>[
// Dashboard(),
// TaskList(),
// ],
// ),
// );
// }
//}
// Before Provider
class TasksScreen extends StatefulWidget {
@override
_TasksScreenState createState() => _TasksScreenState();
}
class _TasksScreenState extends State<TasksScreen> {
List<Task> tasks = Task.sampleTasks();
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
backgroundColor: kColourPrimary,
child: Icon(Icons.add, size: 36.0),
onPressed: () {
showModalBottomSheet(
backgroundColor: Colors.transparent,
isScrollControlled: true,
context: context,
builder: (context) => SingleChildScrollView(
child: AddTaskScreen(
onTaskAdded: (String text) {
setState(() => tasks.add(Task(text)));
},
),
),
);
},
),
body: Column(
children: <Widget>[
Dashboard(numberOfTasks: tasks.length),
TaskList(
tasks: tasks,
onTaskTapped: (int index) => setState(
() => tasks[index].isCompleted = !tasks[index].isCompleted,
),
onTaskDragged: (int index) => setState(() => tasks.removeAt(index)),
),
],
),
);
}
}