-
Notifications
You must be signed in to change notification settings - Fork 12
/
add_task_screen.dart
117 lines (109 loc) · 3.3 KB
/
add_task_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import 'package:flutter/material.dart';
import 'package:iamrick/utilities/constants.dart';
import 'package:iamrick/components/bottom_padded_card.dart';
import 'package:provider/provider.dart';
import 'package:iamrick/models/task_data.dart';
// After Provider
//class AddTaskScreen extends StatefulWidget {
// @override
// _AddTaskScreenState createState() => _AddTaskScreenState();
//}
//
//class _AddTaskScreenState extends State<AddTaskScreen> {
// String text;
//
// @override
// Widget build(BuildContext context) {
// return BottomPaddedCard(
// padding: EdgeInsets.only(
// left: 20.0,
// top: 30.0,
// right: 20.0,
// bottom: MediaQuery.of(context).viewInsets.bottom),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: <Widget>[
// Text(
// 'Add Task',
// style: kTextStyleTitleDark,
// textAlign: TextAlign.center,
// ),
// SizedBox(height: 12.0),
// TextField(
// cursorColor: kColourPrimary,
// style: kTextStyleListItem,
// textCapitalization: TextCapitalization.sentences,
// autofocus: true,
// minLines: 1,
// maxLines: 3,
// onChanged: (String value) => text = value,
// ),
// SizedBox(height: 20.0),
// FlatButton(
// color: kColourPrimary,
// padding: EdgeInsets.symmetric(vertical: 12.0),
// onPressed: () {
// Provider.of<TaskData>(context, listen: false).addTask(text);
// Navigator.pop(context);
// },
// child: Text('Add', style: kTextStyleAddButton),
// ),
// SizedBox(height: 20.0),
// ],
// ),
// );
// }
//}
// Before Provider
class AddTaskScreen extends StatefulWidget {
final Function onTaskAdded;
AddTaskScreen({@required this.onTaskAdded});
@override
_AddTaskScreenState createState() => _AddTaskScreenState();
}
class _AddTaskScreenState extends State<AddTaskScreen> {
String text;
@override
Widget build(BuildContext context) {
return BottomPaddedCard(
padding: EdgeInsets.only(
left: 20.0,
top: 30.0,
right: 20.0,
bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
'Add Task',
style: kTextStyleTitleDark,
textAlign: TextAlign.center,
),
SizedBox(height: 12.0),
TextField(
cursorColor: kColourPrimary,
style: kTextStyleListItem,
textCapitalization: TextCapitalization.sentences,
autofocus: true,
minLines: 1,
maxLines: 3,
onChanged: (String value) {
text = value;
},
),
SizedBox(height: 20.0),
FlatButton(
color: kColourPrimary,
padding: EdgeInsets.symmetric(vertical: 12.0),
onPressed: () {
widget.onTaskAdded(text);
Navigator.pop(context);
},
child: Text('Add', style: kTextStyleAddButton),
),
SizedBox(height: 20.0),
],
),
);
}
}