123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- import 'dart:convert';
- // import 'dart:html';
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter_login/flutter_login.dart';
- import 'package:flutter/material.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'register.dart';
- import 'package:http/http.dart' as http;
- import 'dart:convert' as convert;
- import 'navigation.dart';
-
-
-
-
- class WelcomePage extends StatefulWidget {
- WelcomePage({Key key, this.title}) : super(key: key);
-
- final String title;
-
- @override
- _WelcomePageState createState() => _WelcomePageState();
- }
-
- class _WelcomePageState extends State<WelcomePage> {
- var Token;
- TextEditingController email = new TextEditingController();
- TextEditingController password = new TextEditingController();
-
-
- Future<List> send_data() async {
-
- var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/API/login.php';
- http.Response response = await http.post(url, body: {
- "email": email.text,
- "password": password.text,
- });
- print(response.body);
- print(response.statusCode);
- print(HttpStatus.ok);
- if("user not found" == response.body){
- print("maybe we use this");
- }
- else{
- print("User found");
- Token = email.text;
-
- Navigator.push(
- context, MaterialPageRoute(builder: (context) => NavigationPage()));
-
- }
- }
-
-
- Widget _message(BuildContext context){
- return RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
- text: "Don't have an account?",
- style: GoogleFonts.cabin(
- fontSize: 18,
- color: Colors.black
- )
- ),
- );
- }
-
- Widget _title(BuildContext context){
- return RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
- text: "Welcome to FastMed",
- style: GoogleFonts.cabin(
- fontSize: 30,
- color: Colors.red
- )
- ),
- );
-
- }
-
- Widget _LoginField(String title, TextEditingController controller, {bool pass = false}){
- return Container(
- padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
-
- children: <Widget> [
- Text(
- title,
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- SizedBox(
- height: 30
- ),
- TextField(
- controller: controller,
- obscureText: pass,
- decoration: InputDecoration(
- border: (
- UnderlineInputBorder(
-
- )
- ),
- ),
- ),
- ]
- ),
-
- );
- }
-
-
-
- Widget _Fills(){
- return Column(
- children: <Widget> [
- _LoginField("Email", email),
- _LoginField("Password", password, pass: true),
-
- ]
- );
- }
-
-
-
-
- Widget _SubmitButton(BuildContext context){
- return InkResponse(
- onTap: (){
-
- send_data();
-
-
- },
- child: Container(
- padding: EdgeInsets.symmetric(vertical: 10),
- width: 180,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.circular(30),
- ),
- child: Text(
- "Login",
- style: TextStyle(fontSize: 22, color: Colors.white),
- ),
- ),
- );
- }
-
-
- Widget _RegisterButton(BuildContext context){
- return InkWell(
- onTap: () {
- Navigator.push(
- context, MaterialPageRoute(builder: (context) => RegisterPage()));
- },
- child: Container(
- // width: MediaQuery.of(context).size.width,
- width: 180,
- padding: EdgeInsets.symmetric(vertical:8),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: Colors.red,
- // shape:
-
- borderRadius: BorderRadius.circular(30),
- ),
- child: Text(
- "Register",
- style: TextStyle(fontSize: 22, color: Colors.white),
- ),
-
- )
- );
- }
-
- @override
- Widget build(BuildContext context) {
- final height = MediaQuery.of(context).size.height;
- return Scaffold(
- body: Container(
- height: height,
- child:Container(
- width: MediaQuery.of(context).size.width,
- padding: EdgeInsets.symmetric(horizontal: 20),
- // height: MediaQuery.of(context).size.height,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(4)),
- boxShadow: [
- BoxShadow(
- color: Colors.white,
- offset: Offset(0,3),
- blurRadius: 5,
- spreadRadius: 2)
- ]
-
- ),
- child: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget> [
- SizedBox(
- height: 80,
- ),
- _title(context),
- SizedBox(
- height: 150,
- ),
- // _LogInButton(context),
- _Fills(),
- SizedBox(
- height: 60,
- ),
- _SubmitButton(context),
- SizedBox(
- height: 45,
- ),
- _message(context),
- SizedBox(
- height: 15,
- ),
- _RegisterButton(context),
- SizedBox(
- height: 20,
- )
- ],
- )
- ),
- ),
- )
- );
- }
- }
|