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/_configs/screen_helper.dart';
6 : import 'package:app_finance/_configs/theme_helper.dart';
7 : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
8 : import 'package:app_finance/pages/_interfaces/interface_page_inject.dart';
9 : import 'package:app_finance/pages/automation/widgets/payments_tab.dart';
10 : import 'package:app_finance/pages/automation/widgets/sync_tab.dart';
11 : import 'package:app_finance/design/wrapper/tab_widget.dart';
12 : import 'package:material_ui/material_ui.dart';
13 :
14 : class AutomationPage extends StatefulWidget {
15 2 : const AutomationPage({super.key});
16 :
17 0 : @override
18 0 : AutomationPageState createState() => AutomationPageState();
19 : }
20 :
21 : class AutomationPageState extends AbstractPageState<AutomationPage> with TickerProviderStateMixin {
22 : PageInject? inject;
23 :
24 0 : @override
25 0 : String getTitle() => inject?.title ?? AppLocale.labels.automationHeadline;
26 :
27 0 : @override
28 0 : String getButtonName() => inject?.buttonName ?? '';
29 :
30 0 : @override
31 : Widget buildButton(BuildContext context, BoxConstraints constraints) =>
32 0 : inject?.buildButton(context, constraints) ?? ThemeHelper.emptyBox;
33 :
34 0 : void update(PageInject data) {
35 0 : if (data != inject) {
36 0 : WidgetsBinding.instance.addPostFrameCallback((_) => setState(() => inject = data));
37 : }
38 : }
39 :
40 0 : @override
41 : Widget buildContent(BuildContext context, BoxConstraints constraints) {
42 0 : final isLeft = ScreenHelper.state().isLeftBar;
43 0 : return Column(
44 0 : children: [
45 0 : Expanded(
46 0 : child: TabWidget(
47 : type: TabType.secondary,
48 : isLeft: isLeft,
49 0 : tabs: [
50 0 : Tab(icon: const Icon(Icons.free_cancellation_rounded), text: AppLocale.labels.paymentsHeadline),
51 0 : Tab(icon: const Icon(Icons.sync), text: AppLocale.labels.syncHeadline),
52 : ],
53 0 : children: [
54 0 : PaymentsTab(callback: update, state: state),
55 0 : SyncTab(callback: update),
56 : ],
57 : ),
58 : ),
59 : ],
60 : );
61 : }
62 : }
|