feat: Add color and icon properties to categories, enhance category management in UI

This commit is contained in:
2026-05-20 17:10:44 +02:00
parent def755e1c5
commit 3ff4efb738
8 changed files with 517 additions and 45 deletions
+35 -3
View File
@@ -1,14 +1,19 @@
import 'package:flutter/material.dart';
import 'package:notas/models/category.dart';
class MenuDrawer extends StatelessWidget {
const MenuDrawer({
super.key,
this.onMenuItemTapped,
this.selectedItem,
this.categories = const [],
this.onCreateCategory,
});
final ValueChanged<String>? onMenuItemTapped;
final String? selectedItem;
final List<Category> categories;
final VoidCallback? onCreateCategory;
@override
Widget build(BuildContext context) {
@@ -31,8 +36,36 @@ class MenuDrawer extends StatelessWidget {
Expanded(
child: SingleChildScrollView(
child: Column(
children: const [
SizedBox.shrink(),
children: [
if (categories.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Column(
children: categories.map((category) {
final categoryId = 'category_${category.id}';
final IconData categoryIcon = category.iconCodePoint == null
? Icons.folder_outlined
: IconData(
category.iconCodePoint!,
fontFamily: 'MaterialIcons',
);
return _MenuItemTile(
icon: categoryIcon,
label: category.name,
selected: selectedItem == categoryId,
onTap: () => onMenuItemTapped?.call(categoryId),
iconColor: Color(category.colorValue ?? 0xFFFFC107),
textColor: Color(category.colorValue ?? 0xFFFFC107),
);
}).toList(),
),
),
_MenuItemTile(
icon: Icons.add_circle_outline,
label: 'Crear categoría',
onTap: onCreateCategory,
),
],
),
),
@@ -86,7 +119,6 @@ class _MenuItemTile extends StatelessWidget {
duration: const Duration(milliseconds: 180),
curve: Curves.easeOutCubic,
margin: EdgeInsets.only(
left: selected ? 0 : 8,
right: 8,
top: 2,
bottom: 2,