// import 'dart:convert'; // import 'package:flutter/material.dart'; // import 'package:authsec_flutter/hadwin_components.dart'; // import 'package:shared_preferences/shared_preferences.dart'; // import '../../Utils/color_constants.dart'; // import '../../Utils/image_constant.dart'; // import '../../Utils/size_utils.dart'; // import '../../providers/token_manager.dart'; // import '../../theme/app_style.dart'; // import '../../widgets/app_bar/appbar_title.dart'; // import '../../widgets/app_bar/custom_app_bar.dart'; // import '../../widgets/custom_button.dart'; // import '../../widgets/custom_image_view.dart'; // import '../../widgets/custom_text_form_field.dart'; // import '../forgot_password/forgotPasswordScreen.dart'; // import '../main_app_screen/newlanding_page.dart'; // import '../sign_up_screen/sign_up_step_1.dart'; // // // // class LoginScreen extends StatefulWidget { // const LoginScreen({Key? key}) : super(key: key); // // @override // _LoginScreenState createState() => _LoginScreenState(); // } // // class _LoginScreenState extends State { // TextEditingController inputFieldController = TextEditingController(); // TextEditingController inputFieldOneController = TextEditingController(); // // String errorMessage1 = ""; // String errorMessage2 = ""; // bool isPasswordVisible = false; // bool stayLoggedIn = false; // // @override // initState(){ // super.initState(); // } // // GlobalKey _formKey = GlobalKey(); // // void errorMessageSetter(int fieldNumber, String message) { // setState(() { // if (fieldNumber == 1) { // errorMessage1 = message; // } else { // errorMessage2 = message; // } // }); // } // // void tryLoggingIn() async { // final dataReceived = await sendData( // urlPath: "/token/session", // data: {"email": inputFieldController.text, "password": inputFieldOneController.text}, // ); // // if (dataReceived.containsValue('ERROR')) { // var error = dataReceived['operationMessage'].toString(); // // ignore: use_build_context_synchronously // ScaffoldMessenger.of(context) // .showSnackBar(SnackBar( // content: Text(error), // backgroundColor: Colors.redAccent, // )) // .closed; // } else { // var token = dataReceived['item']['token']; // var user = dataReceived['item']; // await TokenManager.setToken(token); // // if (stayLoggedIn) { // await _saveLoggedInUserData(token, user); // } // // ignore: use_build_context_synchronously // ScaffoldMessenger.of(context) // .showSnackBar(const SnackBar( // content: Text("Login Successful"), // backgroundColor: Colors.green, // )) // .closed // .then( // (value) => Navigator.of(context).pushAndRemoveUntil( // MaterialPageRoute( // builder: (context) => TabbedLayoutComponentb(), // ), // (route) => false, // ), // ); // // print('after login'); // } // } // // Future _saveLoggedInUserData( // String loggedInUserAuthKey, Map user) async { // try { // var userId = user['userId'].toString(); // var firstName = user['firstName'].toString(); // // final prefs = await SharedPreferences.getInstance(); // await prefs.setString('userData', json.encode(user)); // await prefs.setBool('isLoggedIn', true); // await prefs.setString('token', loggedInUserAuthKey); // // print('userId ....$userId'); // print('firstName ....$firstName'); // // if (mounted) { // debugPrint("user data saved"); // } // // return true; // } catch (e) { // return false; // } // } // // // @override // Widget build(BuildContext context) { // return Scaffold( // backgroundColor: ColorConstant.gray50, // appBar: CustomAppBar( // height: getVerticalSize(54), // leadingWidth: 40, // centerTitle: true, // title: AppbarTitle(text: "Login")), // body: SingleChildScrollView( // child: Form( // key: _formKey, // child: Container( // width: double.maxFinite, // padding: // getPadding(left: 16, top: 22, right: 16, bottom: 22), // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, // children: [ // Padding( // padding: getPadding(top: 19), // child: Text("Email", // overflow: TextOverflow.ellipsis, // textAlign: TextAlign.left, // style: AppStyle.txtGilroyMedium16Bluegray900),), // // CustomTextFormField( // focusNode: FocusNode(), // controller: inputFieldController, // hintText: "Enter Your Email", // padding: TextFormFieldPadding.PaddingT12, // // margin: getMargin(top: 7), // textInputType: TextInputType.emailAddress), // Padding( // padding: getPadding(top: 19), // child: Text("Password", // overflow: TextOverflow.ellipsis, // textAlign: TextAlign.left, // style: // AppStyle.txtGilroyMedium16Bluegray900)), // CustomTextFormField( // focusNode: FocusNode(), // controller: inputFieldOneController, // hintText: "Enter Password", // margin: getMargin(top: 6), // padding: TextFormFieldPadding.PaddingT12, // textInputAction: TextInputAction.done, // textInputType:TextInputType.visiblePassword, // suffix: IconButton( // icon: Icon( // isPasswordVisible ? Icons.visibility_off : Icons.visibility, // size: 12, // ), // onPressed: () { // setState(() { // isPasswordVisible = !isPasswordVisible; // }); // }, // ), // suffixConstraints: BoxConstraints( // maxHeight: getVerticalSize(44)), // isObscureText: !isPasswordVisible), // Padding( // padding: getPadding(top: 17), // child: Row(children: [ // Checkbox(value: stayLoggedIn, // activeColor: ColorConstant.blueA700, // onChanged: (value) { // setState(() { // stayLoggedIn = value!; // }); // },), // Padding( // padding: // getPadding(left: 8, top: 1, bottom: 1), // child: Text("Remember me", // overflow: TextOverflow.ellipsis, // textAlign: TextAlign.left, // style: AppStyle.txtGilroyMedium14)), // Spacer(), // GestureDetector( // onTap: getLoginHelp, // child: Padding( // padding: getPadding(top: 3), // child: Text("Forgot Password?", // overflow: TextOverflow.ellipsis, // textAlign: TextAlign.left, // style: // AppStyle.txtGilroyMedium14BlueA700)), // ) // ])), // CustomButton( // height: getVerticalSize(50), // width: getHorizontalSize(396), // text: "Log in", // margin: getMargin(top: 25), // onTap: (){ // if(inputFieldOneController.text==''||inputFieldController.text==''){ // ScaffoldMessenger.of(context).showSnackBar( // const SnackBar( // content: Text('Please provide all required details'), // backgroundColor: Colors.red, // ), // ); // }else{ // _validateLoginDetails(); // } // }, // ), // Padding( // padding: getPadding(top: 26), // child: Row( // mainAxisAlignment: // MainAxisAlignment.spaceBetween, // crossAxisAlignment: CrossAxisAlignment.end, // children: [ // Padding( // padding: getPadding(top: 10, bottom: 7), // child: Divider( // height: getVerticalSize(1), // thickness: getVerticalSize(1), // color: ColorConstant.blueGray200)), // Text("Or continue with", // overflow: TextOverflow.ellipsis, // textAlign: TextAlign.left, // style: AppStyle // .txtGilroyRegular16Bluegray200), // Padding( // padding: getPadding(top: 10, bottom: 7), // child: Divider( // height: getVerticalSize(1), // thickness: getVerticalSize(1), // color: ColorConstant.blueGray200)) // ])), // CustomButton( // height: getVerticalSize(50), // text: "Sign Up", // margin: getMargin(top: 28), // variant: ButtonVariant.OutlineBlueA700, // padding: ButtonPadding.PaddingT14, // fontStyle: ButtonFontStyle.GilroyMedium16BlueA700, // onTap:goToSignUpScreen , // // prefixWidget: Container( // // margin: getMargin(right: 8), // // child: CustomImageView( // // svgPath: ImageConstant.imgGoogle)) // ), // CustomButton( // height: getVerticalSize(50), // text: "Sign in with Google", // margin: getMargin(top: 28), // variant: ButtonVariant.OutlineBlueA700, // padding: ButtonPadding.PaddingT14, // fontStyle: ButtonFontStyle.GilroyMedium16BlueA700, // prefixWidget: Container( // margin: getMargin(right: 8), // child: CustomImageView( // svgPath: ImageConstant.imgGoogle))), // CustomButton( // height: getVerticalSize(50), // text: "Sign in with Facebook", // margin: getMargin(top: 17), // variant: ButtonVariant.OutlineBlueA700, // padding: ButtonPadding.PaddingT14, // fontStyle: ButtonFontStyle.GilroyMedium16BlueA700, // prefixWidget: Container( // padding: // getPadding(left: 9, top: 4, right: 3), // margin: getMargin(right: 8), // decoration: BoxDecoration( // color: ColorConstant.blue700, // borderRadius: BorderRadius.circular( // getHorizontalSize(3))), // child: CustomImageView( // svgPath: ImageConstant.imgFacebook))), // CustomButton( // height: getVerticalSize(50), // text: "Sign in with Linkedin", // margin: getMargin(top: 17), // variant: ButtonVariant.OutlineBlueA700, // padding: ButtonPadding.PaddingT14, // fontStyle: ButtonFontStyle.GilroyMedium16BlueA700, // prefixWidget: Container( // margin: getMargin(right: 8), // child: CustomImageView( // svgPath: ImageConstant.imgLinkedin11))), // Align( // alignment: Alignment.center, // child: Padding( // padding: getPadding(top: 28, bottom: 5), // child: RichText( // text: TextSpan(children: [ // TextSpan( // text: "", // style: TextStyle( // color: ColorConstant.fromHex( // "#ff12282a"), // fontSize: getFontSize(16), // fontFamily: 'Gilroy', // fontWeight: FontWeight.w400)), // TextSpan( // text: " ", // style: TextStyle( // color: ColorConstant.fromHex( // "#ff12282a"), // fontSize: getFontSize(16), // fontFamily: 'Gilroy', // fontWeight: FontWeight.w700)), // TextSpan( // text: "", // style: TextStyle( // color: ColorConstant.fromHex( // "#ff0061ff"), // fontSize: getFontSize(16), // fontFamily: 'Gilroy', // fontWeight: FontWeight.w700, // decoration: // TextDecoration.underline)) // ]), // textAlign: TextAlign.left))) // ]))), // ), // ); // } // // // onTapArrowleft6(BuildContext context) { // // Navigator.pop(context); // // } // // void _validateLoginDetails() { // FocusManager.instance.primaryFocus?.unfocus(); // if (_formKey.currentState!.validate()) { // if (errorMessage1 != "" || errorMessage2 != "") { // ScaffoldMessenger.of(context).showSnackBar( // const SnackBar( // content: Text('Please provide all required details'), // backgroundColor: Colors.red, // ), // ); // } else { // ScaffoldMessenger.of(context).showSnackBar( // SnackBar( // onVisible: tryLoggingIn, // content: const Text('Processing...'), // backgroundColor: Colors.blue, // ), // ); // } // } // } // // void getLoginHelp() { // //ForgotPasswordPage // Navigator.push( // context, MaterialPageRoute(builder: (context) => ForgotPasswordPage())); // // Navigator.push( // // context, // // SlideRightRoute( // // page: const HadWinMarkdownViewer( // // screenName: 'Login Help', // // urlRequested: // // 'https://raw.githubusercontent.com/brownboycodes/HADWIN/master/docs/HADWIN_WIKI.md'))); // } // // void goToSignUpScreen() { // // Navigator.push(context, // // MaterialPageRoute(builder: (context) => SignUpUserScreen())) // // .then((value) => const LoginScreen()); // // Navigator.push(context, // MaterialPageRoute(builder: (context) => SignUpUserScreenNew())) // .then((value) => const LoginScreen()); // // // } // // } import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import '../../Utils/color_constants.dart'; import '../../utilities/hadwin_markdown_viewer.dart'; import '../../utilities/slide_right_route.dart'; import '../sign_up_screen/SignUpUser.dart'; import '../sign_up_screen/sign_up_step_1.dart'; import 'form_component.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State { @override Widget build(BuildContext context) { Widget helpInfoContainer = SizedBox( width: double.infinity, height: 36, child: Center( child: InkWell( onTap: getLoginHelp, child: const Text( 'Having trouble logging in?', style: TextStyle(fontSize: 14, color: Color(0xFF929BAB)), ), // FOR LOGIN HELP ), ), ); Widget signUpContainer = const SizedBox( width: double.infinity, height: 36, child: Center( child: InkWell( //onTap: goToSignUpScreen, child: Text( 'Or Continue with', style: TextStyle(fontSize: 14, color: Color(0xFF929BAB)), ), // FOR SIGN UP ), ), ); List loginScreenContents = [ _spacing(30), Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: SvgPicture.asset( 'assets/images/cloudnsuresp.svg', width: 300, ), ), _spacing(30), const LoginFormComponent(), // ON LOGIN SCREEN _spacing(10), signUpContainer, _spacing(10), Container( margin: const EdgeInsets.symmetric(vertical: 16.0), width: double.infinity, height: 64, child: ElevatedButton( onPressed: goToSignUpScreen, style: ElevatedButton.styleFrom( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), side: BorderSide(color: ColorConstant.blue700, width: 2.0), ), ), child: Text( 'Sign Up', style: TextStyle( fontSize: 16, color: ColorConstant.blue700, fontWeight: FontWeight.w600, ), ), ), ), Container( margin: const EdgeInsets.symmetric(vertical: 16.0), width: double.infinity, height: 64, child: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), side: BorderSide(color: ColorConstant.blue700, width: 2.0), ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( 'assets/images/img_google.svg', ), const SizedBox( width: 10, ), Text( 'Sign in with Google', style: TextStyle( fontSize: 16, color: Colors.grey, //ColorConstant.blue700, fontWeight: FontWeight.w600, ), ), ], ), ), ), Container( margin: const EdgeInsets.symmetric(vertical: 16.0), width: double.infinity, height: 64, child: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), side: BorderSide(color: ColorConstant.blue700, width: 2.0), ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( 'assets/images/img_linkedin_1_1.svg', ), const SizedBox( width: 10, ), Text( 'Sign in with LinkedIn', style: TextStyle( fontSize: 16, color: Colors.grey, //ColorConstant.blue700, fontWeight: FontWeight.w600, ), ), ], ), ), ), ]; return Scaffold( body: SingleChildScrollView( padding: const EdgeInsets.all(45), child: Column( children: loginScreenContents, ), ), ); } void getLoginHelp() { Navigator.push( context, SlideRightRoute( page: const HadWinMarkdownViewer( screenName: 'Login Help', urlRequested: 'https://raw.githubusercontent.com/brownboycodes/HADWIN/master/docs/HADWIN_WIKI.md'))); } void goToSignUpScreen() { Navigator.push(context, MaterialPageRoute(builder: (context) => SignUpUserScreenNew())) .then((value) => const LoginScreen()); } SizedBox _spacing(double height) => SizedBox( height: height, ); }