Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
profile_information_form.dart
Go to the documentation of this file.
1import 'package:connect/core/localization/app_localizations.dart';
2import 'package:connect/features/account/screens/cubit/profile_cubit/load_profile_cubit_cubit.dart';
3import 'package:flutter_bloc/flutter_bloc.dart';
4
5import '../../../../../core/ui/theme/color_palette.dart';
6import '../../../../../core/ui/widgets/custom_snackbar.dart';
7import '/core/ui/widgets/custom_card.dart';
8import '/core/ui/widgets/custom_text_form_field.dart';
9import 'package:flutter/material.dart';
10import 'package:flutter_screenutil/flutter_screenutil.dart';
11import 'package:hugeicons/hugeicons.dart';
12
13class ProfileInformationForm extends StatefulWidget {
14 const ProfileInformationForm({super.key});
15
16 @override
17 State<ProfileInformationForm> createState() => _ProfileInformationFormState();
18}
19
20class _ProfileInformationFormState extends State<ProfileInformationForm> {
21 //profile fields
22 final _nameController = TextEditingController();
23 final _phoneNumberController = TextEditingController();
24 final _emailController = TextEditingController();
25 final _formKey = GlobalKey<FormState>();
26
28
29 @override
30 Widget build(BuildContext context) {
31 return BlocConsumer<LoadProfileCubitCubit, LoadProfileCubitState>(
32 listener: (context, state) {
33 if (state is ProfileLoadingFailureState) {
35 context,
37 AppLocalizations.of(context)
38 .translate('Faild to load profile informations'),
39 );
40 }
41 if (state is ProfileLoadedState) {
42 setState(() {
43 _nameController.text = state.profileInformations.name ?? '';
44 _emailController.text = state.profileInformations.email ?? '';
46 state.profileInformations.phoneNumber ?? '';
47 });
48 }
49 },
50 builder: (context, state) {
51 if (state is LoadingProfileState) {
52 return Center(
53 child: CircularProgressIndicator(),
54 );
55 } else {
56 return CustomCard(
57 padding: EdgeInsets.all(15.sp),
58 child: Column(
59 children: [
60 Form(
61 child: Column(
62 crossAxisAlignment: CrossAxisAlignment.start,
63 children: [
64 Text(
65 AppLocalizations.of(context)
66 .translate('Profile Informations'),
67 style: Theme.of(context).textTheme.bodySmall,
68 ),
69 SizedBox(height: 15.sp),
70 CustomTextFormField(
71 hintText: AppLocalizations.of(context)
72 .translate('Enter full name'),
73 labelText:
74 AppLocalizations.of(context).translate('Full Name'),
75 suffix: Icon(
76 HugeIcons.strokeRoundedText,
77 size: 15.sp,
78 ),
79 controller: _nameController,
80 ),
81 SizedBox(height: 15.sp),
82 CustomTextFormField(
83 hintText: AppLocalizations.of(context)
84 .translate('Enter Phone Number'),
85 labelText: AppLocalizations.of(context)
86 .translate('Phone Number'),
87 suffix: Icon(
88 HugeIcons.strokeRoundedSmartPhone01,
89 size: 15.sp,
90 ),
91 controller: _phoneNumberController,
92 ),
93 SizedBox(height: 15.sp),
94 SizedBox(height: 15.sp),
95 CustomTextFormField(
96 hintText: AppLocalizations.of(context)
97 .translate('Enter E-mail'),
98 labelText:
99 AppLocalizations.of(context).translate('E-mail'),
100 suffix: Icon(
101 HugeIcons.strokeRoundedMail01,
102 size: 15.sp,
103 ),
104 controller: _emailController,
105 ),
106 ],
107 ),
108 ),
109 SizedBox(height: 20.sp),
110 SizedBox(
111 width: MediaQuery.of(context).size.width,
112 child: ElevatedButton(
113 onPressed: null, // _onUpdateProfileInformation,
114 child: Text(
115 AppLocalizations.of(context).translate('UPDATE PROFILE'),
116 ),
117 ),
118 ),
119 ],
120 ),
121 );
122 }
123 },
124 );
125 }
126}
String translate(String key)
static AppLocalizations of(BuildContext context)
static const red
static display(final BuildContext context, final Color color, final String message,)
const ProfileInformationForm({super.key})
override State< ProfileInformationForm > createState()
const CustomCard({ super.key, required this.child, this.padding, this.bgColor, })
final Widget child
final EdgeInsets padding
const ProfileLoadingFailureState({required this.failure})
override Widget build(BuildContext context)
class ProfileInformationForm extends StatefulWidget _nameController
final _phoneNumberController
void _onUpdateProfileInformation()
final _emailController