Files
sendico/frontend/pweb/lib/pages/payout_page/wallet/edit/header.dart
Stephan D c4d34c5663
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
added wallet management localizations
2025-11-26 23:25:31 +01:00

119 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pweb/providers/wallets.dart';
import 'package:pweb/widgets/error/snackbar.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
class WalletEditHeader extends StatefulWidget {
const WalletEditHeader({super.key});
@override
State<WalletEditHeader> createState() => _WalletEditHeaderState();
}
class _WalletEditHeaderState extends State<WalletEditHeader> {
bool _isEditing = false;
late TextEditingController _controller;
@override
void initState() {
super.initState();
_controller = TextEditingController();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final provider = context.watch<WalletsProvider>();
final wallet = provider.selectedWallet;
final loc = AppLocalizations.of(context)!;
if (wallet == null) {
return SizedBox.shrink();
}
final theme = Theme.of(context);
if (!_isEditing) {
_controller.text = wallet.name;
}
return Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: !_isEditing
? Row(
children: [
Expanded(
child: Text(
wallet.name,
style: theme.textTheme.headlineMedium!.copyWith(
fontWeight: FontWeight.bold,
),
),
),
IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
setState(() {
_isEditing = true;
});
},
),
],
)
: Row(
children: [
Expanded(
child: TextFormField(
controller: _controller,
decoration: InputDecoration(
border: OutlineInputBorder(),
isDense: true,
hintText: loc.walletName,
),
),
),
IconButton(
icon: const Icon(Icons.check),
color: theme.colorScheme.primary,
onPressed: () async {
await executeActionWithNotification(
context: context,
action: () async => await provider.updateWallet(wallet.copyWith(name: _controller.text)),
errorMessage: loc.walletNameUpdateFailed,
successMessage: loc.walletNameSaved,
);
setState(() {
_isEditing = false;
});
},
),
IconButton(
icon: const Icon(Icons.close),
onPressed: () {
_controller.text = wallet.name;
setState(() {
_isEditing = false;
});
},
),
],
),
),
],
);
}
}