dynamic theme, basic category settings
This commit is contained in:
58
lib/app.dart
58
lib/app.dart
@@ -1,3 +1,4 @@
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@@ -6,7 +7,6 @@ import 'package:tunas/pages/home/home_page.dart';
|
||||
import 'package:tunas/repositories/json/json_repository.dart';
|
||||
import 'package:tunas/repositories/metadata/metadata_repository.dart';
|
||||
import 'package:tunas/repositories/transactions/transactions_repository.dart';
|
||||
import 'package:tunas/theme.dart';
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({super.key});
|
||||
@@ -56,24 +56,44 @@ class _AppViewState extends State<AppView> {
|
||||
RepositoryProvider.value(value: _transactionsRepository),
|
||||
RepositoryProvider.value(value: _metadataRepository),
|
||||
],
|
||||
child: MaterialApp(
|
||||
title: 'Tunas',
|
||||
theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
|
||||
darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme),
|
||||
themeMode: ThemeMode.dark,
|
||||
initialRoute: '/home',
|
||||
routes: {
|
||||
'/home':(context) => const HomePage(),
|
||||
},
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('fr')
|
||||
],
|
||||
)
|
||||
child: DynamicColorBuilder(
|
||||
builder: ((lightDynamic, darkDynamic) {
|
||||
ColorScheme lightColorScheme;
|
||||
ColorScheme darkColorScheme;
|
||||
|
||||
if (lightDynamic != null && darkDynamic != null) {
|
||||
lightColorScheme = lightDynamic.harmonized();
|
||||
darkColorScheme = darkDynamic.harmonized();
|
||||
} else {
|
||||
lightColorScheme = ColorScheme.fromSeed(
|
||||
seedColor: const Color.fromARGB(1, 5, 236, 55),
|
||||
);
|
||||
|
||||
darkColorScheme = ColorScheme.fromSeed(
|
||||
seedColor: const Color.fromARGB(1, 5, 236, 55),
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
}
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Tunas',
|
||||
theme: ThemeData(colorScheme: lightColorScheme),
|
||||
darkTheme: ThemeData(colorScheme: darkColorScheme),
|
||||
initialRoute: '/home',
|
||||
routes: {
|
||||
'/home':(context) => const HomePage(),
|
||||
},
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('fr')
|
||||
],
|
||||
);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -172,10 +172,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
|
||||
_onAccountEditLabel(AccountEditLabel event, Emitter<AccountState> emit) async {
|
||||
Account account = event.account;
|
||||
account.label = event.label;
|
||||
emit(
|
||||
state.copyWith(await _saveAccount(account))
|
||||
);
|
||||
// TODO check for existance, rename every transaction
|
||||
}
|
||||
|
||||
_onAccountEditSaving(AccountEditSaving event, Emitter<AccountState> emit) async {
|
||||
|
||||
@@ -1,18 +1,35 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/repositories/metadata/metadata_repository.dart';
|
||||
import 'package:tunas/repositories/metadata/models/category.dart';
|
||||
import 'package:tunas/repositories/transactions/models/transaction.dart';
|
||||
import 'package:tunas/repositories/transactions/transactions_repository.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
part 'category_event.dart';
|
||||
part 'category_state.dart';
|
||||
|
||||
class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
|
||||
final MetadataRepository _metadataRepository;
|
||||
final TransactionsRepository _transactionsRepository;
|
||||
|
||||
CategoryBloc({required MetadataRepository metadataRepository}) : _metadataRepository = metadataRepository, super(const CategoryState()) {
|
||||
CategoryBloc({
|
||||
required MetadataRepository metadataRepository,
|
||||
required TransactionsRepository transactionsRepository,
|
||||
})
|
||||
: _metadataRepository = metadataRepository,
|
||||
_transactionsRepository = transactionsRepository,
|
||||
super(const CategoryState()) {
|
||||
on<CategoriesLoad>(_onCategoriesLoad);
|
||||
on<CategoryEditColor>(_onCategoryEditColor);
|
||||
on<CategoryEditTransfert>(_onCategoryEditTransfert);
|
||||
on<CategoryEditEssential>(_onCategoryEditEssential);
|
||||
on<CategoryEditLabel>(_onCategoryEditLabel);
|
||||
on<CategoryRemove>(_onCategoryRemove);
|
||||
on<CategoryAdd>(_onCategoryAdd);
|
||||
|
||||
_metadataRepository
|
||||
.getCategoriesStream()
|
||||
@@ -22,9 +39,81 @@ class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
|
||||
_onCategoriesLoad(
|
||||
CategoriesLoad event, Emitter<CategoryState> emit
|
||||
) {
|
||||
emit(state.copyWith(
|
||||
categories: event.categories,
|
||||
categoriesColors: { for (var category in event.categories) category.label : category.rgbToColor() }
|
||||
));
|
||||
emit(_computeState(event.categories));
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryEditColor(CategoryEditColor event, Emitter<CategoryState> emit) async {
|
||||
Category category = event.category;
|
||||
category.color = event.color;
|
||||
emit(_computeState(await _saveCategory(category)));
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryEditTransfert(CategoryEditTransfert event, Emitter<CategoryState> emit) async {
|
||||
Category category = event.category;
|
||||
category.transfert = event.transfert;
|
||||
emit(_computeState(await _saveCategory(category)));
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryEditEssential(CategoryEditEssential event, Emitter<CategoryState> emit) async {
|
||||
Category category = event.category;
|
||||
category.essential = event.essential;
|
||||
emit(_computeState(await _saveCategory(category)));
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryEditLabel(CategoryEditLabel event, Emitter<CategoryState> emit) async {
|
||||
// TODO check for existance, rename every transaction
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryRemove(CategoryRemove event, Emitter<CategoryState> emit) async {
|
||||
CategoryState originalCategoryState = state.copyWith();
|
||||
Category categoryToRemove = event.category;
|
||||
List<Category> categories = state.categories;
|
||||
List<Transaction> transactions = _transactionsRepository.getTransactions();
|
||||
|
||||
if (transactions.any((transaction) => transaction.category == categoryToRemove.label)) {
|
||||
emit(CategoryRemoveFail());
|
||||
emit(originalCategoryState);
|
||||
} else {
|
||||
categories.removeWhere((category) => category.label == categoryToRemove.label);
|
||||
emit(CategoryRemoveSucess());
|
||||
emit(_computeState(await _metadataRepository.saveCategories(categories)));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _onCategoryAdd(CategoryAdd event, Emitter<CategoryState> emit) async {
|
||||
String uuid = const Uuid().v8();
|
||||
Category category = Category(
|
||||
label: 'Category $uuid',
|
||||
color: 'FF74feff',
|
||||
);
|
||||
|
||||
emit(_computeState(await _saveCategory(category)));
|
||||
}
|
||||
|
||||
_saveCategory(Category categoryToSave) async {
|
||||
List<Category> categories = _metadataRepository.getCategories();
|
||||
|
||||
try {
|
||||
Category categoryFound = categories.firstWhere((category) => category.label == categoryToSave.label);
|
||||
categoryFound.color = categoryToSave.color;
|
||||
categoryFound.essential = categoryToSave.essential;
|
||||
categoryFound.transfert = categoryToSave.transfert;
|
||||
} catch (e) {
|
||||
if (categories.isEmpty) {
|
||||
categories = [categoryToSave];
|
||||
} else {
|
||||
categories.add(categoryToSave);
|
||||
}
|
||||
}
|
||||
|
||||
await _metadataRepository.saveCategories(categories);
|
||||
return categories;
|
||||
}
|
||||
|
||||
CategoryState _computeState(List<Category> categories) {
|
||||
return state.copyWith(
|
||||
categories: categories,
|
||||
categoriesColors: { for (var category in categories) category.label : category.rgbToColor() }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,55 @@ final class CategoriesLoad extends CategoryEvent {
|
||||
|
||||
@override
|
||||
List<Object> get props => [categories];
|
||||
}
|
||||
}
|
||||
|
||||
final class CategoryEditColor extends CategoryEvent {
|
||||
final Category category;
|
||||
final String color;
|
||||
|
||||
const CategoryEditColor(this.category, this.color);
|
||||
|
||||
@override
|
||||
List<Object> get props => [category, color];
|
||||
}
|
||||
|
||||
final class CategoryEditTransfert extends CategoryEvent {
|
||||
final Category category;
|
||||
final bool transfert;
|
||||
|
||||
const CategoryEditTransfert(this.category, this.transfert);
|
||||
|
||||
@override
|
||||
List<Object> get props => [category, transfert];
|
||||
}
|
||||
|
||||
final class CategoryEditEssential extends CategoryEvent {
|
||||
final Category category;
|
||||
final bool essential;
|
||||
|
||||
const CategoryEditEssential(this.category, this.essential);
|
||||
|
||||
@override
|
||||
List<Object> get props => [category, essential];
|
||||
}
|
||||
|
||||
final class CategoryEditLabel extends CategoryEvent {
|
||||
final Category category;
|
||||
final String label;
|
||||
|
||||
const CategoryEditLabel(this.category, this.label);
|
||||
|
||||
@override
|
||||
List<Object> get props => [category, label];
|
||||
}
|
||||
|
||||
final class CategoryRemove extends CategoryEvent {
|
||||
final Category category;
|
||||
|
||||
const CategoryRemove(this.category);
|
||||
|
||||
@override
|
||||
List<Object> get props => [category];
|
||||
}
|
||||
|
||||
final class CategoryAdd extends CategoryEvent {}
|
||||
@@ -1,6 +1,6 @@
|
||||
part of 'category_bloc.dart';
|
||||
|
||||
final class CategoryState extends Equatable {
|
||||
final class CategoryState {
|
||||
final List<Category> categories;
|
||||
final Map<String, Color> categoriesColors;
|
||||
|
||||
@@ -18,7 +18,7 @@ final class CategoryState extends Equatable {
|
||||
categoriesColors: categoriesColors ?? this.categoriesColors,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => [categories, categoriesColors];
|
||||
}
|
||||
|
||||
final class CategoryRemoveFail extends CategoryState {}
|
||||
final class CategoryRemoveSucess extends CategoryState {}
|
||||
@@ -35,15 +35,6 @@ class TitledContainer extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(2, 2),
|
||||
spreadRadius: 0.1,
|
||||
blurStyle: BlurStyle.normal,
|
||||
)
|
||||
]
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 0),
|
||||
child: Column(
|
||||
@@ -56,7 +47,12 @@ class TitledContainer extends StatelessWidget {
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(14), topRight: Radius.circular(15)),
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
)
|
||||
)
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15),
|
||||
child: _computeTitleRow()
|
||||
|
||||
@@ -16,12 +16,12 @@ class CategoriesSettings extends StatelessWidget {
|
||||
color: category.rgbToColor(),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
onPressed: () => context.read<CategoryBloc>().add(CategoryEditTransfert(category, !category.transfert)),
|
||||
icon: const Icon(Icons.swap_horiz),
|
||||
color: category.transfert ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
onPressed: () => context.read<CategoryBloc>().add(CategoryEditEssential(category, !category.essential)),
|
||||
icon: const Icon(Icons.foundation),
|
||||
color: category.essential ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||
),
|
||||
@@ -34,7 +34,7 @@ class CategoriesSettings extends StatelessWidget {
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
onPressed: () => context.read<CategoryBloc>().add(CategoryRemove(category)),
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
@@ -43,9 +43,30 @@ class CategoriesSettings extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CategoryBloc, CategoryState>(
|
||||
return BlocConsumer<CategoryBloc, CategoryState>(
|
||||
listener: (context, state) {
|
||||
if (state is CategoryRemoveSucess) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
backgroundColor: Colors.green,
|
||||
content: Text('Category succesfuly removed !'),
|
||||
)
|
||||
);
|
||||
} else if (state is CategoryRemoveFail) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
backgroundColor: Colors.red,
|
||||
content: Text('Cannot remove category. Still present on some transactions.'),
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) => TitledContainer(
|
||||
title: "Categories",
|
||||
action: IconButton(
|
||||
onPressed: () => context.read<CategoryBloc>().add(CategoryAdd()),
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/domains/account/account_bloc.dart';
|
||||
import 'package:tunas/domains/budget/budget_bloc.dart';
|
||||
import 'package:tunas/domains/category/category_bloc.dart';
|
||||
import 'package:tunas/domains/charts/chart_bloc.dart';
|
||||
import 'package:tunas/domains/transaction/transaction_bloc.dart';
|
||||
import 'package:tunas/pages/budgets/budgets_page.dart';
|
||||
import 'package:tunas/pages/data/data_page.dart';
|
||||
@@ -14,14 +15,86 @@ import 'package:tunas/repositories/transactions/transactions_repository.dart';
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
Widget _tabBar() {
|
||||
return TabBar(
|
||||
tabAlignment: TabAlignment.center,
|
||||
splashBorderRadius: BorderRadius.circular(25),
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.insights)),
|
||||
Tab(icon: Icon(Icons.receipt_long)),
|
||||
Tab(icon: Icon(Icons.pie_chart)),
|
||||
Tab(icon: Icon(Icons.settings)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _largeScreenTotalsCharts(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: TabBar(
|
||||
tabAlignment: TabAlignment.center,
|
||||
splashBorderRadius: BorderRadius.circular(25),
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.insights)),
|
||||
Tab(icon: Icon(Icons.receipt_long)),
|
||||
Tab(icon: Icon(Icons.pie_chart)),
|
||||
Tab(icon: Icon(Icons.settings)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _smallScreenTotalsCharts(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, -2),
|
||||
spreadRadius: 0.1,
|
||||
blurStyle: BlurStyle.normal,
|
||||
)
|
||||
]
|
||||
),
|
||||
child: Center(
|
||||
child:TabBar(
|
||||
tabAlignment: TabAlignment.center,
|
||||
splashBorderRadius: BorderRadius.circular(25),
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.insights)),
|
||||
Tab(icon: Icon(Icons.receipt_long)),
|
||||
Tab(icon: Icon(Icons.pie_chart)),
|
||||
Tab(icon: Icon(Icons.settings)),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool smallVerticalScreen = MediaQuery.sizeOf(context).width < 1500;
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(create: (context) => AccountBloc(transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context), metadataRepository: RepositoryProvider.of<MetadataRepository>(context))),
|
||||
BlocProvider(create: (context) => AccountBloc(metadataRepository: RepositoryProvider.of<MetadataRepository>(context), transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context))),
|
||||
BlocProvider(create: (context) => TransactionBloc(transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context))),
|
||||
BlocProvider(create: (context) => CategoryBloc(metadataRepository: RepositoryProvider.of<MetadataRepository>(context))),
|
||||
BlocProvider(create: (context) => CategoryBloc(metadataRepository: RepositoryProvider.of<MetadataRepository>(context), transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context))),
|
||||
BlocProvider(create: (context) => BudgetBloc(metadataRepository: RepositoryProvider.of<MetadataRepository>(context))),
|
||||
BlocProvider(create: (context) => ChartBloc(metadataRepository: RepositoryProvider.of<MetadataRepository>(context), transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context))),
|
||||
],
|
||||
child: DefaultTabController(
|
||||
length: 4,
|
||||
@@ -36,26 +109,7 @@ class HomePage extends StatelessWidget {
|
||||
DataPage()
|
||||
],
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color.fromARGB(255, 41, 49, 56),
|
||||
borderRadius: BorderRadius.circular(25)
|
||||
),
|
||||
child: TabBar(
|
||||
tabAlignment: TabAlignment.center,
|
||||
splashBorderRadius: BorderRadius.circular(25),
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.insights)),
|
||||
Tab(icon: Icon(Icons.receipt_long)),
|
||||
Tab(icon: Icon(Icons.pie_chart)),
|
||||
Tab(icon: Icon(Icons.settings)),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
smallVerticalScreen ? _smallScreenTotalsCharts(context) : _largeScreenTotalsCharts(context),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -112,28 +112,22 @@ class StatsPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
bool smallVerticalScreen = MediaQuery.sizeOf(context).width < 800;
|
||||
return BlocProvider(
|
||||
create: (context) => ChartBloc(
|
||||
metadataRepository: RepositoryProvider.of<MetadataRepository>(context),
|
||||
transactionsRepository: RepositoryProvider.of<TransactionsRepository>(context),
|
||||
),
|
||||
child: BlocBuilder<ChartBloc, ChartState>(
|
||||
builder: (context, state) => ListView(
|
||||
padding: mediaQuery.padding.copyWith(bottom: 100.0),
|
||||
children: [
|
||||
smallVerticalScreen ? _smallScreenHeader(state) : _largeScreenHeader(state),
|
||||
SizedBox(
|
||||
height: smallVerticalScreen ? 100 : 200,
|
||||
child: GlobalTotalChart(monthlyTotals: state.scopedMonthlyTotals)
|
||||
),
|
||||
SizedBox(
|
||||
height: smallVerticalScreen ? 200 : 500,
|
||||
child: MonthlyCategoriesTotalChart(categoriesMonthlyTotals: state.scopedCategoriesMonthlyTotals)
|
||||
),
|
||||
smallVerticalScreen ? _smallScreenTotalsCharts(state) : _largeScreenTotalsCharts(state),
|
||||
],
|
||||
)
|
||||
),
|
||||
return BlocBuilder<ChartBloc, ChartState>(
|
||||
builder: (context, state) => ListView(
|
||||
padding: mediaQuery.padding.copyWith(bottom: 100.0),
|
||||
children: [
|
||||
smallVerticalScreen ? _smallScreenHeader(state) : _largeScreenHeader(state),
|
||||
SizedBox(
|
||||
height: smallVerticalScreen ? 100 : 200,
|
||||
child: GlobalTotalChart(monthlyTotals: state.scopedMonthlyTotals)
|
||||
),
|
||||
SizedBox(
|
||||
height: smallVerticalScreen ? 200 : 500,
|
||||
child: MonthlyCategoriesTotalChart(categoriesMonthlyTotals: state.scopedCategoriesMonthlyTotals)
|
||||
),
|
||||
smallVerticalScreen ? _smallScreenTotalsCharts(state) : _largeScreenTotalsCharts(state),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,15 +35,6 @@ class AccountCounter extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(2, 2),
|
||||
spreadRadius: 0.1,
|
||||
blurStyle: BlurStyle.normal,
|
||||
)
|
||||
]
|
||||
),
|
||||
alignment: Alignment.centerRight,
|
||||
child: Column(
|
||||
|
||||
@@ -71,15 +71,6 @@ class CategoriesTotalsChart extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(2, 2),
|
||||
spreadRadius: 0.1,
|
||||
blurStyle: BlurStyle.normal,
|
||||
)
|
||||
]
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -14,15 +14,6 @@ class GlobalCounter extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(2, 2),
|
||||
spreadRadius: 0.1,
|
||||
blurStyle: BlurStyle.normal,
|
||||
)
|
||||
]
|
||||
),
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
|
||||
@@ -16,10 +16,18 @@ class MetadataRepository {
|
||||
required jsonRepository,
|
||||
}) : _jsonRepository = jsonRepository;
|
||||
|
||||
List<Category> getCategories() {
|
||||
return _categoriesController.value;
|
||||
}
|
||||
|
||||
Stream<List<Category>> getCategoriesStream() {
|
||||
return _categoriesController.asBroadcastStream();
|
||||
}
|
||||
|
||||
List<Budget> getBudgets() {
|
||||
return _budgetController.value;
|
||||
}
|
||||
|
||||
Stream<List<Budget>> getBudgetsStream() {
|
||||
return _budgetController.asBroadcastStream();
|
||||
}
|
||||
@@ -32,30 +40,33 @@ class MetadataRepository {
|
||||
return _accountController.asBroadcastStream();
|
||||
}
|
||||
|
||||
loadMetadata() async {
|
||||
void loadMetadata() async {
|
||||
Metadata metadata = await _jsonRepository.loadJson(Metadata(), MetadataFactory());
|
||||
_broadcastMetadata(metadata);
|
||||
}
|
||||
|
||||
saveCategories(List<Category> categories) async {
|
||||
Future<List<Category>> saveCategories(List<Category> categories) async {
|
||||
Metadata metadata = _constructMetadataFromControllers();
|
||||
metadata.categories = categories;
|
||||
await _jsonRepository.saveJson(metadata);
|
||||
_categoriesController.add(categories);
|
||||
return categories;
|
||||
}
|
||||
|
||||
saveBudgets(List<Budget> budgets) async {
|
||||
Future<List<Budget>> saveBudgets(List<Budget> budgets) async {
|
||||
Metadata metadata = _constructMetadataFromControllers();
|
||||
metadata.budgets = budgets;
|
||||
await _jsonRepository.saveJson(metadata);
|
||||
_budgetController.add(budgets);
|
||||
return budgets;
|
||||
}
|
||||
|
||||
saveAccounts(List<Account> accounts) async {
|
||||
Future<List<Account>> saveAccounts(List<Account> accounts) async {
|
||||
Metadata metadata = _constructMetadataFromControllers();
|
||||
metadata.accounts = accounts;
|
||||
await _jsonRepository.saveJson(metadata);
|
||||
_accountController.add(accounts);
|
||||
return accounts;
|
||||
}
|
||||
|
||||
deleteMetadata() async {
|
||||
|
||||
Reference in New Issue
Block a user