瀏覽代碼

sprint 3 hector integrado

Oniel Mendez 3 年之前
父節點
當前提交
6e8275bf04

+ 1
- 1
fast_med_flutter/lib/main.dart 查看文件

@@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
10 10
 import 'package:fast_med_flutter/routes/especialidades.dart';
11 11
 
12 12
 void main() => runApp(MaterialApp(
13
-    initialRoute: '/home',
13
+    initialRoute: '/welcome',
14 14
     routes: {
15 15
       '/home': (context) => Home(),
16 16
       '/verOficinas': (context) => VerOficinas(),

+ 60
- 0
fast_med_flutter/lib/routes/OfficeScreen.dart 查看文件

@@ -0,0 +1,60 @@
1
+import 'package:flutter/material.dart';
2
+import 'dart:convert';
3
+import 'Offices.dart';
4
+import 'appointments.dart';
5
+import 'package:flutter/foundation.dart';
6
+
7
+
8
+class OfficesScreen extends StatelessWidget {
9
+  final List<Offices> off;
10
+  Offices ofi;
11
+  // final Offices Of;
12
+  // final offlist = List<Offices>.generate(
13
+  //   2,
14
+  //       (i) => Offices(
15
+  //         'Office $i',
16
+  //         docs[i], spec[i], addrs[i],
17
+  //   ),
18
+  // );
19
+
20
+  var docs = ["Collazo", "Albizu"];
21
+  var spec = ["General", "Pediatra"];
22
+  var addrs = ["Bo. Montellano, Cayey", "Las Dalias, Mayagüez"];
23
+
24
+  //requiring the list of todos
25
+  OfficesScreen({Key key, @required this.off}) : super(key: key);
26
+
27
+  @override
28
+  Widget build(BuildContext context) {
29
+    // print(docs[0]);
30
+
31
+    final offlist = List<Offices>.generate(
32
+      2,
33
+          (i) => Offices(
34
+            'Office $i',
35
+            // "sds", "gfdf", "fvfgv",
36
+            docs[i], spec[i], addrs[i]
37
+      ),
38
+    );
39
+    return Scaffold(
40
+
41
+      appBar: AppBar(
42
+        title: Text('Todos'),
43
+      ),
44
+      //passing in the ListView.builder
45
+      body: ListView.builder(
46
+        itemCount: offlist.length,
47
+        itemBuilder: (context, index) {
48
+          return ListTile(
49
+              title: Text(offlist[index].office),
50
+              onTap: (){
51
+                Navigator.push(context, MaterialPageRoute(builder: (context) => 
52
+                AppointmentPage(O: offlist[index])),
53
+                );
54
+              },
55
+          );
56
+        },
57
+      ),
58
+    );
59
+  }
60
+}

+ 69
- 0
fast_med_flutter/lib/routes/Offices.dart 查看文件

@@ -0,0 +1,69 @@
1
+// import 'package:flutter/material.dart';
2
+// import 'dart:convert';
3
+// import 'package:flutter/foundation.dart';
4
+// import 'OfficeScreen.dart';
5
+// import 'appointments.dart';
6
+//
7
+// class Officess {
8
+//   final String office;
9
+//   final String doctor;
10
+//   final String specialty;
11
+//   final String address;
12
+//
13
+//   Officess({this.office, this.doctor, this.specialty, this.address});
14
+//
15
+//   factory Officess.fromJson(Map<String, dynamic> json) {
16
+//     return Officess(
17
+//       office: json['office'],
18
+//       doctor: json['doctor'],
19
+//       specialty: json['id'],
20
+//       address: json['title'],
21
+//     );
22
+//   }
23
+// }
24
+
25
+class Offices {
26
+  final String office;
27
+  final String doctor;
28
+  final String specialty;
29
+  final String address;
30
+
31
+  var variable = 32;
32
+
33
+  var docs = ["Collazo", "Albizu"];
34
+  var spec = ["General", "Pediatra"];
35
+  var addrs = ["Bo. Montellano, Cayey", "Las Dalias, Mayagüez"];
36
+
37
+  Offices(this.office, this.doctor, this.specialty, this.address);
38
+
39
+
40
+}
41
+// var docs = List<String> ("juan", "pedro");
42
+
43
+
44
+// final off = List<Offices>.generate(
45
+//   2,
46
+//       (i) => Offices(
47
+//     'Office $i',
48
+//     docs[i], spec[i], addrs[i],
49
+//   ),
50
+// );
51
+
52
+
53
+
54
+
55
+
56
+
57
+// final off = List<Offices>.generate(
58
+//   2,
59
+//       (i) => Offices(
60
+//     'Office $i',
61
+//     docs[i],
62
+//     spec[i],
63
+//     addrs[i],
64
+//   ),
65
+// );
66
+
67
+
68
+
69
+

+ 135
- 0
fast_med_flutter/lib/routes/appointments.dart 查看文件

@@ -0,0 +1,135 @@
1
+import 'package:flutter/cupertino.dart';
2
+import 'package:flutter_login/flutter_login.dart';
3
+import 'package:flutter/material.dart';
4
+import 'package:google_fonts/google_fonts.dart';
5
+import 'Offices.dart';
6
+import 'dynamic.dart';
7
+import 'Offices.dart';
8
+import 'OfficeScreen.dart';
9
+import 'package:flutter/foundation.dart';
10
+import 'package:http/http.dart' as http;
11
+
12
+//This page only works when called by other OfficeScreenPage()
13
+//Need to add the functionality to work on its own
14
+
15
+
16
+class AppointmentPage extends StatelessWidget {
17
+
18
+
19
+  final Offices O;
20
+  AppointmentPage({Key key, @required this.O}) :super(key: key);
21
+  // AppointmentPage({Key key, @required this.O}) : super(key: key);
22
+
23
+  // final String title;
24
+  //
25
+  // Future<http.Response> fetchAlbum() {
26
+  //   return http.get('https://ada.uprrp.edu/~hector.sierra/FastMed/API/API/getcitas.php');
27
+  // }
28
+
29
+
30
+
31
+  // List<dynamicWidget> listDynamic = [];
32
+  // List<String> data = [];
33
+  // Icon floatingIcon = new Icon(Icons.add);
34
+  //
35
+  // addDynamic() {
36
+  //   if (data.length != 0) {
37
+  //     floatingIcon = new Icon(Icons.add);
38
+  //     data = [];
39
+  //     listDynamic = [];
40
+  //     print('if');
41
+  //   }
42
+  //   setState(() {});
43
+  //   if (listDynamic.length >= 5) {
44
+  //     return;
45
+  //   }
46
+  //   listDynamic.add(new dynamicWidget());
47
+  // }
48
+  //
49
+
50
+  // var docs = ["Collazo", "Albizu"];
51
+  // var spec = ["General", "Pediatra"];
52
+  // var addrs = ["Bo. Montellano, Cayey", "Las Dalias, Mayagüez"];
53
+
54
+
55
+  @override
56
+  Widget card() {
57
+  return SizedBox(
58
+    width: 380,
59
+    height: 150,
60
+      child: Card(
61
+        child: Column(
62
+          mainAxisSize: MainAxisSize.min,
63
+            children: <Widget>[
64
+              ListTile(
65
+
66
+                leading: Icon(
67
+                  Icons.check,
68
+                  color: Colors.green,
69
+                  size: 60,
70
+              ),
71
+                title: Text( O.doctor + "\n" + O.specialty, textScaleFactor: 1.5,),
72
+                subtitle: Text(O.address, textScaleFactor: 1.45,),
73
+                trailing: Text("\n10:45 - 11:45      ", textScaleFactor: 1.30,),
74
+
75
+              ),
76
+              // ListTile(
77
+              //   leading: Icon(
78
+              //     Icons.check,
79
+              //     color: Colors.green,
80
+              //     size: 60,
81
+              //   ),
82
+              //   title: Text("Figueroa" + "\n" + "Gastrointerologo", textScaleFactor: 1.5,),
83
+              //   subtitle: Text("Las Dalias, Mayagüez", textScaleFactor: 1.45,),
84
+              //   trailing: Text("\n10:45 - 11:45      ", textScaleFactor: 1.30,),
85
+              //
86
+              // )
87
+           ],
88
+          ),
89
+        ),
90
+      );
91
+    }
92
+
93
+  @override
94
+  Widget build(BuildContext context) {
95
+    final height = MediaQuery.of(context).size.height;
96
+    return Scaffold(
97
+
98
+        body: Container(
99
+          height: height,
100
+          child:Container(
101
+            width: MediaQuery.of(context).size.width,
102
+            padding: EdgeInsets.symmetric(horizontal: 20),
103
+            // height: MediaQuery.of(context).size.height,
104
+            decoration: BoxDecoration(
105
+                borderRadius: BorderRadius.all(Radius.circular(4)),
106
+                boxShadow: [
107
+                  BoxShadow(
108
+                      color: Colors.white,
109
+                      offset: Offset(0,3),
110
+                      blurRadius: 5,
111
+                      spreadRadius: 2)
112
+                ]
113
+
114
+            ),
115
+            child: SingleChildScrollView(
116
+                child: Column(
117
+                  crossAxisAlignment: CrossAxisAlignment.center,
118
+                  mainAxisAlignment: MainAxisAlignment.center,
119
+                  children: <Widget> [
120
+                    SizedBox(
121
+                      height: 80,
122
+                    ),
123
+                    card(),
124
+                    SizedBox(
125
+                      height: 25,
126
+                    ),
127
+                    // card(docs[1], spec[1], addrs[1]),
128
+                  ],
129
+                )
130
+            ),
131
+          ),
132
+        )
133
+    );
134
+  }
135
+}

+ 39
- 0
fast_med_flutter/lib/routes/dynamic.dart 查看文件

@@ -0,0 +1,39 @@
1
+import 'package:flutter/material.dart';
2
+
3
+
4
+class dynamicWidget extends StatelessWidget {
5
+  TextEditingController Product = new TextEditingController();
6
+  TextEditingController Price = new TextEditingController();
7
+
8
+  @override
9
+  Widget build(BuildContext context) {
10
+
11
+    Widget card() {
12
+      return SizedBox(
13
+        width: 380,
14
+        height: 140,
15
+        child: Card(
16
+          child: Column(
17
+            mainAxisSize: MainAxisSize.min,
18
+            children: <Widget>[
19
+              const ListTile(
20
+
21
+                leading: Icon(
22
+                  Icons.check,
23
+                  color: Colors.green,
24
+                  size: 60,
25
+                ),
26
+                title: Text("\nVacunación\nDr. Jímenez", textScaleFactor: 1.15,),
27
+                subtitle: Text("Bo. Montellano, Cayey", textScaleFactor: 1.25,),
28
+                trailing: Text("\n10:45 - 11:45      ", textScaleFactor: 1.30,),
29
+
30
+              ),
31
+            ],
32
+          ),
33
+        ),
34
+      );
35
+    }
36
+
37
+  }
38
+
39
+}

+ 88
- 0
fast_med_flutter/lib/routes/navigation.dart 查看文件

@@ -0,0 +1,88 @@
1
+
2
+import 'package:flutter_login/flutter_login.dart';
3
+import 'package:flutter/material.dart';
4
+import 'package:google_fonts/google_fonts.dart';
5
+import 'register.dart';
6
+import 'welcome.dart';
7
+import 'profileinfo.dart';
8
+import 'appointments.dart';
9
+import 'package:http/http.dart' as http;
10
+import 'OfficeScreen.dart';
11
+import 'Offices.dart';
12
+import 'package:fast_med_flutter/routes/home.dart';
13
+
14
+
15
+class NavigationPage extends StatefulWidget{
16
+
17
+  NavigationPage({Key key, this.title}) : super(key: key);
18
+  final String title;
19
+
20
+  @override
21
+  _NavigationPageState createState() => _NavigationPageState();
22
+}
23
+
24
+class _NavigationPageState extends State<NavigationPage>{
25
+
26
+
27
+  int _selectedIndex = 0;
28
+
29
+  static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
30
+
31
+  final _pageOptions = [
32
+    OfficesScreen(),
33
+    ProfilePage(),
34
+    Home()
35
+  ];
36
+
37
+  // static const List<Navigator> _widgetOptions = <Navigator>[
38
+  // //   Navigator.push(
39
+  // // context, MaterialPageRoute(builder: (context) => ProfilePage()));
40
+  // ];
41
+
42
+
43
+  // void _onItemTapped(int index) {
44
+  //   setState(() {
45
+  //     _selectedIndex = index;
46
+  //   });
47
+  // }
48
+  @override
49
+  Widget build(BuildContext context) {
50
+    final height = MediaQuery.of(context).size.height;
51
+    return Scaffold(
52
+      // appBar: AppBar(
53
+      //   title: Text("Title"),
54
+      // ),
55
+      body:  _pageOptions[_selectedIndex],
56
+      bottomNavigationBar: BottomNavigationBar(
57
+        onTap: (int index){
58
+          setState(() {
59
+            _selectedIndex = index;
60
+          });
61
+        },
62
+          selectedItemColor: Colors.red[800],
63
+        currentIndex: _selectedIndex,
64
+        // onTap: ,
65
+        // currentIndex: ,
66
+        // selectedItemColor: Colors.red, onTap: ,
67
+        //
68
+
69
+        items: [
70
+          BottomNavigationBarItem(icon: Icon(Icons.medical_services),
71
+              label: 'FastMed'),
72
+          BottomNavigationBarItem(icon: Icon(Icons.person_rounded),
73
+              label: 'Profile'),
74
+          BottomNavigationBarItem(icon: Icon(Icons.event_note_rounded),
75
+              label: 'Appointments')
76
+        ],
77
+
78
+      ),
79
+      // body: Container(
80
+      //
81
+      // ),
82
+    );
83
+    // TODO: implement build
84
+    throw UnimplementedError();
85
+  }
86
+
87
+
88
+}

+ 226
- 0
fast_med_flutter/lib/routes/profileinfo.dart 查看文件

@@ -0,0 +1,226 @@
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
+}

+ 217
- 104
fast_med_flutter/lib/routes/register.dart 查看文件

@@ -1,13 +1,19 @@
1
+import 'dart:convert';
2
+
1 3
 import 'package:flutter_login/flutter_login.dart';
2 4
 import 'package:flutter/material.dart';
3 5
 import 'package:google_fonts/google_fonts.dart';
6
+import 'package:http/http.dart' as http;
7
+import 'dart:convert' as convert;
8
+
9
+
4 10
 
5 11
 //
6 12
 //Still to add: 
7 13
 //  Email verification, that the input has "@" and "."
8
-//  Send email and password to database
9
-//
10
-//
14
+//  Hash the passwords
15
+//  Allow users to login
16
+//  Verify password and confirm password match
11 17
 //
12 18
 
13 19
 class RegisterPage extends StatefulWidget{
@@ -20,48 +26,138 @@ class RegisterPage extends StatefulWidget{
20 26
 }
21 27
 
22 28
 class _RegisterPageState extends State<RegisterPage> {
29
+  // TextEditingController name = new TextEditingController();
30
+  TextEditingController email = new TextEditingController();
31
+  TextEditingController password = new TextEditingController() ;
32
+  TextEditingController confirmpass = new TextEditingController();
23 33
 
24
-  TextEditingController email;
25
-  TextEditingController password;
26
-  TextEditingController confirmpass;
27 34
 
28
-  // Future<List> send_data() async {
29
-  //   final data = await
30
-  // }
35
+  Future<List> send_data() async {
31 36
 
32
-  String _SamePass(){
33
-    if(password == confirmpass){
34
-      return "Same password";
37
+
38
+    var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/API/insertuser.php';
39
+    final data = await http.post(url, body: {
40
+        "email": email.text,
41
+        "password": password.text,
42
+      });
43
+    print(data.body);
44
+    if("user not registered" == data.body){
45
+      print("maybe we use this");
35 46
     }
36
-    else{
37
-      return "Different passwords";
47
+
48
+  }
49
+
50
+  bool _SamePass() {
51
+    if (password.text == confirmpass.text) {
52
+      return true;
53
+    }
54
+    else {
55
+      return false;
38 56
     }
39 57
   }
40 58
 
41
-  Widget _BackButton(BuildContext context){
59
+  _Alerts(BuildContext context){
60
+
61
+    TextEditingController msg = new TextEditingController();
62
+
63
+
64
+   //
65
+   //Useful code for adding pop up messages with animations
66
+   //
67
+   //
68
+
69
+    // Navigator.of(context).push(
70
+    //
71
+    //   PageRouteBuilder(
72
+    //       transitionDuration: Duration(seconds: 2),
73
+    //       pageBuilder: (context, animation, secAnimation ) => AlertDialog(
74
+    //         title: Text("Testing"),
75
+    //         elevation: 1,
76
+    //         backgroundColor: Colors.transparent,
77
+    //
78
+    //       ),
79
+    //       opaque: false,
80
+    //   )
81
+    //
82
+    // );
83
+
84
+    showDialog<void>(
85
+      context: context,
86
+      barrierDismissible: false,
87
+      barrierColor: Colors.transparent,
88
+
89
+      builder: (BuildContext context){
90
+        Future.delayed(Duration(seconds: 2), () {
91
+          Navigator.of(context).pop(true);
92
+        });
93
+
94
+        return Material(
95
+          color: Colors.transparent,
96
+          child: InkResponse(
97
+            child: Container(
98
+
99
+              alignment: Alignment.bottomCenter,
100
+              padding: EdgeInsets.only(bottom: 30),
101
+              child: Text(
102
+                  "Email address is already registered",
103
+                  style: TextStyle(fontSize: 18, color: Colors.red),),
104
+
105
+            ),
106
+          )
107
+        );
108
+
109
+        // return Banner(
110
+        //   location: BannerLocation.bottomEnd,
111
+        //   message: "Hello there",
112
+        //
113
+        // );
114
+
115
+        // // allows the message to disappear
116
+        // Future.delayed(Duration(seconds: 2), () {
117
+        //   Navigator.of(context).pop(true);
118
+        // });
119
+        // return AlertDialog(
120
+        //   buttonPadding: ,
121
+        //   title: Text("Testing"),
122
+        //   elevation: 1,
123
+        //   backgroundColor: Colors.transparent,
124
+        // );
125
+      }
126
+    );
127
+  }
128
+
129
+
130
+
131
+  Widget _BackButton(BuildContext context) {
42 132
     return InkWell(
43
-      onTap: (){
133
+      onTap: () {
44 134
         Navigator.pop(context);
45 135
       },
46 136
       child: Row(
47
-        children: <Widget>[
48
-          Container(
49
-            padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
50
-            child: Icon(Icons.arrow_back_ios, color: Colors.black),
51
-          ),
52
-          Text("Back",
53
-          style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500))
54
-        ]
137
+          children: <Widget>[
138
+            Container(
139
+              padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
140
+              child: Icon(Icons.arrow_back_ios, color: Colors.black),
141
+            ),
142
+            Text("Back",
143
+                style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500))
144
+          ]
55 145
       ),
56 146
     );
57 147
   }
58 148
 
59
-  Widget _SubmitButton(BuildContext context){
60
-    return InkWell(
61
-       onTap: (){
62
-
63
-       },
64
-      child: Container(
149
+  Widget _SubmitButton(BuildContext context) {
150
+    return InkResponse(
151
+      onTap: () {
152
+        send_data();
153
+        // _Alert(BuildContext);
154
+        // _Match(context);
155
+        _Alerts(context);
156
+      },
157
+      child: Material(
158
+        borderRadius: BorderRadius.circular(30),
159
+        elevation: 3,
160
+        child: Container(
65 161
         padding: EdgeInsets.symmetric(vertical: 10),
66 162
         width: 250,
67 163
         alignment: Alignment.center,
@@ -69,93 +165,110 @@ class _RegisterPageState extends State<RegisterPage> {
69 165
           color: Colors.red,
70 166
           borderRadius: BorderRadius.circular(30),
71 167
         ),
168
+
72 169
         child: Text(
73 170
           "Submit",
74 171
           style: TextStyle(fontSize: 22, color: Colors.white),
75 172
         ),
173
+        ),
76 174
       ),
77 175
     );
78 176
   }
79 177
 
80
-  Widget _EntryField(String title, TextEditingController controller, {bool pass = false}){
81
-    return Container(
82
-      padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
83
-      child: Column(
84
-        crossAxisAlignment: CrossAxisAlignment.start,
85
-      
86
-        children: <Widget> [
87
-          Text(
88
-            title,
89
-            style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
90
-          ),
91
-          SizedBox(
92
-            height: 30
93
-          ),
94
-          TextField(
95
-            controller: controller,
96
-            obscureText: pass,
97
-            decoration: InputDecoration(
98
-              border: (
99
-                  UnderlineInputBorder()
178
+    Widget _EntryField(String title, TextEditingController controller,
179
+        {bool pass = false}) {
180
+      return Container(
181
+        padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
182
+        child: Column(
183
+            crossAxisAlignment: CrossAxisAlignment.start,
184
+
185
+            children: <Widget>[
186
+              Text(
187
+                title,
188
+                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
100 189
               ),
101
-            ),
102
-          )
103
-        ]
104
-      ),
105
-      
106
-    );
107
-  }
190
+              SizedBox(
191
+                  height: 30
192
+              ),
193
+              TextField(
194
+                controller: controller,
195
+                obscureText: pass,
196
+                decoration: InputDecoration(
197
+                  border: (
198
+                      UnderlineInputBorder()
199
+                  ),
200
+                ),
201
+              )
202
+            ]
203
+        ),
108 204
 
109
-  Widget _Fills(){
110
-    return Column(
111
-      children: <Widget> [
112
-      _EntryField("Email", email),
113
-      _EntryField("Password", password, pass: true),
114
-      _EntryField("Confirm Password", confirmpass, pass: true)
115
-    
116
-    ]
117
-    );
118
-  }
205
+      );
206
+    }
119 207
 
120
-//add column or stack
121
-  @override
122
-  Widget build(BuildContext context) {
123
-    final height = MediaQuery.of(context).size.height;
124
-    return Scaffold(
125
-      body: Container(
126
-        height: height,
127
-        child: Stack(
128
-          
208
+    Widget _Fills() {
209
+      return Column(
129 210
           children: <Widget>[
130
-            Container(
131
-              padding: EdgeInsets.symmetric(horizontal: 20),
132
-              child: SingleChildScrollView(
133
-                child: Column(
134
-                  crossAxisAlignment: CrossAxisAlignment.center,
135
-                  mainAxisAlignment: MainAxisAlignment.center,
136
-                  children: <Widget>[
137
-                     SizedBox(
138
-                      height: 200,
139
-                    ),
140
-                    _Fills(),
141
-                    //Add code to verify if password and confirm password match
142
-                    SizedBox(
143
-                      height: 20,
144
-                    ),
145
-                    _SubmitButton(context),
146
-                  ],
211
+            _EntryField("Email", email),
212
+            _EntryField("Password", password, pass: true),
213
+            _EntryField("Confirm Password", confirmpass, pass: true)
214
+
215
+          ]
216
+      );
217
+    }
218
+
219
+//add column or stack
220
+    @override
221
+    Widget build(BuildContext context) {
222
+      final height = MediaQuery
223
+          .of(context)
224
+          .size
225
+          .height;
226
+      return Scaffold(
227
+          body: Container(
228
+            height: height,
229
+            child: Stack(
230
+
231
+              children: <Widget>[
232
+                Container(
233
+                    padding: EdgeInsets.symmetric(horizontal: 20),
234
+                    child: SingleChildScrollView(
235
+                      child: Column(
236
+                        crossAxisAlignment: CrossAxisAlignment.center,
237
+                        mainAxisAlignment: MainAxisAlignment.center,
238
+                        children: <Widget>[
239
+                          // Text("Username", style: TextStyle(fontSize: 18.0),),
240
+                          // TextField(
241
+                          //   controller: name,
242
+                          //   decoration: InputDecoration(
243
+                          //       hintText: 'name'
244
+                          //   ),
245
+                          // ),
246
+                          SizedBox(
247
+                            height: 100,
248
+                          ),
249
+                          _Fills(),
250
+                          //Add code to verify if password and confirm password match
251
+                          SizedBox(
252
+                            height: 20,
253
+                          ),
254
+                          _SubmitButton(context),
255
+                          SizedBox(
256
+                            height: 10,
257
+                          ),
258
+                          // ElevatedButton(
259
+                          //     onPressed: send_data, child: Text("Register")),
260
+                        ],
261
+                      ),
262
+                    )
147 263
                 ),
148
-              )
264
+                Positioned(
265
+                  top: 15, left: 20, child: _BackButton(context),
266
+                ),
267
+              ],
268
+
149 269
             ),
150
-            Positioned(
151
-            top: 12, left: 20, child: _BackButton(context),
152
-          ),
153
-          ],
154
-          
155
-        ),
156
-      )
157
-    );
270
+          )
271
+      );
272
+    }
158 273
   }
159
-    
160
-}
161 274
 

+ 68
- 33
fast_med_flutter/lib/routes/welcome.dart 查看文件

@@ -1,10 +1,14 @@
1
-
2
-
1
+import 'dart:convert';
2
+// import 'dart:html';
3
+import 'dart:io';
4
+import 'package:flutter/cupertino.dart';
3 5
 import 'package:flutter_login/flutter_login.dart';
4 6
 import 'package:flutter/material.dart';
5 7
 import 'package:google_fonts/google_fonts.dart';
6 8
 import 'register.dart';
7
-
9
+import 'package:http/http.dart' as http;
10
+import 'dart:convert' as convert;
11
+import 'navigation.dart';
8 12
 
9 13
 
10 14
 
@@ -19,9 +23,34 @@ class WelcomePage extends StatefulWidget {
19 23
 }
20 24
 
21 25
 class _WelcomePageState extends State<WelcomePage> {
26
+  var Token;
27
+  TextEditingController email = new TextEditingController();
28
+  TextEditingController password = new TextEditingController();
29
+
30
+
31
+  Future<List> send_data() async {
32
+
33
+    var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/API/login.php';
34
+    http.Response response = await http.post(url, body: {
35
+      "email": email.text,
36
+      "password": password.text,
37
+    });
38
+    print(response.body);
39
+    print(response.statusCode);
40
+    print(HttpStatus.ok);
41
+    if("user not found" == response.body){
42
+      print("maybe we use this");
43
+    }
44
+    else{
45
+      print("User found");
46
+      Token = email.text;
47
+
48
+      Navigator.push(
49
+          context, MaterialPageRoute(builder: (context) => NavigationPage()));
50
+
51
+    }
52
+  }
22 53
 
23
-  TextEditingController email;
24
-  TextEditingController password;
25 54
 
26 55
   Widget _message(BuildContext context){
27 56
     return RichText(
@@ -59,7 +88,7 @@ class _WelcomePageState extends State<WelcomePage> {
59 88
           children: <Widget> [
60 89
             Text(
61 90
               title,
62
-              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
91
+              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
63 92
             ),
64 93
             SizedBox(
65 94
                 height: 30
@@ -81,6 +110,8 @@ class _WelcomePageState extends State<WelcomePage> {
81 110
     );
82 111
   }
83 112
 
113
+
114
+
84 115
   Widget _Fills(){
85 116
     return Column(
86 117
         children: <Widget> [
@@ -93,31 +124,31 @@ class _WelcomePageState extends State<WelcomePage> {
93 124
 
94 125
 
95 126
 
96
-  // Widget _LogInButton(BuildContext context){
97
-  //   return InkWell(
98
-  //     // onTap: () {
99
-  //     //   Navigator.push(context, MaterialPageRoute(builder: (context)) => __LoginPage())
100
-  //     // },
101
-  //     child: Container(
102
-  //       // width: MediaQuery.of(context).size.width,
103
-  //       width: 200,
104
-  //       // height: ,
105
-  //       padding: EdgeInsets.symmetric(vertical:8),
106
-  //       alignment: Alignment.center,
107
-  //       decoration: BoxDecoration(
108
-  //         color: Colors.red,
109
-  //         // shape:
110
-  //
111
-  //         borderRadius: BorderRadius.circular(30),
112
-  //       ),
113
-  //       child: Text(
114
-  //         "Login",
115
-  //         style: TextStyle(fontSize: 25, color: Colors.white),
116
-  //       ),
117
-  //
118
-  //     )
119
-  //   );
120
-  // }
127
+
128
+  Widget _SubmitButton(BuildContext context){
129
+    return InkResponse(
130
+      onTap: (){
131
+
132
+        send_data();
133
+
134
+
135
+      },
136
+      child: Container(
137
+        padding: EdgeInsets.symmetric(vertical: 10),
138
+        width: 180,
139
+        alignment: Alignment.center,
140
+        decoration: BoxDecoration(
141
+          color: Colors.red,
142
+          borderRadius: BorderRadius.circular(30),
143
+        ),
144
+        child: Text(
145
+          "Login",
146
+          style: TextStyle(fontSize: 22, color: Colors.white),
147
+        ),
148
+      ),
149
+    );
150
+  }
151
+
121 152
 
122 153
   Widget _RegisterButton(BuildContext context){
123 154
     return InkWell(
@@ -183,13 +214,17 @@ class _WelcomePageState extends State<WelcomePage> {
183 214
                     SizedBox(
184 215
                       height: 60,
185 216
                     ),
217
+                    _SubmitButton(context),
218
+                    SizedBox(
219
+                      height: 45,
220
+                    ),
186 221
                     _message(context),
187 222
                     SizedBox(
188
-                      height: 10,
223
+                      height: 15,
189 224
                     ),
190 225
                     _RegisterButton(context),
191 226
                     SizedBox(
192
-                      height: 10,
227
+                      height: 20,
193 228
                     )
194 229
                   ],
195 230
                 )