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 { try {
await AuthenticationAPI.deleteAccount(); await AuthenticationAPI.deleteAccount();
emit(ChangedPassState()); emit(ChangedPassState());
} on DioException catch (e) { } catch (e) {
final errorData = e.response!.data; validate = e.toString();
String errorMessage =
errorData['error']['message'] ?? 'something went wrong';
validate = errorMessage;
emit(AuthInitialState()); 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_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_event.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_state.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 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import '../../../../../../generated/assets.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../../../../../../utils/resource_manager/color_manager.dart';
import '../../../../../shared_widgets/default_scaffold.dart';
class DeleteAccountPage extends StatelessWidget { class DeleteAccountPage extends StatelessWidget {
const DeleteAccountPage({super.key}); const DeleteAccountPage({super.key});
@ -30,25 +29,37 @@ class DeleteAccountPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
InkWell( Column(
onTap: () { children: [
context.read<SecurityBloc>().add(DeleteAccountEvent()); Text(
}, 'Thank you for using Syncrow',
child: Container( ),
height: 50, SizedBox(
margin: const EdgeInsets.only(right: 20, left: 20), height: 10,
decoration: const BoxDecoration( ),
color: ColorsManager.blueColor, ElevatedButton(
borderRadius: BorderRadius.all(Radius.circular(20))), onPressed: () {
child: const Center( context.read<SecurityBloc>().add(DeleteAccountEvent());
child: Text( },
'Delete Account', style: ElevatedButton.styleFrom(
style: TextStyle( backgroundColor: ColorsManager.blueColor,
fontSize: 16, shape: RoundedRectangleBorder(
fontWeight: FontWeight.w700, borderRadius: BorderRadius.circular(12),
color: ColorsManager.onPrimaryColor), ),
)), 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( const BodyMedium(
text: 'if you confirm to "delete account",', text:
fontWeight: FontWeight.w400, 'if you confirm to "delete account",the account will be deleted',
fontSize: 16,
),
const SizedBox(
height: 4,
),
const BodyMedium(
text: 'the account will be deleted',
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontSize: 16, fontSize: 16,
), ),

View File

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

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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_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/change_password_page.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/view/verification_code_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'; 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/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../bloc/security_event.dart';
class SecurtyView extends StatelessWidget { class SecurtyView extends StatelessWidget {
const SecurtyView({super.key}); const SecurtyView({super.key});
@ -28,145 +27,34 @@ class SecurtyView extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
InkWell( SecurityListTileWidget(
title: 'Change Password',
onTap: () { onTap: () {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const ChangePasswordPage(), 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( Container(
margin: const EdgeInsets.symmetric(vertical: 15), margin: const EdgeInsets.symmetric(vertical: 15),
height: 1, height: 1,
color: ColorsManager.greyColor, color: ColorsManager.greyColor,
), ),
InkWell( SecurityListTileWidget(
title: 'Delete Account',
fontColor: ColorsManager.red,
onTap: () { onTap: () {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (context) => BlocProvider( builder: (context) => BlocProvider(
create: (_) => SecurityBloc()..add(StartTimerEvent()), create: (_) => SecurityBloc()..add(StartTimerEvent()),
child: VerificationCodePage( child: VerificationCodePage(
title: 'Delete Account', title: '',
isDeleteAccountMode: true, 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/login_with_email_model.dart';
import 'package:syncrow_app/features/auth/model/signup_model.dart'; import 'package:syncrow_app/features/auth/model/signup_model.dart';
import 'package:syncrow_app/features/auth/model/token.dart'; import 'package:syncrow_app/features/auth/model/token.dart';
@ -85,9 +86,16 @@ class AuthenticationAPI {
} }
static Future<void> deleteAccount() async { static Future<void> deleteAccount() async {
await HTTPService().delete( try {
path: ApiEndpoints.deleteProfile, await HTTPService().delete(
expectedResponseModel: (p0) {}, 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);
}
} }
} }