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