|
@@ -0,0 +1,217 @@
|
|
1
|
+import 'package:flutter/material.dart';
|
|
2
|
+import 'package:userstory2translate/classes/language.dart';
|
|
3
|
+import 'package:userstory2translate/localization/language_constants.dart';
|
|
4
|
+import 'package:userstory2translate/main.dart';
|
|
5
|
+import 'package:userstory2translate/router/route_constants.dart';
|
|
6
|
+
|
|
7
|
+class HomePage extends StatefulWidget {
|
|
8
|
+ HomePage({Key key}) : super(key: key);
|
|
9
|
+
|
|
10
|
+ @override
|
|
11
|
+ _HomePageState createState() => _HomePageState();
|
|
12
|
+}
|
|
13
|
+
|
|
14
|
+class _HomePageState extends State<HomePage> {
|
|
15
|
+ final GlobalKey<FormState> _key = GlobalKey<FormState>();
|
|
16
|
+ void _changeLanguage(Language language) async {
|
|
17
|
+ Locale _locale = await setLocale(language.languageCode);
|
|
18
|
+ MyApp.setLocale(context, _locale);
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ void _showSuccessDialog() {
|
|
22
|
+ showTimePicker(context: context, initialTime: TimeOfDay.now());
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+ @override
|
|
26
|
+ Widget build(BuildContext context) {
|
|
27
|
+ return Scaffold(
|
|
28
|
+ appBar: AppBar(
|
|
29
|
+ title: Text(getTranslated(context, 'home_page')),
|
|
30
|
+ actions: <Widget>[
|
|
31
|
+ Padding(
|
|
32
|
+ padding: const EdgeInsets.all(8.0),
|
|
33
|
+ child: DropdownButton<Language>(
|
|
34
|
+ underline: SizedBox(),
|
|
35
|
+ icon: Icon(
|
|
36
|
+ Icons.language,
|
|
37
|
+ color: Colors.white,
|
|
38
|
+ ),
|
|
39
|
+ onChanged: (Language language) {
|
|
40
|
+ _changeLanguage(language);
|
|
41
|
+ },
|
|
42
|
+ items: Language.languageList()
|
|
43
|
+ .map<DropdownMenuItem<Language>>(
|
|
44
|
+ (e) => DropdownMenuItem<Language>(
|
|
45
|
+ value: e,
|
|
46
|
+ child: Row(
|
|
47
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
48
|
+ children: <Widget>[
|
|
49
|
+ Text(
|
|
50
|
+ e.flag,
|
|
51
|
+ style: TextStyle(fontSize: 30),
|
|
52
|
+ ),
|
|
53
|
+ Text(e.name)
|
|
54
|
+ ],
|
|
55
|
+ ),
|
|
56
|
+ ),
|
|
57
|
+ )
|
|
58
|
+ .toList(),
|
|
59
|
+ ),
|
|
60
|
+ ),
|
|
61
|
+ ],
|
|
62
|
+ ),
|
|
63
|
+ drawer: Drawer(
|
|
64
|
+ child: _drawerList(),
|
|
65
|
+ ),
|
|
66
|
+ body: Container(
|
|
67
|
+ padding: EdgeInsets.all(20),
|
|
68
|
+ child: _mainForm(context),
|
|
69
|
+ ),
|
|
70
|
+ );
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ Form _mainForm(BuildContext context) {
|
|
74
|
+ return Form(
|
|
75
|
+ key: _key,
|
|
76
|
+ child: Column(
|
|
77
|
+ children: <Widget>[
|
|
78
|
+ Container(
|
|
79
|
+ height: MediaQuery.of(context).size.height / 4,
|
|
80
|
+ child: Center(
|
|
81
|
+ child: Text(
|
|
82
|
+ getTranslated(context, 'personal_information'),
|
|
83
|
+ // DemoLocalization.of(context).translate('personal_information'),
|
|
84
|
+ textAlign: TextAlign.center,
|
|
85
|
+ style: TextStyle(
|
|
86
|
+ fontSize: 30,
|
|
87
|
+ fontWeight: FontWeight.bold,
|
|
88
|
+ ),
|
|
89
|
+ ),
|
|
90
|
+ ),
|
|
91
|
+ ),
|
|
92
|
+ TextFormField(
|
|
93
|
+ validator: (val) {
|
|
94
|
+ if (val.isEmpty) {
|
|
95
|
+ return getTranslated(context, 'required_field');
|
|
96
|
+ // return DemoLocalization.of(context).translate('required_fiedl');
|
|
97
|
+ }
|
|
98
|
+ return null;
|
|
99
|
+ },
|
|
100
|
+ decoration: InputDecoration(
|
|
101
|
+ border: OutlineInputBorder(),
|
|
102
|
+ labelText: getTranslated(context, 'name'),
|
|
103
|
+ hintText: getTranslated(context, 'name_hint'),
|
|
104
|
+ ),
|
|
105
|
+ ),
|
|
106
|
+ SizedBox(
|
|
107
|
+ height: 10,
|
|
108
|
+ ),
|
|
109
|
+ TextFormField(
|
|
110
|
+ validator: (val) {
|
|
111
|
+ if (val.isEmpty) {
|
|
112
|
+ return getTranslated(context, 'required_field');
|
|
113
|
+ }
|
|
114
|
+ return null;
|
|
115
|
+ },
|
|
116
|
+ decoration: InputDecoration(
|
|
117
|
+ border: OutlineInputBorder(),
|
|
118
|
+ labelText: getTranslated(context, 'email'),
|
|
119
|
+ hintText: getTranslated(context, 'email_hint'),
|
|
120
|
+ ),
|
|
121
|
+ ),
|
|
122
|
+ SizedBox(
|
|
123
|
+ height: 10,
|
|
124
|
+ ),
|
|
125
|
+ TextFormField(
|
|
126
|
+ decoration: InputDecoration(
|
|
127
|
+ border: OutlineInputBorder(),
|
|
128
|
+ hintText: getTranslated(context, 'date_of_birth')),
|
|
129
|
+ onTap: () async {
|
|
130
|
+ FocusScope.of(context).requestFocus(FocusNode());
|
|
131
|
+ await showDatePicker(
|
|
132
|
+ context: context,
|
|
133
|
+ initialDate: DateTime.now(),
|
|
134
|
+ firstDate: DateTime(DateTime.now().year),
|
|
135
|
+ lastDate: DateTime(DateTime.now().year + 20),
|
|
136
|
+ );
|
|
137
|
+ },
|
|
138
|
+ ),
|
|
139
|
+ SizedBox(
|
|
140
|
+ height: 10,
|
|
141
|
+ ),
|
|
142
|
+ MaterialButton(
|
|
143
|
+ onPressed: () {
|
|
144
|
+ if (_key.currentState.validate()) {
|
|
145
|
+ _showSuccessDialog();
|
|
146
|
+ }
|
|
147
|
+ },
|
|
148
|
+ height: 50,
|
|
149
|
+ shape: StadiumBorder(),
|
|
150
|
+ color: Theme.of(context).primaryColor,
|
|
151
|
+ child: Center(
|
|
152
|
+ child: Text(
|
|
153
|
+ getTranslated(context, 'submit_info'),
|
|
154
|
+ style: TextStyle(color: Colors.white, fontSize: 20),
|
|
155
|
+ ),
|
|
156
|
+ ),
|
|
157
|
+ )
|
|
158
|
+ ],
|
|
159
|
+ ),
|
|
160
|
+ );
|
|
161
|
+ }
|
|
162
|
+
|
|
163
|
+ Container _drawerList() {
|
|
164
|
+ TextStyle _textStyle = TextStyle(
|
|
165
|
+ color: Colors.white,
|
|
166
|
+ fontSize: 24,
|
|
167
|
+ );
|
|
168
|
+ return Container(
|
|
169
|
+ color: Theme.of(context).primaryColor,
|
|
170
|
+ child: ListView(
|
|
171
|
+ padding: EdgeInsets.zero,
|
|
172
|
+ children: <Widget>[
|
|
173
|
+ DrawerHeader(
|
|
174
|
+ child: Container(
|
|
175
|
+ height: 100,
|
|
176
|
+ child: CircleAvatar(),
|
|
177
|
+ ),
|
|
178
|
+ ),
|
|
179
|
+ ListTile(
|
|
180
|
+ leading: Icon(
|
|
181
|
+ Icons.info,
|
|
182
|
+ color: Colors.white,
|
|
183
|
+ size: 30,
|
|
184
|
+ ),
|
|
185
|
+ title: Text(
|
|
186
|
+ getTranslated(context, 'about_us'),
|
|
187
|
+ style: _textStyle,
|
|
188
|
+ ),
|
|
189
|
+ onTap: () {
|
|
190
|
+ // To close the Drawer
|
|
191
|
+ Navigator.pop(context);
|
|
192
|
+ // Navigating to About Page
|
|
193
|
+ Navigator.pushNamed(context, aboutRoute);
|
|
194
|
+ },
|
|
195
|
+ ),
|
|
196
|
+ ListTile(
|
|
197
|
+ leading: Icon(
|
|
198
|
+ Icons.settings,
|
|
199
|
+ color: Colors.white,
|
|
200
|
+ size: 30,
|
|
201
|
+ ),
|
|
202
|
+ title: Text(
|
|
203
|
+ getTranslated(context, 'settings'),
|
|
204
|
+ style: _textStyle,
|
|
205
|
+ ),
|
|
206
|
+ onTap: () {
|
|
207
|
+ // To close the Drawer
|
|
208
|
+ Navigator.pop(context);
|
|
209
|
+ // Navigating to About Page
|
|
210
|
+ Navigator.pushNamed(context, settingsRoute);
|
|
211
|
+ },
|
|
212
|
+ ),
|
|
213
|
+ ],
|
|
214
|
+ ),
|
|
215
|
+ );
|
|
216
|
+ }
|
|
217
|
+}
|