Advertisement
bngoding

register

Dec 15th, 2021
1,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 49.82 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_bloc/flutter_bloc.dart';
  3. import 'package:flutter_sda/auth/register/bloc/register_bloc.dart';
  4. import 'package:flutter_sda/auth/register/bloc/register_state.dart';
  5. import 'package:flutter_sda/shared/theme.dart';
  6.  
  7. class Register extends StatefulWidget {
  8.   Register({
  9.     Key? key,
  10.   }) : super(key: key);
  11.  
  12.   @override
  13.   _RegisterState createState() => _RegisterState();
  14. }
  15.  
  16. class _RegisterState extends State<Register>
  17.     with SingleTickerProviderStateMixin {
  18.   bool isButtonEnable = false;
  19.   bool _hasBeenPressed = false;
  20.  
  21.   final TextEditingController _userNameController = TextEditingController();
  22.   final TextEditingController _userEmailController = TextEditingController();
  23.   final TextEditingController _userNumberController = TextEditingController();
  24.   final TextEditingController _passwordController = TextEditingController();
  25.   final TextEditingController _reTypePasswordController =
  26.       TextEditingController();
  27.  
  28.   late TabController _tabController;
  29.  
  30.   @override
  31.   void initState() {
  32.     super.initState();
  33.     _tabController = TabController(vsync: this, length: 2);
  34.   }
  35.  
  36.   @override
  37.   void dispose() {
  38.     _tabController.dispose();
  39.     super.dispose();
  40.   }
  41.  
  42.   @override
  43.   Widget build(BuildContext context) {
  44.     Size size = MediaQuery.of(context).size;
  45.     return Scaffold(
  46.       backgroundColor: Colors.white,
  47.       body: SafeArea(
  48.         child: Container(
  49.             width: size.width,
  50.             height: size.height,
  51.             child: BlocListener<RegisterBloc, RegisterState>(
  52.                 listener: (context, state) {
  53.                   if (state is RegisterFailure) {
  54.                     Scaffold.of(context).showSnackBar(SnackBar(
  55.                       content: Text('${state.error}'),
  56.                       backgroundColor: Colors.red,
  57.                     ));
  58.                   }
  59.                 },
  60.                 child: DefaultTabController(
  61.                   length: 2,
  62.                   child: Container(
  63.                     width: double.infinity,
  64.                     decoration: BoxDecoration(
  65.                         image: DecorationImage(
  66.                       image: AssetImage("assets/images/bg_login.png"),
  67.                       // your bg image
  68.                       fit: BoxFit.cover,
  69.                     )),
  70.                     child: Column(
  71.                       crossAxisAlignment: CrossAxisAlignment.start,
  72.                       children: <Widget>[
  73.                         SizedBox(height: 105),
  74.                         Expanded(
  75.                           child: Container(
  76.                               decoration: BoxDecoration(
  77.                                   color: Colors.white,
  78.                                   borderRadius: BorderRadius.only(
  79.                                       topLeft: Radius.circular(22),
  80.                                       topRight: Radius.circular(22))),
  81.                               child: Column(
  82.                                 children: [
  83.                                   SizedBox(
  84.                                     height: 23,
  85.                                   ),
  86.                                   Text(
  87.                                     "Daftar Akun Baru",
  88.                                     style: blackTextTitleThirtyTwo,
  89.                                   ),
  90.                                   SizedBox(
  91.                                     height: 49,
  92.                                   ),
  93.                                   Expanded(
  94.                                     child: Container(
  95.                                         padding: EdgeInsets.symmetric(
  96.                                             horizontal: 47),
  97.                                         child: Container(
  98.                                           child: Scaffold(
  99.                                             appBar: PreferredSize(
  100.                                               preferredSize: Size.fromHeight(
  101.                                                   kToolbarHeight),
  102.                                               child: SafeArea(
  103.                                                 child: Column(
  104.                                                   children: [
  105.                                                     TabBar(
  106.                                                         controller:
  107.                                                             _tabController,
  108.                                                         tabs: [
  109.                                                           Text(
  110.                                                             "1. Data Diri",
  111.                                                             style:
  112.                                                                 newBlackPrimaySixTeen,
  113.                                                           ),
  114.                                                           Text(
  115.                                                             "2. Perusahaan",
  116.                                                             style:
  117.                                                                 newBlackPrimaySixTeen,
  118.                                                           )
  119.                                                         ])
  120.                                                   ],
  121.                                                 ),
  122.                                               ),
  123.                                             ),
  124.                                             body: TabBarView(
  125.                                                 controller: _tabController,
  126.                                                 children: [
  127.                                                   SingleChildScrollView(
  128.                                                     child: Column(children: [
  129.                                                       SingleChildScrollView(
  130.                                                         child: Column(
  131.                                                           children: [
  132.                                                             Container(
  133.                                                               color:
  134.                                                                   Colors.white,
  135.                                                               height: 48,
  136.                                                               child:
  137.                                                                   TextFormField(
  138.                                                                 controller:
  139.                                                                     _userNameController,
  140.                                                                 maxLines: 1,
  141.                                                                 decoration:
  142.                                                                     InputDecoration(
  143.                                                                   contentPadding:
  144.                                                                       EdgeInsets.only(
  145.                                                                           top:
  146.                                                                               14.5,
  147.                                                                           bottom:
  148.                                                                               14.5,
  149.                                                                           left:
  150.                                                                               10),
  151.                                                                   border: OutlineInputBorder(
  152.                                                                       borderRadius:
  153.                                                                           BorderRadius.circular(
  154.                                                                               5),
  155.                                                                       borderSide:
  156.                                                                           BorderSide(
  157.                                                                               color: Colors.grey)),
  158.                                                                   hintText:
  159.                                                                       "Nama Pengguna",
  160.                                                                 ),
  161.                                                               ),
  162.                                                             ),
  163.                                                             SizedBox(
  164.                                                               height: 37,
  165.                                                             ),
  166.                                                             Container(
  167.                                                               color:
  168.                                                                   Colors.white,
  169.                                                               height: 48,
  170.                                                               child:
  171.                                                                   TextFormField(
  172.                                                                 controller:
  173.                                                                     _userEmailController,
  174.                                                                 maxLines: 1,
  175.                                                                 decoration:
  176.                                                                     InputDecoration(
  177.                                                                   contentPadding:
  178.                                                                       EdgeInsets.only(
  179.                                                                           top:
  180.                                                                               14.5,
  181.                                                                           bottom:
  182.                                                                               14.5,
  183.                                                                           left:
  184.                                                                               10),
  185.                                                                   border: OutlineInputBorder(
  186.                                                                       borderRadius:
  187.                                                                           BorderRadius.circular(
  188.                                                                               5),
  189.                                                                       borderSide: BorderSide(
  190.                                                                           color: Colors
  191.                                                                               .white,
  192.                                                                           width:
  193.                                                                               5.0)),
  194.                                                                   hintText:
  195.                                                                       "Email Pengguna",
  196.                                                                 ),
  197.                                                               ),
  198.                                                             ),
  199.                                                             SizedBox(
  200.                                                               height: 37,
  201.                                                             ),
  202.                                                             Container(
  203.                                                               color:
  204.                                                                   Colors.white,
  205.                                                               height: 48,
  206.                                                               child:
  207.                                                                   TextFormField(
  208.                                                                 controller:
  209.                                                                     _userNumberController,
  210.                                                                 maxLines: 1,
  211.                                                                 decoration:
  212.                                                                     InputDecoration(
  213.                                                                   contentPadding:
  214.                                                                       EdgeInsets.only(
  215.                                                                           top:
  216.                                                                               14.5,
  217.                                                                           bottom:
  218.                                                                               14.5,
  219.                                                                           left:
  220.                                                                               10),
  221.                                                                   border: OutlineInputBorder(
  222.                                                                       borderRadius:
  223.                                                                           BorderRadius.circular(
  224.                                                                               5),
  225.                                                                       borderSide:
  226.                                                                           BorderSide(
  227.                                                                               color: Colors.white)),
  228.                                                                   hintText:
  229.                                                                       "(+62) Nomor Telepon",
  230. //                                                              hintStyle: Colors.white
  231.                                                                 ),
  232.                                                               ),
  233.                                                             ),
  234.                                                             SizedBox(
  235.                                                               height: 37,
  236.                                                             ),
  237.                                                             Container(
  238.                                                               color:
  239.                                                                   Colors.white,
  240.                                                               height: 48,
  241.                                                               child:
  242.                                                                   TextFormField(
  243.                                                                 controller:
  244.                                                                     _passwordController,
  245.                                                                 validator:
  246.                                                                     (value) {
  247.                                                                   /* if (value.isNotEmpty) {
  248.                                                     return 'Kata Sandi Tidak Boleh Kosong';
  249.                                                   } else {
  250.                                                     return null;
  251.                                                   }*/
  252.                                                                 },
  253.                                                                 obscureText:
  254.                                                                     true,
  255.                                                                 maxLines: 1,
  256.                                                                 decoration:
  257.                                                                     InputDecoration(
  258.                                                                   suffixIcon:
  259.                                                                       GestureDetector(
  260.                                                                     onTap: () {
  261.                                                                       setState(
  262.                                                                           () {
  263. //                                                                        obscureText =
  264. //                                                                        !obscureText;
  265.                                                                       });
  266.                                                                     },
  267.                                                                     child: true
  268.                                                                         ? Icon(
  269.                                                                             Icons.visibility_off,
  270.                                                                             color:
  271.                                                                                 Colors.grey,
  272.                                                                           )
  273.                                                                         : Icon(
  274.                                                                             Icons.visibility,
  275.                                                                             color:
  276.                                                                                 Colors.grey,
  277.                                                                           ),
  278.                                                                   ),
  279.                                                                   contentPadding:
  280.                                                                       EdgeInsets.only(
  281.                                                                           top:
  282.                                                                               14.5,
  283.                                                                           bottom:
  284.                                                                               14.5,
  285.                                                                           left:
  286.                                                                               10),
  287.                                                                   border: OutlineInputBorder(
  288.                                                                       borderRadius:
  289.                                                                           BorderRadius.circular(
  290.                                                                               5),
  291.                                                                       borderSide:
  292.                                                                           BorderSide(
  293.                                                                               color: Colors.white)),
  294.                                                                   hintText:
  295.                                                                       "Kata Sandi",
  296. //                                                              hintStyle: Colors.white
  297.                                                                 ),
  298.                                                               ),
  299.                                                             ),
  300.                                                             SizedBox(
  301.                                                               height: 37,
  302.                                                             ),
  303.                                                             Container(
  304.                                                               color:
  305.                                                                   Colors.white,
  306.                                                               height: 48,
  307.                                                               child:
  308.                                                                   TextFormField(
  309.                                                                 controller:
  310.                                                                     _reTypePasswordController,
  311.                                                                 validator:
  312.                                                                     (value) {
  313.                                                                   /* if (value
  314.                                                       .isNotEmpty) {
  315.                                                     return 'Kata Sandi Tidak Boleh Kosong';
  316.                                                   } else {
  317.                                                     return null;
  318.                                                   }*/
  319.                                                                 },
  320.                                                                 obscureText:
  321.                                                                     true,
  322.                                                                 maxLines: 1,
  323.                                                                 decoration:
  324.                                                                     InputDecoration(
  325.                                                                   suffixIcon:
  326.                                                                       GestureDetector(
  327.                                                                     onTap: () {
  328.                                                                       setState(
  329.                                                                           () {
  330. //                                                                        obscureText =
  331. //                                                                        !obscureText;
  332.                                                                       });
  333.                                                                     },
  334.                                                                     child: true
  335.                                                                         ? Icon(
  336.                                                                             Icons.visibility_off,
  337.                                                                             color:
  338.                                                                                 Colors.grey,
  339.                                                                           )
  340.                                                                         : Icon(
  341.                                                                             Icons.visibility,
  342.                                                                             color:
  343.                                                                                 Colors.grey,
  344.                                                                           ),
  345.                                                                   ),
  346.                                                                   contentPadding:
  347.                                                                       EdgeInsets.only(
  348.                                                                           top:
  349.                                                                               14.5,
  350.                                                                           bottom:
  351.                                                                               14.5,
  352.                                                                           left:
  353.                                                                               10),
  354.                                                                   border: OutlineInputBorder(
  355.                                                                       borderRadius:
  356.                                                                           BorderRadius.circular(
  357.                                                                               5),
  358.                                                                       borderSide: BorderSide(
  359.                                                                           color: Colors
  360.                                                                               .white,
  361.                                                                           width:
  362.                                                                               0.5)),
  363.                                                                   hintText:
  364.                                                                       "Input Ulang Kata Sandi",
  365. //                                                              hintStyle: Colors.white
  366.                                                                 ),
  367.                                                               ),
  368.                                                             ),
  369.                                                             SizedBox(
  370.                                                               height: 69,
  371.                                                             ),
  372.                                                             Padding(
  373.                                                               padding:
  374.                                                                   const EdgeInsets
  375.                                                                           .symmetric(
  376.                                                                       vertical:
  377.                                                                           0),
  378.                                                               child: Container(
  379.                                                                 height: 52,
  380.                                                                 width: double
  381.                                                                     .infinity,
  382.                                                                 color: isButtonEnable ? Colors.blue : Colors.grey,
  383.                                                                 child:
  384.                                                                     RaisedButton(
  385.                                                                   onPressed:
  386.                                                                       () {
  387.                                                                     setState(() {
  388.                                                                       _hasBeenPressed = !_hasBeenPressed;
  389.                                                                     });
  390.  
  391.                                                                     if (_userNameController.text.trim() != "" &&
  392.                                                                         _userEmailController.text.trim() !=
  393.                                                                             "" &&
  394.                                                                         _userNumberController.text.trim() !=
  395.                                                                             "" &&
  396.                                                                         _passwordController.text.trim() !=
  397.                                                                             "" &&
  398.                                                                         _reTypePasswordController.text.trim() !=
  399.                                                                             "") {
  400.                                                                       _tabController.animateTo((_tabController.index + 1) % 2);
  401.                                                                     } else {
  402.                                                                       isButtonEnable =
  403.                                                                           false;
  404.                                                                     }
  405.                                                                     // Switch tabs
  406.                                                                   },
  407.                                                                   elevation: 5,
  408.                                                                   shape:
  409.                                                                       RoundedRectangleBorder(
  410.                                                                     borderRadius:
  411.                                                                         BorderRadius.circular(
  412.                                                                             15),
  413.                                                                   ),
  414.                                                                   padding:
  415.                                                                       EdgeInsets
  416.                                                                           .all(
  417.                                                                               10),
  418.                                                                   child: Text(
  419.                                                                     "Selanjutnya",
  420. //                                                              style: whitePrimaryTextStyle,
  421.                                                                   ),
  422.                                                                 ),
  423.                                                               ),
  424.                                                             ),
  425.                                                             SizedBox(
  426.                                                               height: 37,
  427.                                                             ),
  428.                                                             Padding(
  429.                                                               padding:
  430.                                                                   const EdgeInsets
  431.                                                                           .symmetric(
  432.                                                                       vertical:
  433.                                                                           0),
  434.                                                               child: Container(
  435.                                                                 height: 52,
  436.                                                                 width: double
  437.                                                                     .infinity,
  438.                                                                 child:
  439.                                                                     RaisedButton(
  440.                                                                   onPressed:
  441.                                                                       () {},
  442.                                                                   elevation: 5,
  443.                                                                   shape: RoundedRectangleBorder(
  444.                                                                       borderRadius: BorderRadius.circular(15),
  445.                                                                       side: BorderSide(
  446.                                                                         color:
  447.                                                                             purplePrimary,
  448.                                                                       )),
  449.                                                                   color: Colors
  450.                                                                       .white,
  451.                                                                   padding:
  452.                                                                       EdgeInsets
  453.                                                                           .all(
  454.                                                                               10),
  455.                                                                   child: Text(
  456.                                                                     "Batal",
  457. //                                                              style:
  458.                                                                   ),
  459.                                                                 ),
  460.                                                               ),
  461.                                                             ),
  462.                                                             SizedBox(
  463.                                                               height: 24,
  464.                                                             ),
  465.                                                           ],
  466.                                                         ),
  467.                                                       )
  468.                                                     ]),
  469.                                                   ),
  470.                                                   SingleChildScrollView(
  471.                                                     child: Column(children: [
  472.                                                       SingleChildScrollView(
  473.                                                         child: Column(
  474.                                                           children: [
  475.                                                             Container(
  476.                                                               color:
  477.                                                                   Colors.white,
  478.                                                               height: 48,
  479.                                                               child:
  480.                                                                   TextFormField(
  481.                                                                 maxLines: 1,
  482.                                                                 decoration:
  483.                                                                     InputDecoration(
  484.                                                                   contentPadding:
  485.                                                                       EdgeInsets.only(
  486.                                                                           top:
  487.                                                                               14.5,
  488.                                                                           bottom:
  489.                                                                               14.5,
  490.                                                                           left:
  491.                                                                               10),
  492.                                                                   border: OutlineInputBorder(
  493.                                                                       borderRadius:
  494.                                                                           BorderRadius.circular(
  495.                                                                               5),
  496.                                                                       borderSide:
  497.                                                                           BorderSide(
  498.                                                                               color: Colors.grey)),
  499.                                                                   hintText:
  500.                                                                       "Nama Perusahaan",
  501.                                                                 ),
  502.                                                               ),
  503.                                                             ),
  504.                                                             SizedBox(
  505.                                                               height: 37,
  506.                                                             ),
  507.                                                             Container(
  508.                                                               color:
  509.                                                                   Colors.white,
  510.                                                               height: 48,
  511.                                                               child:
  512.                                                                   TextFormField(
  513.                                                                 maxLines: 1,
  514.                                                                 decoration:
  515.                                                                     InputDecoration(
  516.                                                                   contentPadding:
  517.                                                                       EdgeInsets.only(
  518.                                                                           top:
  519.                                                                               14.5,
  520.                                                                           bottom:
  521.                                                                               14.5,
  522.                                                                           left:
  523.                                                                               10),
  524.                                                                   border: OutlineInputBorder(
  525.                                                                       borderRadius:
  526.                                                                           BorderRadius.circular(
  527.                                                                               5),
  528.                                                                       borderSide: BorderSide(
  529.                                                                           color: Colors
  530.                                                                               .white,
  531.                                                                           width:
  532.                                                                               5.0)),
  533.                                                                   hintText:
  534.                                                                       "Sektor Industri",
  535.                                                                 ),
  536.                                                               ),
  537.                                                             ),
  538.                                                             SizedBox(
  539.                                                               height: 37,
  540.                                                             ),
  541.                                                             Container(
  542.                                                               color:
  543.                                                                   Colors.white,
  544.                                                               height: 48,
  545.                                                               child:
  546.                                                                   TextFormField(
  547.                                                                 maxLines: 1,
  548.                                                                 decoration:
  549.                                                                     InputDecoration(
  550.                                                                   contentPadding:
  551.                                                                       EdgeInsets.only(
  552.                                                                           top:
  553.                                                                               14.5,
  554.                                                                           bottom:
  555.                                                                               14.5,
  556.                                                                           left:
  557.                                                                               10),
  558.                                                                   border: OutlineInputBorder(
  559.                                                                       borderRadius:
  560.                                                                           BorderRadius.circular(
  561.                                                                               5),
  562.                                                                       borderSide:
  563.                                                                           BorderSide(
  564.                                                                               color: Colors.white)),
  565.                                                                   hintText:
  566.                                                                       "Jabatan",
  567. //                                                              hintStyle: Colors.white
  568.                                                                 ),
  569.                                                               ),
  570.                                                             ),
  571.                                                             SizedBox(
  572.                                                               height: 37,
  573.                                                             ),
  574.                                                             Container(
  575.                                                               color:
  576.                                                                   grayPrimaryTwo,
  577.                                                               height: 138,
  578.                                                               child:
  579.                                                                   TextFormField(
  580.                                                                 maxLines: 1,
  581.                                                                 textAlign:
  582.                                                                     TextAlign
  583.                                                                         .left,
  584.                                                                 decoration: InputDecoration(
  585.                                                                     contentPadding: EdgeInsets.only(
  586.                                                                         top: 69,
  587.                                                                         bottom:
  588.                                                                             69,
  589.                                                                         left:
  590.                                                                             10),
  591.                                                                     border: OutlineInputBorder(
  592.                                                                         borderRadius:
  593.                                                                             BorderRadius.all(Radius.circular(
  594.                                                                                 5))),
  595.                                                                     hintText:
  596.                                                                         "Alamat Perusahaan",
  597.                                                                     hintStyle:
  598.                                                                         smallHintGray),
  599.                                                               ),
  600.                                                             ),
  601.                                                             SizedBox(
  602.                                                               height: 58,
  603.                                                             ),
  604.                                                             Padding(
  605.                                                               padding:
  606.                                                                   const EdgeInsets
  607.                                                                           .symmetric(
  608.                                                                       vertical:
  609.                                                                           0),
  610.                                                               child: Container(
  611.                                                                 height: 52,
  612.                                                                 width: double
  613.                                                                     .infinity,
  614.                                                                 child:
  615.                                                                     RaisedButton(
  616.                                                                   onPressed:
  617.                                                                       () {},
  618.                                                                   elevation: 5,
  619.                                                                   shape:
  620.                                                                       RoundedRectangleBorder(
  621.                                                                     borderRadius:
  622.                                                                         BorderRadius.circular(
  623.                                                                             15),
  624.                                                                   ),
  625.                                                                   color:
  626.                                                                       purplePrimary,
  627.                                                                   padding:
  628.                                                                       EdgeInsets
  629.                                                                           .all(
  630.                                                                               10),
  631.                                                                   child: Text(
  632.                                                                     "Selanjutnya",
  633.                                                                     style:
  634.                                                                         whitePrimaryTextStyle,
  635.                                                                   ),
  636.                                                                 ),
  637.                                                               ),
  638.                                                             ),
  639.                                                             SizedBox(
  640.                                                               height: 37,
  641.                                                             ),
  642.                                                             Padding(
  643.                                                               padding:
  644.                                                                   const EdgeInsets
  645.                                                                           .symmetric(
  646.                                                                       vertical:
  647.                                                                           0),
  648.                                                               child: Container(
  649.                                                                 height: 52,
  650.                                                                 width: double
  651.                                                                     .infinity,
  652.                                                                 child:
  653.                                                                     RaisedButton(
  654.                                                                   onPressed:
  655.                                                                       () {},
  656.                                                                   elevation: 5,
  657.                                                                   shape:
  658.                                                                       RoundedRectangleBorder(
  659.                                                                     borderRadius:
  660.                                                                         BorderRadius.circular(
  661.                                                                             15),
  662.                                                                     side: BorderSide(
  663.                                                                         color:
  664.                                                                             purplePrimary),
  665.                                                                   ),
  666.                                                                   color: Colors
  667.                                                                       .white,
  668.                                                                   padding:
  669.                                                                       EdgeInsets
  670.                                                                           .all(
  671.                                                                               10),
  672.                                                                   child: Text(
  673.                                                                     "Batal",
  674.                                                                     style:
  675.                                                                         purplePrimaryTextStyle,
  676.                                                                   ),
  677.                                                                 ),
  678.                                                               ),
  679.                                                             ),
  680.                                                             SizedBox(
  681.                                                               height: 24,
  682.                                                             ),
  683.                                                           ],
  684.                                                         ),
  685.                                                       )
  686.                                                     ]),
  687.                                                   ),
  688.                                                 ]),
  689.                                             backgroundColor: Colors.white,
  690.                                           ),
  691.                                         )),
  692.                                   )
  693.                                 ],
  694.                               )),
  695.                         ),
  696.                       ],
  697.                     ),
  698.                   ),
  699.                 ))),
  700.       ),
  701.     );
  702.   }
  703. }
  704.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement