Skip to content

Commit

Permalink
fix: notes broken
Browse files Browse the repository at this point in the history
  • Loading branch information
orl0pl committed Oct 21, 2024
1 parent 0f1e3cf commit 293bd2c
Showing 1 changed file with 103 additions and 110 deletions.
213 changes: 103 additions & 110 deletions lib/screens/notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,117 +120,110 @@ class NotesScreenState extends State<NotesScreen> {
@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();
}
},
))
]),
),
);
}
Expand Down

0 comments on commit 293bd2c

Please sign in to comment.