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/controller/flow_state_machine.dart';
6 : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
7 : import 'package:app_finance/_configs/theme_helper.dart';
8 : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
9 : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
10 : import 'package:app_finance/pages/invoice/widgets/invoice_header_widget.dart';
11 : import 'package:app_finance/pages/tags/widgets/tags_chips_widget.dart';
12 : import 'package:app_finance/design/wrapper/confirmation_wrapper.dart';
13 : import 'package:material_ui/material_ui.dart';
14 :
15 : class InvoiceViewPage extends StatefulWidget {
16 : final String uuid;
17 :
18 0 : const InvoiceViewPage({
19 : super.key,
20 : required this.uuid,
21 : });
22 :
23 0 : @override
24 0 : InvoiceViewPageState createState() => InvoiceViewPageState();
25 : }
26 :
27 : class InvoiceViewPageState extends AbstractPageState<InvoiceViewPage> {
28 : late InvoiceAppData item = state.getByUuid(widget.uuid);
29 :
30 0 : @override
31 0 : String getTitle() => item.title;
32 :
33 0 : @override
34 : String getButtonName() => '';
35 :
36 0 : @override
37 : Widget buildButton(BuildContext context, BoxConstraints constraints) {
38 0 : double indent = ThemeHelper.getIndent(4);
39 0 : NavigatorState nav = Navigator.of(context);
40 0 : return Container(
41 0 : margin: EdgeInsets.only(left: 2 * indent, right: 2 * indent),
42 0 : child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
43 0 : FloatingActionButton(
44 : heroTag: 'invoice_view_page_edit',
45 0 : onPressed: () => nav.pushNamed(AppRoute.invoiceEditRoute, arguments: {routeArguments.uuid: widget.uuid}),
46 : tooltip:
47 0 : item.accountFrom != null ? AppLocale.labels.editTransferTooltip : AppLocale.labels.editInvoiceTooltip,
48 : child: const Icon(Icons.edit),
49 : ),
50 0 : FloatingActionButton(
51 : heroTag: 'invoice_view_page_deactivate',
52 0 : onPressed: () => ConfirmationWrapper.show(
53 : context,
54 0 : () => FlowStateMachine.deactivate(nav, store: super.state, uuid: widget.uuid),
55 : ),
56 : tooltip:
57 0 : item.accountFrom != null ? AppLocale.labels.deleteTransferTooltip : AppLocale.labels.deleteInvoiceTooltip,
58 : child: const Icon(Icons.delete),
59 : ),
60 : ]),
61 : );
62 : }
63 :
64 0 : @override
65 : Widget buildContent(BuildContext context, BoxConstraints constraints) {
66 0 : return Padding(
67 0 : padding: EdgeInsets.only(top: ThemeHelper.getIndent()),
68 0 : child: Column(
69 0 : children: [
70 0 : InvoiceHeaderWidget(
71 0 : item: state.getByUuid(widget.uuid) as InvoiceAppData,
72 0 : width: ThemeHelper.getWidth(context, 2, constraints),
73 : ),
74 0 : TagsChipsWidget(tags: (state.getByUuid(widget.uuid) as InvoiceAppData).tags),
75 : ThemeHelper.hIndent05,
76 : const Divider(height: 2),
77 : // Details of income
78 : // Images
79 : ],
80 : ),
81 : );
82 : }
83 : }
|