WIP: integration with ledger

This commit is contained in:
Arseni
2026-02-04 02:01:22 +03:00
parent f1f16a30e6
commit f44ef56ff3
32 changed files with 1226 additions and 405 deletions

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pshared/controllers/balance_mask/ledger_accounts.dart';
import 'package:pshared/models/ledger/account.dart';
import 'package:pweb/pages/payout_page/wallet/ledger/format.dart';
import 'package:pweb/widgets/refresh_balance/ledger.dart';
class LedgerEditBalanceRow extends StatelessWidget {
final LedgerAccount account;
const LedgerEditBalanceRow({super.key, required this.account});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Consumer<LedgerBalanceMaskController>(
builder: (context, controller, _) {
final isMasked = controller.isBalanceMasked(account.ledgerAccountRef);
final money = account.balance?.balance;
final displayBalance = money == null
? '--'
: isMasked
? formatMaskedLedgerBalance(money.currency)
: formatLedgerBalance(
amount: money.amount,
currency: money.currency,
);
return Row(
children: [
Expanded(
child: Row(
children: [
Text(
displayBalance,
style: theme.textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 12),
GestureDetector(
onTap: () =>
controller.toggleBalanceMask(account.ledgerAccountRef),
child: Icon(
isMasked ? Icons.visibility_off : Icons.visibility,
size: 24,
),
),
],
),
),
LedgerBalanceRefreshButton(
ledgerAccountRef: account.ledgerAccountRef,
),
],
);
},
);
}
}

View File

@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class LedgerEditCopyableRow extends StatelessWidget {
final String title;
final String value;
const LedgerEditCopyableRow({
super.key,
required this.title,
required this.value,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: theme.textTheme.bodySmall),
const SizedBox(height: 2),
Text(value, style: theme.textTheme.bodyLarge),
],
),
),
IconButton(
icon: const Icon(Icons.copy),
iconSize: 18,
onPressed: () => Clipboard.setData(ClipboardData(text: value)),
),
],
);
}
}

View File

@@ -0,0 +1,83 @@
import 'package:flutter/material.dart';
import 'package:pshared/models/ledger/account.dart';
import 'package:pweb/pages/payout_page/wallet/edit/buttons/buttons.dart';
import 'package:pweb/pages/payout_page/wallet/edit/ledger/balance_row.dart';
import 'package:pweb/pages/payout_page/wallet/edit/ledger/copyable_row.dart';
import 'package:pweb/utils/dimensions.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
class LedgerEditView extends StatelessWidget {
final LedgerAccount account;
final VoidCallback onBack;
const LedgerEditView({
super.key,
required this.account,
required this.onBack,
});
@override
Widget build(BuildContext context) {
final dimensions = AppDimensions();
final loc = AppLocalizations.of(context)!;
final theme = Theme.of(context);
return Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: dimensions.maxContentWidth),
child: Material(
elevation: dimensions.elevationSmall,
color: theme.colorScheme.onSecondary,
borderRadius: BorderRadius.circular(dimensions.borderRadiusMedium),
child: Padding(
padding: EdgeInsets.all(dimensions.paddingLarge),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: onBack,
),
Text(
loc.paymentTypeLedger,
style: theme.textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
if (account.currency.trim().isNotEmpty)
Text(
account.currency,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 24),
LedgerEditBalanceRow(account: account),
const SizedBox(height: 12),
LedgerEditCopyableRow(
title: loc.ledgerAccountRef,
value: account.ledgerAccountRef,
),
const SizedBox(height: 8),
LedgerEditCopyableRow(
title: 'Account code',
value: account.accountCode,
),
const SizedBox(height: 24),
const ButtonsWalletWidget(),
],
),
),
),
),
),
);
}
}