Advertisement
rifki_cs29

RegisterPageFixEmail

Feb 20th, 2022
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 15.83 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_bloc/flutter_bloc.dart';
  3. import 'package:flutter_svg/svg.dart';
  4. import 'package:google_fonts/google_fonts.dart';
  5. import 'package:module_auth/presentation/bloc/register_access_email_bloc/register_access_email_bloc.dart';
  6. import 'package:module_auth/presentation/pages/register/send_register_otp_page.dart';
  7. import 'package:module_core/common/state_enum.dart';
  8. import 'package:module_core/custom_widgets/custom_button/custom_button.dart';
  9. import 'package:module_core/custom_widgets/custom_dialog_register/custom_dialog_register.dart';
  10. import 'package:module_core/custom_widgets/custom_textfield/custom_textfield.dart';
  11. import 'package:module_core/utils/app_colors.dart';
  12. import 'package:module_core/utils/app_image.dart';
  13.  
  14. class RegisterPage extends StatelessWidget {
  15.   RegisterPage({Key? key}) : super(key: key);
  16.  
  17.   final TextEditingController _fieldController =
  18.       TextEditingController(text: '');
  19.  
  20.   @override
  21.   Widget build(BuildContext context) {
  22.     return Scaffold(
  23.         body: BlocListener<RegisterAccessEmailBloc, RegisterAccessEmailState>(
  24.             listener: (context, state) {
  25.               if (state.state == RequestState.Loaded) {
  26.                 Navigator.of(context).push(MaterialPageRoute(
  27.                   builder: (context) => SendRegisterOtpPage(data: state.data),
  28.                 ));
  29.               } else if (state.state == RequestState.Error) {
  30.                 Center(child: Text(state.errorMessage));
  31.               }
  32.             },
  33.             listenWhen: (previousState, currentState) =>
  34.                 currentState.state == RequestState.Loaded ||
  35.                 currentState.state == RequestState.Error,
  36.             child: BlocConsumer<RegisterAccessEmailBloc,
  37.                     RegisterAccessEmailState>(
  38.                 listener: (context, state) {
  39.                   if (state.errorMessage.isNotEmpty) {
  40.                     ScaffoldMessenger.of(context).showSnackBar(SnackBar(
  41.                       content: Text(state.errorMessage),
  42.                     ));
  43.                   }
  44.                 },
  45.                 listenWhen: (previousState, currentState) =>
  46.                     previousState.errorMessage != currentState.errorMessage &&
  47.                     currentState.errorMessage != '',
  48.                 builder: (context, state) {
  49.                   return SafeArea(
  50.                     child: ListView(children: [
  51.                       Padding(
  52.                         padding: const EdgeInsets.only(left: 30, top: 30),
  53.                         child: Row(
  54.                           children: [
  55.                             GestureDetector(
  56.                               onTap: () => print('Back'),
  57.                               child: Container(
  58.                                 width: 32,
  59.                                 height: 32,
  60.                                 decoration: BoxDecoration(
  61.                                   color: AppColors.greyLight,
  62.                                   borderRadius: BorderRadius.circular(18),
  63.                                 ),
  64.                                 child: SvgPicture.asset(AppImage.back_button,
  65.                                     height: 24,
  66.                                     width: 24,
  67.                                     fit: BoxFit.scaleDown),
  68.                               ),
  69.                             ),
  70.                           ],
  71.                         ),
  72.                       ),
  73.                       SizedBox(height: 8),
  74.                       Padding(
  75.                         padding: const EdgeInsets.symmetric(horizontal: 30),
  76.                         child: AspectRatio(
  77.                           aspectRatio: 3 / 2,
  78.                           child: Container(
  79.                             height: 196,
  80.                             decoration: BoxDecoration(
  81.                               image: DecorationImage(
  82.                                 image: AssetImage(AppImage.register_image),
  83.                                 fit: BoxFit.cover,
  84.                               ),
  85.                             ),
  86.                           ),
  87.                         ),
  88.                       ),
  89.                       SizedBox(height: 16),
  90.                       Row(
  91.                         mainAxisAlignment: MainAxisAlignment.center,
  92.                         children: [
  93.                           Text(
  94.                             'Buat Akunmu Sekarang',
  95.                             style: GoogleFonts.poppins(
  96.                               fontSize: 16,
  97.                               fontWeight: FontWeight.w600,
  98.                               color: Color(0xff2D2F2E),
  99.                             ),
  100.                           ),
  101.                         ],
  102.                       ),
  103.                       SizedBox(height: 6),
  104.                       Row(
  105.                         mainAxisAlignment: MainAxisAlignment.center,
  106.                         children: [
  107.                           Text(
  108.                             'Sudah Punya Akun?',
  109.                             style: GoogleFonts.roboto(
  110.                               fontSize: 12,
  111.                               fontWeight: FontWeight.w400,
  112.                               color: Color(0xff2D2F2E),
  113.                             ),
  114.                           ),
  115.                           SizedBox(width: 2),
  116.                           GestureDetector(
  117.                             onTap: () => print('Masuk'),
  118.                             child: Text(
  119.                               'Masuk',
  120.                               style: GoogleFonts.roboto(
  121.                                 fontSize: 12,
  122.                                 fontWeight: FontWeight.w500,
  123.                                 color: Color(0xff2D2F2E),
  124.                               ),
  125.                             ),
  126.                           ),
  127.                         ],
  128.                       ),
  129.                       SizedBox(height: 18),
  130.                       Divider(
  131.                         color: Color(0xffC4C4C4),
  132.                         thickness: 1,
  133.                       ),
  134.                       Padding(
  135.                         padding: const EdgeInsets.fromLTRB(30, 18, 30, 0),
  136.                         child: CustomTextField(
  137.                           title: 'Full Name',
  138.                           hintText: 'Your full name',
  139.                           controller: _fieldController,
  140.                         ),
  141.                       ),
  142.                       Padding(
  143.                         padding: const EdgeInsets.only(left: 42),
  144.                         child: Text('Contoh: account@email.com',
  145.                             style: GoogleFonts.roboto(
  146.                                 fontSize: 12,
  147.                                 fontWeight: FontWeight.w400,
  148.                                 color: Color(0xff505050))),
  149.                       ),
  150.                       Padding(
  151.                           padding: const EdgeInsets.fromLTRB(30, 18, 30, 0),
  152.                           child: CustomButton(
  153.                               title: 'Daftar',
  154.                               onPressed: () {
  155.                                 showDialog(
  156.                                     context: context,
  157.                                     builder: (BuildContext context) {
  158.                                       return CustomDialogRegister(
  159.                                         title: 'email@email.com',
  160.                                         descriptions:
  161.                                             'Apakah email yang anda masukkan sudah benar?',
  162.                                         textYes: 'Ya, benar',
  163.                                         textNo: "Ubah",
  164.                                         onPressedYes: () {
  165.                                           BlocProvider.of<
  166.                                                       RegisterAccessEmailBloc>(
  167.                                                   context)
  168.                                               .add(OnClickRegisterAccess(
  169.                                                   _fieldController.text));
  170.                                         },
  171.                                         onPressedNo: () {
  172.                                           Navigator.pop(context);
  173.                                         },
  174.                                         image: AppImage.register_email,
  175.                                       );
  176.                                     });
  177.                               })),
  178.                       Padding(
  179.                         padding: const EdgeInsets.symmetric(
  180.                             horizontal: 40, vertical: 10),
  181.                         child: RichText(
  182.                           textAlign: TextAlign.center,
  183.                           text: TextSpan(
  184.                             text: 'Dengan mendaftar, saya menyetujui ',
  185.                             style: GoogleFonts.roboto(
  186.                               fontSize: 12,
  187.                               fontWeight: FontWeight.w400,
  188.                               color: Color(0xff2D2F2E),
  189.                             ),
  190.                             children: <TextSpan>[
  191.                               TextSpan(
  192.                                   text: 'Syarat dan ketentuan ',
  193.                                   style: GoogleFonts.roboto(
  194.                                     fontSize: 12,
  195.                                     fontWeight: FontWeight.w500,
  196.                                     color: Color(0xff2D2F2E),
  197.                                   )),
  198.                               TextSpan(
  199.                                 text: ' yang berlaku di sistem kami',
  200.                                 style: GoogleFonts.roboto(
  201.                                   fontSize: 12,
  202.                                   fontWeight: FontWeight.w400,
  203.                                   color: Color(0xff2D2F2E),
  204.                                 ),
  205.                               ),
  206.                             ],
  207.                           ),
  208.                         ),
  209.                       ),
  210.                       Padding(
  211.                         padding: const EdgeInsets.fromLTRB(30, 10, 30, 20),
  212.                         child: IntrinsicHeight(
  213.                           child: Row(
  214.                             children: [
  215.                               Expanded(
  216.                                 child: Container(
  217.                                   margin: EdgeInsets.only(right: 10),
  218.                                   height: 1,
  219.                                   color: Color(0xffC4C4C4),
  220.                                 ),
  221.                               ),
  222.                               Text(
  223.                                 'atau daftar dengan metode lain',
  224.                                 style: GoogleFonts.roboto(
  225.                                   fontSize: 10,
  226.                                   fontWeight: FontWeight.w400,
  227.                                   color: Color(0xff2D2F2E),
  228.                                 ),
  229.                               ),
  230.                               Expanded(
  231.                                 child: Container(
  232.                                   height: 1,
  233.                                   margin: EdgeInsets.only(left: 10),
  234.                                   color: Color(0xffC4C4C4),
  235.                                 ),
  236.                               ),
  237.                             ],
  238.                           ),
  239.                         ),
  240.                       ),
  241.                       Padding(
  242.                         padding: EdgeInsets.symmetric(horizontal: 30),
  243.                         child: Row(
  244.                             mainAxisAlignment: MainAxisAlignment.spaceBetween,
  245.                             children: [
  246.                               Container(
  247.                                 height: 40,
  248.                                 width:
  249.                                     MediaQuery.of(context).size.width / 2 - 40,
  250.                                 decoration: BoxDecoration(
  251.                                     borderRadius: BorderRadius.circular(8),
  252.                                     color: Color(0xffFEFEFE),
  253.                                     boxShadow: [
  254.                                       BoxShadow(
  255.                                           color: Colors.black12,
  256.                                           blurRadius: 4,
  257.                                           spreadRadius: 1,
  258.                                           offset: Offset(4, 4)) // Shadow ),
  259.                                     ]),
  260.                                 child: Padding(
  261.                                   padding: const EdgeInsets.symmetric(
  262.                                       horizontal: 24, vertical: 12),
  263.                                   child: Row(
  264.                                     mainAxisAlignment: MainAxisAlignment.center,
  265.                                     children: [
  266.                                       SvgPicture.asset(AppImage.google,
  267.                                           height: 24,
  268.                                           width: 24,
  269.                                           fit: BoxFit.scaleDown),
  270.                                       SizedBox(width: 8),
  271.                                       Text(
  272.                                         'Google',
  273.                                         style: GoogleFonts.roboto(
  274.                                           fontSize: 14,
  275.                                           fontWeight: FontWeight.w500,
  276.                                           color: Color(0xff2D2F2E),
  277.                                         ),
  278.                                       ),
  279.                                     ],
  280.                                   ),
  281.                                 ),
  282.                               ),
  283.                               Container(
  284.                                 height: 40,
  285.                                 width:
  286.                                     MediaQuery.of(context).size.width / 2 - 40,
  287.                                 decoration: BoxDecoration(
  288.                                     borderRadius: BorderRadius.circular(8),
  289.                                     color: Color(0xff395185),
  290.                                     boxShadow: [
  291.                                       BoxShadow(
  292.                                           color: Colors.black12,
  293.                                           blurRadius: 4,
  294.                                           spreadRadius: 1,
  295.                                           offset: Offset(4, 4)) // Shadow ),
  296.                                     ]),
  297.                                 child: Padding(
  298.                                   padding: const EdgeInsets.symmetric(
  299.                                       horizontal: 24, vertical: 12),
  300.                                   child: Row(
  301.                                     mainAxisAlignment: MainAxisAlignment.center,
  302.                                     children: [
  303.                                       SvgPicture.asset(AppImage.facebook,
  304.                                           height: 30,
  305.                                           width: 30,
  306.                                           fit: BoxFit.scaleDown),
  307.                                       SizedBox(width: 8),
  308.                                       Text(
  309.                                         'Facebook',
  310.                                         style: GoogleFonts.roboto(
  311.                                           fontSize: 14,
  312.                                           fontWeight: FontWeight.w500,
  313.                                           color: Color(0xffFEFEFE),
  314.                                         ),
  315.                                       ),
  316.                                     ],
  317.                                   ),
  318.                                 ),
  319.                               )
  320.                             ]),
  321.                       )
  322.                     ]),
  323.                   );
  324.                 })));
  325.   }
  326. }
  327.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement