Improved category with colors
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/domains/account/account_bloc.dart';
|
||||
import 'package:tunas/pages/data/widgets/categories_settings.dart';
|
||||
import 'package:tunas/pages/data/widgets/import_settings.dart';
|
||||
|
||||
class DataPage extends StatelessWidget {
|
||||
const DataPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AccountBloc, AccountState>(
|
||||
builder: (context, state) => Column(
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10),
|
||||
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10),
|
||||
child: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountImportCSV()),
|
||||
child: const Text('Import CSV')
|
||||
Text(
|
||||
'Settings',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: 35,
|
||||
),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountImportJSON()),
|
||||
child: const Text('Import JSON')
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountExportCSV()),
|
||||
child: const Text('Export CSV')
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountExportJSON()),
|
||||
child: const Text('Export JSON')
|
||||
),
|
||||
],
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ImportSettings(),
|
||||
CategoriesSettings()
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
57
lib/pages/data/widgets/categories_settings.dart
Normal file
57
lib/pages/data/widgets/categories_settings.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/domains/category/category_bloc.dart';
|
||||
import 'package:tunas/repositories/account/models/category.dart';
|
||||
|
||||
class CategoriesSettings extends StatelessWidget {
|
||||
const CategoriesSettings({super.key});
|
||||
|
||||
List<Widget> _computeCategoryList(List<Category> categories) {
|
||||
return categories.map((category) => Row(
|
||||
children: [
|
||||
Container(
|
||||
height: 10,
|
||||
width: 10,
|
||||
color: category.rgbToColor(),
|
||||
),
|
||||
Container(width: 5),
|
||||
Text(category.label),
|
||||
],
|
||||
)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CategoryBloc, CategoryState>(
|
||||
builder: (context, state) => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
margin: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Categories",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _computeCategoryList(state.categories),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
54
lib/pages/data/widgets/import_settings.dart
Normal file
54
lib/pages/data/widgets/import_settings.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/domains/account/account_bloc.dart';
|
||||
|
||||
class ImportSettings extends StatelessWidget {
|
||||
const ImportSettings({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AccountBloc, AccountState>(
|
||||
builder: (context, state) => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(5)
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
margin: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Import",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountImportCSV()),
|
||||
child: const Text('Import CSV')
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountImportJSON()),
|
||||
child: const Text('Import JSON')
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountExportCSV()),
|
||||
child: const Text('Export CSV')
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
FilledButton(
|
||||
onPressed: () => context.read<AccountBloc>().add(const AccountExportJSON()),
|
||||
child: const Text('Export JSON')
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user