PR requests

This commit is contained in:
Rafeek-Khoudare
2025-07-10 16:52:34 +03:00
parent 2ff34a07a7
commit 24c7bcef55
5 changed files with 97 additions and 163 deletions

View File

@ -201,11 +201,8 @@ class SecurityBloc extends Bloc<SecurityEvent, SecurityState> {
try {
await AuthenticationAPI.deleteAccount();
emit(ChangedPassState());
} on DioException catch (e) {
final errorData = e.response!.data;
String errorMessage =
errorData['error']['message'] ?? 'something went wrong';
validate = errorMessage;
} catch (e) {
validate = e.toString();
emit(AuthInitialState());
}
}

View File

@ -5,11 +5,10 @@ import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_bloc.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_event.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_state.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import '../../../../../../generated/assets.dart';
import '../../../../../../utils/resource_manager/color_manager.dart';
import '../../../../../shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class DeleteAccountPage extends StatelessWidget {
const DeleteAccountPage({super.key});
@ -30,25 +29,37 @@ class DeleteAccountPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
context.read<SecurityBloc>().add(DeleteAccountEvent());
},
child: Container(
height: 50,
margin: const EdgeInsets.only(right: 20, left: 20),
decoration: const BoxDecoration(
color: ColorsManager.blueColor,
borderRadius: BorderRadius.all(Radius.circular(20))),
child: const Center(
child: Text(
'Delete Account',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: ColorsManager.onPrimaryColor),
)),
),
Column(
children: [
Text(
'Thank you for using Syncrow',
),
SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {
context.read<SecurityBloc>().add(DeleteAccountEvent());
},
style: ElevatedButton.styleFrom(
backgroundColor: ColorsManager.blueColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
fixedSize: Size(
MediaQuery.sizeOf(context).width * 0.8,
40,
),
),
child: Text(
'Delete Account',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: ColorsManager.onPrimaryColor),
),
)
],
),
],
),
@ -68,15 +79,8 @@ class DeleteAccountPage extends StatelessWidget {
),
),
const BodyMedium(
text: 'if you confirm to "delete account",',
fontWeight: FontWeight.w400,
fontSize: 16,
),
const SizedBox(
height: 4,
),
const BodyMedium(
text: 'the account will be deleted',
text:
'if you confirm to "delete account",the account will be deleted',
fontWeight: FontWeight.w400,
fontSize: 16,
),

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_bloc.dart';
@ -24,12 +23,11 @@ class ChangePasswordPage extends StatelessWidget {
children: [
InkWell(
onTap: () {
// In your parent widget or navigator
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BlocProvider(
create: (_) => SecurityBloc(), // Provide the Bloc
create: (_) => SecurityBloc(),
child: const VerificationCodePage(
title: 'Change Password',
isDeleteAccountMode: false,

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_bloc.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_event.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/view/change_password_page.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/view/verification_code_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
@ -8,8 +9,6 @@ import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../bloc/security_event.dart';
class SecurtyView extends StatelessWidget {
const SecurtyView({super.key});
@ -28,145 +27,34 @@ class SecurtyView extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
InkWell(
SecurityListTileWidget(
title: 'Change Password',
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const ChangePasswordPage(),
));
},
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BodyMedium(
text: 'Change Password',
),
Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
)
],
),
// Container(
// margin: const EdgeInsets.symmetric(vertical: 15),
// height: 1,
// color: ColorsManager.greyColor,
// ),
],
),
),
// InkWell(
// onTap: () {},
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// const Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// BodyMedium(
// text: 'App Lock',
// ),
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// )
// ],
// ),
// Container(
// margin: const EdgeInsets.symmetric(vertical: 15),
// height: 1,
// color: ColorsManager.greyColor,
// ),
// ],
// ),
// ),
// InkWell(
// onTap: () {},
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// const Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// BodyMedium(
// text: 'User Code',
// ),
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// )
// ],
// ),
// Container(
// margin: const EdgeInsets.symmetric(vertical: 15),
// height: 1,
// color: ColorsManager.greyColor,
// ),
// ],
// ),
// ),
Container(
margin: const EdgeInsets.symmetric(vertical: 15),
height: 1,
color: ColorsManager.greyColor,
),
InkWell(
SecurityListTileWidget(
title: 'Delete Account',
fontColor: ColorsManager.red,
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => BlocProvider(
create: (_) => SecurityBloc()..add(StartTimerEvent()),
child: VerificationCodePage(
title: 'Delete Account',
title: '',
isDeleteAccountMode: true,
),
),
));
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BodyMedium(
text: 'Delete Account',
fontColor: ColorsManager.red,
),
Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
)
],
),
],
),
),
// InkWell(
// onTap: () {},
// child: const Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// BodyMedium(
// text: 'Device Update',
// ),
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// )
// ],
// ),
// ),
],
),
),
@ -175,3 +63,42 @@ class SecurtyView extends StatelessWidget {
);
}
}
class SecurityListTileWidget extends StatelessWidget {
final String title;
final void Function() onTap;
final Color? fontColor;
const SecurityListTileWidget({
super.key,
required this.title,
required this.onTap,
this.fontColor,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BodyMedium(
text: title,
fontColor: fontColor,
),
Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
)
],
),
],
),
);
}
}

View File

@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
import 'package:syncrow_app/features/auth/model/signup_model.dart';
import 'package:syncrow_app/features/auth/model/token.dart';
@ -85,9 +86,16 @@ class AuthenticationAPI {
}
static Future<void> deleteAccount() async {
await HTTPService().delete(
path: ApiEndpoints.deleteProfile,
expectedResponseModel: (p0) {},
);
try {
await HTTPService().delete(
path: ApiEndpoints.deleteProfile,
expectedResponseModel: (p0) {},
);
} on DioException catch (e) {
final errorData = e.response!.data;
String errorMessage =
errorData['error']['message'] ?? 'something went wrong';
throw Exception(errorMessage);
}
}
}