menu, bugfixes
This commit is contained in:
parent
57732c7242
commit
78f47362cc
1 changed files with 63 additions and 9 deletions
|
|
@ -18,6 +18,15 @@ class _MuzzleVelocityAppState extends State<MuzzleVelocityApp> {
|
||||||
ThemeMode _themeMode = ThemeMode.system;
|
ThemeMode _themeMode = ThemeMode.system;
|
||||||
bool showTags = true;
|
bool showTags = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// Ensure the correct theme mode is set on startup
|
||||||
|
_themeMode = WidgetsBinding.instance.window.platformBrightness == Brightness.dark
|
||||||
|
? ThemeMode.dark
|
||||||
|
: ThemeMode.light;
|
||||||
|
}
|
||||||
|
|
||||||
void _toggleTheme(bool darkMode) {
|
void _toggleTheme(bool darkMode) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -292,15 +301,58 @@ class _NoteListScreenState extends State<NoteListScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
Padding(
|
||||||
icon: Icon(!widget.showTags ? Icons.tag : Icons.horizontal_rule),
|
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
onPressed: widget.toggleTags,
|
child: PopupMenuButton<String>(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.trip_origin,
|
||||||
|
color: Colors.orange
|
||||||
|
), // Menu button (⋮)
|
||||||
|
onSelected: (String value) {
|
||||||
|
switch (value) {
|
||||||
|
case 'Toggle Tags':
|
||||||
|
widget.toggleTags();
|
||||||
|
break;
|
||||||
|
case 'Toggle Theme':
|
||||||
|
setState(() {
|
||||||
|
widget.toggleTheme(!widget.isDarkMode);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'Empty Trash':
|
||||||
|
_confirmEmptyTrash();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) => [
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'Toggle Tags',
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(widget.showTags ? Icons.label_off : Icons.label),
|
||||||
|
title: Text(widget.showTags ? 'Hide Tags' : 'Show Tags'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'Toggle Theme',
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Theme.of(context).brightness == Brightness.dark ? Icons.light_mode : Icons.dark_mode,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
Theme.of(context).brightness == Brightness.dark ? 'Switch to Light Mode' : 'Switch to Dark Mode',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'Empty Trash',
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.delete, color: Colors.redAccent),
|
||||||
|
title: Text('Empty Trash', style: TextStyle(color: Colors.redAccent)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: IconButton(
|
),
|
||||||
icon: Icon(!widget.isDarkMode ? Icons.dark_mode : Icons.light_mode),
|
],
|
||||||
onPressed: () => widget.toggleTheme(!widget.isDarkMode),
|
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
|
@ -326,8 +378,8 @@ class _NoteListScreenState extends State<NoteListScreen> {
|
||||||
subtitle: widget.showTags && tagSpans.isNotEmpty
|
subtitle: widget.showTags && tagSpans.isNotEmpty
|
||||||
? RichText(text: TextSpan(style: DefaultTextStyle.of(context).style, children: tagSpans))
|
? RichText(text: TextSpan(style: DefaultTextStyle.of(context).style, children: tagSpans))
|
||||||
: null,
|
: null,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => NoteEditorScreen(
|
builder: (context) => NoteEditorScreen(
|
||||||
|
|
@ -336,6 +388,8 @@ class _NoteListScreenState extends State<NoteListScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
_loadNotes(); // 🔄 Reload notes after returning
|
||||||
|
setState(() {}); // 🔄 Force UI refresh
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue