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/structure/budget_app_data.dart'; 5 : import 'package:app_finance/_classes/storage/app_data.dart'; 6 : import 'package:app_finance/_configs/theme_helper.dart'; 7 : import 'package:app_finance/design/form/list_selector.dart'; 8 : import 'package:app_finance/pages/budget/widgets/budget_line_widget.dart'; 9 : import 'package:app_finance/design/form/list_account_selector.dart'; 10 : import 'package:flutter/material.dart'; 11 : 12 : class ListBudgetSelectorItem extends ListAccountSelectorItem { 13 1 : @override 14 2 : Widget suggest(context) => LayoutBuilder(builder: (_, constraints) { 15 1 : return BudgetLineWidget( 16 2 : uuid: item.uuid ?? '', 17 2 : title: item.title ?? '', 18 2 : description: item.description ?? '', 19 2 : details: item.detailsFormatted ?? '', 20 3 : amount: item.amount.toString(), 21 : progress: 1.0, 22 2 : color: item.color ?? Colors.transparent, 23 2 : icon: item.icon ?? Icons.radio_button_unchecked_sharp, 24 2 : hidden: item.hidden ?? false, 25 3 : width: constraints.maxWidth - ThemeHelper.getIndent(), 26 : showDivider: false, 27 : ); 28 : }); 29 : 30 1 : ListBudgetSelectorItem({ 31 : required BudgetAppData? super.item, 32 : }); 33 : } 34 : 35 : class ListBudgetSelector extends ListAccountSelector<ListBudgetSelectorItem> { 36 1 : const ListBudgetSelector({ 37 : super.key, 38 : required super.state, 39 : required super.setState, 40 : required super.width, 41 : required super.hintText, 42 : super.value, 43 : super.tooltip, 44 : super.withLabel, 45 1 : }) : super(); 46 : 47 1 : @override 48 : List<ListBudgetSelectorItem> get options => 49 6 : state.getList(AppDataType.budgets).map((item) => ListBudgetSelectorItem(item: item)).toList(); 50 : 51 1 : @override 52 1 : ListSelectorState createState() => ListSelectorState<ListBudgetSelector, ListBudgetSelectorItem>(); 53 : }