feat: Introduce category selection functionality in NoteEditorScreen and related components

This commit is contained in:
2026-05-21 19:31:29 +02:00
parent 7e210871dd
commit 8be7819528
7 changed files with 421 additions and 58 deletions
+41
View File
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
class CategoryStyle {
CategoryStyle._();
static const List<Color> colors = <Color>[
Colors.amber,
Colors.blue,
Colors.green,
Colors.purple,
Colors.red,
Colors.teal,
Colors.orange,
Colors.grey,
];
static const List<IconData> icons = <IconData>[
Icons.folder,
Icons.work,
Icons.star,
Icons.home,
Icons.school,
Icons.book,
Icons.music_note,
Icons.lightbulb,
];
static IconData iconForCodePoint(int? codePoint) {
if (codePoint == null) {
return Icons.folder_outlined;
}
for (final IconData icon in icons) {
if (icon.codePoint == codePoint) {
return icon;
}
}
return Icons.folder_outlined;
}
}
+5 -28
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:notas/models/category.dart';
import 'package:notas/widgets/category_style.dart';
class MenuDrawer extends StatelessWidget {
const MenuDrawer({
@@ -45,9 +46,10 @@ class MenuDrawer extends StatelessWidget {
child: Column(
children: categories.map((category) {
final categoryId = 'category_${category.id}';
final IconData categoryIcon = _iconForCodePoint(
category.iconCodePoint,
);
final IconData categoryIcon =
CategoryStyle.iconForCodePoint(
category.iconCodePoint,
);
return _MenuItemTile(
icon: categoryIcon,
@@ -105,31 +107,6 @@ class MenuDrawer extends StatelessWidget {
}
}
IconData _iconForCodePoint(int? codePoint) {
if (codePoint == null) {
return Icons.folder_outlined;
}
const List<IconData> icons = [
Icons.folder,
Icons.work,
Icons.star,
Icons.home,
Icons.school,
Icons.book,
Icons.music_note,
Icons.lightbulb,
];
for (final IconData icon in icons) {
if (icon.codePoint == codePoint) {
return icon;
}
}
return Icons.folder_outlined;
}
class _MenuItemTile extends StatefulWidget {
const _MenuItemTile({
required this.icon,