Wallet update for correct name and symbol appearance
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
import 'package:pweb/models/wallet.dart';
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
|
||||
@@ -48,9 +49,21 @@ class WalletCard extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
Text(
|
||||
wallet.name,
|
||||
style: theme.textTheme.bodyLarge!.copyWith(fontWeight: FontWeight.w500),
|
||||
AppLocalizations.of(context)!.paymentTypeCryptoWallet,
|
||||
style: theme.textTheme.bodyLarge!.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (wallet.tokenSymbol != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
wallet.tokenSymbol!,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -60,4 +73,4 @@ class WalletCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,114 +3,46 @@ 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 {
|
||||
class WalletEditHeader extends StatelessWidget {
|
||||
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();
|
||||
return const 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;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'Crypto Wallet',
|
||||
style: theme.textTheme.headlineMedium!.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (wallet.tokenSymbol != null)
|
||||
Text(
|
||||
wallet.tokenSymbol!,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user