73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:okane/database/collections/account.dart';
|
|
import 'package:okane/i18n/strings.g.dart';
|
|
import 'package:okane/ui/state/core.dart';
|
|
|
|
class DeleteAccountPopup extends StatelessWidget {
|
|
final Account account;
|
|
|
|
final VoidCallback onCancel;
|
|
final VoidCallback afterDelete;
|
|
|
|
const DeleteAccountPopup({
|
|
super.key,
|
|
required this.account,
|
|
required this.onCancel,
|
|
required this.afterDelete,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<CoreCubit, CoreState>(
|
|
builder:
|
|
(context, state) => AlertDialog(
|
|
title: Text(t.pages.accounts.deleteAccount.title),
|
|
content:
|
|
state.isDeletingAccount
|
|
? Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 80,
|
|
height: 80,
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
],
|
|
)
|
|
: Text(
|
|
t.pages.accounts.deleteAccount.content(
|
|
name: account.name!,
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed:
|
|
state.isDeletingAccount
|
|
? null
|
|
: () async {
|
|
await GetIt.I.get<CoreCubit>().deleteAccount(account);
|
|
afterDelete();
|
|
},
|
|
child: Text(
|
|
t.modals.delete,
|
|
style: TextStyle(color: Colors.red),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed:
|
|
state.isDeletingAccount
|
|
? null
|
|
: () {
|
|
onCancel();
|
|
},
|
|
child: Text(t.modals.cancel),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|