feat: Refactor note editor dialog and delete confirmation for improved readability and reusability
This commit is contained in:
@@ -45,12 +45,9 @@ class MenuDrawer extends StatelessWidget {
|
||||
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',
|
||||
);
|
||||
final IconData categoryIcon = _iconForCodePoint(
|
||||
category.iconCodePoint,
|
||||
);
|
||||
|
||||
return _MenuItemTile(
|
||||
icon: categoryIcon,
|
||||
@@ -102,6 +99,31 @@ 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 StatelessWidget {
|
||||
const _MenuItemTile({
|
||||
required this.icon,
|
||||
@@ -136,7 +158,7 @@ class _MenuItemTile extends StatelessWidget {
|
||||
top: 2,
|
||||
bottom: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
child: Material(
|
||||
color: backgroundColor,
|
||||
borderRadius: selected
|
||||
? const BorderRadius.only(
|
||||
@@ -144,16 +166,17 @@ class _MenuItemTile extends StatelessWidget {
|
||||
bottomRight: Radius.circular(999),
|
||||
)
|
||||
: BorderRadius.circular(12),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: Icon(icon, color: iconColor ?? foregroundColor),
|
||||
trailing: trailing,
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(color: textColor ?? foregroundColor, fontSize: 14),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ListTile(
|
||||
leading: Icon(icon, color: iconColor ?? foregroundColor),
|
||||
trailing: trailing,
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(color: textColor ?? foregroundColor, fontSize: 14),
|
||||
),
|
||||
onTap: onTap,
|
||||
hoverColor: Colors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
onTap: onTap,
|
||||
hoverColor: Colors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user