profile page

This commit is contained in:
mohammad
2024-07-25 15:19:10 +03:00
parent 2b8767aa4b
commit 378f4396d8
4 changed files with 15 additions and 10 deletions
@@ -54,8 +54,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
final lastName = nameParts.length > 1 ? nameParts[1] : '';
var response = await ProfileApi.saveName(firstName: firstName, lastName: lastName);
add(InitialProfileEvent());
final homeCubit = event.context.read<HomeCubit>();
await homeCubit.fetchUserInfo();
await HomeCubit.getInstance().fetchUserInfo();
Navigator.of(event.context).pop(true);
CustomSnackBar.displaySnackBar('Save Successfully');
emit(SaveState());
@@ -102,7 +101,6 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
}
}
Future selectTimeZone(SelectTimeZoneEvent event, Emitter<ProfileState> emit) async {
try {
emit(LoadingInitialState());
@@ -135,6 +133,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
return region.name.toLowerCase().contains(query);
}).toList() ?? [];
regionList = filteredRegions;// Assume this fetches the regions
emit(RegionsLoadedState(regions: filteredRegions));
}else{
regionList = await ProfileApi.fetchRegion();
@@ -243,7 +242,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
if (Platform.isAndroid ) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
PermissionStatus status = await Permission.photos.status;
if(androidInfo.version.sdkInt<= 33){
if(androidInfo.version.sdkInt<33){
if (status.isDenied) {
PermissionStatus status = await Permission.storage.request();
if (status.isGranted) {
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_bloc.dart';
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_event.dart';
import 'package:syncrow_app/features/menu/bloc/profile_bloc/profile_state.dart';
@@ -37,8 +36,7 @@ class ProfileView extends StatelessWidget {
),
InkWell(
onTap: () {
profileBloc.add(
SelectImageEvent(context: context, isSelected: false));
profileBloc.add(SelectImageEvent(context: context, isSelected: false));
},
child: SizedBox.square(
dimension: 125,
@@ -23,6 +23,11 @@ class RegionPage extends StatelessWidget {
),
);
}
if (state is SaveState) {
new Future.delayed(const Duration(milliseconds: 500), () {
Navigator.of(context).pop(true);
});
}
},
builder: (context, state) {
final profileBloc = BlocProvider.of<ProfileBloc>(context);
@@ -60,8 +65,7 @@ class RegionPage extends StatelessWidget {
itemBuilder: (context, index) {
return InkWell(
onTap: () {
profileBloc.add(SelectRegionEvent(
val: regionList[index].id, context: context));
profileBloc.add(SelectRegionEvent(val: regionList[index].id, context: context));
},
child: Padding(
padding: const EdgeInsets.all(10.0),
@@ -25,7 +25,11 @@ class TimeZoneScreenPage extends StatelessWidget {
backgroundColor: Colors.red,
),
);
}
}if (state is SaveState) {
new Future.delayed(const Duration(milliseconds: 500), () {
Navigator.of(context).pop(true);
});
}
},
builder: (context, state) {
final profileBloc = BlocProvider.of<ProfileBloc>(context);