Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
signin_form_view.dart
Go to the documentation of this file.
1import 'package:easy_localization/easy_localization.dart';
2import 'package:flutter/material.dart';
3import 'package:flutter_bloc/flutter_bloc.dart';
4import 'package:flutter_screenutil/flutter_screenutil.dart';
5import '../../../../../../core/ui/widgets/custom_text_form_field.dart';
6import '../../../../domain/entities/credentials_entity.dart';
7import '../../../bloc/authentication_bloc/authentication_bloc.dart';
8
9class SignInFormView extends StatefulWidget {
10 const SignInFormView({super.key});
11
12 @override
13 State<SignInFormView> createState() => _SignInFormViewState();
14}
15
16class _SignInFormViewState extends State<SignInFormView> {
17 bool _isObscure = true;
18 // bool _isCheked = true;
19 final _emailController = TextEditingController();
20 final _passwordController = TextEditingController();
21 final _formKey = GlobalKey<FormState>();
22
23 @override
24 void initState() {
25 super.initState();
26 context.read<AuthenticationBloc>().add(LoadEmailEvent());
27 }
28
30 if (_formKey.currentState!.validate()) {
31 context.read<AuthenticationBloc>().add(
34 email: _emailController.text.trim(),
35 password: _passwordController.text.trim(),
36 ),
37 ),
38 );
39 }
40 }
41
42 @override
43 Widget build(BuildContext context) {
44 return BlocListener<AuthenticationBloc, AuthenticationState>(
45 listener: (context, state) {
46 if (state is EmailLoadedState) {
47 _emailController.text = state.email ?? '';
48 }
49 },
50 child: SingleChildScrollView(
51 padding: EdgeInsets.symmetric(
52 horizontal: 10.sp,
53 vertical: 15.sp,
54 ),
55 child: Form(
56 key: _formKey,
58 mainAxisAlignment: MainAxisAlignment.center, // Added this line
59 children: [
60 Padding(
61 padding: EdgeInsets.all(15.sp),
63 crossAxisAlignment: CrossAxisAlignment.center,
64 children: [
65 CustomTextFormField(
66 hintText: 'login.email'.tr(),
67 controller: _emailController,
68 validator: (value) {
69 if (value == null || value.isEmpty) {
70 return 'Email is required';
71 }
72 return null;
73 },
74 suffixIcon: const Icon(Icons.mail_outline),
75 ),
76 SizedBox(height: 15.sp),
77 CustomTextFormField(
78 hintText: 'login.password'.tr(),
79 controller: _passwordController,
80 validator: (value) {
81 if (value == null || value.isEmpty) {
82 return 'Password is required';
83 }
84 return null;
85 },
86 isObscure: _isObscure,
87 suffixIcon: InkWell(
88 onTap: () {
89 setState(() {
91 });
92 },
93 child: Icon(
94 _isObscure ? Icons.lock_outlined : Icons.lock_open_outlined,
95 ),
96 ),
97 ),
98 // SizedBox(height: 40.sp),
99 // TermsAndConditionsCheckbox(
100 // isChecked: _isCheked,
101 // onCheckStatuschanged: (value) {
102 // setState(() {
103 // _isCheked = !_isCheked;
104 // });
105 // },
106 // ),
107 SizedBox(height: 34.sp),
108 SizedBox(
109 width: MediaQuery.of(context).size.width,
110 child: ElevatedButton(
111 // onPressed: _isCheked ? _onSignInButtonClicked : null,
113 child: Text('login.login_button'.tr()),
114 ),
115 ),
116 ],
117 ),
118 ),
119 ],
120 ),
121 ),
122 ),
123 );
124 }
125}
override void initState()
class App extends StatefulWidget build(BuildContext context)
Definition app.dart:31
const SignInEvent({required this.reqEntity})
sealed class AuthenticationEvent extends Equatable reqEntity
const SignInFormView({super.key})
override State< SignInFormView > createState()
final Widget child
final EdgeInsets padding
final VoidCallback onPressed
final VoidCallback onTap
class SignInFormView extends StatefulWidget _isObscure
void _onSignInButtonClicked()
final _passwordController
final _formKey
final _emailController
style Text( '${ 'scheduling.reference'.tr()}:${collection.internalCode}', style:Theme.of(context).textTheme.bodySmall,)
style SizedBox(height:2.h)
style Column(crossAxisAlignment:CrossAxisAlignment.end, children:[Container(padding:EdgeInsets.symmetric(horizontal:8.w, vertical:4.h), decoration:BoxDecoration(color:ColorPalette.tiffanyBlue.withValues(alpha:0.1), borderRadius:BorderRadius.circular(12),), child:Text(collection.type ?? '', style:Theme.of(context).textTheme.bodySmall?.copyWith(color:ColorPalette.tiffanyBlue, fontWeight:FontWeight.bold,),),),],)