Fix invalid categories finally!
This commit is contained in:
@@ -31,7 +31,7 @@ class _CategoriesPageState extends State<CategoriesPage> {
|
||||
),
|
||||
body: Consumer<CategoriesAPI>(builder: (context, categories, child) {
|
||||
return ListView.builder(
|
||||
itemCount: categories.total + 1,
|
||||
itemCount: categories.total,
|
||||
itemBuilder: (context, i) {
|
||||
if (i < categories.total) {
|
||||
Category category = categories.get(i);
|
||||
@@ -42,15 +42,17 @@ class _CategoriesPageState extends State<CategoriesPage> {
|
||||
height: 0,
|
||||
thickness: 2,
|
||||
),
|
||||
category.number == -1
|
||||
category.number < 0
|
||||
? SizedBox.shrink()
|
||||
: CategoryRow(category: category),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return CategoryRow(category: category);
|
||||
}
|
||||
else{
|
||||
print("Huh?");
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -47,29 +47,34 @@ class _DayViewState extends State<DayView> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
void getDayEntry() async{
|
||||
List<Document> entries = database.entries;
|
||||
String formattedDate = formatDate(
|
||||
dateISO: _date.toIso8601String(),
|
||||
format: "yyyy-MM-dd",
|
||||
);
|
||||
|
||||
try {
|
||||
dayEntry = entries.singleWhere((element) => element.$id == formattedDate);
|
||||
String date = formatDate(
|
||||
format: "LLL d", dateISO: dayEntry?.data['date'].toString());
|
||||
print("Got entry for $date");
|
||||
} catch (e) {
|
||||
database.getOne(date: formattedDate).then((value) {
|
||||
dayEntry = value;
|
||||
});
|
||||
dayEntry = entries.last;
|
||||
print("Got entry for ${entries.last.$id}");
|
||||
}
|
||||
// print(entries.length);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
getDayEntry();
|
||||
|
||||
setState(() {
|
||||
if (dayEntry != null) {
|
||||
comments = dayEntry?.data["comments"];
|
||||
String? newComment = dayEntry?.data["comments"];
|
||||
if(newComment == null){
|
||||
newComment = "";
|
||||
}
|
||||
comments = newComment;
|
||||
mood = dayEntry?.data["mood"];
|
||||
}
|
||||
});
|
||||
@@ -512,7 +517,7 @@ class _HourFormFieldState extends State<HourFormField> {
|
||||
}
|
||||
});
|
||||
if (widget.category != null) {
|
||||
catNum = widget.category!.number.toString();
|
||||
catNum = widget.dayEntry!.data['hours'][widget.index].toString();
|
||||
fgColor = widget.category!.foregroundColor;
|
||||
catName = widget.category!.name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user