From 2b53d1ab7494fc16fbe42a5e7f69f838b3c95acb Mon Sep 17 00:00:00 2001 From: gltron Date: Sun, 25 Feb 2024 13:22:45 +0100 Subject: [PATCH] dynamic theme, basic category settings --- lib/app.dart | 58 +++++++---- lib/domains/account/account_bloc.dart | 5 +- lib/domains/category/category_bloc.dart | 99 ++++++++++++++++++- lib/domains/category/category_event.dart | 53 +++++++++- lib/domains/category/category_state.dart | 8 +- lib/pages/common/titled_container.dart | 16 ++- .../data/widgets/categories_settings.dart | 29 +++++- lib/pages/home/home_page.dart | 98 +++++++++++++----- lib/pages/stats/stats_page.dart | 38 +++---- lib/pages/stats/widgets/account_counters.dart | 9 -- .../widgets/categories_totals_chart.dart | 9 -- lib/pages/stats/widgets/global_counter.dart | 9 -- .../metadata/metadata_repository.dart | 19 +++- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 52 +++++----- pubspec.yaml | 5 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 20 files changed, 372 insertions(+), 146 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 8191bdc..c5e0396 100644 --- a/lib/app.dart +++ b/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 { 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') + ], + ); + }) + ) ); } } \ No newline at end of file diff --git a/lib/domains/account/account_bloc.dart b/lib/domains/account/account_bloc.dart index 0fd7316..2e65717 100644 --- a/lib/domains/account/account_bloc.dart +++ b/lib/domains/account/account_bloc.dart @@ -172,10 +172,7 @@ class AccountBloc extends Bloc { _onAccountEditLabel(AccountEditLabel event, Emitter 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 emit) async { diff --git a/lib/domains/category/category_bloc.dart b/lib/domains/category/category_bloc.dart index ee1b73f..4ec5a7a 100644 --- a/lib/domains/category/category_bloc.dart +++ b/lib/domains/category/category_bloc.dart @@ -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 { 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(_onCategoriesLoad); + on(_onCategoryEditColor); + on(_onCategoryEditTransfert); + on(_onCategoryEditEssential); + on(_onCategoryEditLabel); + on(_onCategoryRemove); + on(_onCategoryAdd); _metadataRepository .getCategoriesStream() @@ -22,9 +39,81 @@ class CategoryBloc extends Bloc { _onCategoriesLoad( CategoriesLoad event, Emitter emit ) { - emit(state.copyWith( - categories: event.categories, - categoriesColors: { for (var category in event.categories) category.label : category.rgbToColor() } - )); + emit(_computeState(event.categories)); + } + + FutureOr _onCategoryEditColor(CategoryEditColor event, Emitter emit) async { + Category category = event.category; + category.color = event.color; + emit(_computeState(await _saveCategory(category))); + } + + FutureOr _onCategoryEditTransfert(CategoryEditTransfert event, Emitter emit) async { + Category category = event.category; + category.transfert = event.transfert; + emit(_computeState(await _saveCategory(category))); + } + + FutureOr _onCategoryEditEssential(CategoryEditEssential event, Emitter emit) async { + Category category = event.category; + category.essential = event.essential; + emit(_computeState(await _saveCategory(category))); + } + + FutureOr _onCategoryEditLabel(CategoryEditLabel event, Emitter emit) async { + // TODO check for existance, rename every transaction + } + + FutureOr _onCategoryRemove(CategoryRemove event, Emitter emit) async { + CategoryState originalCategoryState = state.copyWith(); + Category categoryToRemove = event.category; + List categories = state.categories; + List 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 _onCategoryAdd(CategoryAdd event, Emitter 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 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 categories) { + return state.copyWith( + categories: categories, + categoriesColors: { for (var category in categories) category.label : category.rgbToColor() } + ); } } diff --git a/lib/domains/category/category_event.dart b/lib/domains/category/category_event.dart index 02b270e..415d019 100644 --- a/lib/domains/category/category_event.dart +++ b/lib/domains/category/category_event.dart @@ -13,4 +13,55 @@ final class CategoriesLoad extends CategoryEvent { @override List get props => [categories]; -} \ No newline at end of file +} + +final class CategoryEditColor extends CategoryEvent { + final Category category; + final String color; + + const CategoryEditColor(this.category, this.color); + + @override + List get props => [category, color]; +} + +final class CategoryEditTransfert extends CategoryEvent { + final Category category; + final bool transfert; + + const CategoryEditTransfert(this.category, this.transfert); + + @override + List get props => [category, transfert]; +} + +final class CategoryEditEssential extends CategoryEvent { + final Category category; + final bool essential; + + const CategoryEditEssential(this.category, this.essential); + + @override + List get props => [category, essential]; +} + +final class CategoryEditLabel extends CategoryEvent { + final Category category; + final String label; + + const CategoryEditLabel(this.category, this.label); + + @override + List get props => [category, label]; +} + +final class CategoryRemove extends CategoryEvent { + final Category category; + + const CategoryRemove(this.category); + + @override + List get props => [category]; +} + +final class CategoryAdd extends CategoryEvent {} \ No newline at end of file diff --git a/lib/domains/category/category_state.dart b/lib/domains/category/category_state.dart index 9eb461f..cf800e6 100644 --- a/lib/domains/category/category_state.dart +++ b/lib/domains/category/category_state.dart @@ -1,6 +1,6 @@ part of 'category_bloc.dart'; -final class CategoryState extends Equatable { +final class CategoryState { final List categories; final Map categoriesColors; @@ -18,7 +18,7 @@ final class CategoryState extends Equatable { categoriesColors: categoriesColors ?? this.categoriesColors, ); } - - @override - List get props => [categories, categoriesColors]; } + +final class CategoryRemoveFail extends CategoryState {} +final class CategoryRemoveSucess extends CategoryState {} \ No newline at end of file diff --git a/lib/pages/common/titled_container.dart b/lib/pages/common/titled_container.dart index 0e385de..e004915 100644 --- a/lib/pages/common/titled_container.dart +++ b/lib/pages/common/titled_container.dart @@ -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() diff --git a/lib/pages/data/widgets/categories_settings.dart b/lib/pages/data/widgets/categories_settings.dart index 6b1f2f8..00306b3 100644 --- a/lib/pages/data/widgets/categories_settings.dart +++ b/lib/pages/data/widgets/categories_settings.dart @@ -16,12 +16,12 @@ class CategoriesSettings extends StatelessWidget { color: category.rgbToColor(), ), IconButton( - onPressed: () {}, + onPressed: () => context.read().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().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().add(CategoryRemove(category)), icon: const Icon(Icons.delete), ), ], @@ -43,9 +43,30 @@ class CategoriesSettings extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocConsumer( + 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().add(CategoryAdd()), + icon: const Icon(Icons.add), + ), child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 6f7b30f..5c15120 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -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(context), metadataRepository: RepositoryProvider.of(context))), + BlocProvider(create: (context) => AccountBloc(metadataRepository: RepositoryProvider.of(context), transactionsRepository: RepositoryProvider.of(context))), BlocProvider(create: (context) => TransactionBloc(transactionsRepository: RepositoryProvider.of(context))), - BlocProvider(create: (context) => CategoryBloc(metadataRepository: RepositoryProvider.of(context))), + BlocProvider(create: (context) => CategoryBloc(metadataRepository: RepositoryProvider.of(context), transactionsRepository: RepositoryProvider.of(context))), BlocProvider(create: (context) => BudgetBloc(metadataRepository: RepositoryProvider.of(context))), + BlocProvider(create: (context) => ChartBloc(metadataRepository: RepositoryProvider.of(context), transactionsRepository: RepositoryProvider.of(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), ], ), ) diff --git a/lib/pages/stats/stats_page.dart b/lib/pages/stats/stats_page.dart index 2de8075..6b77463 100644 --- a/lib/pages/stats/stats_page.dart +++ b/lib/pages/stats/stats_page.dart @@ -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(context), - transactionsRepository: RepositoryProvider.of(context), - ), - child: BlocBuilder( - 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( + 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), + ], + ) ); } } \ No newline at end of file diff --git a/lib/pages/stats/widgets/account_counters.dart b/lib/pages/stats/widgets/account_counters.dart index b734363..197d96d 100644 --- a/lib/pages/stats/widgets/account_counters.dart +++ b/lib/pages/stats/widgets/account_counters.dart @@ -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( diff --git a/lib/pages/stats/widgets/categories_totals_chart.dart b/lib/pages/stats/widgets/categories_totals_chart.dart index cbf4dbd..e7dae3c 100644 --- a/lib/pages/stats/widgets/categories_totals_chart.dart +++ b/lib/pages/stats/widgets/categories_totals_chart.dart @@ -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: [ diff --git a/lib/pages/stats/widgets/global_counter.dart b/lib/pages/stats/widgets/global_counter.dart index 357548c..80a7e92 100644 --- a/lib/pages/stats/widgets/global_counter.dart +++ b/lib/pages/stats/widgets/global_counter.dart @@ -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( diff --git a/lib/repositories/metadata/metadata_repository.dart b/lib/repositories/metadata/metadata_repository.dart index 38b91bc..445e7c5 100644 --- a/lib/repositories/metadata/metadata_repository.dart +++ b/lib/repositories/metadata/metadata_repository.dart @@ -16,10 +16,18 @@ class MetadataRepository { required jsonRepository, }) : _jsonRepository = jsonRepository; + List getCategories() { + return _categoriesController.value; + } + Stream> getCategoriesStream() { return _categoriesController.asBroadcastStream(); } + List getBudgets() { + return _budgetController.value; + } + Stream> 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 categories) async { + Future> saveCategories(List categories) async { Metadata metadata = _constructMetadataFromControllers(); metadata.categories = categories; await _jsonRepository.saveJson(metadata); _categoriesController.add(categories); + return categories; } - saveBudgets(List budgets) async { + Future> saveBudgets(List budgets) async { Metadata metadata = _constructMetadataFromControllers(); metadata.budgets = budgets; await _jsonRepository.saveJson(metadata); _budgetController.add(budgets); + return budgets; } - saveAccounts(List accounts) async { + Future> saveAccounts(List accounts) async { Metadata metadata = _constructMetadataFromControllers(); metadata.accounts = accounts; await _jsonRepository.saveJson(metadata); _accountController.add(accounts); + return accounts; } deleteMetadata() async { diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..675b719 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include 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); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..3e303c1 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index e777c67..effcc0d 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -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")) } diff --git a/pubspec.lock b/pubspec.lock index 94e636a..27f36a4 100644 --- a/pubspec.lock +++ b/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: diff --git a/pubspec.yaml b/pubspec.yaml index 8a0c7a5..19c9a24 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..e4899a6 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + DynamicColorPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..841e8c4 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color ) list(APPEND FLUTTER_FFI_PLUGIN_LIST