Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_classes/herald/app_locale.dart';
5 : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
6 : import 'package:app_finance/_ext/double_ext.dart';
7 : import 'package:app_finance/pages/bill/widgets/transfer_tab.dart';
8 :
9 : class TransferEditTab extends TransferTab {
10 : final String uuid;
11 :
12 0 : const TransferEditTab({
13 : super.key,
14 : required this.uuid,
15 : required super.state,
16 : required super.callback,
17 : super.accountFrom,
18 : super.accountTo,
19 : super.amount,
20 : super.description,
21 : super.currency,
22 : super.createdAt,
23 : super.tags,
24 : });
25 :
26 0 : @override
27 0 : TransferEditTabState createState() => TransferEditTabState();
28 : }
29 :
30 : class TransferEditTabState extends TransferTabState<TransferEditTab> {
31 0 : @override
32 : void updateStorage() {
33 0 : exchange.save();
34 0 : widget.state.update(
35 : // ignore: unnecessary_cast
36 0 : (widget as TransferEditTab).uuid,
37 0 : InvoiceAppData(
38 : // ignore: unnecessary_cast
39 0 : uuid: (widget as TransferEditTab).uuid,
40 0 : title: description.text,
41 0 : color: widget.state.getByUuid(accountTo!)?.color,
42 0 : account: accountTo!,
43 0 : accountFrom: accountFrom,
44 0 : details: double.tryParse(amount.text)?.toFixed(currency?.decimalDigits) ?? 0.0,
45 0 : currency: currency,
46 0 : createdAt: createdAt,
47 0 : tags: tags.value,
48 : ));
49 : }
50 :
51 0 : @override
52 0 : String getTitle() => AppLocale.labels.editTransferTooltip;
53 :
54 0 : @override
55 0 : String getButtonName() => AppLocale.labels.editTransferTooltip;
56 : }
|