login

 avatar
unknown
plain_text
2 years ago
8.8 kB
3
Indexable
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sizer/sizer.dart';
import 'package:smartbutler/utils/colors.dart';
import 'package:smartbutler/utils/textstyle.dart';
import '../../../../utils/images.dart';
import '../../../../utils/widgets/button.dart';
import '../../../../utils/widgets/or_widget.dart';
import '../../../../utils/widgets/row_text.dart';
import '../../../../utils/widgets/textfield.dart';
import '../../../routes/app_pages.dart';
import '../controllers/login_controller.dart';

class LoginView extends GetView<LoginController> {
  const LoginView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<LoginController>(
      init: LoginController(),
      builder: (controller) {
        return Scaffold(
          resizeToAvoidBottomInset: false,
          body: Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage(AppImages.loginBg),
                fit: BoxFit.fill,
              ),
            ),
            child: Column(
              // mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Padding(
                  padding:  EdgeInsets.only(left: 20.sp),
                  child: Container(
                    margin: EdgeInsets.only(top: 60.sp),
                    child: Form(
                      key: controller.loginFormKey,
                      autovalidateMode: AutovalidateMode.onUserInteraction,
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            'welcome_back_com'.tr,
                            style: AppStyle.montserrat(fontSize: 40,color: darkGrey),
                            textAlign: TextAlign.start,
                          ),
                          Padding(
                            padding: const EdgeInsets.symmetric(vertical: 8.0),
                            child: Row(
                              children: [
                                Text(
                                  'Login',
                                  style: AppStyle.montserrat(
                                    fontSize: 20,color: blue,
                                  ),
                                  textAlign: TextAlign.start,
                                ),
                                Padding(
                                  padding: const EdgeInsets.only(left: 5),
                                  child: Text(
                                    'back '+'into_acc'.tr,
                                    style: AppStyle.montserrat(fontSize: 20,fontWeight: FontWeight.w500, ),
                                    textAlign: TextAlign.start,
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                Spacer(),
                Stack(
                  children: [
                    Container(
                      margin: EdgeInsets.only(top: 70),
                      height: MediaQuery.of(context).size.height / 2.05,
                      width: MediaQuery.of(context).size.width,
                      decoration: BoxDecoration(
                        color: white,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(50),
                          topRight: Radius.circular(50),),),
                      child: Padding(
                        padding:
                        const EdgeInsets.only(left: 45, right: 45, top: 40),
                        child: SingleChildScrollView(
                          child: Column(
                            children: [
                              Padding(
                                padding: const EdgeInsets.only(bottom: 15),
                                child: CommonTextField(
                                  controller: controller.txtEmailController,
                                  focusNode: controller.emailFocus,
                                  validator: (val) {
                                    Pattern pattern = 'email_validation'.tr;
                                    RegExp regex = RegExp(pattern.toString());
                                    if (val!.isEmpty) {
                                      return 'enter_email'.tr;
                                    } else if (!regex.hasMatch(val)) {
                                      return 'enter_valid_email'.tr;
                                    }
                                    return null;
                                  },
                                  color: purple,
                                  prefixIcon: Padding(
                                    padding: const EdgeInsets.all(14),
                                    child: SizedBox(
                                      height: 10,
                                      width: 10,
                                      child: Image.asset(AppImages.email),),
                                  ),
                                  hintText: 'email'.tr,
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(bottom: 15),
                                child: CommonTextField(
                                  controller: controller.txtLoginPassword,
                                  obscureText: controller.IsShowPwd.value,
                                  validator: (val) {
                                    if (val!.isEmpty) {
                                      return 'enter_password'.tr;
                                    }
                                    return null;
                                  },
                                  color: blue,
                                  prefixIcon: Padding(
                                    padding: const EdgeInsets.all(14),
                                    child: SizedBox(
                                      height: 10,
                                      width: 10,
                                      child: Image.asset(AppImages.lock),),
                                  ),
                                  hintText: 'password'.tr,
                                ),
                              ),
                              Button(
                                onTap: (){
                                  // Get.toNamed(Routes.HOME);
                                  if (controller.loginFormKey.currentState!
                                      .validate()) {
                                    controller.signIn();
                                  }
                                },
                                text: 'Login',
                              ),
                              Padding(
                                padding: const EdgeInsets.symmetric(vertical: 18,horizontal: 20),
                                child: OrWidget(),
                              ),
                              GoogleButton(
                                onTap: (){
                                  controller.googleSignIn();
                                },
                                isGoogleIcon: true,
                                text: 'google_sign_in'.tr,
                              ),
                              Padding(
                                padding: const EdgeInsets.symmetric(vertical: 18),
                                child: RowText(
                                  firstTxt: 'create_account'.tr,
                                  secondTxt: 'join_now'.tr,
                                  onTap: () {
                                    Get.offAndToNamed(
                                      Routes.REGISTERVIEW,
                                    );
                                  },
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    Center(
                      child: SizedBox(
                        height: 100,
                        width: 100,
                        child: Image.asset(AppImages.robo),),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
Editor is loading...