Line data Source code
1 : // Copyright 2024 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/storage/app_data.dart';
6 : import 'package:app_finance/_classes/structure/bill_app_data.dart';
7 : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
8 : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
9 : import 'package:app_finance/_classes/structure/payment_app_data.dart';
10 : import 'package:app_finance/_ext/data_ext.dart';
11 : import 'package:app_finance/_ext/date_time_ext.dart';
12 : import 'package:app_finance/design/generic/base_line_widget.dart';
13 : import 'package:material_ui/material_ui.dart';
14 :
15 : class PaymentListWidget extends StatelessWidget {
16 : final PaymentAppData item;
17 : final AppData state;
18 : final double? width;
19 : final BoxConstraints? constraints;
20 :
21 0 : const PaymentListWidget({
22 : super.key,
23 : required this.item,
24 : required this.state,
25 : this.width,
26 : this.constraints,
27 : });
28 :
29 0 : @override
30 : Widget build(BuildContext context) {
31 0 : final uuid = item.uuid ?? '';
32 0 : dynamic obj = item.data.toDataObject(state);
33 0 : String type = AppLocale.labels.flowTypeInvoice;
34 : String symbol = '+';
35 0 : if (obj is BillAppData) {
36 0 : type = AppLocale.labels.bill;
37 : symbol = '-';
38 0 : } else if (obj is InvoiceAppData && obj.accountFrom != null) {
39 0 : type = AppLocale.labels.transferHeadline;
40 : symbol = '';
41 : }
42 0 : return BaseLineWidget(
43 : uuid: uuid,
44 0 : title: '$type: ${obj.title}',
45 0 : description: '${item.description}, ${item.updatedAt.monthDay()}',
46 0 : details: '$symbol${obj.detailsFormatted}',
47 : progress: 1.0,
48 0 : color: obj.color ?? Colors.transparent,
49 0 : icon: obj.icon ?? Icons.radio_button_unchecked_sharp,
50 0 : hidden: obj.hidden,
51 0 : skip: obj.skip,
52 0 : width: width ?? constraints!.maxWidth,
53 : route: AppRoute.automationPaymentViewRoute,
54 : );
55 : }
56 : }
|