From 293bd2ce77d4d3101144c35477f46c2411a367dd Mon Sep 17 00:00:00 2001 From: orl0pl <93262125+orl0pl@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:28:26 +0200 Subject: [PATCH] fix: notes broken --- lib/screens/notes.dart | 213 ++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 110 deletions(-) diff --git a/lib/screens/notes.dart b/lib/screens/notes.dart index 9b00fb4..1903234 100644 --- a/lib/screens/notes.dart +++ b/lib/screens/notes.dart @@ -120,117 +120,110 @@ class NotesScreenState extends State { @override Widget build(BuildContext context) { AppLocalizations l = AppLocalizations.of(context); - return SafeArea( - child: Scaffold( - appBar: AppBar( - title: Text(l.notes), - ), - floatingActionButton: FloatingActionButton( - child: const Icon(Icons.add), - onPressed: () async { - await Navigator.of(context) - .push(MaterialPageRoute(builder: (context) { - return const AddScreen( - entryType: EntryType.note, returnToHome: false); - })); - fetchNotes(); - }, - ), - body: Expanded( - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: IntrinsicHeight( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - ...?tags?.map((tag) { - return Row( - children: [ - FilterChip( - label: TagLabel(tag: tag), - selected: selectedTagsIds.contains(tag.tagId), - onSelected: (_) { - setState(() { - if (selectedTagsIds.contains(tag.tagId)) { - selectedTagsIds.remove(tag.tagId); - } else { - selectedTagsIds.add(tag.tagId ?? -1); - } - fetchNotes(); - }); - }), - const SizedBox(width: 8), - ], - ); - }), - const VerticalDivider(), - const SizedBox(width: 8), - ...?places?.map((place) { - return Row( - children: [ - FilterChip( - label: Text(place.name), - selected: - selectedPlacesIds.contains(place.placeId), - onSelected: (_) { - setState(() { - if (selectedPlacesIds - .contains(place.placeId)) { - selectedPlacesIds.remove(place.placeId); - } else { - selectedPlacesIds - .add(place.placeId ?? -1); - } - fetchNotes(); - }); - }), - const SizedBox(width: 8), - ], - ); - }), - ], - ), + return Scaffold( + appBar: AppBar( + title: Text(l.notes), + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.add), + onPressed: () async { + await Navigator.of(context) + .push(MaterialPageRoute(builder: (context) { + return const AddScreen( + entryType: EntryType.note, returnToHome: false); + })); + fetchNotes(); + }, + ), + body: SafeArea( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: IntrinsicHeight( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + ...?tags?.map((tag) { + return Row( + children: [ + FilterChip( + label: TagLabel(tag: tag), + selected: selectedTagsIds.contains(tag.tagId), + onSelected: (_) { + setState(() { + if (selectedTagsIds.contains(tag.tagId)) { + selectedTagsIds.remove(tag.tagId); + } else { + selectedTagsIds.add(tag.tagId ?? -1); + } + fetchNotes(); + }); + }), + const SizedBox(width: 8), + ], + ); + }), + const VerticalDivider(), + const SizedBox(width: 8), + ...?places?.map((place) { + return Row( + children: [ + FilterChip( + label: Text(place.name), + selected: + selectedPlacesIds.contains(place.placeId), + onSelected: (_) { + setState(() { + if (selectedPlacesIds + .contains(place.placeId)) { + selectedPlacesIds.remove(place.placeId); + } else { + selectedPlacesIds + .add(place.placeId ?? -1); + } + fetchNotes(); + }); + }), + const SizedBox(width: 8), + ], + ); + }), + ], ), - )), - const Divider(), - entryList == null - ? const Center(child: CircularProgressIndicator()) - : notes?.isNotEmpty == false - ? Center(child: Text(l.no_notes)) - : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Expanded( - child: ListView.builder( - scrollDirection: Axis.vertical, - itemCount: entryList!.length, - itemBuilder: (context, index) { - if (entryList![index].type == - NotesListViewEntryType.label) { - return Container( - child: entryList![index].label!, - margin: EdgeInsets.only(bottom: 8, top: 16), - ); - } else if (entryList![index].note != null) { - return Container( - margin: const EdgeInsets.only(bottom: 8), - child: NoteWidget( - note: entryList![index].note!, - refresh: () => fetchNotes(), - ), - ); - } else { - return Container(); - } - }, - ), - ), - ) - ]), - ), + ), + )), + const Divider(), + Expanded( + child: entryList == null + ? const Center(child: CircularProgressIndicator()) + : notes?.isNotEmpty == false + ? Center(child: Text(l.no_notes)) + : ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + itemCount: entryList!.length, + itemBuilder: (context, index) { + if (entryList![index].type == + NotesListViewEntryType.label) { + return Container( + child: entryList![index].label!, + margin: EdgeInsets.only(bottom: 8, top: 16), + ); + } else if (entryList![index].note != null) { + return Container( + margin: const EdgeInsets.only(bottom: 8), + child: NoteWidget( + note: entryList![index].note!, + refresh: () => fetchNotes(), + ), + ); + } else { + return Container(); + } + }, + )) + ]), ), ); }