80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:sxchnge_wallet/sxchnge_wallet.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
class BankPasteDialog extends StatefulWidget {
|
|
const BankPasteDialog({super.key});
|
|
@override
|
|
State<BankPasteDialog> createState() => _BankPasteDialogState();
|
|
}
|
|
|
|
class _BankPasteDialogState extends State<BankPasteDialog> {
|
|
final text = TextEditingController();
|
|
BankPaste? result;
|
|
@override
|
|
void dispose() {
|
|
text.clear();
|
|
text.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l = AppLocalizations.of(context)!;
|
|
final labels = {
|
|
'firstName': l.dFirst,
|
|
'lastName': l.dLast,
|
|
'patronymic': l.dPatronymic,
|
|
'account': l.dAccount,
|
|
'bik': 'BIK',
|
|
'bank': l.dBankSearch,
|
|
'holder': l.dHolder,
|
|
'correspondent': l.dCorrespondent,
|
|
};
|
|
return AlertDialog(
|
|
title: Text(l.dPaste),
|
|
content: SizedBox(
|
|
width: 480,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(l.dPasteHelp),
|
|
const SizedBox(height: 12),
|
|
TextField(
|
|
controller: text,
|
|
maxLines: 6,
|
|
decoration: InputDecoration(labelText: l.dBankDetails),
|
|
onChanged: (_) => setState(() => result = null),
|
|
),
|
|
if (result != null) ...[
|
|
const SizedBox(height: 12),
|
|
if (result!.conflicts.isNotEmpty) Text(l.dPasteConflict),
|
|
for (final e in result!.values.entries)
|
|
Text('${labels[e.key]}: ${e.value}'),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(l.wClose),
|
|
),
|
|
FilledButton(
|
|
onPressed: result == null
|
|
? () => setState(() => result = BankPaste.parse(text.text))
|
|
: result!.values.isEmpty
|
|
? null
|
|
: () => Navigator.pop(context, result),
|
|
child: Text(result == null ? l.dPasteReview : l.dPasteApply),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|