auth changes

This commit is contained in:
mohammad
2024-08-06 16:40:03 +03:00
parent 1f5a119c60
commit e88be3cf17
4 changed files with 46 additions and 28 deletions

View File

@ -98,6 +98,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
String newPassword = ''; String newPassword = '';
String maskedEmail = ''; String maskedEmail = '';
String otpCode = ''; String otpCode = '';
String validate = '';
static Token token = Token.emptyConstructor(); static Token token = Token.emptyConstructor();
static UserModel? user; static UserModel? user;
bool showValidationMessage = false; bool showValidationMessage = false;
@ -118,6 +119,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
), ),
); );
} catch (failure) { } catch (failure) {
validate='Something went wrong';
emit(const LoginFailure(error: 'Something went wrong')); emit(const LoginFailure(error: 'Something went wrong'));
// emit(LoginFailure(error: failure.toString())); // emit(LoginFailure(error: failure.toString()));
return; return;

View File

@ -49,7 +49,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
child: ListView( child: ListView(
children: [ children: [
Container( Container(
padding:const EdgeInsets.all(50) , padding:const EdgeInsets.all(30) ,
margin: const EdgeInsets.all(90), margin: const EdgeInsets.all(90),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
@ -92,12 +92,12 @@ class ForgetPasswordWebPage extends StatelessWidget {
fontSize: 24, fontSize: 24,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 20), const SizedBox(height: 10),
Text( Text(
'Please fill in your account information to\nretrieve your password', 'Please fill in your account information to\nretrieve your password',
style: smallTextStyle, style: smallTextStyle,
), ),
const SizedBox(height: 20), const SizedBox(height: 10),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -226,18 +226,27 @@ class ForgetPasswordWebPage extends StatelessWidget {
height: 10, height: 10,
), ),
const SizedBox(height: 20.0), const SizedBox(height: 20.0),
SizedBox( Row(
width: MediaQuery.sizeOf(context).width * 0.2, crossAxisAlignment: CrossAxisAlignment.center,
child: DefaultButton( mainAxisAlignment: MainAxisAlignment.center,
backgroundColor: ColorsManager.btnColor, children: [
child: const Text('Submit'), SizedBox(
onPressed: () { width: MediaQuery.sizeOf(context).width * 0.2,
if (forgetBloc.forgetFormKey.currentState!.validate()) { child: DefaultButton(
forgetBloc.add(ChangePasswordEvent()); backgroundColor: ColorsManager.btnColor,
} child: const Text('Submit'),
}, onPressed: () {
), if (forgetBloc.forgetFormKey.currentState!.validate()) {
forgetBloc.add(ChangePasswordEvent());
}
},
),
),
],
), ),
const SizedBox(height: 10.0),
SizedBox(child: Text(forgetBloc.validate,
style: const TextStyle(fontWeight: FontWeight.w700,color: ColorsManager.red ),),),
SizedBox(height: 10,), SizedBox(height: 10,),
SizedBox( SizedBox(
width: MediaQuery.sizeOf(context).width * 0.2, width: MediaQuery.sizeOf(context).width * 0.2,

View File

@ -7,7 +7,6 @@ import 'package:syncrow_web/utils/responsive_layout.dart';
class LoginPage extends StatelessWidget { class LoginPage extends StatelessWidget {
const LoginPage({super.key}); const LoginPage({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const ResponsiveLayout( return const ResponsiveLayout(

View File

@ -22,7 +22,7 @@ class LoginWebPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: BlocProvider( body: BlocProvider(
create: (BuildContext context) => AuthBloc()..add(RegionInitialEvent()), create: (BuildContext context) => AuthBloc(),
child: BlocConsumer<AuthBloc, AuthState>( child: BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is LoginSuccess) { if (state is LoginSuccess) {
@ -54,14 +54,15 @@ class LoginWebPage extends StatelessWidget {
Widget _buildLoginForm(BuildContext context,AuthState state) { Widget _buildLoginForm(BuildContext context,AuthState state) {
final loginBloc = BlocProvider.of<AuthBloc>(context); final loginBloc = BlocProvider.of<AuthBloc>(context);
Size size= MediaQuery.of(context).size;
return FirstLayer( return FirstLayer(
second: Center( second: Center(
child: ListView( child: ListView(
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
Container( Container(
padding:const EdgeInsets.all(50) , padding: EdgeInsets.all(size.width*0.02) ,
margin: const EdgeInsets.all(90), margin: EdgeInsets.all(size.width*0.09),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
borderRadius: const BorderRadius.all(Radius.circular(20)), borderRadius: const BorderRadius.all(Radius.circular(20)),
@ -89,12 +90,14 @@ class LoginWebPage extends StatelessWidget {
child: Form( child: Form(
key: loginBloc.loginFormKey, key: loginBloc.loginFormKey,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 25), padding: EdgeInsets.symmetric(
horizontal: size.width*0.040,
vertical: size.width*0.003),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
const SizedBox(height: 15), const SizedBox(height: 40),
const Text( const Text(
'Login', 'Login',
style: TextStyle( style: TextStyle(
@ -102,7 +105,7 @@ class LoginWebPage extends StatelessWidget {
fontSize: 24, fontSize: 24,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 40), SizedBox(height: size.height*0.03),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -121,7 +124,7 @@ class LoginWebPage extends StatelessWidget {
decoration: textBoxDecoration()!.copyWith( decoration: textBoxDecoration()!.copyWith(
hintText: null,), hintText: null,),
hint: SizedBox( hint: SizedBox(
width: MediaQuery.sizeOf(context).width * 0.11, width: size.width * 0.11,
child: const Align( child: const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
@ -142,7 +145,7 @@ class LoginWebPage extends StatelessWidget {
}).toList(), }).toList(),
onChanged: (String? value) { onChanged: (String? value) {
print(value); print(value);
}, },
), ),
) )
], ],
@ -224,7 +227,7 @@ class LoginWebPage extends StatelessWidget {
), ),
), ),
const SizedBox( const SizedBox(
height: 32, height: 20,
), ),
Row( Row(
children: [ children: [
@ -242,7 +245,7 @@ class LoginWebPage extends StatelessWidget {
), ),
), ),
SizedBox( SizedBox(
width: MediaQuery.sizeOf(context).width * 0.16, width:size.width * 0.14,
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
text: 'Agree to ', text: 'Agree to ',
@ -283,9 +286,9 @@ class LoginWebPage extends StatelessWidget {
), ),
], ],
), ),
const SizedBox(height: 30.0), const SizedBox(height: 20.0),
SizedBox( SizedBox(
width: MediaQuery.sizeOf(context).width * 0.2, width:size.width * 0.2,
child: DefaultButton( child: DefaultButton(
backgroundColor: loginBloc.isChecked? backgroundColor: loginBloc.isChecked?
ColorsManager.btnColor:ColorsManager.grayColor, ColorsManager.btnColor:ColorsManager.grayColor,
@ -301,7 +304,12 @@ class LoginWebPage extends StatelessWidget {
}, },
), ),
), ),
const SizedBox(height: 15.0),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [ SizedBox(child: Text(loginBloc.validate,
style: const TextStyle(fontWeight: FontWeight.w700,color: ColorsManager.red ),),)],)
], ],
), ),
), ),