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