| 1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import 'package:flutter/widgets.dart'; |
| 6 | |
| 7 | import '../../../gallery_localizations.dart'; |
| 8 | import '../charts/pie_chart.dart'; |
| 9 | import '../data.dart'; |
| 10 | import '../finance.dart'; |
| 11 | import 'sidebar.dart'; |
| 12 | |
| 13 | class BudgetsView extends StatefulWidget { |
| 14 | const BudgetsView({super.key}); |
| 15 | |
| 16 | @override |
| 17 | State<BudgetsView> createState() => _BudgetsViewState(); |
| 18 | } |
| 19 | |
| 20 | class _BudgetsViewState extends State<BudgetsView> with SingleTickerProviderStateMixin { |
| 21 | @override |
| 22 | Widget build(BuildContext context) { |
| 23 | final List<BudgetData> items = DummyDataService.getBudgetDataList(context); |
| 24 | final double capTotal = sumBudgetDataPrimaryAmount(items); |
| 25 | final double usedTotal = sumBudgetDataAmountUsed(items); |
| 26 | final List<UserDetailData> detailItems = DummyDataService.getBudgetDetailList( |
| 27 | context, |
| 28 | capTotal: capTotal, |
| 29 | usedTotal: usedTotal, |
| 30 | ); |
| 31 | |
| 32 | return TabWithSidebar( |
| 33 | restorationId: 'budgets_view' , |
| 34 | mainView: FinancialEntityView( |
| 35 | heroLabel: GalleryLocalizations.of(context)!.rallyBudgetLeft, |
| 36 | heroAmount: capTotal - usedTotal, |
| 37 | segments: buildSegmentsFromBudgetItems(items), |
| 38 | wholeAmount: capTotal, |
| 39 | financialEntityCards: buildBudgetDataListViews(items, context), |
| 40 | ), |
| 41 | sidebarItems: <Widget>[ |
| 42 | for (final UserDetailData item in detailItems) |
| 43 | SidebarItem(title: item.title, value: item.value), |
| 44 | ], |
| 45 | ); |
| 46 | } |
| 47 | } |
| 48 | |