Advertisement
NappDev

Untitled

Jun 12th, 2022 (edited)
1,392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.83 KB | None | 0 0
  1. import 'package:dog_diary/screens/authentication/signup.dart';
  2. import 'package:dog_diary/screens/home.dart';
  3. import 'package:dog_diary/services/auth_service.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:dog_diary/widgets/button.dart';
  6. import 'package:dog_diary/widgets/textfield_input.dart';
  7. import 'package:flutter_svg/flutter_svg.dart';
  8. import 'package:dog_diary/utils/global_variables.dart';
  9.  
  10. class SignIn extends StatefulWidget {
  11.   static const String routeName = '/signin';
  12.   const SignIn({Key? key}) : super(key: key);
  13.  
  14.   @override
  15.   _SignInState createState() => _SignInState();
  16. }
  17.  
  18. class _SignInState extends State<SignIn> {
  19.   final AuthService authService = AuthService();
  20.   final _signInFormKey = GlobalKey<FormState>();
  21.   final TextEditingController _emailController = TextEditingController();
  22.   final TextEditingController _passwordController = TextEditingController();
  23.  
  24.   @override
  25.   void dispose() {
  26.     super.dispose();
  27.     _emailController.dispose();
  28.     _passwordController.dispose();
  29.   }
  30.  
  31.   void signInUser() {
  32.     authService.signInUser(
  33.       context: context,
  34.       email: _emailController.text,
  35.       password: _passwordController.text,
  36.     );
  37.   }
  38.  
  39.   @override
  40.   Widget build(BuildContext context) {
  41.     return Scaffold(
  42.         resizeToAvoidBottomInset: false,
  43.         backgroundColor: GlobalVariables.backgroundColor,
  44.         body: SafeArea(
  45.             top: true,
  46.             bottom: false,
  47.             child: Container(
  48.               width: double.infinity,
  49.               padding: const EdgeInsets.only(top: 10.0),
  50.               child: SingleChildScrollView(
  51.                 reverse: true,
  52.                 child: Column(
  53.                   crossAxisAlignment: CrossAxisAlignment.center,
  54.                   children: [
  55.                     SvgPicture.asset('assets/images/logo.svg'),
  56.                     Image.asset('assets/images/frenchie@3x.png'),
  57.                     Container(
  58.                       decoration: const BoxDecoration(
  59.                         color: Colors.white,
  60.                         borderRadius: BorderRadius.only(
  61.                             topLeft: Radius.circular(30.0),
  62.                             topRight: Radius.circular(30.0)),
  63.                       ),
  64.                       child: Form(
  65.                           key: _signInFormKey,
  66.                           child: Column(
  67.                             children: [
  68.                               Container(
  69.                                 padding:
  70.                                     const EdgeInsets.fromLTRB(20, 10, 20, 5),
  71.                                 child: TextFieldInput(
  72.                                   hintText: 'Enter your email',
  73.                                   controller: _emailController,
  74.                                 ),
  75.                               ),
  76.                               Container(
  77.                                 padding:
  78.                                     const EdgeInsets.fromLTRB(20, 10, 20, 5),
  79.                                 child: TextFieldInput(
  80.                                   hintText: 'Enter your password',
  81.                                   controller: _passwordController,
  82.                                   isPass: true,
  83.                                 ),
  84.                               ),
  85.                               Container(
  86.                                 padding:
  87.                                     const EdgeInsets.fromLTRB(20, 30, 20, 5),
  88.                                 child: CustomButton(
  89.                                   text: 'SIGN IN',
  90.                                   onTap: () {
  91.                                     if (_signInFormKey.currentState!
  92.                                         .validate()) {
  93.                                       signInUser();
  94.                                     }
  95.                                   },
  96.                                 ),
  97.                               ),
  98.                               Container(
  99.                                   padding:
  100.                                       const EdgeInsets.fromLTRB(20, 20, 20, 35),
  101.                                   child: Row(
  102.                                     mainAxisAlignment: MainAxisAlignment.center,
  103.                                     crossAxisAlignment:
  104.                                         CrossAxisAlignment.center,
  105.                                     children: [
  106.                                       Container(
  107.                                         child: const Text(
  108.                                           'NOT YET A MEMBER?',
  109.                                         ),
  110.                                       ),
  111.                                       GestureDetector(
  112.                                         onTap: () =>
  113.                                             Navigator.pushNamedAndRemoveUntil(
  114.                                           context,
  115.                                           SignUp.routeName,
  116.                                           (route) => false,
  117.                                         ),
  118.                                         child: Container(
  119.                                           child: const Text(
  120.                                             ' SIGN UP .',
  121.                                             style: TextStyle(
  122.                                                 fontWeight: FontWeight.bold,
  123.                                                 color:
  124.                                                     GlobalVariables.mainColor),
  125.                                           ),
  126.                                         ),
  127.                                       ),
  128.                                     ],
  129.                                   ))
  130.                             ],
  131.                           )),
  132.                     )
  133.                   ],
  134.                 ),
  135.               ),
  136.             )));
  137.   }
  138. }
  139.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement