feat: Introduce category selection functionality in NoteEditorScreen and related components
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:notas/models/note.dart';
|
||||
import 'package:notas/screens/note_editor_screen.dart';
|
||||
import 'package:notas/models/category.dart';
|
||||
import 'package:notas/widgets/menu_drawer.dart';
|
||||
import 'package:notas/widgets/category_style.dart';
|
||||
import 'package:notas/widgets/note_card.dart';
|
||||
import 'package:notas/widgets/search_app_bar.dart';
|
||||
import 'package:notas/widgets/sync_status.dart';
|
||||
@@ -148,6 +149,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final dynamic result = await NoteEditorScreen.showDialog(
|
||||
context,
|
||||
categoryId: _showDeletedNotes ? null : _selectedCategoryId,
|
||||
categories: _categories,
|
||||
);
|
||||
|
||||
if (result == null) {
|
||||
@@ -199,6 +201,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final dynamic result = await NoteEditorScreen.showDialog(
|
||||
context,
|
||||
note: note,
|
||||
categories: _categories,
|
||||
);
|
||||
|
||||
if (result == null) {
|
||||
@@ -786,28 +789,6 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
IconData? _selectedIcon;
|
||||
int _selectedSection = 0;
|
||||
|
||||
final List<Color> _palette = [
|
||||
Colors.amber,
|
||||
Colors.blue,
|
||||
Colors.green,
|
||||
Colors.purple,
|
||||
Colors.red,
|
||||
Colors.teal,
|
||||
Colors.orange,
|
||||
Colors.grey,
|
||||
];
|
||||
|
||||
final List<IconData> _icons = [
|
||||
Icons.folder,
|
||||
Icons.work,
|
||||
Icons.star,
|
||||
Icons.home,
|
||||
Icons.school,
|
||||
Icons.book,
|
||||
Icons.music_note,
|
||||
Icons.lightbulb,
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -817,9 +798,9 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
? Color(widget.category!.colorValue!)
|
||||
: null;
|
||||
if (widget.category != null && widget.category!.iconCodePoint != null) {
|
||||
_selectedIcon = _icons.firstWhere(
|
||||
_selectedIcon = CategoryStyle.icons.firstWhere(
|
||||
(IconData icon) => icon.codePoint == widget.category!.iconCodePoint,
|
||||
orElse: () => _icons.first,
|
||||
orElse: () => CategoryStyle.icons.first,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -977,7 +958,7 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
key: const ValueKey<String>('colors'),
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: _palette.map((Color color) {
|
||||
children: CategoryStyle.colors.map((Color color) {
|
||||
final bool isSelected =
|
||||
_selectedColor?.value == color.value;
|
||||
return GestureDetector(
|
||||
@@ -1009,7 +990,7 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
key: const ValueKey<String>('icons'),
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: _icons.map((IconData icon) {
|
||||
children: CategoryStyle.icons.map((IconData icon) {
|
||||
final bool isSelected = _selectedIcon == icon;
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() {
|
||||
|
||||
Reference in New Issue
Block a user