register

mail@pastecode.io avatar
unknown
plain_text
a year ago
9.8 kB
2
Indexable
Never
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sizer/sizer.dart';
import 'package:smartbutler/utils/textstyle.dart';
import '../../../../utils/colors.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/registerview_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RegisterviewController>(
      init: RegisterviewController(),
      builder: (controller) {
        return Scaffold(
          resizeToAvoidBottomInset: false,
          body: Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage(AppImages.loginBg),
                fit: BoxFit.fill,
              ),
            ),
            child: Column(
              children: [
                Padding(
                  padding:  EdgeInsets.only(left: 20.sp),
                  child: Container(
                    margin: EdgeInsets.only(top: 60.sp),
                    child: SingleChildScrollView(
                      child: Form(
                        key: controller.registerFormKey,
                        autovalidateMode: AutovalidateMode.onUserInteraction,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              'welcome_to_com'.tr,
                              style: AppStyle.montserrat(fontSize: 40,color: darkGrey),
                              textAlign: TextAlign.start,
                            ),
                            Padding(
                              padding: const EdgeInsets.symmetric(vertical: 8.0),
                              child: Row(
                                children: [
                                  Text(
                                    'Signup',
                                    style: AppStyle.montserrat(
                                      fontSize: 20,
                                      color: blue,
                                    ),
                                    textAlign: TextAlign.start,
                                  ),
                                  Padding(
                                    padding: const EdgeInsets.only(left: 5),
                                    child: Text(
                                      'into_acc'.tr,
                                      style: AppStyle.montserrat(fontSize: 20,fontWeight: FontWeight.w500),
                                      textAlign: TextAlign.center,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                ),
                Spacer(),
                Stack(
                  children: [
                    Container(
                      height: MediaQuery.of(context).size.height / 1.75,
                      width: MediaQuery.of(context).size.width,
                      margin: EdgeInsets.only(top: 70),
                      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: 45),
                        child: SingleChildScrollView(
                          child: Column(
                            children: [
                              Padding(
                                padding: const EdgeInsets.only(bottom: 15),
                                child: CommonTextField(
                                  color: orange,
                                  prefixIcon: Padding(
                                    padding: const EdgeInsets.all(14),
                                    child: SizedBox(
                                      height: 10,
                                      width: 10,
                                      child: Image.asset(AppImages.user),
                                    ),
                                  ),
                                  hintText: 'full_name'.tr,
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(bottom: 15),
                                child: CommonTextField(
                                  controller: controller.txtEmailController,
                                  color: purple,
                                  prefixIcon: Padding(
                                    padding: const EdgeInsets.all(14),
                                    child: SizedBox(
                                      height: 10,
                                      width: 10,
                                      child: Image.asset(AppImages.email),
                                    ),
                                  ),
                                  hintText: 'email'.tr,
                                  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;
                                  },
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(bottom: 15),
                                child: CommonTextField(
                                  controller: controller.txtPassword,
                                  color: blue,
                                  prefixIcon: Padding(
                                    padding: const EdgeInsets.all(14),
                                    child: SizedBox(
                                      height: 10,
                                      width: 10,
                                      child: Image.asset(AppImages.lock),
                                    ),
                                  ),
                                  hintText: 'password'.tr,
                                  obscureText: controller.IsShowPwd.value,
                                  validator: (val) {
                                    if (val!.isEmpty) {
                                      return 'enter_password'.tr;
                                    }
                                    return null;
                                  },
                                ),
                              ),
                              Button(
                                text: 'Sign Up',
                                onTap: () {
                                  // Get.toNamed(Routes.HOME);
                                  if (controller.registerFormKey.currentState!
                                      .validate()) {
                                    controller.signUp();
                                  }
                                },
                              ),
                              Padding(
                                padding: const EdgeInsets.symmetric(vertical: 18,horizontal: 20),
                                child: OrWidget(),
                              ),
                              GoogleButton(
                                isGoogleIcon: true,
                                text: 'google_sign_in'.tr,
                                onTap: () {
                                  controller.googleSignIn();
                                },
                              ),
                              Padding(
                                padding: const EdgeInsets.symmetric(vertical: 18),
                                child: RowText(
                                  firstTxt: 'have_account'.tr,
                                  secondTxt: 'login'.tr,
                                  onTap: () {
                                    Get.offAndToNamed(
                                      Routes.LOGIN,
                                    );
                                  },
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    Center(
                      child: SizedBox(
                        height: 100,
                        width: 100,
                        child: Image.asset(AppImages.robo),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}