Line data Source code
1 : // Copyright 2025 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/controller/iterator_controller.dart';
5 : import 'package:app_finance/_classes/herald/app_start_of_month.dart';
6 : import 'package:app_finance/_classes/storage/app_data.dart';
7 : import 'package:app_finance/_classes/herald/app_locale.dart';
8 : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
9 : import 'package:app_finance/_configs/screen_helper.dart';
10 : import 'package:app_finance/_configs/theme_helper.dart';
11 : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
12 : import 'package:app_finance/_ext/date_time_ext.dart';
13 : import 'package:app_finance/design/generic/base_line_widget.dart';
14 : import 'package:app_finance/pages/bill/bill_page.dart';
15 : import 'package:app_finance/design/generic/base_header_widget.dart';
16 : import 'package:app_finance/design/generic/base_swipe_widget.dart';
17 : import 'package:material_ui/material_ui.dart';
18 :
19 : class InvoicePage extends StatefulWidget {
20 0 : const InvoicePage({super.key});
21 :
22 0 : @override
23 0 : InvoicePageState createState() => InvoicePageState();
24 : }
25 :
26 : class InvoicePageState<T extends StatefulWidget> extends BillPageState<T> {
27 0 : @override
28 : Widget addHeaderWidget() {
29 0 : final width = ScreenHelper.state().width - ThemeHelper.getIndent(4);
30 0 : DateTime startingDay = DateTime.now().getStartingDay(AppStartOfMonth.get());
31 0 : return SliverToBoxAdapter(
32 0 : child: BaseHeaderWidget(
33 : route: AppRoute.homeRoute,
34 0 : tooltip: AppLocale.labels.homeTooltip,
35 : width: width,
36 0 : total: state.getTotal(AppDataType.invoice),
37 0 : title: '${AppLocale.labels.invoiceHeadline}, ${startingDay.fullMonth()}',
38 : searchRoute: AppRoute.invoiceSearchRoute,
39 : ),
40 : );
41 : }
42 :
43 0 : @override
44 : Widget addLineWidget(dynamic item) {
45 0 : final width = ScreenHelper.state().width - ThemeHelper.getIndent(4);
46 0 : final account = state.getByUuid(item.account);
47 0 : return BaseSwipeWidget(
48 : routePath: AppRoute.invoiceEditRoute,
49 0 : uuid: item.uuid!,
50 0 : child: BaseLineWidget(
51 0 : uuid: item.uuid!,
52 0 : title: item.title,
53 0 : description: account != null ? '${account.title} (${account.description})' : '',
54 0 : details: item.detailsFormatted,
55 0 : progress: item.progress,
56 0 : color: item.color ?? Colors.transparent,
57 0 : icon: item.icon ?? Icons.radio_button_unchecked_sharp,
58 0 : hidden: item.hidden,
59 : width: width,
60 : route: AppRoute.invoiceViewRoute,
61 : ),
62 : );
63 : }
64 :
65 0 : @override
66 : Widget buildButton(BuildContext context, BoxConstraints constraints) {
67 0 : NavigatorState nav = Navigator.of(context);
68 0 : return FloatingActionButton(
69 : heroTag: 'invoice_page',
70 0 : onPressed: () => nav.pushNamed(AppRoute.billAddRoute, arguments: {'focus': 0}),
71 0 : tooltip: getButtonName(),
72 : child: const Icon(Icons.add),
73 : );
74 : }
75 :
76 0 : @override
77 0 : String getTitle() => AppLocale.labels.invoiceHeadline;
78 :
79 0 : bool getContentFilter(InvoiceAppData o) => o.accountFrom != null;
80 :
81 0 : @override
82 : InterfaceIterator getContentStream() =>
83 0 : state.getStream<InvoiceAppData>(AppDataType.invoice, filter: getContentFilter);
84 : }
|