dynamic theme, basic category settings
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user