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 : }); 23 : 24 0 : @override 25 0 : IncomeEditTabState createState() => IncomeEditTabState(); 26 : } 27 : 28 : class IncomeEditTabState extends IncomeTabState<IncomeEditTab> { 29 0 : @override 30 : void updateStorage() { 31 0 : String uuid = account ?? ''; 32 0 : exchange.save(); 33 0 : widget.state.update( 34 0 : (widget as IncomeEditTab).uuid, 35 0 : InvoiceAppData( 36 0 : uuid: (widget as IncomeEditTab).uuid, 37 0 : title: description.text, 38 0 : color: widget.state.getByUuid(uuid)?.color, 39 : account: uuid, 40 0 : details: double.tryParse(amount.text)?.toFixed(currency?.decimalDigits) ?? 0.0, 41 0 : currency: currency, 42 0 : createdAt: createdAt, 43 : )); 44 : } 45 : 46 0 : @override 47 0 : String getTitle() => AppLocale.labels.editInvoiceTooltip; 48 : 49 0 : @override 50 0 : String getButtonName() => AppLocale.labels.editInvoiceTooltip; 51 : }