👽 Update the API request path due to the sepration of the wallet service

This commit is contained in:
2026-02-05 00:14:18 +08:00
parent 0237e457fc
commit 4b1c9b5820
7 changed files with 297 additions and 325 deletions

View File

@@ -30,7 +30,7 @@ part 'wallet.g.dart';
Future<SnWallet?> walletCurrent(Ref ref) async {
try {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get('/pass/wallets');
final resp = await apiClient.get('/wallet/wallets');
return SnWallet.fromJson(resp.data);
} catch (err) {
if (err is DioException && err.response?.statusCode == 404) {
@@ -43,7 +43,7 @@ Future<SnWallet?> walletCurrent(Ref ref) async {
@riverpod
Future<SnWalletStats> walletStats(Ref ref) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/pass/wallets/stats');
final resp = await client.get('/wallet/wallets/stats');
return SnWalletStats.fromJson(resp.data);
}
@@ -976,7 +976,7 @@ class TransactionListNotifier
final queryParams = {'offset': offset, 'take': pageSize};
final response = await client.get(
'/pass/wallets/transactions',
'/wallet/wallets/transactions',
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
@@ -1003,7 +1003,7 @@ class WalletFundsNotifier extends AsyncNotifier<PaginationState<SnWalletFund>>
final offset = fetchedCount;
final response = await client.get(
'/pass/wallets/funds?offset=$offset&take=$pageSize',
'/wallet/wallets/funds?offset=$offset&take=$pageSize',
);
// Assuming total count header is present or we just check if list is empty
final list = (response.data as List)
@@ -1031,7 +1031,7 @@ class WalletFundRecipientsNotifier
final offset = fetchedCount;
final response = await client.get(
'/pass/wallets/funds/recipients?offset=$offset&take=$_pageSize',
'/wallet/wallets/funds/recipients?offset=$offset&take=$_pageSize',
);
final list = (response.data as List)
.map((e) => SnWalletFundRecipient.fromJson(e))
@@ -1047,7 +1047,7 @@ class WalletFundRecipientsNotifier
@riverpod
Future<SnWalletFund> walletFund(Ref ref, String fundId) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/pass/wallets/funds/$fundId');
final resp = await client.get('/wallet/wallets/funds/$fundId');
return SnWalletFund.fromJson(resp.data);
}
@@ -1239,7 +1239,7 @@ class WalletScreen extends HookConsumerWidget {
Future<void> createWallet() async {
final client = ref.read(apiClientProvider);
try {
await client.post('/pass/wallets');
await client.post('/wallet/wallets');
ref.invalidate(walletCurrentProvider);
} catch (err) {
showErrorAlert(err);
@@ -1715,7 +1715,7 @@ class WalletScreen extends HookConsumerWidget {
try {
showLoadingModal(context);
final resp = await client.post(
'/pass/wallets/funds',
'/wallet/wallets/funds',
data: fundData,
options: Options(headers: {'X-Noop': true}),
);
@@ -1723,7 +1723,7 @@ class WalletScreen extends HookConsumerWidget {
if (fund.status == 0) return; // Already created
final orderResp = await client.post(
'/pass/wallets/funds/${fund.id}/order',
'/wallet/wallets/funds/${fund.id}/order',
);
final order = SnWalletOrder.fromJson(orderResp.data);
@@ -1763,7 +1763,7 @@ class WalletScreen extends HookConsumerWidget {
final client = ref.read(apiClientProvider);
try {
showLoadingModal(context);
await client.post('/pass/wallets/transfer', data: transferData);
await client.post('/wallet/wallets/transfer', data: transferData);
if (context.mounted) hideLoadingModal(context);

View File

@@ -31,7 +31,7 @@ class RestorePurchaseSheet extends HookConsumerWidget {
try {
final client = ref.read(apiClientProvider);
await client.post(
'/pass/subscriptions/order/restore/${selectedProvider.value!}',
'/wallet/subscriptions/order/restore/${selectedProvider.value!}',
data: {'order_id': orderIdController.text.trim()},
);
@@ -79,23 +79,22 @@ class RestorePurchaseSheet extends HookConsumerWidget {
hint: Text('selectProvider'.tr()),
isExpanded: true,
padding: const EdgeInsets.symmetric(horizontal: 12),
items:
providers.map((provider) {
return DropdownMenuItem<String>(
value: provider,
child: Row(
children: [
getProviderIcon(
provider,
size: 20,
color: Theme.of(context).colorScheme.onSurface,
),
const Gap(12),
Text(getLocalizedProviderName(provider)),
],
items: providers.map((provider) {
return DropdownMenuItem<String>(
value: provider,
child: Row(
children: [
getProviderIcon(
provider,
size: 20,
color: Theme.of(context).colorScheme.onSurface,
),
);
}).toList(),
const Gap(12),
Text(getLocalizedProviderName(provider)),
],
),
);
}).toList(),
onChanged: (value) {
selectedProvider.value = value;
},
@@ -122,14 +121,13 @@ class RestorePurchaseSheet extends HookConsumerWidget {
// Restore Button
FilledButton(
onPressed: isLoading.value ? null : restorePurchase,
child:
isLoading.value
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text('restore'.tr()),
child: isLoading.value
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text('restore'.tr()),
),
const Gap(16),
],

View File

@@ -30,7 +30,7 @@ part 'stellar_program_tab.g.dart';
Future<SnWalletSubscription?> accountStellarSubscription(Ref ref) async {
try {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/pass/subscriptions/fuzzy/solian.stellar');
final resp = await client.get('/wallet/subscriptions/fuzzy/solian.stellar');
return SnWalletSubscription.fromJson(resp.data);
} catch (err) {
if (err is DioException && err.response?.statusCode == 404) return null;
@@ -46,7 +46,7 @@ Future<List<SnWalletGift>> accountSentGifts(
}) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get(
'/pass/subscriptions/gifts/sent?offset=$offset&take=$take',
'/wallet/subscriptions/gifts/sent?offset=$offset&take=$take',
);
return (resp.data as List).map((e) => SnWalletGift.fromJson(e)).toList();
}
@@ -59,7 +59,7 @@ Future<List<SnWalletGift>> accountReceivedGifts(
}) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get(
'/pass/subscriptions/gifts/received?offset=$offset&take=$take',
'/wallet/subscriptions/gifts/received?offset=$offset&take=$take',
);
return (resp.data as List).map((e) => SnWalletGift.fromJson(e)).toList();
}
@@ -67,7 +67,7 @@ Future<List<SnWalletGift>> accountReceivedGifts(
@riverpod
Future<SnWalletGift> accountGift(Ref ref, String giftId) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/pass/subscriptions/gifts/$giftId');
final resp = await client.get('/wallet/subscriptions/gifts/$giftId');
return SnWalletGift.fromJson(resp.data);
}
@@ -379,7 +379,7 @@ class StellarProgramTab extends HookConsumerWidget {
showLoadingModal(context);
final client = ref.watch(apiClientProvider);
await client.post(
'/pass/subscriptions/${membership.identifier}/cancel',
'/wallet/subscriptions/${membership.identifier}/cancel',
);
ref.invalidate(accountStellarSubscriptionProvider);
ref.read(userInfoProvider.notifier).fetchUser();
@@ -680,7 +680,7 @@ class StellarProgramTab extends HookConsumerWidget {
try {
showLoadingModal(context);
final resp = await client.post(
'/pass/subscriptions',
'/wallet/subscriptions',
data: {
'identifier': tierId,
'payment_method': 'solian.wallet',
@@ -692,7 +692,7 @@ class StellarProgramTab extends HookConsumerWidget {
final subscription = SnWalletSubscription.fromJson(resp.data);
if (subscription.status == 1) return;
final orderResp = await client.post(
'/pass/subscriptions/${subscription.identifier}/order',
'/wallet/subscriptions/${subscription.identifier}/order',
);
final order = SnWalletOrder.fromJson(orderResp.data);
@@ -1188,7 +1188,7 @@ class StellarProgramTab extends HookConsumerWidget {
try {
showLoadingModal(context);
final resp = await client.post(
'/pass/subscriptions/gifts/purchase',
'/wallet/subscriptions/gifts/purchase',
data: {
'subscription_identifier': subscriptionId,
'recipient_id': ?recipientId,
@@ -1204,7 +1204,7 @@ class StellarProgramTab extends HookConsumerWidget {
if (gift.status == 1) return; // Already paid
final orderResp = await client.post(
'/pass/subscriptions/gifts/${gift.id}/order',
'/wallet/subscriptions/gifts/${gift.id}/order',
);
final order = SnWalletOrder.fromJson(orderResp.data);
@@ -1226,7 +1226,7 @@ class StellarProgramTab extends HookConsumerWidget {
// Get the updated gift
final giftResp = await client.get(
'/pass/subscriptions/gifts/${gift.id}',
'/wallet/subscriptions/gifts/${gift.id}',
);
final updatedGift = SnWalletGift.fromJson(giftResp.data);
@@ -1328,7 +1328,7 @@ class StellarProgramTab extends HookConsumerWidget {
// First check if gift can be redeemed
final checkResp = await client.get(
'/pass/subscriptions/gifts/check/$giftCode',
'/wallet/subscriptions/gifts/check/$giftCode',
);
final checkData = checkResp.data as Map<String, dynamic>;
@@ -1340,7 +1340,7 @@ class StellarProgramTab extends HookConsumerWidget {
// Redeem the gift
await client.post(
'/pass/subscriptions/gifts/redeem',
'/wallet/subscriptions/gifts/redeem',
data: {'gift_code': giftCode},
);
@@ -1384,7 +1384,7 @@ class StellarProgramTab extends HookConsumerWidget {
final client = ref.watch(apiClientProvider);
try {
showLoadingModal(context);
await client.post('/pass/subscriptions/gifts/${gift.id}/cancel');
await client.post('/wallet/subscriptions/gifts/${gift.id}/cancel');
ref.invalidate(accountSentGiftsProvider);
if (context.mounted) {
hideLoadingModal(context);

View File

@@ -66,21 +66,20 @@ class PaymentOverlay extends HookConsumerWidget {
isScrollControlled: true,
backgroundColor: Colors.transparent,
useSafeArea: true,
builder:
(context) => PaymentOverlay(
order: order,
enableBiometric: enableBiometric,
onPaymentSuccess: (completedOrder) {
Navigator.of(context).pop(completedOrder);
},
onPaymentError: (err) {
Navigator.of(context).pop();
showErrorAlert(err);
},
onCancel: () {
Navigator.of(context).pop();
},
),
builder: (context) => PaymentOverlay(
order: order,
enableBiometric: enableBiometric,
onPaymentSuccess: (completedOrder) {
Navigator.of(context).pop(completedOrder);
},
onPaymentError: (err) {
Navigator.of(context).pop();
showErrorAlert(err);
},
onCancel: () {
Navigator.of(context).pop();
},
),
);
}
}
@@ -241,7 +240,7 @@ class _PaymentContentState extends ConsumerState<_PaymentContent> {
try {
final client = ref.read(apiClientProvider);
final response = await client.post(
'/pass/orders/${widget.order.id}/pay',
'/wallet/orders/${widget.order.id}/pay',
data: {'pin_code': pin},
);
@@ -415,46 +414,42 @@ class _PaymentContentState extends ConsumerState<_PaymentContent> {
Widget _buildBiometricAuth() {
return SingleChildScrollView(
child:
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Symbols.fingerprint, size: 48),
const Gap(16),
Text(
'useBiometricToConfirm'.tr(),
style: Theme.of(
context,
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
Text(
'The biometric data will only be processed on your device',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 11,
),
textAlign: TextAlign.center,
).opacity(0.75),
const Gap(28),
ElevatedButton.icon(
onPressed: _authenticateWithBiometric,
icon: const Icon(Symbols.fingerprint),
label: Text('authenticateNow'.tr()),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
),
),
),
TextButton(
onPressed: () => _fallbackToPinMode(null),
child: Text('usePinInstead'.tr()),
),
],
).center(),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Symbols.fingerprint, size: 48),
const Gap(16),
Text(
'useBiometricToConfirm'.tr(),
style: Theme.of(
context,
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
Text(
'The biometric data will only be processed on your device',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 11,
),
textAlign: TextAlign.center,
).opacity(0.75),
const Gap(28),
ElevatedButton.icon(
onPressed: _authenticateWithBiometric,
icon: const Icon(Symbols.fingerprint),
label: Text('authenticateNow'.tr()),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
),
),
TextButton(
onPressed: () => _fallbackToPinMode(null),
child: Text('usePinInstead'.tr()),
),
],
).center(),
);
}

View File

@@ -232,7 +232,7 @@ class ComposeFundSheet extends HookConsumerWidget {
showLoadingModal(context);
final resp = await client.post(
'/pass/wallets/funds',
'/wallet/wallets/funds',
data: result,
options: Options(
headers: {'X-Noop': true},
@@ -253,7 +253,7 @@ class ComposeFundSheet extends HookConsumerWidget {
}
final orderResp = await client.post(
'/pass/wallets/funds/${fund.id}/order',
'/wallet/wallets/funds/${fund.id}/order',
);
final order = SnWalletOrder.fromJson(
orderResp.data,
@@ -284,7 +284,7 @@ class ComposeFundSheet extends HookConsumerWidget {
// Return the created fund
final updatedResp = await client.get(
'/pass/wallets/funds/${fund.id}',
'/wallet/wallets/funds/${fund.id}',
);
final updatedFund =
SnWalletFund.fromJson(

View File

@@ -311,7 +311,7 @@ class PostAwardSheet extends HookConsumerWidget {
final orderId = awardResponse.data['order_id'] as String;
// Fetch order details
final orderResponse = await client.get('/pass/orders/$orderId');
final orderResponse = await client.get('/wallet/orders/$orderId');
final order = SnWalletOrder.fromJson(orderResponse.data);
if (context.mounted) {

View File

@@ -12,7 +12,7 @@ part 'fund_envelope.g.dart';
@riverpod
Future<SnWalletFund> walletFund(Ref ref, String fundId) async {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get('/pass/wallets/funds/$fundId');
final resp = await apiClient.get('/wallet/wallets/funds/$fundId');
return SnWalletFund.fromJson(resp.data);
}
@@ -36,202 +36,181 @@ class FundEnvelopeWidget extends HookConsumerWidget {
width: maxWidth,
margin: margin ?? const EdgeInsets.symmetric(vertical: 8),
child: fundAsync.when(
loading:
() => Card(
margin: EdgeInsets.zero,
child: const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
),
),
error:
(error, stack) => Card(
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
Icon(
Icons.error_outline,
color: Theme.of(context).colorScheme.error,
),
const SizedBox(height: 8),
Text(
'fundEnvelopeLoadFailed'.tr(),
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
loading: () => Card(
margin: EdgeInsets.zero,
child: const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
),
),
error: (error, stack) => Card(
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
Icon(
Icons.error_outline,
color: Theme.of(context).colorScheme.error,
),
),
const SizedBox(height: 8),
Text(
'fundEnvelopeLoadFailed'.tr(),
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
),
data:
(fund) => Card(
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => _showClaimDialog(context, ref, fund),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
),
),
data: (fund) => Card(
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => _showClaimDialog(context, ref, fund),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Fund title and status
Row(
children: [
// Fund title and status
Row(
children: [
Icon(
Icons.account_balance_wallet,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'fundEnvelope'.tr(),
style: Theme.of(context).textTheme.titleMedium
?.copyWith(fontWeight: FontWeight.w600),
),
),
_buildStatusChips(context, fund),
],
Icon(
Icons.account_balance_wallet,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 12),
const SizedBox(width: 8),
Expanded(
child: Text(
'fundEnvelope'.tr(),
style: Theme.of(context).textTheme.titleMedium
?.copyWith(fontWeight: FontWeight.w600),
),
),
_buildStatusChips(context, fund),
],
),
const SizedBox(height: 12),
// Amount information
Row(
// Amount information
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${fund.totalAmount.toStringAsFixed(2)} ${fund.currency}',
style: Theme.of(
context,
).textTheme.headlineSmall?.copyWith(
Text(
'${fund.totalAmount.toStringAsFixed(2)} ${fund.currency}',
style: Theme.of(context).textTheme.headlineSmall
?.copyWith(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 4),
if (fund.remainingAmount != fund.totalAmount)
Text(
'fundEnvelopeRemaining'.tr(
args: [
fund.remainingAmount.toStringAsFixed(2),
fund.currency,
],
),
const SizedBox(height: 4),
if (fund.remainingAmount != fund.totalAmount)
Text(
'fundEnvelopeRemaining'.tr(
args: [
fund.remainingAmount.toStringAsFixed(2),
fund.currency,
],
),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(context).colorScheme.secondary,
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.secondary,
fontWeight: FontWeight.w500,
),
),
Text(
'fundEnvelopeSplit'.tr(
args: [
fund.splitType == 0
? 'fundEnvelopeSplitEvenly'.tr()
: 'fundEnvelopeSplitRandomly'.tr(),
],
),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
),
Text(
'fundEnvelopeSplit'.tr(
args: [
fund.splitType == 0
? 'fundEnvelopeSplitEvenly'.tr()
: 'fundEnvelopeSplitRandomly'.tr(),
],
),
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(context)
.textTheme
.bodySmall
?.color
?.withOpacity(0.7),
),
),
],
),
],
),
// Recipients overview
if (fund.recipients.isNotEmpty) ...[
const SizedBox(height: 12),
_buildRecipientsOverview(context, fund),
],
// Message
if (fund.message != null && fund.message!.isNotEmpty) ...[
const SizedBox(height: 12),
Text(
'"${fund.message}"',
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
fontStyle: FontStyle.italic,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
// Creator info
if (fund.creatorAccount != null) ...[
const SizedBox(height: 12),
Row(
children: [
Icon(
Icons.person,
size: 16,
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
fund.creatorAccount!.nick,
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
],
),
],
// Expiry info
const SizedBox(height: 6),
Row(
children: [
Icon(
Icons.schedule,
size: 16,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
_formatDate(fund.expiredAt),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
],
),
],
),
),
// Recipients overview
if (fund.recipients.isNotEmpty) ...[
const SizedBox(height: 12),
_buildRecipientsOverview(context, fund),
],
// Message
if (fund.message != null && fund.message!.isNotEmpty) ...[
const SizedBox(height: 12),
Text(
'"${fund.message}"',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontStyle: FontStyle.italic,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
// Creator info
if (fund.creatorAccount != null) ...[
const SizedBox(height: 12),
Row(
children: [
Icon(
Icons.person,
size: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
fund.creatorAccount!.nick,
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
],
),
],
// Expiry info
const SizedBox(height: 6),
Row(
children: [
Icon(
Icons.schedule,
size: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
_formatDate(fund.expiredAt),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
],
),
),
),
),
),
);
}
@@ -243,26 +222,25 @@ class FundEnvelopeWidget extends HookConsumerWidget {
) {
showDialog(
context: context,
builder:
(dialogContext) => FundClaimDialog(
fund: fund,
onClaim: () async {
try {
final apiClient = ref.read(apiClientProvider);
await apiClient.post('/pass/wallets/funds/${fund.id}/receive');
builder: (dialogContext) => FundClaimDialog(
fund: fund,
onClaim: () async {
try {
final apiClient = ref.read(apiClientProvider);
await apiClient.post('/wallet/wallets/funds/${fund.id}/receive');
// Refresh the fund data after claiming
ref.invalidate(walletFundProvider(fund.id));
// Refresh the fund data after claiming
ref.invalidate(walletFundProvider(fund.id));
if (dialogContext.mounted) {
Navigator.of(dialogContext).pop();
showSnackBar('fundEnvelopeClaimSuccess'.tr());
}
} catch (e) {
showErrorAlert(e);
}
},
),
if (dialogContext.mounted) {
Navigator.of(dialogContext).pop();
showSnackBar('fundEnvelopeClaimSuccess'.tr());
}
} catch (e) {
showErrorAlert(e);
}
},
),
);
}
@@ -343,8 +321,9 @@ class FundEnvelopeWidget extends HookConsumerWidget {
Widget _buildRecipientsOverview(BuildContext context, SnWalletFund fund) {
final claimedCount = fund.recipients.where((r) => r.isReceived).length;
final totalCount =
fund.isOpen ? fund.amountOfSplits : fund.recipients.length;
final totalCount = fund.isOpen
? fund.amountOfSplits
: fund.recipients.length;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -362,8 +341,9 @@ class FundEnvelopeWidget extends HookConsumerWidget {
const SizedBox(height: 4),
LinearProgressIndicator(
value: totalCount > 0 ? claimedCount / totalCount : 0,
backgroundColor:
Theme.of(context).colorScheme.surfaceContainerHighest,
backgroundColor: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
),
],
);
@@ -436,15 +416,16 @@ class FundClaimDialog extends HookConsumerWidget {
!isExpired && hasRemainingAmount && !hasUserClaimed && userAbleToClaim;
// Get claimed recipients for display
final claimedRecipients =
fund.recipients.where((r) => r.isReceived).toList();
final unclaimedRecipients =
fund.recipients.where((r) => !r.isReceived).toList();
final claimedRecipients = fund.recipients
.where((r) => r.isReceived)
.toList();
final unclaimedRecipients = fund.recipients
.where((r) => !r.isReceived)
.toList();
final remainingSplits =
fund.isOpen
? fund.amountOfSplits - claimedRecipients.length
: unclaimedRecipients.length;
final remainingSplits = fund.isOpen
? fund.amountOfSplits - claimedRecipients.length
: unclaimedRecipients.length;
return AlertDialog(
title: Row(
@@ -491,16 +472,14 @@ class FundClaimDialog extends HookConsumerWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color:
fund.isOpen
? Colors.green.withOpacity(0.1)
: Colors.blue.withOpacity(0.1),
color: fund.isOpen
? Colors.green.withOpacity(0.1)
: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color:
fund.isOpen
? Colors.green.withOpacity(0.3)
: Colors.blue.withOpacity(0.3),
color: fund.isOpen
? Colors.green.withOpacity(0.3)
: Colors.blue.withOpacity(0.3),
),
),
child: Text(
@@ -535,13 +514,13 @@ class FundClaimDialog extends HookConsumerWidget {
child: Text(
recipient.recipientAccount?.nick ??
'fundEnvelopeUnknownUser'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
decoration: TextDecoration.lineThrough,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
),
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
decoration: TextDecoration.lineThrough,
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
),
Text(