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 {
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <dynamic_color/dynamic_color_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
|
||||
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
dynamic_color
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import dynamic_color
|
||||
import path_provider_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
}
|
||||
|
||||
52
pubspec.lock
52
pubspec.lock
@@ -29,10 +29,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: bloc
|
||||
sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49"
|
||||
sha256: f53a110e3b48dcd78136c10daa5d51512443cea5e1348c9d80a320095fa2db9e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.1.2"
|
||||
version: "8.1.3"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -113,6 +113,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.6"
|
||||
dynamic_color:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dynamic_color
|
||||
sha256: a866f1f8947bfdaf674d7928e769eac7230388a2e7a2542824fad4bb5b87be3b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.9"
|
||||
equatable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -157,10 +165,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: "5a74434cc83bf64346efb562f1a06eefaf1bcb530dc3d96a104f631a1eff8d79"
|
||||
sha256: "00b74ae680df6b1135bdbea00a7d1fc072a9180b7c3f3702e4b19a9943f5ed7d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.65.0"
|
||||
version: "0.66.2"
|
||||
flex_color_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -289,10 +297,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: formz
|
||||
sha256: df8301299601139de7e653e68a07c332fd2db7cec65745eca1a1ea73fb711e06
|
||||
sha256: a58eb48d84685b7ffafac1d143bf47d585bf54c7db89fe81c175dfd6e53201c7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.1"
|
||||
version: "0.7.0"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -385,26 +393,26 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
||||
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
|
||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
version: "2.2.2"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
version: "2.3.2"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -417,10 +425,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
|
||||
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -441,18 +449,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
|
||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
version: "3.1.4"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
|
||||
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.7"
|
||||
version: "2.1.8"
|
||||
pointer_interceptor:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -606,18 +614,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574
|
||||
sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.1"
|
||||
version: "5.2.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
|
||||
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
version: "1.0.4"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -13,7 +13,7 @@ dependencies:
|
||||
sdk: flutter
|
||||
|
||||
cupertino_icons: ^1.0.2
|
||||
fl_chart: ^0.65.0
|
||||
fl_chart: ^0.66.2
|
||||
logging: ^1.2.0
|
||||
flutter_bloc: ^8.1.4
|
||||
path_provider: ^2.1.1
|
||||
@@ -24,10 +24,11 @@ dependencies:
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
intl: any
|
||||
formz: ^0.6.1
|
||||
formz: ^0.7.0
|
||||
uuid: ^4.3.2
|
||||
flutter_typeahead: ^5.2.0
|
||||
flex_color_picker: ^3.3.1
|
||||
dynamic_color: ^1.6.9
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <dynamic_color/dynamic_color_plugin_c_api.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
DynamicColorPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
dynamic_color
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
Reference in New Issue
Block a user