|
1 | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:todolistapp_updates/widgets/TasksList.dart'; |
| 3 | +import 'add_task_screen.dart'; |
| 4 | +import 'package:todolistapp_updates/models/task_data.dart'; |
| 5 | +import 'package:provider/provider.dart'; |
2 | 6 |
|
3 | | -class TasksScreen extends StatelessWidget { |
| 7 | +class TasksScreen extends StatelessWidget{ |
4 | 8 | const TasksScreen({Key? key}) : super(key: key); |
5 | 9 |
|
| 10 | + |
6 | 11 | @override |
7 | 12 | Widget build(BuildContext context) { |
8 | 13 | return Scaffold( |
9 | 14 | backgroundColor: Colors.lightBlueAccent, |
10 | 15 | floatingActionButton: FloatingActionButton( |
11 | | - onPressed: (){}, |
| 16 | + onPressed: () { |
| 17 | + showModalBottomSheet( |
| 18 | + context: context, |
| 19 | + builder: (context) => SingleChildScrollView( |
| 20 | + child:Container( |
| 21 | + padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), |
| 22 | + child: AddTaskScreen( |
| 23 | + addTaskCallback: (newValue){ |
| 24 | + // setState((){ |
| 25 | + // tasks.add(Task(name: newValue)); |
| 26 | + // }); |
| 27 | + Navigator.pop(context); |
| 28 | + |
| 29 | + |
| 30 | + }, |
| 31 | + ), |
| 32 | + ) |
| 33 | + ), |
| 34 | + isScrollControlled: true, |
| 35 | + ); //return a widget |
| 36 | + }, |
12 | 37 | backgroundColor: Colors.lightBlueAccent, |
13 | 38 | child: const Icon(Icons.add), |
14 | 39 | ), |
15 | 40 | body: Column( |
16 | 41 | children: <Widget>[ |
17 | 42 | Container( |
18 | | - padding: |
19 | | - const EdgeInsets.only(top: 60.0, left: 30.0, right: 30.0, bottom: 30.0), |
| 43 | + padding: const EdgeInsets.only( |
| 44 | + top: 60.0, left: 30.0, right: 30.0, bottom: 30.0), |
20 | 45 | child: Column( |
21 | 46 | crossAxisAlignment: CrossAxisAlignment.start, |
22 | 47 | children: <Widget>[ |
23 | 48 | CircleAvatar( |
24 | | - backgroundColor: Colors.white, |
25 | | - radius: 30.0, |
26 | | - child: Icon(Icons.list), |
| 49 | + backgroundColor: Colors.white, |
| 50 | + radius: 30.0, |
| 51 | + child: Icon(Icons.list), |
27 | 52 | ), |
28 | 53 | SizedBox( |
29 | 54 | height: 10.0, |
30 | 55 | ), |
31 | | - Text('Todoey', |
| 56 | + Text( |
| 57 | + 'Todoey', |
32 | 58 | style: TextStyle( |
33 | 59 | color: Colors.white, |
34 | 60 | fontSize: 50.0, |
35 | 61 | fontWeight: FontWeight.w700, |
36 | 62 | ), |
37 | | - |
38 | 63 | ), |
39 | 64 | Text( |
40 | | - '12 Tasks', |
| 65 | + '${Provider.of<TaskData>(context).taskCount} Tasks', |
41 | 66 | style: TextStyle( |
42 | 67 | fontSize: 18, |
43 | 68 | color: Colors.white, |
44 | 69 | ), |
45 | 70 | ), |
46 | | - |
47 | 71 | ], |
48 | 72 | ), |
49 | 73 | ), |
50 | 74 | Expanded( |
51 | 75 | child: Container( |
52 | | - decoration: const BoxDecoration( |
53 | | - color: Colors.white, |
54 | | - borderRadius: BorderRadius.only( |
55 | | - topLeft: Radius.circular(20.0), |
56 | | - topRight: Radius.circular(20.0), |
| 76 | + padding: const EdgeInsets.symmetric(horizontal: 20.0), |
| 77 | + decoration: const BoxDecoration( |
| 78 | + color: Colors.white, |
| 79 | + borderRadius: BorderRadius.only( |
| 80 | + topLeft: Radius.circular(20.0), |
| 81 | + topRight: Radius.circular(20.0), |
| 82 | + ), |
57 | 83 | ), |
58 | | - ), |
59 | | - |
60 | | - ), |
| 84 | + child: TasksList()), |
61 | 85 | ), |
62 | 86 | ], |
63 | 87 | ), |
|
0 commit comments