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;
|
||||
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) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
@ -292,16 +301,59 @@ class _NoteListScreenState extends State<NoteListScreen> {
|
|||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(!widget.showTags ? Icons.tag : Icons.horizontal_rule),
|
||||
onPressed: widget.toggleTags,
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
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(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: ListView.builder(
|
||||
|
|
@ -326,8 +378,8 @@ class _NoteListScreenState extends State<NoteListScreen> {
|
|||
subtitle: widget.showTags && tagSpans.isNotEmpty
|
||||
? RichText(text: TextSpan(style: DefaultTextStyle.of(context).style, children: tagSpans))
|
||||
: null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
onTap: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
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