fixes
This commit is contained in:
@@ -91,16 +91,22 @@ class BalanceSourceActionsController {
|
||||
}
|
||||
|
||||
void _openWalletOperationHistory(BuildContext context, String walletRef) {
|
||||
context.read<PaymentSourceController>().selectWalletByRef(walletRef);
|
||||
context.pushNamed(PayoutRoutes.editWallet);
|
||||
_withSelectedWallet(
|
||||
context,
|
||||
walletRef,
|
||||
() => context.pushNamed(PayoutRoutes.editWallet),
|
||||
);
|
||||
}
|
||||
|
||||
void _sendWalletPayout(BuildContext context, String walletRef) {
|
||||
context.read<PaymentSourceController>().selectWalletByRef(walletRef);
|
||||
context.pushNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: PaymentType.wallet,
|
||||
_withSelectedWallet(
|
||||
context,
|
||||
walletRef,
|
||||
() => context.pushNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: PaymentType.wallet,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -114,4 +120,13 @@ class BalanceSourceActionsController {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _withSelectedWallet(
|
||||
BuildContext context,
|
||||
String walletRef,
|
||||
VoidCallback action,
|
||||
) {
|
||||
context.read<PaymentSourceController>().selectWalletByRef(walletRef);
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class BalanceCopyState {
|
||||
final String label;
|
||||
@@ -13,23 +16,26 @@ class BalanceCopyState {
|
||||
class BalanceSourceCopyController {
|
||||
const BalanceSourceCopyController();
|
||||
|
||||
BalanceCopyState wallet(String? depositAddress) {
|
||||
return BalanceCopyState(
|
||||
label: 'Copy Deposit Address',
|
||||
payload: depositAddress?.trim() ?? '',
|
||||
);
|
||||
}
|
||||
BalanceCopyState wallet(BuildContext context, String? depositAddress) =>
|
||||
_buildCopyAddressState(context, depositAddress);
|
||||
|
||||
BalanceCopyState ledger(String? accountCode) {
|
||||
return BalanceCopyState(
|
||||
label: 'Copy Deposit Address',
|
||||
payload: accountCode?.trim() ?? '',
|
||||
);
|
||||
}
|
||||
BalanceCopyState ledger(BuildContext context, String? accountCode) =>
|
||||
_buildCopyAddressState(context, accountCode);
|
||||
|
||||
Future<bool> copy(BalanceCopyState state) async {
|
||||
if (!state.canCopy) return false;
|
||||
await Clipboard.setData(ClipboardData(text: state.payload));
|
||||
return true;
|
||||
}
|
||||
|
||||
BalanceCopyState _buildCopyAddressState(
|
||||
BuildContext context,
|
||||
String? payload,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return BalanceCopyState(
|
||||
label: l10n.copyAddress,
|
||||
payload: payload?.trim() ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
import 'package:pshared/models/payment/payment.dart';
|
||||
import 'package:pshared/models/payment/source_type.dart';
|
||||
@@ -131,16 +131,14 @@ class ReportOperationsController extends ChangeNotifier {
|
||||
bool _matchesCurrentSource(Payment payment) {
|
||||
final sourceType = _sourceType;
|
||||
if (sourceType == null || _sourceRefs.isEmpty) return true;
|
||||
for (final sourceRef in _sourceRefs) {
|
||||
if (paymentMatchesSource(
|
||||
payment,
|
||||
sourceType: sourceType,
|
||||
sourceRef: sourceRef,
|
||||
)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return _sourceRefs.firstWhereOrNull(
|
||||
(sourceRef) => paymentMatchesSource(
|
||||
payment,
|
||||
sourceType: sourceType,
|
||||
sourceRef: sourceRef,
|
||||
),
|
||||
) !=
|
||||
null;
|
||||
}
|
||||
|
||||
Set<String> _normalizeRefs(List<String> refs) {
|
||||
|
||||
Reference in New Issue
Block a user