|
@@ -1,226 +0,0 @@
|
1
|
|
-
|
2
|
|
-
|
3
|
|
-import 'package:flutter_login/flutter_login.dart';
|
4
|
|
-import 'package:flutter/material.dart';
|
5
|
|
-import 'package:google_fonts/google_fonts.dart';
|
6
|
|
-import 'register.dart';
|
7
|
|
-import 'package:http/http.dart' as http;
|
8
|
|
-
|
9
|
|
-
|
10
|
|
-
|
11
|
|
-class ProfilePage extends StatefulWidget{
|
12
|
|
-
|
13
|
|
- ProfilePage({Key key, this.title}) : super(key: key);
|
14
|
|
- final String title;
|
15
|
|
-
|
16
|
|
- @override
|
17
|
|
- _ProfilePageState createState() => _ProfilePageState();
|
18
|
|
-}
|
19
|
|
-
|
20
|
|
-class _ProfilePageState extends State<ProfilePage>{
|
21
|
|
- TextEditingController first_name = new TextEditingController();
|
22
|
|
- TextEditingController last_name = new TextEditingController() ;
|
23
|
|
- TextEditingController country = new TextEditingController();
|
24
|
|
- TextEditingController city = new TextEditingController();
|
25
|
|
- TextEditingController phone = new TextEditingController();
|
26
|
|
- TextEditingController healthcare = new TextEditingController();
|
27
|
|
-
|
28
|
|
- // trying to create a an array of controllers
|
29
|
|
- // final List<TextEditingController> controllers = List();
|
30
|
|
- // controllers.add(first_name);
|
31
|
|
-
|
32
|
|
- Future<List> clear_controllers() async {
|
33
|
|
- first_name.text = "";
|
34
|
|
- last_name.text = "";
|
35
|
|
- country.text = "";
|
36
|
|
- city.text = "";
|
37
|
|
- phone.text = "";
|
38
|
|
- healthcare.text = "";
|
39
|
|
- }
|
40
|
|
-
|
41
|
|
-
|
42
|
|
- _Notice(BuildContext context, String message, int r, int g, int b){
|
43
|
|
- showDialog<void>(
|
44
|
|
- context: context,
|
45
|
|
- barrierDismissible: false,
|
46
|
|
- barrierColor: Colors.transparent,
|
47
|
|
-
|
48
|
|
- builder: (BuildContext context){
|
49
|
|
- Future.delayed(Duration(seconds: 3), () {
|
50
|
|
- Navigator.of(context).pop(true);
|
51
|
|
- });
|
52
|
|
-
|
53
|
|
- return Material(
|
54
|
|
- color: Colors.transparent,
|
55
|
|
- child: InkResponse(
|
56
|
|
- child: Container(
|
57
|
|
-
|
58
|
|
- alignment: Alignment.bottomCenter,
|
59
|
|
- padding: EdgeInsets.only(bottom: 130),
|
60
|
|
- child: Text(
|
61
|
|
- message,
|
62
|
|
- style: TextStyle(fontSize: 20, color: Color.fromARGB(255, r, g, b)),),
|
63
|
|
-
|
64
|
|
- ),
|
65
|
|
- )
|
66
|
|
- );
|
67
|
|
- }
|
68
|
|
- );
|
69
|
|
- }
|
70
|
|
- Future<List> send_data() async {
|
71
|
|
-
|
72
|
|
-
|
73
|
|
- var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/UpdateProfile.php';
|
74
|
|
- final data = await http.post(url, body: {
|
75
|
|
- "first_name": first_name.text,
|
76
|
|
- "last_name": last_name.text,
|
77
|
|
- "country": country.text,
|
78
|
|
- "city": city.text,
|
79
|
|
- "phone": phone.text,
|
80
|
|
- "healthcare": healthcare.text,
|
81
|
|
- });
|
82
|
|
- print(data.body);
|
83
|
|
- if("User not registered" == data.body){
|
84
|
|
- _Notice(context, "Error, unable to update profile", 255, 0, 0);
|
85
|
|
- }
|
86
|
|
- else{
|
87
|
|
- _Notice(context, "Profile Updated", 0, 255, 0);
|
88
|
|
- }
|
89
|
|
-
|
90
|
|
- }
|
91
|
|
-
|
92
|
|
- Widget _BackButton(BuildContext context) {
|
93
|
|
- return InkWell(
|
94
|
|
- onTap: () {
|
95
|
|
- Navigator.pop(context);
|
96
|
|
- },
|
97
|
|
- child: Row(
|
98
|
|
- children: <Widget>[
|
99
|
|
- Container(
|
100
|
|
- padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
|
101
|
|
- child: Icon(Icons.arrow_back_ios, color: Colors.black),
|
102
|
|
- ),
|
103
|
|
- Text("Back",
|
104
|
|
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500))
|
105
|
|
- ]
|
106
|
|
- ),
|
107
|
|
- );
|
108
|
|
- }
|
109
|
|
-
|
110
|
|
-
|
111
|
|
- Widget _SubmitButton(BuildContext context) {
|
112
|
|
- return InkResponse(
|
113
|
|
- onTap: () {
|
114
|
|
- send_data();
|
115
|
|
- // clear_controllers();
|
116
|
|
- },
|
117
|
|
- child: Material(
|
118
|
|
- borderRadius: BorderRadius.circular(30),
|
119
|
|
- elevation: 3,
|
120
|
|
- child: Container(
|
121
|
|
- padding: EdgeInsets.symmetric(vertical: 10),
|
122
|
|
- width: 250,
|
123
|
|
- alignment: Alignment.center,
|
124
|
|
- decoration: BoxDecoration(
|
125
|
|
- color: Colors.red,
|
126
|
|
- borderRadius: BorderRadius.circular(30),
|
127
|
|
- ),
|
128
|
|
-
|
129
|
|
- child: Text(
|
130
|
|
- "Update",
|
131
|
|
- style: TextStyle(fontSize: 22, color: Colors.white),
|
132
|
|
- ),
|
133
|
|
- ),
|
134
|
|
- ),
|
135
|
|
- );
|
136
|
|
- }
|
137
|
|
-
|
138
|
|
- Widget _Fills() {
|
139
|
|
- return Column(
|
140
|
|
- children: <Widget>[
|
141
|
|
- _EntryField("First Name", first_name),
|
142
|
|
- _EntryField("Last Name", last_name),
|
143
|
|
- _EntryField("Country", country),
|
144
|
|
- _EntryField("City", city),
|
145
|
|
- _EntryField("Phone Number", phone),
|
146
|
|
- _EntryField("Healthcare Provider", healthcare),
|
147
|
|
- ]
|
148
|
|
- );
|
149
|
|
- }
|
150
|
|
-
|
151
|
|
- Widget _EntryField(String title, TextEditingController controller,
|
152
|
|
- {bool pass = false}) {
|
153
|
|
- return Container(
|
154
|
|
- padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
|
155
|
|
- child: Column(
|
156
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
157
|
|
-
|
158
|
|
- children: <Widget>[
|
159
|
|
- Text(
|
160
|
|
- title,
|
161
|
|
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
162
|
|
- ),
|
163
|
|
- SizedBox(
|
164
|
|
- height: 30
|
165
|
|
- ),
|
166
|
|
- TextField(
|
167
|
|
- controller: controller,
|
168
|
|
- obscureText: pass,
|
169
|
|
- decoration: InputDecoration(
|
170
|
|
- border: (
|
171
|
|
- UnderlineInputBorder()
|
172
|
|
- ),
|
173
|
|
- ),
|
174
|
|
- )
|
175
|
|
- ]
|
176
|
|
- ),
|
177
|
|
-
|
178
|
|
- );
|
179
|
|
- }
|
180
|
|
-
|
181
|
|
-
|
182
|
|
-
|
183
|
|
- @override
|
184
|
|
- Widget build(BuildContext context) {
|
185
|
|
- final height = MediaQuery.of(context).size.height;
|
186
|
|
- return Scaffold(
|
187
|
|
- body: Container(
|
188
|
|
- height: height,
|
189
|
|
- child: Stack(
|
190
|
|
-
|
191
|
|
- children: <Widget>[
|
192
|
|
- Container(
|
193
|
|
- padding: EdgeInsets.symmetric(horizontal: 20),
|
194
|
|
- child: SingleChildScrollView(
|
195
|
|
- child: Column(
|
196
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
197
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
198
|
|
- children: <Widget>[
|
199
|
|
- SizedBox(
|
200
|
|
- height: 60,
|
201
|
|
- ),
|
202
|
|
- _Fills(),
|
203
|
|
- //Add code to verify if password and confirm password match
|
204
|
|
- SizedBox(
|
205
|
|
- height: 80,
|
206
|
|
- ),
|
207
|
|
- _SubmitButton(context),
|
208
|
|
- SizedBox(
|
209
|
|
- height: 50,
|
210
|
|
- ),
|
211
|
|
- // ElevatedButton(
|
212
|
|
- // onPressed: send_data, child: Text("Register")),
|
213
|
|
- ],
|
214
|
|
- ),
|
215
|
|
- )
|
216
|
|
- ),
|
217
|
|
- // Positioned(
|
218
|
|
- // top: 15, left: 20, child: _BackButton(context),
|
219
|
|
- // ),
|
220
|
|
- ],
|
221
|
|
-
|
222
|
|
- ),
|
223
|
|
- )
|
224
|
|
- );
|
225
|
|
- }
|
226
|
|
-}
|