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/income_tab.dart';
8 :
9 : class IncomeEditTab extends IncomeTab {
10 : final String uuid;
11 :
12 0 : const IncomeEditTab({
13 : super.key,
14 : required this.uuid,
15 : required super.state,
16 : required super.callback,
17 : super.account,
18 : super.description,
19 : super.currency,
20 : super.amount,
21 : super.createdAt,
22 : super.tags,
23 : });
24 :
25 0 : @override
26 0 : IncomeEditTabState createState() => IncomeEditTabState();
27 : }
28 :
29 : class IncomeEditTabState extends IncomeTabState<IncomeEditTab> {
30 0 : @override
31 : void updateStorage() {
32 0 : String uuid = account ?? '';
33 0 : exchange.save();
34 0 : widget.state.update(
35 0 : (widget as IncomeEditTab).uuid,
36 0 : InvoiceAppData(
37 0 : uuid: (widget as IncomeEditTab).uuid,
38 0 : title: description.text,
39 0 : color: widget.state.getByUuid(uuid)?.color,
40 : account: uuid,
41 0 : details: double.tryParse(amount.text)?.toFixed(currency?.decimalDigits) ?? 0.0,
42 0 : currency: currency,
43 0 : createdAt: createdAt,
44 0 : tags: tags.value,
45 : ));
46 : }
47 :
48 0 : @override
49 0 : String getTitle() => AppLocale.labels.editInvoiceTooltip;
50 :
51 0 : @override
52 0 : String getButtonName() => AppLocale.labels.editInvoiceTooltip;
53 : }
|