From f2ff08b16ef6473584a346c983db71926af9dddc Mon Sep 17 00:00:00 2001 From: ZhiXin18 <95596621+ZhiXin18@users.noreply.github.com> Date: Sat, 21 Sep 2024 14:59:21 +0800 Subject: [PATCH] Delete loginScreen.dart --- loginScreen.dart | 191 ----------------------------------------------- 1 file changed, 191 deletions(-) delete mode 100644 loginScreen.dart diff --git a/loginScreen.dart b/loginScreen.dart deleted file mode 100644 index 3d3efca..0000000 --- a/loginScreen.dart +++ /dev/null @@ -1,191 +0,0 @@ -import 'package:flowmotion/screens/homeScreen.dart'; -import 'package:flutter/material.dart'; -import 'package:firebase_core/firebase_core.dart'; -import '../firebase_options.dart'; - -import 'package:firebase_auth/firebase_auth.dart' hide EmailAuthProvider; -//import 'package:firebase_ui_auth/firebase_ui_auth.dart'; - -import '../screens/registerScreen.dart'; -import '../components/background.dart'; -import 'forgetPasswordScreen.dart'; - -final FirebaseAuth _auth = FirebaseAuth.instance; - -Future main() async { - //make sure native code is set up correctly, need initialise native app before initialising firebase - WidgetsFlutterBinding.ensureInitialized(); //auto called inside runApp, but need do before runApp so need do this codes - await Firebase.initializeApp( //start firebase - options: DefaultFirebaseOptions.currentPlatform, - ); - runApp(LoginScreen()); -} - -class LoginScreen extends StatefulWidget { - @override - State createState() => _LoginScreenState(); -} - -class _LoginScreenState extends State { - final TextEditingController _usernameController = TextEditingController(); - final TextEditingController _emailController = TextEditingController(); - final TextEditingController _passwordController = TextEditingController(); - - int _success = 1; - String _userEmail = ""; - - void _signIn() async { - final User? user = (await _auth.signInWithEmailAndPassword(email: _emailController.text, password: _passwordController.text)).user; - - if(user != null) { - setState(() { - _success = 2; - _userEmail = user.email!; - Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen())); - }); - } else { - setState(() { - _success = 3; - }); - } - } - - @override - void dispose() { - _usernameController.dispose(); - _emailController.dispose(); - _passwordController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - Size size = MediaQuery.of(context).size; - - return Scaffold( - body: Background( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - alignment: Alignment.centerLeft, - padding: EdgeInsets.symmetric(horizontal: 40), - child: Text( - "LOGIN", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Color(0xFF2661FA), - fontSize: 36 - ), - textAlign: TextAlign.left, - ), - ), - - SizedBox(height: size.height * 0.03), - - Container( - alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 40), - child: TextField( - controller: _emailController, - decoration: InputDecoration( - labelText: "Email" - ), - ), - ), - - SizedBox(height: size.height * 0.03), - - Container( - alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 40), - child: TextField( - controller: _passwordController, - decoration: InputDecoration( - labelText: "Password" - ), - obscureText: true, //hide pwd with dots - ), - ), - - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) { - return ForgetPasswordScreen(); - })); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.symmetric(horizontal: 40, vertical: 10), - child: Text( - "Forgot your password?", - style: TextStyle( - fontSize: 12, - color: Color(0XFF2661FA) - ), - ), - ), - ), - - SizedBox(height: size.height * 0.05), - - Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.symmetric(horizontal: 40, vertical: 10), - child: ElevatedButton( - onPressed: () { - _signIn(); - }, - style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(80.0)), - padding: EdgeInsets.all(0), - ), - child: Container( - alignment: Alignment.center, - height: 50.0, - width: size.width * 0.5, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(80.0), - gradient: LinearGradient( - colors: [ - Color.fromARGB(255, 255, 136, 34), - Color.fromARGB(255, 255, 177, 41) - ], - ), - ), - padding: EdgeInsets.all(0), - child: Text( - "LOGIN", - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ), - - - Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.symmetric(horizontal: 40, vertical: 10), - child: GestureDetector( - onTap: () => { - Navigator.push(context, MaterialPageRoute(builder: (context) => RegisterScreen())) - }, - child: Text( - "Don't Have an Account? Sign up", - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Color(0xFF2661FA) - ), - ), - ), - ) - ], - ), - ), - ); - } -} \ No newline at end of file