add loading indicator and state for deleting acount

This commit is contained in:
Rafeek-Khoudare
2025-07-15 09:02:42 +03:00
parent 24c7bcef55
commit 228aee97e6
2 changed files with 32 additions and 20 deletions

View File

@ -198,6 +198,7 @@ class SecurityBloc extends Bloc<SecurityEvent, SecurityState> {
Future<void> onDeleteAccountEvent(
DeleteAccountEvent event, Emitter<SecurityState> emit) async {
emit(LoadingForgetState());
try {
await AuthenticationAPI.deleteAccount();
emit(ChangedPassState());

View File

@ -37,9 +37,18 @@ class DeleteAccountPage extends StatelessWidget {
SizedBox(
height: 10,
),
ElevatedButton(
BlocBuilder<SecurityBloc, SecurityState>(
builder: (context, state) {
if (state is LoadingForgetState) {
return Center(
child: CircularProgressIndicator(),
);
}
return ElevatedButton(
onPressed: () {
context.read<SecurityBloc>().add(DeleteAccountEvent());
context
.read<SecurityBloc>()
.add(DeleteAccountEvent());
},
style: ElevatedButton.styleFrom(
backgroundColor: ColorsManager.blueColor,
@ -58,6 +67,8 @@ class DeleteAccountPage extends StatelessWidget {
fontWeight: FontWeight.w700,
color: ColorsManager.onPrimaryColor),
),
);
},
)
],
),