mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 04:14:54 +00:00
profile page fix bugs
This commit is contained in:
@ -15,7 +15,6 @@ import 'package:image_picker/image_picker.dart';
|
|||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
|
|
||||||
bool isSaving = false;
|
bool isSaving = false;
|
||||||
bool editName = false;
|
bool editName = false;
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
@ -24,7 +23,8 @@ 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(text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}');
|
final TextEditingController nameController = TextEditingController(
|
||||||
|
text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}');
|
||||||
List<TimeZone>? timeZoneList;
|
List<TimeZone>? timeZoneList;
|
||||||
List<RegionModel>? regionList;
|
List<RegionModel>? regionList;
|
||||||
|
|
||||||
@ -45,7 +45,6 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||||||
Future<void> saveName(SaveNameEvent event, Emitter<ProfileState> emit) async {
|
Future<void> saveName(SaveNameEvent event, Emitter<ProfileState> emit) async {
|
||||||
if (_validateInputs()) return;
|
if (_validateInputs()) return;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
add(const ChangeNameEvent(value: false));
|
add(const ChangeNameEvent(value: false));
|
||||||
isSaving = true;
|
isSaving = true;
|
||||||
emit(LoadingInitialState());
|
emit(LoadingInitialState());
|
||||||
@ -56,11 +55,10 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||||||
var response = await ProfileApi.saveName(firstName: firstName, lastName: lastName);
|
var response = await ProfileApi.saveName(firstName: firstName, lastName: lastName);
|
||||||
add(InitialProfileEvent());
|
add(InitialProfileEvent());
|
||||||
await HomeCubit.getInstance().fetchUserInfo();
|
await HomeCubit.getInstance().fetchUserInfo();
|
||||||
// Navigator.of(event.context).pop(true);
|
|
||||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||||
emit(SaveState());
|
emit(SaveState());
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
// Handle the error
|
emit(FailedState(errorMessage: e.toString()));
|
||||||
} finally {
|
} finally {
|
||||||
isSaving = false;
|
isSaving = false;
|
||||||
}
|
}
|
||||||
@ -133,8 +131,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||||||
final filteredRegions = regionList?.where((region) {
|
final filteredRegions = regionList?.where((region) {
|
||||||
return region.name.toLowerCase().contains(query);
|
return region.name.toLowerCase().contains(query);
|
||||||
}).toList() ?? [];
|
}).toList() ?? [];
|
||||||
regionList = filteredRegions;// Assume this fetches the regions
|
regionList = filteredRegions;
|
||||||
|
|
||||||
emit(RegionsLoadedState(regions: filteredRegions));
|
emit(RegionsLoadedState(regions: filteredRegions));
|
||||||
}else{
|
}else{
|
||||||
regionList = await ProfileApi.fetchRegion();
|
regionList = await ProfileApi.fetchRegion();
|
||||||
|
|||||||
Reference in New Issue
Block a user