Skip to content

Commit 3b3042e

Browse files
Merge pull request #79 from owlistic-notes/fix-create-button
Fix create button
2 parents 8148a99 + d99f424 commit 3b3042e

File tree

2 files changed

+72
-20
lines changed

2 files changed

+72
-20
lines changed

src/frontend/lib/screens/home_screen.dart

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:go_router/go_router.dart';
3+
import 'package:owlistic/core/theme.dart';
34
import 'package:owlistic/utils/data_converter.dart';
45
import 'package:provider/provider.dart';
56
import 'package:owlistic/models/user.dart';
@@ -604,7 +605,7 @@ class _HomeScreenState extends State<HomeScreen> {
604605
selectedNotebookId!,
605606
);
606607

607-
Navigator.pop(context);
608+
// Navigator.pop(context);
608609

609610
if (note != null) {
610611
// Navigate to the new note
@@ -624,6 +625,7 @@ class _HomeScreenState extends State<HomeScreen> {
624625
}
625626
}
626627
},
628+
style: AppTheme.getSuccessButtonStyle(),
627629
child: const Text('Create'),
628630
),
629631
],
@@ -634,6 +636,12 @@ class _HomeScreenState extends State<HomeScreen> {
634636
void _showAddTaskDialog(BuildContext context) {
635637
final titleController = TextEditingController();
636638

639+
// Use HomeViewModel for notebooks
640+
final homeViewModel = context.read<HomeViewModel>();
641+
final notes = homeViewModel.recentNotes;
642+
643+
String? selectedNoteId;
644+
637645
showDialog(
638646
context: context,
639647
builder: (ctx) => AlertDialog(
@@ -647,13 +655,44 @@ class _HomeScreenState extends State<HomeScreen> {
647655
shape: RoundedRectangleBorder(
648656
borderRadius: BorderRadius.circular(16),
649657
),
650-
content: TextField(
651-
controller: titleController,
652-
decoration: const InputDecoration(
653-
labelText: 'Task Title',
654-
prefixIcon: Icon(Icons.title),
655-
),
656-
autofocus: true,
658+
content: Column(
659+
mainAxisSize: MainAxisSize.min,
660+
children: [
661+
TextField(
662+
controller: titleController,
663+
decoration: const InputDecoration(
664+
labelText: 'Task Title',
665+
prefixIcon: Icon(Icons.title),
666+
),
667+
autofocus: true,
668+
),
669+
const SizedBox(height: 16),
670+
DropdownButtonFormField<String>(
671+
decoration: const InputDecoration(
672+
labelText: 'Select Note',
673+
prefixIcon: Icon(Icons.book),
674+
),
675+
value: selectedNoteId,
676+
items: [
677+
if (notes.isEmpty)
678+
const DropdownMenuItem(
679+
value: '',
680+
child: Text('No notes available'),
681+
),
682+
...notes.map(
683+
(note) => DropdownMenuItem(
684+
value: note.id,
685+
child: Text(note.title),
686+
),
687+
),
688+
],
689+
onChanged: (value) {
690+
setState(() {
691+
selectedNoteId = value;
692+
});
693+
},
694+
),
695+
],
657696
),
658697
actions: [
659698
TextButton(
@@ -681,6 +720,7 @@ class _HomeScreenState extends State<HomeScreen> {
681720
}
682721
}
683722
},
723+
style: AppTheme.getSuccessButtonStyle(),
684724
child: const Text('Create'),
685725
),
686726
],
@@ -762,6 +802,7 @@ class _HomeScreenState extends State<HomeScreen> {
762802
}
763803
}
764804
},
805+
style: AppTheme.getSuccessButtonStyle(),
765806
child: const Text('Create'),
766807
),
767808
],

src/frontend/lib/screens/notebooks_screen.dart

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:owlistic/core/theme.dart';
23
import 'package:provider/provider.dart';
34
import 'package:owlistic/models/notebook.dart';
45
import 'package:owlistic/models/note.dart';
@@ -105,7 +106,7 @@ class _NotebooksScreenState extends State<NotebooksScreen> {
105106
icon: Icons.book,
106107
title: 'No Notebooks',
107108
message: 'Create your first notebook to start organizing your notes.',
108-
actionLabel: 'Create Notebook',
109+
actionLabel: 'Add Notebook',
109110
onAction: () => _showAddNotebookDialog(context),
110111
);
111112
}
@@ -399,9 +400,7 @@ class _NotebooksScreenState extends State<NotebooksScreen> {
399400
}
400401
}
401402
},
402-
style: ElevatedButton.styleFrom(
403-
backgroundColor: Theme.of(context).primaryColor,
404-
),
403+
style: AppTheme.getSuccessButtonStyle(),
405404
child: const Text('Create'),
406405
),
407406
],
@@ -415,33 +414,44 @@ class _NotebooksScreenState extends State<NotebooksScreen> {
415414

416415
showDialog(
417416
context: context,
418-
builder: (context) => AlertDialog(
419-
title: const Text('Create Notebook'),
417+
builder: (ctx) => AlertDialog(
418+
shape: RoundedRectangleBorder(
419+
borderRadius: BorderRadius.circular(16),
420+
),
421+
title: Row(
422+
children: [
423+
Icon(Icons.create_new_folder, color: Theme.of(context).primaryColor),
424+
const SizedBox(width: 8),
425+
const Text('Add Notebook'),
426+
],
427+
),
420428
content: Column(
421429
mainAxisSize: MainAxisSize.min,
422430
children: [
423431
TextField(
424432
controller: nameController,
425433
decoration: const InputDecoration(
426-
labelText: 'Name',
427-
hintText: 'Enter notebook name',
434+
labelText: 'Notebook Name',
435+
prefixIcon: Icon(Icons.book),
428436
),
429437
autofocus: true,
430438
),
431439
const SizedBox(height: 16),
432440
TextField(
433441
controller: descriptionController,
434442
decoration: const InputDecoration(
435-
labelText: 'Description (optional)',
436-
hintText: 'Enter notebook description',
443+
labelText: 'Description (Optional)',
444+
prefixIcon: Icon(Icons.description),
437445
),
438-
maxLines: 3,
446+
maxLines: 2,
439447
),
440448
],
441449
),
442450
actions: [
443451
TextButton(
444-
onPressed: () => Navigator.pop(context),
452+
onPressed: () {
453+
Navigator.pop(context);
454+
},
445455
child: const Text('Cancel'),
446456
),
447457
ElevatedButton(
@@ -476,6 +486,7 @@ class _NotebooksScreenState extends State<NotebooksScreen> {
476486
}
477487
}
478488
},
489+
style: AppTheme.getSuccessButtonStyle(),
479490
child: const Text('Create'),
480491
),
481492
],

0 commit comments

Comments
 (0)