diff --git a/lib/pages/user/login_with_password_page.dart b/lib/pages/user/login_with_password_page.dart index 0a090b5..9ec5d43 100644 --- a/lib/pages/user/login_with_password_page.dart +++ b/lib/pages/user/login_with_password_page.dart @@ -19,6 +19,7 @@ import 'package:car_provider_app/extensions/int_extensions.dart'; import 'package:car_provider_app/extensions/string_extensions.dart'; import 'package:car_provider_app/extensions/widget_extensions.dart'; import 'package:car_provider_app/widgets/show_fill_button.dart'; +import 'package:car_provider_app/widgets/tab/login_email_tab.dart'; import 'package:car_provider_app/widgets/txt_field.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; @@ -30,8 +31,8 @@ class LoginWithPassword extends StatefulWidget { class _LoginWithPasswordState extends State { int otpType = 1; - bool _email = true; - bool _mobile = true; + + ClassType type = ClassType.NUMBER; String phoneNum = "", password = ""; @@ -47,42 +48,20 @@ class _LoginWithPasswordState extends State { padding: EdgeInsets.all(40), child: Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - onPressed: () { - setState(() { - _mobile = true; - _email = false; - }); - },child: - Text("Mobile Number", - style: TextStyle(fontSize: 14, - fontWeight: FontWeight.w600,), - ),color: _mobile ? Colors.blue : Colors.transparent,textColor: _mobile ? Colors.white : Colors.blue, - padding: EdgeInsets.symmetric(horizontal: 18, vertical: 12),), - - RaisedButton(onPressed: () { - setState(() { - _mobile = false; - _email = true; - }); - },child: - Text("Email Address", - style: TextStyle(fontSize: 14, - fontWeight: FontWeight.w600,),),color: _email? Colors.blue : Colors.transparent - ,textColor: _email ? Colors.white : Colors.blue, - padding: EdgeInsets.symmetric(horizontal: 18, vertical: 12),), - ], + LoginEmailTab( + onSelection: (ClassType type) { + setState(() { + this.type = type; + }); + }, ), 50.height, - "Enter Mobile or Email".toText24(), + (type == ClassType.NUMBER ? "Enter Phone" : "Enter Email").toText24(), mFlex(1), - Column( + Column( children: [ TxtField( - hint: _mobile ? "Enter phone number" : "Enter Email", + hint: type == ClassType.NUMBER ? "Enter phone number" : "Enter Email", value: phoneNum, onChanged: (v) { phoneNum = v; @@ -90,7 +69,7 @@ class _LoginWithPasswordState extends State { ), 12.height, TxtField( - hint: "Enter Password", + hint: "Enter Password?", value: password, isPasswordEnabled: true, maxLines: 1, @@ -101,14 +80,14 @@ class _LoginWithPasswordState extends State { ], ), 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - "Forget Password ?".toText12(color: Colors.blue).onPress(() { - navigateWithName(context, AppRoutes.forgetPassword); - }), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + "Forget Password".toText12(color: Colors.blue).onPress(() { + navigateWithName(context, AppRoutes.forgetPassword); + }), + ], + ), 50.height, ShowFillButton( title: "Log In", @@ -138,7 +117,5 @@ class _LoginWithPasswordState extends State { } } - Future performBasicOtpEmail(BuildContext context) async { - - } + Future performBasicOtpEmail(BuildContext context) async {} } diff --git a/lib/widgets/tab/login_email_tab.dart b/lib/widgets/tab/login_email_tab.dart new file mode 100644 index 0000000..7c29b63 --- /dev/null +++ b/lib/widgets/tab/login_email_tab.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; + +enum ClassType { EMAIL, NUMBER } + +class LoginEmailTab extends StatefulWidget { + Function(ClassType) onSelection; + + LoginEmailTab({required this.onSelection}); + + @override + State createState() => _LoginEmailTabState(); +} + +class _LoginEmailTabState extends State { + ClassType type = ClassType.NUMBER; + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + child: Row( + children: [ + Expanded( + child: InkWell( + onTap: () { + type = ClassType.NUMBER; + widget.onSelection(ClassType.NUMBER); + }, + child: Container( + width: double.infinity, + height: 45, + color: type == ClassType.NUMBER ? Colors.blue : Colors.transparent, + child: Center( + child: Text( + "Number", + style: TextStyle( + color: type == ClassType.NUMBER ? Colors.white : Colors.black, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ), + ), + Expanded( + child: InkWell( + onTap: () { + type = ClassType.EMAIL; + widget.onSelection(ClassType.EMAIL); + }, + child: Container( + width: double.infinity, + height: 45, + color: type == ClassType.EMAIL ? Colors.blue : Colors.transparent, + child: Center( + child: Text( + "Email", + style: TextStyle( + color: type == ClassType.EMAIL ? Colors.white : Colors.black, + fontWeight: FontWeight.bold, + ), + )), + ), + ), + ), + ], + ), + ); + } +}