mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
profile page fix bugs
This commit is contained in:
@ -23,8 +23,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||||||
String timeZoneSelected = '';
|
String timeZoneSelected = '';
|
||||||
String regionSelected = '';
|
String regionSelected = '';
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
final TextEditingController nameController = TextEditingController(
|
final TextEditingController nameController = TextEditingController(text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}');
|
||||||
text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}');
|
|
||||||
List<TimeZone>? timeZoneList;
|
List<TimeZone>? timeZoneList;
|
||||||
List<RegionModel>? regionList;
|
List<RegionModel>? regionList;
|
||||||
|
|
||||||
@ -240,25 +239,17 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||||||
|
|
||||||
String? fullNameValidator(String? value) {
|
String? fullNameValidator(String? value) {
|
||||||
if (value == null) return 'Full name is required';
|
if (value == null) return 'Full name is required';
|
||||||
|
|
||||||
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
|
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
|
||||||
|
|
||||||
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
|
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
|
||||||
return 'Full name must be between 2 and 30 characters long';
|
return 'Full name must be between 2 and 30 characters long';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if it contains anything but alphanumeric spaces and single quote
|
// Test if it contains anything but alphanumeric spaces and single quote
|
||||||
|
|
||||||
if (RegExp(r"/[^ a-zA-Z0-9-\']/").hasMatch(withoutExtraSpaces)) {
|
if (RegExp(r"/[^ a-zA-Z0-9-\']/").hasMatch(withoutExtraSpaces)) {
|
||||||
return 'Only alphanumeric characters, space, dash and single quote are allowed';
|
return 'Only alphanumeric characters, space, dash and single quote are allowed';
|
||||||
}
|
}
|
||||||
|
|
||||||
final parts = withoutExtraSpaces.split(' ');
|
final parts = withoutExtraSpaces.split(' ');
|
||||||
|
|
||||||
if (parts.length < 2) return 'Full name must contain first and last names';
|
if (parts.length < 2) return 'Full name must contain first and last names';
|
||||||
|
if (parts.length > 2) return 'Full name can at most contain 3 parts';
|
||||||
if (parts.length > 3) return 'Full name can at most contain 3 parts';
|
|
||||||
|
|
||||||
if (parts.any((part) => part.length < 2 || part.length > 30)) {
|
if (parts.any((part) => part.length < 2 || part.length > 30)) {
|
||||||
return 'Full name parts must be between 2 and 30 characters long';
|
return 'Full name parts must be between 2 and 30 characters long';
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,7 @@ class RegionPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (state is SaveState) {
|
if (state is SaveState) {
|
||||||
new Future.delayed(const Duration(milliseconds: 500), () {
|
Navigator.of(context).pop(true);
|
||||||
Navigator.of(context).pop(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
@ -17,7 +17,7 @@ class TimeZoneScreenPage extends StatelessWidget {
|
|||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (BuildContext context) => ProfileBloc()..add(TimeZoneInitialEvent()),
|
create: (BuildContext context) => ProfileBloc()..add(TimeZoneInitialEvent()),
|
||||||
child:
|
child:
|
||||||
BlocConsumer<ProfileBloc, ProfileState>(listener: (context, state) {
|
BlocConsumer<ProfileBloc, ProfileState>(listener: (context, state) {
|
||||||
if (state is FailedState) {
|
if (state is FailedState) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@ -26,10 +26,8 @@ class TimeZoneScreenPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}if (state is SaveState) {
|
}if (state is SaveState) {
|
||||||
new Future.delayed(const Duration(milliseconds: 500), () {
|
Navigator.of(context).pop(true);
|
||||||
Navigator.of(context).pop(true);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final profileBloc = BlocProvider.of<ProfileBloc>(context);
|
final profileBloc = BlocProvider.of<ProfileBloc>(context);
|
||||||
@ -38,8 +36,8 @@ class TimeZoneScreenPage extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
title: 'Time Zone',
|
title: 'Time Zone',
|
||||||
child: state is LoadingInitialState
|
child: state is LoadingInitialState
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller:profileBloc.searchController ,
|
controller:profileBloc.searchController ,
|
||||||
|
Reference in New Issue
Block a user