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/navigation/app_route.dart';
7 : import 'package:app_finance/_configs/theme_helper.dart';
8 : import 'package:app_finance/components/widgets/payment_widget.dart';
9 : import 'package:app_finance/design/button/full_sized_button_widget.dart';
10 : import 'package:app_finance/pages/_interfaces/interface_page_inject.dart';
11 : import 'package:material_ui/material_ui.dart';
12 :
13 : class PaymentsTab extends StatefulWidget {
14 : final FnPageCallback callback;
15 : final AppData state;
16 :
17 0 : const PaymentsTab({
18 : super.key,
19 : required this.callback,
20 : required this.state,
21 : });
22 :
23 0 : @override
24 0 : PaymentsTabState createState() => PaymentsTabState();
25 : }
26 :
27 : class PaymentsTabState extends State<PaymentsTab> {
28 0 : @override
29 : void initState() {
30 0 : widget.callback((
31 0 : buildButton: buildButton,
32 0 : buttonName: getButtonName(),
33 0 : title: AppLocale.labels.paymentsHeadline,
34 : ));
35 0 : super.initState();
36 : }
37 :
38 0 : String getButtonName() => AppLocale.labels.createPaymentTooltip;
39 :
40 0 : Widget buildButton(BuildContext context, BoxConstraints constraints) {
41 0 : NavigatorState nav = Navigator.of(context);
42 0 : return FullSizedButtonWidget(
43 : constraints: constraints,
44 0 : onPressed: () => nav.pushNamed(AppRoute.automationPaymentRoute),
45 0 : title: getButtonName(),
46 : icon: Icons.add_alert_sharp,
47 : );
48 : }
49 :
50 0 : @override
51 : Widget build(BuildContext context) {
52 0 : final indent = ThemeHelper.getIndent();
53 0 : return PaymentWidget(
54 0 : data: widget.state.getList(AppDataType.payments).cast(),
55 0 : state: widget.state,
56 0 : margin: EdgeInsets.fromLTRB(0, indent, 0, indent),
57 : );
58 : }
59 : }
|