import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:pshared/models/payment/methods/data.dart'; import 'package:pshared/models/payment/methods/type.dart'; import 'package:pshared/provider/recipient/pmethods.dart'; import 'package:pweb/pages/payment_methods/add/widget.dart'; import 'package:pweb/widgets/dialogs/confirmation_dialog.dart'; import 'package:pweb/generated/i18n/app_localizations.dart'; class PaymentConfigController { final BuildContext context; PaymentConfigController(this.context); Future addMethod() async => showDialog( context: context, builder: (_) => const AddPaymentMethodDialog(), ); Future editMethod(PaymentMethod method) async { // TODO: implement edit functionality } Future deleteMethod(PaymentMethod method) async { final methodsProvider = context.read(); final l10n = AppLocalizations.of(context)!; final confirmed = await showConfirmationDialog( context: context, title: l10n.delete, message: l10n.deletePaymentConfirmation, confirmLabel: l10n.delete, ); if (confirmed) { methodsProvider.delete(method.id); } } void toggleEnabled(PaymentMethod method, bool value) { context.read().setArchivedMethod(method: method, newIsArchived: value); } void makeMain(PaymentMethod method) { context.read().makeMain(method); } void reorder(int oldIndex, int newIndex) { // TODO: rimplement on top of Indexable // context.read().reorderMethods(oldIndex, newIndex); } }