Improved mobile layout
This commit is contained in:
@@ -8,10 +8,12 @@ class BudgetsPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return Center(
|
||||||
child: ConstrainedBox(
|
child: Container(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
maxWidth: 1000
|
maxWidth: 1000
|
||||||
),
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10),
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10),
|
||||||
child: const Column(
|
child: const Column(
|
||||||
children: [
|
children: [
|
||||||
BudgetsActions(),
|
BudgetsActions(),
|
||||||
|
|||||||
@@ -9,24 +9,18 @@ class BudgetsActions extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<AccountBloc, AccountState>(
|
return BlocBuilder<AccountBloc, AccountState>(
|
||||||
builder: (context, state) => Container(
|
builder: (context, state) => Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10),
|
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 0),
|
||||||
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10),
|
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 0),
|
||||||
child: Row(
|
child: const Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'Budgets',
|
'Budgets',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
fontSize: 35,
|
fontSize: 35,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
|
||||||
onPressed: () => null,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.add
|
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ class DataPage extends StatelessWidget {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
children: const [
|
children: const [
|
||||||
ImportSettings(),
|
ImportSettings(),
|
||||||
CategoriesSettings(),
|
|
||||||
AccountSettings(),
|
AccountSettings(),
|
||||||
|
CategoriesSettings(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,8 +14,103 @@ import 'package:tunas/repositories/transactions/transactions_repository.dart';
|
|||||||
class StatsPage extends StatelessWidget {
|
class StatsPage extends StatelessWidget {
|
||||||
const StatsPage({super.key});
|
const StatsPage({super.key});
|
||||||
|
|
||||||
|
Widget _largeScreenHeader(ChartState state) {
|
||||||
|
return Center (
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 1000
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: GlobalCounter(value: state.globalTotal)
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: AccountCounter(accountsTotals: state.accountsTotals)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const YearSelector(),
|
||||||
|
ProfitIndicator(profit: state.scoppedProfit)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _smallScreenHeader(ChartState state) {
|
||||||
|
return Center (
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 1000
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
GlobalCounter(value: state.globalTotal),
|
||||||
|
AccountCounter(accountsTotals: state.accountsTotals),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
ProfitIndicator(profit: state.scoppedProfit),
|
||||||
|
const YearSelector(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _largeScreenTotalsCharts(ChartState state) {
|
||||||
|
return Center (
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 1500
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 450,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesPositiveTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesPositiveTotalsPercents),
|
||||||
|
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesNegativeTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesNegativeTotalsPercents),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _smallScreenTotalsCharts(ChartState state) {
|
||||||
|
return Center (
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 1500
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesPositiveTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesPositiveTotalsPercents),
|
||||||
|
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesNegativeTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesNegativeTotalsPercents),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
bool smallVerticalScreen = MediaQuery.sizeOf(context).width < 800;
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => ChartBloc(
|
create: (context) => ChartBloc(
|
||||||
metadataRepository: RepositoryProvider.of<MetadataRepository>(context),
|
metadataRepository: RepositoryProvider.of<MetadataRepository>(context),
|
||||||
@@ -24,60 +119,16 @@ class StatsPage extends StatelessWidget {
|
|||||||
child: BlocBuilder<ChartBloc, ChartState>(
|
child: BlocBuilder<ChartBloc, ChartState>(
|
||||||
builder: (context, state) => ListView(
|
builder: (context, state) => ListView(
|
||||||
children: [
|
children: [
|
||||||
Center (
|
smallVerticalScreen ? _smallScreenHeader(state) : _largeScreenHeader(state),
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxWidth: 1000
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: GlobalCounter(value: state.globalTotal)
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: AccountCounter(accountsTotals: state.accountsTotals)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
const YearSelector(),
|
|
||||||
ProfitIndicator(profit: state.scoppedProfit)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 200,
|
height: smallVerticalScreen ? 100 : 200,
|
||||||
child: GlobalTotalChart(monthlyTotals: state.scopedMonthlyTotals)
|
child: GlobalTotalChart(monthlyTotals: state.scopedMonthlyTotals)
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 500,
|
height: smallVerticalScreen ? 200 : 500,
|
||||||
child: MonthlyCategoriesTotalChart(categoriesMonthlyTotals: state.scopedCategoriesMonthlyTotals)
|
child: MonthlyCategoriesTotalChart(categoriesMonthlyTotals: state.scopedCategoriesMonthlyTotals)
|
||||||
),
|
),
|
||||||
Center (
|
smallVerticalScreen ? _smallScreenTotalsCharts(state) : _largeScreenTotalsCharts(state),
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxWidth: 1500
|
|
||||||
),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 450,
|
|
||||||
child: OverflowBar(
|
|
||||||
children: [
|
|
||||||
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesPositiveTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesPositiveTotalsPercents),
|
|
||||||
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesNegativeTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesNegativeTotalsPercents),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class AccountCounter extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
margin: const EdgeInsets.all(20),
|
margin: const EdgeInsets.only(bottom: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CategoriesTotalsChart extends StatelessWidget {
|
|||||||
|
|
||||||
const CategoriesTotalsChart({super.key, required this.categoriesTotals, required this.categoriesTotalsPercents});
|
const CategoriesTotalsChart({super.key, required this.categoriesTotals, required this.categoriesTotalsPercents});
|
||||||
|
|
||||||
List<PieChartSectionData> _convertDataForChart(Map<String, Color> categoriesColors) {
|
List<PieChartSectionData> _convertDataForChart(Map<String, Color> categoriesColors, bool smallVerticalScreen) {
|
||||||
return categoriesTotalsPercents
|
return categoriesTotalsPercents
|
||||||
.map((item) =>
|
.map((item) =>
|
||||||
PieChartSectionData(
|
PieChartSectionData(
|
||||||
@@ -21,9 +21,10 @@ class CategoriesTotalsChart extends StatelessWidget {
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w300
|
fontWeight: FontWeight.w300
|
||||||
),
|
),
|
||||||
|
showTitle: !smallVerticalScreen,
|
||||||
titlePositionPercentageOffset: 0.5,
|
titlePositionPercentageOffset: 0.5,
|
||||||
borderSide: const BorderSide(width: 0),
|
borderSide: const BorderSide(width: 0),
|
||||||
radius: 40,
|
radius: smallVerticalScreen ? 30 : 40,
|
||||||
color: categoriesColors[item.label]
|
color: categoriesColors[item.label]
|
||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
@@ -60,10 +61,11 @@ class CategoriesTotalsChart extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
bool smallVerticalScreen = MediaQuery.sizeOf(context).width < 800;
|
||||||
return BlocBuilder<CategoryBloc, CategoryState>(
|
return BlocBuilder<CategoryBloc, CategoryState>(
|
||||||
builder: (context, state) => Container(
|
builder: (context, state) => Container(
|
||||||
height: 320,
|
height: 320,
|
||||||
width: 500,
|
width: smallVerticalScreen ? null : 500,
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
margin: const EdgeInsets.all(20),
|
margin: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -84,11 +86,11 @@ class CategoriesTotalsChart extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: PieChart(
|
child: PieChart(
|
||||||
PieChartData(
|
PieChartData(
|
||||||
sections: _convertDataForChart(state.categoriesColors),
|
sections: _convertDataForChart(state.categoriesColors, smallVerticalScreen),
|
||||||
borderData: FlBorderData(
|
borderData: FlBorderData(
|
||||||
show: false
|
show: false
|
||||||
),
|
),
|
||||||
centerSpaceRadius: 50,
|
centerSpaceRadius: smallVerticalScreen ? 30 :50,
|
||||||
sectionsSpace: 4
|
sectionsSpace: 4
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class GlobalCounter extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
margin: const EdgeInsets.all(20),
|
margin: const EdgeInsets.only(bottom: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
|||||||
@@ -7,31 +7,64 @@ import 'package:tunas/pages/transactions/widgets/transaction_add_dialog.dart';
|
|||||||
class TransactionsActions extends StatelessWidget {
|
class TransactionsActions extends StatelessWidget {
|
||||||
const TransactionsActions({super.key});
|
const TransactionsActions({super.key});
|
||||||
|
|
||||||
@override
|
Widget _smallScreenLayout(BuildContext context) {
|
||||||
Widget build(BuildContext context) {
|
return Column(
|
||||||
return BlocBuilder<TransactionBloc, TransactionState>(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
builder: (context, state) => Container(
|
children: [
|
||||||
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10),
|
Row(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text (
|
||||||
'Transactions',
|
'Transactions',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w900,
|
||||||
fontSize: 35,
|
fontSize: 35,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
CategoryFilter(),
|
FilledButton.icon(
|
||||||
IconButton(
|
|
||||||
onPressed: () => TransactionAddDialog.show(context, null),
|
onPressed: () => TransactionAddDialog.show(context, null),
|
||||||
|
label: const Text('Add transaction'),
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add
|
Icons.add
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
const CategoryFilter(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _largeScreenLayout(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Transactions',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const CategoryFilter(),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => TransactionAddDialog.show(context, null),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.add
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
bool smallVerticalScreen = MediaQuery.sizeOf(context).width < 800;
|
||||||
|
return BlocBuilder<TransactionBloc, TransactionState>(
|
||||||
|
builder: (context, state) => Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10),
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10),
|
||||||
|
child: smallVerticalScreen ? _smallScreenLayout(context) : _largeScreenLayout(context),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user