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