startTask method

  1. @override
Future<void> startTask(
  1. AppModel app,
  2. BuildContext context,
  3. String? memberId,
  4. AssignmentModel? assignmentModel,
)
override

Implementation

@override
Future<void> startTask(AppModel app, BuildContext context, String? memberId,
    AssignmentModel? assignmentModel) {
  var accessState = AccessBloc.getState(context);
  if (accessState is LoggedIn) {
    if (paymentType is CreditCardPayTypeModel) {
      var casted = paymentType as CreditCardPayTypeModel;
      if ((casted.requiresConfirmation != null) &&
          casted.requiresConfirmation!) {
        openAckNackDialog(app, context, '${app.documentID}/payment',
            title: 'Payment',
            message:
                'Proceed with payment of ${getAmount(context)} ${getCcy(context)!} for ${assignmentModel!.workflow!.name!}?',
            onSelection: (value) {
          if (value == 0) {
            _confirmedCreditCardPayment(
                app, context, assignmentModel, accessState);
          }
        });
      } else {
        _creditCardPayment(app, context, assignmentModel, accessState);
      }
    } else if (paymentType is ManualPayTypeModel) {
      var p = paymentType as ManualPayTypeModel;
      openWidgetDialog(app, context, '${app.documentID}/payment',
          child: ManualPaymentDialog(
              app: app,
              purpose: assignmentModel!.task!.description,
              amount: getAmount(context),
              ccy: getCcy(context),
              payTo: p.payTo,
              country: p.country,
              bankIdentifierCode: p.bankIdentifierCode,
              payeeIBAN: p.payeeIBAN,
              bankName: p.bankName,
              payedWithTheseDetails:
                  (paymentReference, String paymentName, bool success) =>
                      handleManualPayment(app, context, assignmentModel,
                          paymentReference, paymentName, success)));
    }
  }
  return Future.value(null);
}