Advertisement
Guest User

P

a guest
Nov 12th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 27.42 KB | None | 0 0
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:font_awesome_flutter/font_awesome_flutter.dart';
  5. import 'package:the_gorgeous_login/style/theme.dart' as Theme;
  6. import 'package:the_gorgeous_login/ui/dashboard.dart';
  7. import 'package:the_gorgeous_login/utils/bubble_indication_painter.dart';
  8. import 'package:firebase_auth/firebase_auth.dart';
  9. import 'package:google_sign_in/google_sign_in.dart';
  10.  
  11. class LoginPage extends StatefulWidget {
  12.   LoginPage({Key key}) : super(key: key);
  13.  
  14.   @override
  15.   _LoginPageState createState() => new _LoginPageState();
  16. }
  17.  
  18. class _LoginPageState extends State<LoginPage>
  19.     with SingleTickerProviderStateMixin {
  20.   final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
  21.  
  22.   final FocusNode myFocusNodeEmailLogin = FocusNode();
  23.   final FocusNode myFocusNodePasswordLogin = FocusNode();
  24.  
  25.   final FocusNode myFocusNodePassword = FocusNode();
  26.   final FocusNode myFocusNodeEmail = FocusNode();
  27.   final FocusNode myFocusNodeName = FocusNode();
  28.  
  29.   TextEditingController loginEmailController = new TextEditingController();
  30.   TextEditingController loginPasswordController = new TextEditingController();
  31.  
  32.   bool _obscureTextLogin = true;
  33.   bool _obscureTextSignup = true;
  34.   bool _obscureTextSignupConfirm = true;
  35.  
  36.   TextEditingController signupEmailController = new TextEditingController();
  37.   TextEditingController signupNameController = new TextEditingController();
  38.   TextEditingController signupPasswordController = new TextEditingController();
  39.   TextEditingController signupConfirmPasswordController =
  40.       new TextEditingController();
  41.  
  42.   PageController _pageController;
  43.  
  44.   Color left = Colors.black;
  45.   Color right = Colors.white;
  46.  
  47.   final FirebaseAuth _auth = FirebaseAuth.instance;
  48.   final GoogleSignIn googleSignIn = GoogleSignIn();
  49.  
  50.   String name;
  51.   String email;
  52.   String imageUrl;
  53.  
  54.   Future<String> signInWithGoogle() async {
  55.     final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  56.     final GoogleSignInAuthentication googleSignInAuthentication =
  57.         await googleSignInAccount.authentication;
  58.  
  59.     final AuthCredential credential = GoogleAuthProvider.getCredential(
  60.       accessToken: googleSignInAuthentication.accessToken,
  61.       idToken: googleSignInAuthentication.idToken,
  62.     );
  63.  
  64.     final AuthResult authResult = await _auth.signInWithCredential(credential);
  65.     final FirebaseUser user = authResult.user;
  66.  
  67.     // Checking if email and name is null
  68.     assert(user.email != null);
  69.     assert(user.displayName != null);
  70.     assert(user.photoUrl != null);
  71.  
  72.     name = user.displayName;
  73.     email = user.email;
  74.     imageUrl = user.photoUrl;
  75.  
  76.     // Only taking the first part of the name, i.e., First Name
  77.     if (name.contains(" ")) {
  78.       name = name.substring(0, name.indexOf(" "));
  79.     }
  80.  
  81.     assert(!user.isAnonymous);
  82.     assert(await user.getIdToken() != null);
  83.  
  84.     final FirebaseUser currentUser = await _auth.currentUser();
  85.     assert(user.uid == currentUser.uid);
  86.  
  87.     return 'signInWithGoogle succeeded: $user';
  88.   }
  89.  
  90.   void signOutGoogle() async {
  91.     await googleSignIn.signOut();
  92.  
  93.     print("User Sign Out");
  94.   }
  95.  
  96.   @override
  97.   Widget build(BuildContext context) {
  98.     return new Scaffold(
  99.       key: _scaffoldKey,
  100.       body: NotificationListener<OverscrollIndicatorNotification>(
  101.         onNotification: (overscroll) {
  102.           overscroll.disallowGlow();
  103.         },
  104.         child: SingleChildScrollView(
  105.           child: Container(
  106.             width: MediaQuery.of(context).size.width,
  107.             height: MediaQuery.of(context).size.height >= 775.0
  108.                 ? MediaQuery.of(context).size.height
  109.                 : 775.0,
  110.             decoration: new BoxDecoration(
  111.               gradient: new LinearGradient(
  112.                   colors: [
  113.                     Theme.Colors.loginGradientStart,
  114.                     Theme.Colors.loginGradientEnd
  115.                   ],
  116.                   begin: const FractionalOffset(0.0, 0.0),
  117.                   end: const FractionalOffset(1.0, 1.0),
  118.                   stops: [0.0, 1.0],
  119.                   tileMode: TileMode.clamp),
  120.             ),
  121.             child: Column(
  122.               mainAxisSize: MainAxisSize.max,
  123.               children: <Widget>[
  124.                 Padding(
  125.                   padding: EdgeInsets.only(top: 75.0),
  126.                   child: new Image(
  127.                       width: 250.0,
  128.                       height: 191.0,
  129.                       fit: BoxFit.fill,
  130.                       image: new AssetImage('assets/img/logo2.png')),
  131.                 ),
  132.                 Padding(
  133.                   padding: EdgeInsets.only(top: 20.0),
  134.                   child: _buildMenuBar(context),
  135.                 ),
  136.                 Expanded(
  137.                   flex: 2,
  138.                   child: PageView(
  139.                     controller: _pageController,
  140.                     onPageChanged: (i) {
  141.                       if (i == 0) {
  142.                         setState(() {
  143.                           right = Colors.white;
  144.                           left = Colors.black;
  145.                         });
  146.                       } else if (i == 1) {
  147.                         setState(() {
  148.                           right = Colors.black;
  149.                           left = Colors.white;
  150.                         });
  151.                       }
  152.                     },
  153.                     children: <Widget>[
  154.                       new ConstrainedBox(
  155.                         constraints: const BoxConstraints.expand(),
  156.                         child: _buildSignIn(context),
  157.                       ),
  158.                       new ConstrainedBox(
  159.                         constraints: const BoxConstraints.expand(),
  160.                         child: _buildSignUp(context),
  161.                       ),
  162.                     ],
  163.                   ),
  164.                 ),
  165.               ],
  166.             ),
  167.           ),
  168.         ),
  169.       ),
  170.     );
  171.   }
  172.  
  173.   @override
  174.   void dispose() {
  175.     myFocusNodePassword.dispose();
  176.     myFocusNodeEmail.dispose();
  177.     myFocusNodeName.dispose();
  178.     _pageController?.dispose();
  179.     super.dispose();
  180.   }
  181.  
  182.   @override
  183.   void initState() {
  184.     super.initState();
  185.  
  186.     SystemChrome.setPreferredOrientations([
  187.       DeviceOrientation.portraitUp,
  188.       DeviceOrientation.portraitDown,
  189.     ]);
  190.  
  191.     _pageController = PageController();
  192.   }
  193.  
  194.   void showInSnackBar(String value) {
  195.     FocusScope.of(context).requestFocus(new FocusNode());
  196.     _scaffoldKey.currentState?.removeCurrentSnackBar();
  197.     _scaffoldKey.currentState.showSnackBar(new SnackBar(
  198.       content: new Text(
  199.         value,
  200.         textAlign: TextAlign.center,
  201.         style: TextStyle(
  202.             color: Colors.white,
  203.             fontSize: 16.0,
  204.             fontFamily: "WorkSansSemiBold"),
  205.       ),
  206.       backgroundColor: Colors.blue,
  207.       duration: Duration(seconds: 3),
  208.     ));
  209.   }
  210.  
  211.   Widget _buildMenuBar(BuildContext context) {
  212.     return Container(
  213.       width: 300.0,
  214.       height: 50.0,
  215.       decoration: BoxDecoration(
  216.         color: Color(0x552B2B2B),
  217.         borderRadius: BorderRadius.all(Radius.circular(25.0)),
  218.       ),
  219.       child: CustomPaint(
  220.         painter: TabIndicationPainter(pageController: _pageController),
  221.         child: Row(
  222.           mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  223.           children: <Widget>[
  224.             Expanded(
  225.               child: FlatButton(
  226.                 splashColor: Colors.transparent,
  227.                 highlightColor: Colors.transparent,
  228.                 onPressed: _onSignInButtonPress,
  229.                 child: Text(
  230.                   "Log In",
  231.                   style: TextStyle(
  232.                       color: left,
  233.                       fontSize: 16.0,
  234.                       fontFamily: "WorkSansSemiBold"),
  235.                 ),
  236.               ),
  237.             ),
  238.             //Container(height: 33.0, width: 1.0, color: Colors.white),
  239.             Expanded(
  240.               child: FlatButton(
  241.                 splashColor: Colors.transparent,
  242.                 highlightColor: Colors.transparent,
  243.                 onPressed: _onSignUpButtonPress,
  244.                 child: Text(
  245.                   "Daftar Baru",
  246.                   style: TextStyle(
  247.                       color: right,
  248.                       fontSize: 16.0,
  249.                       fontFamily: "WorkSansSemiBold"),
  250.                 ),
  251.               ),
  252.             ),
  253.           ],
  254.         ),
  255.       ),
  256.     );
  257.   }
  258.  
  259.   Widget _buildSignIn(BuildContext context) {
  260.     return Container(
  261.       padding: EdgeInsets.only(top: 23.0),
  262.       child: Column(
  263.         children: <Widget>[
  264.           Stack(
  265.             alignment: Alignment.topCenter,
  266.             overflow: Overflow.visible,
  267.             children: <Widget>[
  268.               Card(
  269.                 elevation: 2.0,
  270.                 color: Colors.white,
  271.                 shape: RoundedRectangleBorder(
  272.                   borderRadius: BorderRadius.circular(8.0),
  273.                 ),
  274.                 child: Container(
  275.                   width: 300.0,
  276.                   height: 190.0,
  277.                   child: Column(
  278.                     children: <Widget>[
  279.                       Padding(
  280.                         padding: EdgeInsets.only(
  281.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  282.                         child: TextField(
  283.                           focusNode: myFocusNodeEmailLogin,
  284.                           controller: loginEmailController,
  285.                           keyboardType: TextInputType.emailAddress,
  286.                           style: TextStyle(
  287.                               fontFamily: "WorkSansSemiBold",
  288.                               fontSize: 16.0,
  289.                               color: Colors.black),
  290.                           decoration: InputDecoration(
  291.                             border: InputBorder.none,
  292.                             icon: Icon(
  293.                               FontAwesomeIcons.envelope,
  294.                               color: Colors.black,
  295.                               size: 22.0,
  296.                             ),
  297.                             hintText: "Email",
  298.                             hintStyle: TextStyle(
  299.                                 fontFamily: "WorkSansSemiBold", fontSize: 17.0),
  300.                           ),
  301.                         ),
  302.                       ),
  303.                       Container(
  304.                         width: 250.0,
  305.                         height: 1.0,
  306.                         color: Colors.grey[400],
  307.                       ),
  308.                       Padding(
  309.                         padding: EdgeInsets.only(
  310.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  311.                         child: TextField(
  312.                           focusNode: myFocusNodePasswordLogin,
  313.                           controller: loginPasswordController,
  314.                           obscureText: _obscureTextLogin,
  315.                           style: TextStyle(
  316.                               fontFamily: "WorkSansSemiBold",
  317.                               fontSize: 16.0,
  318.                               color: Colors.black),
  319.                           decoration: InputDecoration(
  320.                             border: InputBorder.none,
  321.                             icon: Icon(
  322.                               FontAwesomeIcons.lock,
  323.                               size: 22.0,
  324.                               color: Colors.black,
  325.                             ),
  326.                             hintText: "Password",
  327.                             hintStyle: TextStyle(
  328.                                 fontFamily: "WorkSansSemiBold", fontSize: 17.0),
  329.                             suffixIcon: GestureDetector(
  330.                               onTap: _toggleLogin,
  331.                               child: Icon(
  332.                                 _obscureTextLogin
  333.                                     ? FontAwesomeIcons.eye
  334.                                     : FontAwesomeIcons.eyeSlash,
  335.                                 size: 15.0,
  336.                                 color: Colors.black,
  337.                               ),
  338.                             ),
  339.                           ),
  340.                         ),
  341.                       ),
  342.                     ],
  343.                   ),
  344.                 ),
  345.               ),
  346.               Container(
  347.                 margin: EdgeInsets.only(top: 170.0),
  348.                 decoration: new BoxDecoration(
  349.                   borderRadius: BorderRadius.all(Radius.circular(5.0)),
  350.                   boxShadow: <BoxShadow>[
  351.                     BoxShadow(
  352.                       color: Theme.Colors.loginGradientStart,
  353.                       offset: Offset(1.0, 6.0),
  354.                       blurRadius: 20.0,
  355.                     ),
  356.                     BoxShadow(
  357.                       color: Theme.Colors.loginGradientEnd,
  358.                       offset: Offset(1.0, 6.0),
  359.                       blurRadius: 20.0,
  360.                     ),
  361.                   ],
  362.                   gradient: new LinearGradient(
  363.                       colors: [
  364.                         Theme.Colors.loginGradientEnd,
  365.                         Theme.Colors.loginGradientStart
  366.                       ],
  367.                       begin: const FractionalOffset(0.2, 0.2),
  368.                       end: const FractionalOffset(1.0, 1.0),
  369.                       stops: [0.0, 1.0],
  370.                       tileMode: TileMode.clamp),
  371.                 ),
  372.                 child: MaterialButton(
  373.                   highlightColor: Colors.transparent,
  374.                   splashColor: Theme.Colors.loginGradientEnd,
  375.                   //shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5.0))),
  376.                   child: Padding(
  377.                     padding: const EdgeInsets.symmetric(
  378.                         vertical: 10.0, horizontal: 42.0),
  379.                     child: Text(
  380.                       "LOGIN",
  381.                       style: TextStyle(
  382.                           color: Colors.white,
  383.                           fontSize: 25.0,
  384.                           fontFamily: "WorkSansBold"),
  385.                     ),
  386.                   ),
  387.                   onPressed: () {
  388.                     Navigator.push(
  389.                       context,
  390.                       MaterialPageRoute(builder: (context) => Dashboard()),
  391.                     );
  392.                   },
  393.                 ),
  394.               ),
  395.             ],
  396.           ),
  397.           Padding(
  398.             padding: EdgeInsets.only(top: 10.0),
  399.             child: Row(
  400.               mainAxisAlignment: MainAxisAlignment.center,
  401.               children: <Widget>[
  402.                 Container(
  403.                   decoration: BoxDecoration(
  404.                     gradient: new LinearGradient(
  405.                         colors: [
  406.                           Colors.white10,
  407.                           Colors.white,
  408.                         ],
  409.                         begin: const FractionalOffset(0.0, 0.0),
  410.                         end: const FractionalOffset(1.0, 1.0),
  411.                         stops: [0.0, 1.0],
  412.                         tileMode: TileMode.clamp),
  413.                   ),
  414.                   width: 100.0,
  415.                   height: 1.0,
  416.                 ),
  417.                 Padding(
  418.                   padding: EdgeInsets.only(left: 15.0, right: 15.0),
  419.                   child: Text(
  420.                     "Atau",
  421.                     style: TextStyle(
  422.                         color: Colors.white,
  423.                         fontSize: 16.0,
  424.                         fontFamily: "WorkSansMedium"),
  425.                   ),
  426.                 ),
  427.                 Container(
  428.                   decoration: BoxDecoration(
  429.                     gradient: new LinearGradient(
  430.                         colors: [
  431.                           Colors.white,
  432.                           Colors.white10,
  433.                         ],
  434.                         begin: const FractionalOffset(0.0, 0.0),
  435.                         end: const FractionalOffset(1.0, 1.0),
  436.                         stops: [0.0, 1.0],
  437.                         tileMode: TileMode.clamp),
  438.                   ),
  439.                   width: 100.0,
  440.                   height: 1.0,
  441.                 ),
  442.               ],
  443.             ),
  444.           ),
  445.           Row(
  446.             mainAxisAlignment: MainAxisAlignment.center,
  447.             children: <Widget>[
  448.               Padding(
  449.                 padding: EdgeInsets.only(top: 10.0, right: 40.0),
  450.                 child: GestureDetector(
  451.                   onTap: () => showInSnackBar("Facebook button pressed"),
  452.                   child: Container(
  453.                     padding: const EdgeInsets.all(15.0),
  454.                     decoration: new BoxDecoration(
  455.                       shape: BoxShape.circle,
  456.                       color: Colors.white,
  457.                     ),
  458.                     child: new Icon(
  459.                       FontAwesomeIcons.facebookF,
  460.                       color: Color(0xFF0084ff),
  461.                     ),
  462.                   ),
  463.                 ),
  464.               ),
  465.               Padding(
  466.                 padding: EdgeInsets.only(top: 10.0),
  467.                 child: MaterialButton(
  468.                   onPressed: () {
  469.                     signInWithGoogle().whenComplete(() {
  470.                       Navigator.of(context).push(
  471.                         MaterialPageRoute(
  472.                           builder: (context) {
  473.                             return Dashboard();
  474.                           },
  475.                         ),
  476.                       );
  477.                     });
  478.                   },
  479.                   child: Container(
  480.                     padding: const EdgeInsets.all(15.0),
  481.                     decoration: new BoxDecoration(
  482.                       shape: BoxShape.circle,
  483.                       color: Colors.white,
  484.                     ),
  485.                     child: new Icon(
  486.                       FontAwesomeIcons.google,
  487.                       color: Color(0xFF0084ff),
  488.                     ),
  489.                   ),
  490.                 ),
  491.               ),
  492.             ],
  493.           ),
  494.         ],
  495.       ),
  496.     );
  497.   }
  498.  
  499.   Widget _buildSignUp(BuildContext context) {
  500.     return Container(
  501.       padding: EdgeInsets.only(top: 23.0),
  502.       child: Column(
  503.         children: <Widget>[
  504.           Stack(
  505.             alignment: Alignment.topCenter,
  506.             overflow: Overflow.visible,
  507.             children: <Widget>[
  508.               Card(
  509.                 elevation: 2.0,
  510.                 color: Colors.white,
  511.                 shape: RoundedRectangleBorder(
  512.                   borderRadius: BorderRadius.circular(8.0),
  513.                 ),
  514.                 child: Container(
  515.                   width: 300.0,
  516.                   height: 360.0,
  517.                   child: Column(
  518.                     children: <Widget>[
  519.                       Padding(
  520.                         padding: EdgeInsets.only(
  521.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  522.                         child: TextField(
  523.                           focusNode: myFocusNodeName,
  524.                           controller: signupNameController,
  525.                           keyboardType: TextInputType.text,
  526.                           textCapitalization: TextCapitalization.words,
  527.                           style: TextStyle(
  528.                               fontFamily: "WorkSansSemiBold",
  529.                               fontSize: 16.0,
  530.                               color: Colors.black),
  531.                           decoration: InputDecoration(
  532.                             border: InputBorder.none,
  533.                             icon: Icon(
  534.                               FontAwesomeIcons.user,
  535.                               color: Colors.black,
  536.                             ),
  537.                             hintText: "Nama",
  538.                             hintStyle: TextStyle(
  539.                                 fontFamily: "WorkSansSemiBold", fontSize: 16.0),
  540.                           ),
  541.                         ),
  542.                       ),
  543.                       Container(
  544.                         width: 250.0,
  545.                         height: 1.0,
  546.                         color: Colors.grey[400],
  547.                       ),
  548.                       Padding(
  549.                         padding: EdgeInsets.only(
  550.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  551.                         child: TextField(
  552.                           focusNode: myFocusNodeEmail,
  553.                           controller: signupEmailController,
  554.                           keyboardType: TextInputType.emailAddress,
  555.                           style: TextStyle(
  556.                               fontFamily: "WorkSansSemiBold",
  557.                               fontSize: 16.0,
  558.                               color: Colors.black),
  559.                           decoration: InputDecoration(
  560.                             border: InputBorder.none,
  561.                             icon: Icon(
  562.                               FontAwesomeIcons.envelope,
  563.                               color: Colors.black,
  564.                             ),
  565.                             hintText: "Email",
  566.                             hintStyle: TextStyle(
  567.                                 fontFamily: "WorkSansSemiBold", fontSize: 16.0),
  568.                           ),
  569.                         ),
  570.                       ),
  571.                       Container(
  572.                         width: 250.0,
  573.                         height: 1.0,
  574.                         color: Colors.grey[400],
  575.                       ),
  576.                       Padding(
  577.                         padding: EdgeInsets.only(
  578.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  579.                         child: TextField(
  580.                           focusNode: myFocusNodePassword,
  581.                           controller: signupPasswordController,
  582.                           obscureText: _obscureTextSignup,
  583.                           style: TextStyle(
  584.                               fontFamily: "WorkSansSemiBold",
  585.                               fontSize: 16.0,
  586.                               color: Colors.black),
  587.                           decoration: InputDecoration(
  588.                             border: InputBorder.none,
  589.                             icon: Icon(
  590.                               FontAwesomeIcons.lock,
  591.                               color: Colors.black,
  592.                             ),
  593.                             hintText: "Password",
  594.                             hintStyle: TextStyle(
  595.                                 fontFamily: "WorkSansSemiBold", fontSize: 16.0),
  596.                             suffixIcon: GestureDetector(
  597.                               onTap: _toggleSignup,
  598.                               child: Icon(
  599.                                 _obscureTextSignup
  600.                                     ? FontAwesomeIcons.eye
  601.                                     : FontAwesomeIcons.eyeSlash,
  602.                                 size: 15.0,
  603.                                 color: Colors.black,
  604.                               ),
  605.                             ),
  606.                           ),
  607.                         ),
  608.                       ),
  609.                       Container(
  610.                         width: 250.0,
  611.                         height: 1.0,
  612.                         color: Colors.grey[400],
  613.                       ),
  614.                       Padding(
  615.                         padding: EdgeInsets.only(
  616.                             top: 20.0, bottom: 20.0, left: 25.0, right: 25.0),
  617.                         child: TextField(
  618.                           controller: signupConfirmPasswordController,
  619.                           obscureText: _obscureTextSignupConfirm,
  620.                           style: TextStyle(
  621.                               fontFamily: "WorkSansSemiBold",
  622.                               fontSize: 16.0,
  623.                               color: Colors.black),
  624.                           decoration: InputDecoration(
  625.                             border: InputBorder.none,
  626.                             icon: Icon(
  627.                               FontAwesomeIcons.lock,
  628.                               color: Colors.black,
  629.                             ),
  630.                             hintText: "Konfirmasi",
  631.                             hintStyle: TextStyle(
  632.                                 fontFamily: "WorkSansSemiBold", fontSize: 16.0),
  633.                             suffixIcon: GestureDetector(
  634.                               onTap: _toggleSignupConfirm,
  635.                               child: Icon(
  636.                                 _obscureTextSignupConfirm
  637.                                     ? FontAwesomeIcons.eye
  638.                                     : FontAwesomeIcons.eyeSlash,
  639.                                 size: 15.0,
  640.                                 color: Colors.black,
  641.                               ),
  642.                             ),
  643.                           ),
  644.                         ),
  645.                       ),
  646.                     ],
  647.                   ),
  648.                 ),
  649.               ),
  650.               Container(
  651.                 margin: EdgeInsets.only(top: 340.0),
  652.                 decoration: new BoxDecoration(
  653.                   borderRadius: BorderRadius.all(Radius.circular(5.0)),
  654.                   boxShadow: <BoxShadow>[
  655.                     BoxShadow(
  656.                       color: Theme.Colors.loginGradientStart,
  657.                       offset: Offset(1.0, 6.0),
  658.                       blurRadius: 20.0,
  659.                     ),
  660.                     BoxShadow(
  661.                       color: Theme.Colors.loginGradientEnd,
  662.                       offset: Offset(1.0, 6.0),
  663.                       blurRadius: 20.0,
  664.                     ),
  665.                   ],
  666.                   gradient: new LinearGradient(
  667.                       colors: [
  668.                         Theme.Colors.loginGradientEnd,
  669.                         Theme.Colors.loginGradientStart
  670.                       ],
  671.                       begin: const FractionalOffset(0.2, 0.2),
  672.                       end: const FractionalOffset(1.0, 1.0),
  673.                       stops: [0.0, 1.0],
  674.                       tileMode: TileMode.clamp),
  675.                 ),
  676.                 child: MaterialButton(
  677.                     highlightColor: Colors.transparent,
  678.                     splashColor: Theme.Colors.loginGradientEnd,
  679.                     //shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5.0))),
  680.                     child: Padding(
  681.                       padding: const EdgeInsets.symmetric(
  682.                           vertical: 10.0, horizontal: 42.0),
  683.                       child: Text(
  684.                         "DAFTAR",
  685.                         style: TextStyle(
  686.                             color: Colors.white,
  687.                             fontSize: 25.0,
  688.                             fontFamily: "WorkSansBold"),
  689.                       ),
  690.                     ),
  691.                     onPressed: () => showInSnackBar("SignUp button pressed")),
  692.               ),
  693.             ],
  694.           ),
  695.         ],
  696.       ),
  697.     );
  698.   }
  699.  
  700.   void _onSignInButtonPress() {
  701.     _pageController.animateToPage(0,
  702.         duration: Duration(milliseconds: 500), curve: Curves.decelerate);
  703.   }
  704.  
  705.   void _onSignUpButtonPress() {
  706.     _pageController?.animateToPage(1,
  707.         duration: Duration(milliseconds: 500), curve: Curves.decelerate);
  708.   }
  709.  
  710.   void _toggleLogin() {
  711.     setState(() {
  712.       _obscureTextLogin = !_obscureTextLogin;
  713.     });
  714.   }
  715.  
  716.   void _toggleSignup() {
  717.     setState(() {
  718.       _obscureTextSignup = !_obscureTextSignup;
  719.     });
  720.   }
  721.  
  722.   void _toggleSignupConfirm() {
  723.     setState(() {
  724.       _obscureTextSignupConfirm = !_obscureTextSignupConfirm;
  725.     });
  726.   }
  727. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement