refactor models, fix active events view, add basal and bolus profiles to events

This commit is contained in:
spinel 2021-11-27 00:01:12 +01:00
parent f0f8898627
commit 5c22fc0083
35 changed files with 1093 additions and 417 deletions

38
TODO
View File

@ -1,42 +1,37 @@
MAIN TASKS: MAIN TASKS:
General/Framework: General/Framework:
☐ add deleted flag to all data models
☐ adjust remove and fetch methods accordingly
☐ find a general way to deal with duration fields ☐ find a general way to deal with duration fields
☐ implement tostring methods for all models
Accuracies: Accuracies:
☐ implement reordering ☐ implement reordering
Basal/Bolus: Basal/Bolus:
☐ create distinct visual mode for picking the active profile (or remove active flag) ☐ replace active profile picking mode with simple dropdown
☐ indicate both the default rate and the currently active one (according to event)
Log Overview: Log Overview:
☐ add active events view (as main menu item?)
☐ adjust/debug active events view
☐ display more information ☐ display more information
☐ apply target color settings to glucose ☐ apply target color settings to glucose
☐ total bolus and carbs per entry ☐ total bolus and carbs per entry
Log Entry: Log Entry:
☐ replace meal and glucose boli with logbolus entities ☐ replace meal and glucose boli with logbolus entities
☐ check for multiple active events with temporary basal/bolus profiles ☐ check for multiple active events with temporary basal/bolus profiles (smallest covered time frame counts)
☐ provide splitting functionality for overlapping events
Event Types: Event Types:
☐ add option to change bolus/basal profile for event duration (dropdown with detail option) ☐ implement reminders as push notifications
☐ add reminder option
☐ implement reminders as push notification
Settings: Settings:
☐ add objectbox class and use instead of shared preferences ☐ add objectbox class and use instead of shared preferences
☐ add fields for date and time formats ☐ add fields for preferred date and time formats
☐ add fields for glucose target ☐ add fields for glucose target (as map of cutoff glucose and colors)
☐ add option to hide warning dialogs on cancel ☐ add option to hide warning dialogs on cancel or event stop
☐ add option to hide extra customization options (ie. changing pre calculated values)
☐ add setting for decimal places
FUTURE TASKS: FUTURE TASKS:
General/Framework: General/Framework:
☐ make all fields readonly if user somehow gets to a deleted record detail view
☐ add functionality to delete dead records
☐ clean up controllers (dispose method of each stateful widget) ☐ clean up controllers (dispose method of each stateful widget)
☐ add explanations to each section ☐ add explanations to each section
☐ account for deleted/disabled elements in dropdowns ☐ account for deleted/disabled elements in dropdowns
@ -44,9 +39,20 @@ FUTURE TASKS:
☐ add clear button to dropdown (or all text fields?) ☐ add clear button to dropdown (or all text fields?)
Log Overview: Log Overview:
☐ add pagination ☐ add pagination
Event Types:
☐ add colors as indicators for log entries (and later graphs in reports)
Settings:
☐ add option to hide extra customization options (ie. changing pre calculated values)
☐ add setting for decimal places
Archive: Archive:
✔ adjust/debug active events view @done(21-11-26 22:54) @project(MAIN TASKS.Log Overview)
✔ show all active events, not just those assigned to the entry @done(21-11-26 22:12) @project(MAIN TASKS.Log Entry)
✔ add active events view (as main menu item) @done(21-11-26 21:28) @project(MAIN TASKS.Log Overview)
✔ add option to change bolus/basal profile for event duration @done(21-11-26 21:13) @project(MAIN TASKS.Event Types)
✔ add deleted flag to all data models @done(21-11-26 18:56) @project(MAIN TASKS.General/Framework)
✔ adjust remove and fetch methods accordingly @done(21-11-26 20:52) @project(MAIN TASKS.General/Framework)
✔ implement tostring methods for all models @done(21-11-26 20:52) @project(MAIN TASKS.General/Framework)
✔ fix logmeals/logboli/logevents @done(21-11-25 17:10) @project(MAIN TASKS.Log Entry) ✔ fix logmeals/logboli/logevents @done(21-11-25 17:10) @project(MAIN TASKS.Log Entry)
✔ add tab for bolus overview @done(21-11-24 22:05) @project(MAIN TASKS.Log Entry) ✔ add tab for bolus overview @done(21-11-24 22:05) @project(MAIN TASKS.Log Entry)
✔ calculate bolus suggestions according to active profile @done(21-11-24 22:05) @project(MAIN TASKS.Log Entry) ✔ calculate bolus suggestions according to active profile @done(21-11-24 22:05) @project(MAIN TASKS.Log Entry)

View File

@ -5,7 +5,6 @@ class AutoCompleteDropdownButton<T> extends StatefulWidget {
final String label; final String label;
final T? selectedItem; final T? selectedItem;
final List<T> items; final List<T> items;
final String Function(T item) renderItem;
final void Function(T? value) onChanged; final void Function(T? value) onChanged;
final List<T> Function(String? value)? applyQuery; final List<T> Function(String? value)? applyQuery;
@ -14,7 +13,6 @@ class AutoCompleteDropdownButton<T> extends StatefulWidget {
this.selectedItem, this.selectedItem,
required this.label, required this.label,
required this.items, required this.items,
required this.renderItem,
required this.onChanged, required this.onChanged,
this.applyQuery}) this.applyQuery})
: super(key: key); : super(key: key);
@ -40,7 +38,7 @@ class _AutoCompleteDropdownButtonState<T>
setState(() { setState(() {
controller.text = widget.selectedItem == null controller.text = widget.selectedItem == null
? '' ? ''
: widget.renderItem(widget.selectedItem!); : widget.selectedItem!.toString();
options = widget.items; options = widget.items;
suggestions = []; suggestions = [];
}); });
@ -81,8 +79,8 @@ class _AutoCompleteDropdownButtonState<T>
items.addAll(options items.addAll(options
.where((item) => .where((item) =>
!(widget.selectedItem != null && !(widget.selectedItem != null &&
widget.renderItem(item) == item.toString() ==
widget.renderItem(widget.selectedItem!)) && widget.selectedItem!.toString()) &&
!suggestions.contains(item)) !suggestions.contains(item))
.map((item) => buildListTile(item)) .map((item) => buildListTile(item))
.toList()); .toList());
@ -132,7 +130,7 @@ class _AutoCompleteDropdownButtonState<T>
title: Row( title: Row(
children: [ children: [
Expanded( Expanded(
child: Text(widget.renderItem(item)), child: Text(item.toString()),
), ),
], ],
), ),
@ -147,14 +145,14 @@ class _AutoCompleteDropdownButtonState<T>
void handleChanged(item) { void handleChanged(item) {
widget.onChanged(item); widget.onChanged(item);
controller.text = widget.renderItem(item); controller.text = item.toString();
hideOverlay(); hideOverlay();
} }
void onChangeQuery(String value) { void onChangeQuery(String value) {
if (value.trim() == '' || if (value.trim() == '' ||
(widget.selectedItem != null && (widget.selectedItem != null &&
value == widget.renderItem(widget.selectedItem!))) { value == widget.selectedItem!.toString())) {
setState(() { setState(() {
suggestions = []; suggestions = [];
}); });
@ -162,7 +160,7 @@ class _AutoCompleteDropdownButtonState<T>
if (widget.applyQuery == null) { if (widget.applyQuery == null) {
setState(() { setState(() {
suggestions = widget.items.where((item) { suggestions = widget.items.where((item) {
String itemString = widget.renderItem(item).toLowerCase(); String itemString = item.toString().toLowerCase();
String valueLowercase = value.toLowerCase(); String valueLowercase = value.toLowerCase();
return itemString.contains(valueLowercase); return itemString.contains(valueLowercase);
}).toList(); }).toList();

View File

@ -3,6 +3,7 @@ import 'package:diameter/object_box.dart';
import 'package:diameter/screens/accuracy_detail.dart'; import 'package:diameter/screens/accuracy_detail.dart';
import 'package:diameter/screens/basal/basal_profile_detail.dart'; import 'package:diameter/screens/basal/basal_profile_detail.dart';
import 'package:diameter/screens/bolus/bolus_profile_detail.dart'; import 'package:diameter/screens/bolus/bolus_profile_detail.dart';
import 'package:diameter/screens/log/active_log_event_list.dart';
import 'package:diameter/screens/log/log.dart'; import 'package:diameter/screens/log/log.dart';
import 'package:diameter/screens/log/log_entry/log_entry.dart'; import 'package:diameter/screens/log/log_entry/log_entry.dart';
import 'package:diameter/screens/log/log_entry/log_event_detail.dart'; import 'package:diameter/screens/log/log_entry/log_event_detail.dart';
@ -54,6 +55,7 @@ Future<void> main() async {
Routes.logEvent: (context) => const LogEventDetailScreen(), Routes.logEvent: (context) => const LogEventDetailScreen(),
Routes.logEventTypes: (context) => const LogEventTypeListScreen(), Routes.logEventTypes: (context) => const LogEventTypeListScreen(),
Routes.logEventType: (context) => const LogEventTypeDetailScreen(), Routes.logEventType: (context) => const LogEventTypeDetailScreen(),
Routes.activeEvents: (context) => const ActiveEventListScreen(),
Routes.accuracies: (context) => const AccuracyListScreen(), Routes.accuracies: (context) => const AccuracyListScreen(),
Routes.accuracy: (context) => const AccuracyDetailScreen(), Routes.accuracy: (context) => const AccuracyDetailScreen(),
Routes.meals: (context) => const MealListScreen(), Routes.meals: (context) => const MealListScreen(),

View File

@ -1,21 +1,24 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/objectbox.g.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show Accuracy_;
@Entity(uid: 291512798403320400) @Entity(uid: 291512798403320400)
class Accuracy { class Accuracy {
static final Box<Accuracy> box = objectBox.store.box<Accuracy>(); static final Box<Accuracy> box = objectBox.store.box<Accuracy>();
// properties
int id; int id;
bool deleted;
String value; String value;
bool forCarbsRatio; bool forCarbsRatio;
bool forPortionSize; bool forPortionSize;
int? confidenceRating; int? confidenceRating;
String? notes; String? notes;
// constructor
Accuracy({ Accuracy({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.forCarbsRatio = false, this.forCarbsRatio = false,
this.forPortionSize = false, this.forPortionSize = false,
@ -23,25 +26,41 @@ class Accuracy {
this.notes, this.notes,
}); });
// methods
static Accuracy? get(int id) => box.get(id); static Accuracy? get(int id) => box.get(id);
static void put(Accuracy accuracy) => box.put(accuracy);
static List<Accuracy> getAll() { static List<Accuracy> getAll() {
QueryBuilder<Accuracy> all = box.query()..order(Accuracy_.confidenceRating); QueryBuilder<Accuracy> all = box
.query(Accuracy_.deleted.equals(false))
..order(Accuracy_.confidenceRating);
return all.build().find(); return all.build().find();
} }
static void put(Accuracy accuracy) => box.put(accuracy);
static void remove(int id) => box.remove(id); static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static List<Accuracy> getAllForPortionSize() { static List<Accuracy> getAllForPortionSize() {
QueryBuilder<Accuracy> allForPortionSize = box QueryBuilder<Accuracy> allForPortionSize = box
.query(Accuracy_.forPortionSize.equals(true)) .query(Accuracy_.forPortionSize.equals(true) & Accuracy_.deleted.equals(false))
..order(Accuracy_.confidenceRating); ..order(Accuracy_.confidenceRating);
return allForPortionSize.build().find(); return allForPortionSize.build().find();
} }
static List<Accuracy> getAllForCarbsRatio() { static List<Accuracy> getAllForCarbsRatio() {
QueryBuilder<Accuracy> allForCarbsRatio = box QueryBuilder<Accuracy> allForCarbsRatio = box
.query(Accuracy_.forCarbsRatio.equals(true)) .query(Accuracy_.forCarbsRatio.equals(true) & Accuracy_.deleted.equals(false))
..order(Accuracy_.confidenceRating); ..order(Accuracy_.confidenceRating);
return allForCarbsRatio.build().find(); return allForCarbsRatio.build().find();
} }
@override
String toString() {
return value;
}
} }

View File

@ -1,39 +1,55 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/models/basal_profile.dart'; import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/objectbox.g.dart'; import 'package:diameter/utils/date_time_utils.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show Basal_, BasalProfile_;
@Entity(uid: 1467758525778521891) @Entity(uid: 1467758525778521891)
class Basal { class Basal {
static final Box<Basal> box = objectBox.store.box<Basal>(); static final Box<Basal> box = objectBox.store.box<Basal>();
// properties
int id; int id;
bool deleted;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime startTime; DateTime startTime;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime endTime; DateTime endTime;
double units; double units;
// relations
final basalProfile = ToOne<BasalProfile>(); final basalProfile = ToOne<BasalProfile>();
// constructor
Basal({ Basal({
this.id = 0, this.id = 0,
this.deleted = false,
required this.startTime, required this.startTime,
required this.endTime, required this.endTime,
this.units = 0, this.units = 0,
}); });
// methods
static Basal? get(int id) => box.get(id); static Basal? get(int id) => box.get(id);
static void put(Basal basal) => box.put(basal); static void put(Basal basal) => box.put(basal);
static void remove(int id) => box.remove(id);
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static List<Basal> getAllForProfile(int id) { static List<Basal> getAllForProfile(int id) {
QueryBuilder<Basal> builder = box.query()..order(Basal_.startTime); QueryBuilder<Basal> builder = box.query(Basal_.deleted.equals(false))
..order(Basal_.startTime);
builder.link(Basal_.basalProfile, BasalProfile_.id.equals(id)); builder.link(Basal_.basalProfile, BasalProfile_.id.equals(id));
return builder.build().find(); return builder.build().find();
} }
@override
String toString() {
return DateTimeUtils.displayTime(startTime);
}
} }

View File

@ -1,39 +1,59 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/objectbox.g.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show BasalProfile_;
@Entity(uid: 3613736032926903785) @Entity(uid: 3613736032926903785)
class BasalProfile { class BasalProfile {
static final Box<BasalProfile> box = objectBox.store.box<BasalProfile>(); static final Box<BasalProfile> box = objectBox.store.box<BasalProfile>();
// properties
int id; int id;
bool deleted;
String name; String name;
bool active; bool active;
String? notes; String? notes;
// constructor
BasalProfile({ BasalProfile({
this.id = 0, this.id = 0,
this.deleted = false,
this.name = '', this.name = '',
this.active = false, this.active = false,
this.notes, this.notes,
}); });
// methods
static BasalProfile? get(int id) => box.get(id); static BasalProfile? get(int id) => box.get(id);
static List<BasalProfile> getAll() => box.getAll();
static void put(BasalProfile basalProfile) => box.put(basalProfile); static void put(BasalProfile basalProfile) => box.put(basalProfile);
static void remove(int id) => box.remove(id);
static List<BasalProfile> getAll() {
QueryBuilder<BasalProfile> all = box.query(BasalProfile_.deleted.equals(false));
return all.build().find();
}
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static int activeCount() { static int activeCount() {
Query<BasalProfile> query = Query<BasalProfile> query = box
box.query(BasalProfile_.active.equals(true)).build(); .query(BasalProfile_.active.equals(true) & BasalProfile_.deleted.equals(false)).build();
return query.find().length; return query.find().length;
} }
static void setAllInactive() { static void setAllInactive() {
box.putMany(box.getAll().map((element) { box.putMany(box.getAll().map((item) {
element.active = false; item.active = false;
return element; return item;
}).toList()); }).toList());
} }
@override
String toString() {
return name;
}
} }

View File

@ -1,17 +1,19 @@
import 'package:diameter/config.dart'; import 'package:diameter/config.dart';
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/models/bolus_profile.dart'; import 'package:diameter/models/bolus_profile.dart';
import 'package:diameter/objectbox.g.dart'; import 'package:diameter/models/log_event.dart';
import 'package:diameter/utils/date_time_utils.dart'; import 'package:diameter/utils/date_time_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show Bolus_, BolusProfile_;
@Entity(uid: 3417770529060202389) @Entity(uid: 3417770529060202389)
class Bolus { class Bolus {
static final Box<Bolus> box = objectBox.store.box<Bolus>(); static final Box<Bolus> box = objectBox.store.box<Bolus>();
// properties
int id; int id;
bool deleted;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime startTime; DateTime startTime;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
@ -21,10 +23,13 @@ class Bolus {
int? mgPerDl; int? mgPerDl;
double? mmolPerL; double? mmolPerL;
// relations
final bolusProfile = ToOne<BolusProfile>(); final bolusProfile = ToOne<BolusProfile>();
// constructor
Bolus({ Bolus({
this.id = 0, this.id = 0,
this.deleted = false,
required this.startTime, required this.startTime,
required this.endTime, required this.endTime,
this.units = 0, this.units = 0,
@ -33,21 +38,28 @@ class Bolus {
this.mmolPerL, this.mmolPerL,
}); });
// methods
static Bolus? get(int id) => box.get(id); static Bolus? get(int id) => box.get(id);
static void put(Bolus bolus) => box.put(bolus); static void put(Bolus bolus) => box.put(bolus);
static void remove(int id) => box.remove(id);
static List<Bolus> getAllForProfile(int id) { static List<Bolus> getAllForProfile(int id) {
QueryBuilder<Bolus> builder = box.query()..order(Bolus_.startTime); QueryBuilder<Bolus> builder = box.query(Bolus_.deleted.equals(false))
..order(Bolus_.startTime);
builder.link(Bolus_.bolusProfile, BolusProfile_.id.equals(id)); builder.link(Bolus_.bolusProfile, BolusProfile_.id.equals(id));
return builder.build().find(); return builder.build().find();
} }
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static Bolus? getRateForTime(DateTime? dateTime) { static Bolus? getRateForTime(DateTime? dateTime) {
if (dateTime != null) { if (dateTime != null) {
// ignore: todo final bolusProfile = BolusProfile.getActive(dateTime);
// TODO: check if an event is active that would change the active profile
final bolusProfile = BolusProfile.getActive();
final time = DateTimeUtils.convertTimeOfDayToDateTime( final time = DateTimeUtils.convertTimeOfDayToDateTime(
TimeOfDay.fromDateTime(dateTime)); TimeOfDay.fromDateTime(dateTime));
if (bolusProfile != null) { if (bolusProfile != null) {
@ -62,7 +74,12 @@ class Bolus {
}); });
return result.length != 1 ? null : result.single; return result.length != 1 ? null : result.single;
} }
return null;
} }
return null;
}
@override
String toString() {
return DateTimeUtils.displayTime(startTime);
} }
} }

View File

@ -1,32 +1,52 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/objectbox.g.dart'; import 'package:diameter/models/log_event.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show BolusProfile_;
@Entity(uid: 8812452529027052317) @Entity(uid: 8812452529027052317)
class BolusProfile { class BolusProfile {
static final Box<BolusProfile> box = objectBox.store.box<BolusProfile>(); static final Box<BolusProfile> box = objectBox.store.box<BolusProfile>();
// properties
int id; int id;
bool deleted;
String name; String name;
bool active; bool active;
String? notes; String? notes;
// constructor
BolusProfile({ BolusProfile({
this.id = 0, this.id = 0,
this.deleted = false,
this.name = '', this.name = '',
this.active = false, this.active = false,
this.notes, this.notes,
}); });
// methods
static BolusProfile? get(int id) => box.get(id); static BolusProfile? get(int id) => box.get(id);
static List<BolusProfile> getAll() => box.getAll();
static void put(BolusProfile bolusProfile) => box.put(bolusProfile); static void put(BolusProfile bolusProfile) => box.put(bolusProfile);
static void remove(int id) => box.remove(id);
static List<BolusProfile> getAll() {
QueryBuilder<BolusProfile> all =
box.query(BolusProfile_.deleted.equals(false));
return all.build().find();
}
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static int activeCount() { static int activeCount() {
Query<BolusProfile> query = Query<BolusProfile> query = box
box.query(BolusProfile_.active.equals(true)).build(); .query(BolusProfile_.active
.equals(true)
.and(BolusProfile_.deleted.equals(false)))
.build();
return query.find().length; return query.find().length;
} }
@ -37,10 +57,33 @@ class BolusProfile {
}).toList()); }).toList());
} }
static BolusProfile? getActive() { static BolusProfile? getActive(DateTime? dateTime) {
Query<BolusProfile> query = if (dateTime != null) {
box.query(BolusProfile_.active.equals(true)).build(); List<LogEvent> activeEvents = LogEvent.getAllActiveForTime(dateTime)
.where((event) => event.bolusProfile.target != null).toList();
if (activeEvents.length > 1) {
final now = DateTime.now();
activeEvents =
activeEvents.where((item) => !activeEvents.any((other) =>
item.time.isBefore(other.time) || (item.endTime ?? now).isAfter(other.endTime ?? now)
)).toList();
}
if (activeEvents.length == 1) {
return activeEvents.single.bolusProfile.target;
}
}
Query<BolusProfile> query = box
.query(BolusProfile_.active
.equals(true)
.and(BolusProfile_.deleted.equals(false)))
.build();
final result = query.find(); final result = query.find();
return result.length != 1 ? null : result.single; return result.length != 1 ? null : result.single;
} }
@override
String toString() {
return name;
}
} }

View File

@ -2,14 +2,16 @@ import 'package:diameter/main.dart';
import 'package:diameter/models/bolus.dart'; import 'package:diameter/models/bolus.dart';
import 'package:diameter/models/log_entry.dart'; import 'package:diameter/models/log_entry.dart';
import 'package:diameter/models/log_meal.dart'; import 'package:diameter/models/log_meal.dart';
import 'package:diameter/objectbox.g.dart';
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show LogBolus_, LogEntry_;
@Entity(uid: 8033487006694871160) @Entity(uid: 8033487006694871160)
class LogBolus { class LogBolus {
static final Box<LogBolus> box = objectBox.store.box<LogBolus>(); static final Box<LogBolus> box = objectBox.store.box<LogBolus>();
// properties
int id; int id;
bool deleted;
double units; double units;
double? carbs; double? carbs;
int? delay; int? delay;
@ -18,12 +20,15 @@ class LogBolus {
bool setManually; bool setManually;
String? notes; String? notes;
// relations
final logEntry = ToOne<LogEntry>(); final logEntry = ToOne<LogEntry>();
final rate = ToOne<Bolus>(); final rate = ToOne<Bolus>();
final meal = ToOne<LogMeal?>(); final meal = ToOne<LogMeal?>();
// constructor
LogBolus({ LogBolus({
this.id = 0, this.id = 0,
this.deleted = false,
this.units = 0, this.units = 0,
this.carbs, this.carbs,
this.delay, this.delay,
@ -33,7 +38,26 @@ class LogBolus {
this.notes, this.notes,
}); });
// methods
static LogBolus? get(int id) => box.get(id); static LogBolus? get(int id) => box.get(id);
static void put(LogBolus logBolus) => box.put(logBolus); static void put(LogBolus logBolus) => box.put(logBolus);
static void remove(int id) => box.remove(id);
static List<LogBolus> getAllForEntry(int id) {
QueryBuilder<LogBolus> builder = box.query(LogBolus_.deleted.equals(false));
builder.link(LogBolus_.logEntry, LogEntry_.id.equals(id));
return builder.build().find();
}
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return units.toString();
}
} }

View File

@ -1,20 +1,17 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/models/log_bolus.dart'; import 'package:diameter/utils/date_time_utils.dart';
import 'package:diameter/models/log_event.dart';
import 'package:diameter/models/log_meal.dart';
import 'package:diameter/objectbox.g.dart';
// ignore: unnecessary_import
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show LogEntry_;
@Entity(uid: 752131069307970560) @Entity(uid: 752131069307970560)
class LogEntry { class LogEntry {
static final Box<LogEntry> box = objectBox.store.box<LogEntry>(); static final Box<LogEntry> box = objectBox.store.box<LogEntry>();
// properties
int id; int id;
bool deleted;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime time; DateTime time;
int? mgPerDl; int? mgPerDl;
double? mmolPerL; double? mmolPerL;
double? bolusGlucose; double? bolusGlucose;
@ -22,20 +19,10 @@ class LogEntry {
double? delayedBolusRate; double? delayedBolusRate;
String? notes; String? notes;
@Backlink('logEntry') // constructor
final events = ToMany<LogEvent>();
@Backlink('endLogEntry')
final endedEvents = ToMany<LogEvent>();
@Backlink('logEntry')
final meals = ToMany<LogMeal>();
@Backlink('logEntry')
final boli = ToMany<LogBolus>();
LogEntry({ LogEntry({
this.id = 0, this.id = 0,
this.deleted = false,
required this.time, required this.time,
this.mgPerDl, this.mgPerDl,
this.mmolPerL, this.mmolPerL,
@ -45,15 +32,23 @@ class LogEntry {
this.notes, this.notes,
}); });
static LogEntry? get(int id) => box.get(id); // methods
static LogEntry? get(int id) => id == 0 ? null : box.get(id);
static List<LogEntry> getAll() => box.getAll(); static List<LogEntry> getAll() => box.getAll();
static void put(LogEntry logEntry) => box.put(logEntry); static void put(LogEntry logEntry) => box.put(logEntry);
static void remove(int id) => box.remove(id);
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static Map<DateTime, List<LogEntry>> getDailyEntryMap() { static Map<DateTime, List<LogEntry>> getDailyEntryMap() {
Map<DateTime, List<LogEntry>> dateMap = <DateTime, List<LogEntry>>{}; Map<DateTime, List<LogEntry>> dateMap = <DateTime, List<LogEntry>>{};
QueryBuilder<LogEntry> allByDate = box.query() QueryBuilder<LogEntry> allByDate = box.query(LogEntry_.deleted.equals(false))
..order(LogEntry_.time, flags: Order.descending); ..order(LogEntry_.time, flags: Order.descending);
List<LogEntry> entries = allByDate.build().find(); List<LogEntry> entries = allByDate.build().find();
DateTime? date; DateTime? date;
@ -65,4 +60,10 @@ class LogEntry {
return dateMap; return dateMap;
} }
@override
String toString() {
return DateTimeUtils.displayDateTime(time);
}
} }

View File

@ -1,4 +1,6 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/models/bolus_profile.dart';
import 'package:diameter/models/log_entry.dart'; import 'package:diameter/models/log_entry.dart';
import 'package:diameter/models/log_event_type.dart'; import 'package:diameter/models/log_event_type.dart';
import 'package:diameter/objectbox.g.dart'; import 'package:diameter/objectbox.g.dart';
@ -9,37 +11,85 @@ import 'package:objectbox/objectbox.dart';
class LogEvent { class LogEvent {
static final Box<LogEvent> box = objectBox.store.box<LogEvent>(); static final Box<LogEvent> box = objectBox.store.box<LogEvent>();
// properties
int id; int id;
bool deleted;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime time; DateTime time;
@Property(type: PropertyType.date) @Property(type: PropertyType.date)
DateTime? endTime; DateTime? endTime;
bool hasEndTime; bool hasEndTime;
int? reminderDuration;
String? notes; String? notes;
// relations
final logEntry = ToOne<LogEntry>(); final logEntry = ToOne<LogEntry>();
final endLogEntry = ToOne<LogEntry>(); final endLogEntry = ToOne<LogEntry>();
final eventType = ToOne<LogEventType>(); final eventType = ToOne<LogEventType>();
final bolusProfile = ToOne<BolusProfile>();
final basalProfile = ToOne<BasalProfile>();
// constructor
LogEvent({ LogEvent({
this.id = 0, this.id = 0,
this.deleted = false,
required this.time, required this.time,
this.endTime, this.endTime,
this.hasEndTime = false, this.hasEndTime = false,
this.reminderDuration,
this.notes, this.notes,
}); });
// methods
static LogEvent? get(int id) => box.get(id); static LogEvent? get(int id) => box.get(id);
static List<LogEvent> getAll() => box.getAll();
static void put(LogEvent logEvent) => box.put(logEvent); static void put(LogEvent logEvent) => box.put(logEvent);
static void remove(int id) => box.remove(id);
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static List<LogEvent> getAllOngoing() { static List<LogEvent> getAllOngoing() {
QueryBuilder<LogEvent> query = QueryBuilder<LogEvent> query = box.query(LogEvent_.hasEndTime.equals(true) &
box.query(LogEvent_.hasEndTime.equals(true) & LogEvent_.endTime.isNull())..order(LogEvent_.time); LogEvent_.endTime.isNull() &
LogEvent_.deleted.equals(false))
..order(LogEvent_.time);
return query.build().find(); return query.build().find();
} }
static List<LogEvent> getAllActiveForTime(DateTime? dateTime) {
if (dateTime != null) {
QueryBuilder<LogEvent> builder = box.query(
LogEvent_.hasEndTime.equals(true) & LogEvent_.deleted.equals(false))
..order(LogEvent_.time);
final eventsWithEndTime = builder.build().find();
return eventsWithEndTime.where((event) {
return (!dateTime.isBefore(event.time)) &&
!dateTime.isAfter(event.endTime ?? DateTime.now());
}).toList();
}
return [];
}
static List<LogEvent> getAllForEntry(int id) {
QueryBuilder<LogEvent> builder = box.query(LogEvent_.deleted.equals(false))
..order(LogEvent_.time);
builder.link(LogEvent_.logEntry, LogEntry_.id.equals(id));
return builder.build().find();
}
static List<LogEvent> getAllEndedByEntry(int id) {
QueryBuilder<LogEvent> builder = box.query(LogEvent_.deleted.equals(false))
..order(LogEvent_.time);
builder.link(LogEvent_.endLogEntry, LogEntry_.id.equals(id));
return builder.build().find();
}
@override
String toString() {
return eventType.target?.value ?? '';
}
} }

View File

@ -1,26 +1,54 @@
import 'package:diameter/main.dart'; import 'package:diameter/main.dart';
import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/models/bolus_profile.dart';
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show LogEventType_;
@Entity(uid: 8362795406595606110) @Entity(uid: 8362795406595606110)
class LogEventType { class LogEventType {
static final Box<LogEventType> box = objectBox.store.box<LogEventType>(); static final Box<LogEventType> box = objectBox.store.box<LogEventType>();
// properties
int id; int id;
bool deleted;
String value; String value;
bool hasEndTime; bool hasEndTime;
int? defaultReminderDuration; int? defaultReminderDuration;
String? notes; String? notes;
// constructor
LogEventType({ LogEventType({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.hasEndTime = false, this.hasEndTime = false,
this.defaultReminderDuration, this.defaultReminderDuration,
this.notes, this.notes,
}); });
// relations
final bolusProfile = ToOne<BolusProfile>();
final basalProfile = ToOne<BasalProfile>();
// methods
static LogEventType? get(int id) => box.get(id); static LogEventType? get(int id) => box.get(id);
static List<LogEventType> getAll() => box.getAll();
static void put(LogEventType logEventType) => box.put(logEventType); static void put(LogEventType logEventType) => box.put(logEventType);
static void remove(int id) => box.remove(id);
static List<LogEventType> getAll() {
QueryBuilder<LogEventType> builder = box.query(LogEventType_.deleted.equals(false))..order(LogEventType_.value);
return builder.build().find();
}
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return value;
}
} }

View File

@ -6,21 +6,25 @@ import 'package:diameter/models/meal_portion_type.dart';
import 'package:diameter/models/meal_source.dart'; import 'package:diameter/models/meal_source.dart';
import 'package:diameter/models/accuracy.dart'; import 'package:diameter/models/accuracy.dart';
import 'package:objectbox/objectbox.dart'; import 'package:objectbox/objectbox.dart';
import 'package:diameter/objectbox.g.dart' show LogMeal_, LogEntry_;
@Entity(uid: 411177866700467286) @Entity(uid: 411177866700467286)
class LogMeal { class LogMeal {
static final Box<LogMeal> box = objectBox.store.box<LogMeal>(); static final Box<LogMeal> box = objectBox.store.box<LogMeal>();
// properties
int id; int id;
bool deleted;
String value; String value;
double? carbsRatio; double? carbsRatio;
double? portionSize; double? portionSize;
double? carbsPerPortion; double? carbsPerPortion;
double? bolus;
int? delayedBolusDuration; int? delayedBolusDuration;
double? delayedBolusRate; double? delayedBolusRate;
String? notes; String? notes;
double? bolus;
// relations
final logEntry = ToOne<LogEntry>(); final logEntry = ToOne<LogEntry>();
final meal = ToOne<Meal>(); final meal = ToOne<Meal>();
final mealSource = ToOne<MealSource>(); final mealSource = ToOne<MealSource>();
@ -29,8 +33,10 @@ class LogMeal {
final portionSizeAccuracy = ToOne<Accuracy>(); final portionSizeAccuracy = ToOne<Accuracy>();
final carbsRatioAccuracy = ToOne<Accuracy>(); final carbsRatioAccuracy = ToOne<Accuracy>();
// constructor
LogMeal({ LogMeal({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.carbsRatio, this.carbsRatio,
this.portionSize, this.portionSize,
@ -41,8 +47,25 @@ class LogMeal {
this.notes, this.notes,
}); });
// methods
static LogMeal? get(int id) => box.get(id); static LogMeal? get(int id) => box.get(id);
static List<LogMeal> getAll() => box.getAll();
static void put(LogMeal logMeal) => box.put(logMeal); static void put(LogMeal logMeal) => box.put(logMeal);
static void remove(int id) => box.remove(id); static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
static List<LogMeal> getAllForEntry(int id) {
QueryBuilder<LogMeal> builder = box.query(LogMeal_.deleted.equals(false));
builder.link(LogMeal_.logEntry, LogEntry_.id.equals(id));
return builder.build().find();
}
@override
String toString() {
return value;
}
} }

View File

@ -11,7 +11,9 @@ enum PortionCarbsParameter { carbsRatio, portionSize, carbsPerPortion }
class Meal { class Meal {
static final Box<Meal> box = objectBox.store.box<Meal>(); static final Box<Meal> box = objectBox.store.box<Meal>();
// properties
int id; int id;
bool deleted;
String value; String value;
double? carbsRatio; double? carbsRatio;
double? portionSize; double? portionSize;
@ -20,15 +22,17 @@ class Meal {
double? delayedBolusRate; double? delayedBolusRate;
String? notes; String? notes;
// relations
final mealSource = ToOne<MealSource>(); final mealSource = ToOne<MealSource>();
final mealCategory = ToOne<MealCategory>(); final mealCategory = ToOne<MealCategory>();
final mealPortionType = ToOne<MealPortionType>(); final mealPortionType = ToOne<MealPortionType>();
final portionSizeAccuracy = ToOne<Accuracy>(); final portionSizeAccuracy = ToOne<Accuracy>();
final carbsRatioAccuracy = ToOne<Accuracy>(); final carbsRatioAccuracy = ToOne<Accuracy>();
// constructor
Meal({ Meal({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.carbsRatio, this.carbsRatio,
this.portionSize, this.portionSize,
@ -38,8 +42,22 @@ class Meal {
this.notes, this.notes,
}); });
// methods
static Meal? get(int id) => box.get(id); static Meal? get(int id) => box.get(id);
static List<Meal> getAll() => box.getAll();
static void put(Meal meal) => box.put(meal); static void put(Meal meal) => box.put(meal);
static void remove(int id) => box.remove(id);
static List<Meal> getAll() => box.getAll();
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return value;
}
} }

View File

@ -5,18 +5,36 @@ import 'package:objectbox/objectbox.dart';
class MealCategory { class MealCategory {
static final Box<MealCategory> box = objectBox.store.box<MealCategory>(); static final Box<MealCategory> box = objectBox.store.box<MealCategory>();
// properties
int id; int id;
bool deleted;
String value; String value;
String? notes; String? notes;
// constructor
MealCategory({ MealCategory({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.notes, this.notes,
}); });
// methods
static MealCategory? get(int id) => box.get(id); static MealCategory? get(int id) => box.get(id);
static List<MealCategory> getAll() => box.getAll();
static void put(MealCategory mealCategory) => box.put(mealCategory); static void put(MealCategory mealCategory) => box.put(mealCategory);
static void remove(int id) => box.remove(id);
static List<MealCategory> getAll() => box.getAll();
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return value;
}
} }

View File

@ -5,18 +5,36 @@ import 'package:objectbox/objectbox.dart';
class MealPortionType { class MealPortionType {
static final Box<MealPortionType> box = objectBox.store.box<MealPortionType>(); static final Box<MealPortionType> box = objectBox.store.box<MealPortionType>();
// properties
int id; int id;
bool deleted;
String value; String value;
String? notes; String? notes;
// constructor
MealPortionType({ MealPortionType({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.notes, this.notes,
}); });
// methods
static MealPortionType? get(int id) => box.get(id); static MealPortionType? get(int id) => box.get(id);
static List<MealPortionType> getAll() => box.getAll();
static void put(MealPortionType mealPortionType) => box.put(mealPortionType); static void put(MealPortionType mealPortionType) => box.put(mealPortionType);
static void remove(int id) => box.remove(id);
static List<MealPortionType> getAll() => box.getAll();
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return value;
}
} }

View File

@ -8,23 +8,42 @@ import 'package:objectbox/objectbox.dart';
class MealSource { class MealSource {
static final Box<MealSource> box = objectBox.store.box<MealSource>(); static final Box<MealSource> box = objectBox.store.box<MealSource>();
// properties
int id; int id;
bool deleted;
String value; String value;
String? notes; String? notes;
// relations
final defaultMealCategory = ToOne<MealCategory>(); final defaultMealCategory = ToOne<MealCategory>();
final defaultMealPortionType = ToOne<MealPortionType>(); final defaultMealPortionType = ToOne<MealPortionType>();
final defaultCarbsRatioAccuracy = ToOne<Accuracy>(); final defaultCarbsRatioAccuracy = ToOne<Accuracy>();
final defaultPortionSizeAccuracy = ToOne<Accuracy>(); final defaultPortionSizeAccuracy = ToOne<Accuracy>();
// constructor
MealSource({ MealSource({
this.id = 0, this.id = 0,
this.deleted = false,
this.value = '', this.value = '',
this.notes, this.notes,
}); });
// methods
static MealSource? get(int id) => box.get(id); static MealSource? get(int id) => box.get(id);
static List<MealSource> getAll() => box.getAll();
static void put(MealSource mealSource) => box.put(mealSource); static void put(MealSource mealSource) => box.put(mealSource);
static void remove(int id) => box.remove(id);
static List<MealSource> getAll() => box.getAll();
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return value;
}
} }

View File

@ -9,6 +9,7 @@ import 'package:diameter/screens/bolus/bolus_profile_list.dart';
import 'package:diameter/screens/log/log.dart'; import 'package:diameter/screens/log/log.dart';
import 'package:diameter/screens/log/log_entry/log_entry.dart'; import 'package:diameter/screens/log/log_entry/log_entry.dart';
import 'package:diameter/screens/log/log_entry/log_event_detail.dart'; import 'package:diameter/screens/log/log_entry/log_event_detail.dart';
import 'package:diameter/screens/log/active_log_event_list.dart';
import 'package:diameter/screens/log/log_event_type_detail.dart'; import 'package:diameter/screens/log/log_event_type_detail.dart';
import 'package:diameter/screens/log/log_event_type_list.dart'; import 'package:diameter/screens/log/log_event_type_list.dart';
import 'package:diameter/screens/log/log_entry/log_meal_detail.dart'; import 'package:diameter/screens/log/log_entry/log_meal_detail.dart';
@ -42,6 +43,7 @@ class Routes {
static const String logEventType = LogEventTypeDetailScreen.routeName; static const String logEventType = LogEventTypeDetailScreen.routeName;
static const String logEventTypes = LogEventTypeListScreen.routeName; static const String logEventTypes = LogEventTypeListScreen.routeName;
static const List<String> logEventTypeRoutes = [logEventType, logEventTypes]; static const List<String> logEventTypeRoutes = [logEventType, logEventTypes];
static const String activeEvents = ActiveEventListScreen.routeName;
static const String meal = MealDetailScreen.routeName; static const String meal = MealDetailScreen.routeName;
static const String meals = MealListScreen.routeName; static const String meals = MealListScreen.routeName;
@ -105,6 +107,14 @@ class _NavigationState extends State<Navigation> {
}, },
selected: Routes.logEntryRoutes.contains(widget.currentLocation), selected: Routes.logEntryRoutes.contains(widget.currentLocation),
), ),
ListTile(
title: const Text('Active Events'),
leading: const Icon(Icons.event),
onTap: () {
selectDestination(Routes.activeEvents);
},
selected: widget.currentLocation == Routes.activeEvents,
),
ListTile( ListTile(
title: const Text('Meals'), title: const Text('Meals'),
leading: const Icon(Icons.restaurant), leading: const Icon(Icons.restaurant),

View File

@ -5,7 +5,7 @@
"entities": [ "entities": [
{ {
"id": "2:1467758525778521891", "id": "2:1467758525778521891",
"lastPropertyId": "5:3908367275335317130", "lastPropertyId": "6:3409466778841164684",
"name": "Basal", "name": "Basal",
"properties": [ "properties": [
{ {
@ -36,13 +36,18 @@
"flags": 520, "flags": 520,
"indexId": "1:8279975749291974737", "indexId": "1:8279975749291974737",
"relationTarget": "BasalProfile" "relationTarget": "BasalProfile"
},
{
"id": "6:3409466778841164684",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "3:3613736032926903785", "id": "3:3613736032926903785",
"lastPropertyId": "4:6719547342639071472", "lastPropertyId": "5:8140071977687660397",
"name": "BasalProfile", "name": "BasalProfile",
"properties": [ "properties": [
{ {
@ -65,13 +70,18 @@
"id": "4:6719547342639071472", "id": "4:6719547342639071472",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "5:8140071977687660397",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "4:3417770529060202389", "id": "4:3417770529060202389",
"lastPropertyId": "8:7679622918986671917", "lastPropertyId": "9:7440090146687096977",
"name": "Bolus", "name": "Bolus",
"properties": [ "properties": [
{ {
@ -117,13 +127,18 @@
"flags": 520, "flags": 520,
"indexId": "2:1936045997906240691", "indexId": "2:1936045997906240691",
"relationTarget": "BolusProfile" "relationTarget": "BolusProfile"
},
{
"id": "9:7440090146687096977",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "5:8812452529027052317", "id": "5:8812452529027052317",
"lastPropertyId": "4:3030493484602726372", "lastPropertyId": "5:8082994824481464395",
"name": "BolusProfile", "name": "BolusProfile",
"properties": [ "properties": [
{ {
@ -146,13 +161,18 @@
"id": "4:3030493484602726372", "id": "4:3030493484602726372",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "5:8082994824481464395",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "6:752131069307970560", "id": "6:752131069307970560",
"lastPropertyId": "8:6492273995038150006", "lastPropertyId": "9:1692732373071965573",
"name": "LogEntry", "name": "LogEntry",
"properties": [ "properties": [
{ {
@ -195,13 +215,18 @@
"id": "8:6492273995038150006", "id": "8:6492273995038150006",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "9:1692732373071965573",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "7:4303325892753185970", "id": "7:4303325892753185970",
"lastPropertyId": "8:2514297323717317184", "lastPropertyId": "11:2013538196800336796",
"name": "LogEvent", "name": "LogEvent",
"properties": [ "properties": [
{ {
@ -253,13 +278,34 @@
"flags": 520, "flags": 520,
"indexId": "5:1417691902662024007", "indexId": "5:1417691902662024007",
"relationTarget": "LogEventType" "relationTarget": "LogEventType"
},
{
"id": "9:8477413048577624801",
"name": "deleted",
"type": 1
},
{
"id": "10:987218091728524211",
"name": "bolusProfileId",
"type": 11,
"flags": 520,
"indexId": "25:2500612771974500993",
"relationTarget": "BolusProfile"
},
{
"id": "11:2013538196800336796",
"name": "basalProfileId",
"type": 11,
"flags": 520,
"indexId": "26:4562998391990896273",
"relationTarget": "BasalProfile"
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "8:8362795406595606110", "id": "8:8362795406595606110",
"lastPropertyId": "5:7361377572496986196", "lastPropertyId": "8:1869014400856897151",
"name": "LogEventType", "name": "LogEventType",
"properties": [ "properties": [
{ {
@ -287,13 +333,34 @@
"id": "5:7361377572496986196", "id": "5:7361377572496986196",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "6:5428344494256722438",
"name": "deleted",
"type": 1
},
{
"id": "7:9194648252717310397",
"name": "bolusProfileId",
"type": 11,
"flags": 520,
"indexId": "27:758221514459743282",
"relationTarget": "BolusProfile"
},
{
"id": "8:1869014400856897151",
"name": "basalProfileId",
"type": 11,
"flags": 520,
"indexId": "28:4563029809754152081",
"relationTarget": "BasalProfile"
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "9:411177866700467286", "id": "9:411177866700467286",
"lastPropertyId": "16:7121997990741934484", "lastPropertyId": "17:7341439841011629937",
"name": "LogMeal", "name": "LogMeal",
"properties": [ "properties": [
{ {
@ -397,13 +464,18 @@
"flags": 520, "flags": 520,
"indexId": "12:35287836658362611", "indexId": "12:35287836658362611",
"relationTarget": "Accuracy" "relationTarget": "Accuracy"
},
{
"id": "17:7341439841011629937",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "10:382130101578692012", "id": "10:382130101578692012",
"lastPropertyId": "13:4890778480468380841", "lastPropertyId": "14:3567196286623536415",
"name": "Meal", "name": "Meal",
"properties": [ "properties": [
{ {
@ -486,13 +558,18 @@
"flags": 520, "flags": 520,
"indexId": "17:9108886538013386415", "indexId": "17:9108886538013386415",
"relationTarget": "Accuracy" "relationTarget": "Accuracy"
},
{
"id": "14:3567196286623536415",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "11:3158200688796904913", "id": "11:3158200688796904913",
"lastPropertyId": "3:3543757971350345683", "lastPropertyId": "4:824435977543069541",
"name": "MealCategory", "name": "MealCategory",
"properties": [ "properties": [
{ {
@ -510,13 +587,18 @@
"id": "3:3543757971350345683", "id": "3:3543757971350345683",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "4:824435977543069541",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "12:2111511899235985637", "id": "12:2111511899235985637",
"lastPropertyId": "3:1950852666001613408", "lastPropertyId": "4:5680236937391945907",
"name": "MealPortionType", "name": "MealPortionType",
"properties": [ "properties": [
{ {
@ -534,13 +616,18 @@
"id": "3:1950852666001613408", "id": "3:1950852666001613408",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "4:5680236937391945907",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "13:1283034494527412242", "id": "13:1283034494527412242",
"lastPropertyId": "7:5852853174931678667", "lastPropertyId": "8:4547899751779962180",
"name": "MealSource", "name": "MealSource",
"properties": [ "properties": [
{ {
@ -590,13 +677,18 @@
"flags": 520, "flags": 520,
"indexId": "21:1931330716440762729", "indexId": "21:1931330716440762729",
"relationTarget": "Accuracy" "relationTarget": "Accuracy"
},
{
"id": "8:4547899751779962180",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "14:8033487006694871160", "id": "14:8033487006694871160",
"lastPropertyId": "11:4818762109001810295", "lastPropertyId": "12:4765038304548427459",
"name": "LogBolus", "name": "LogBolus",
"properties": [ "properties": [
{ {
@ -663,13 +755,18 @@
"flags": 520, "flags": 520,
"indexId": "24:4224983816051843140", "indexId": "24:4224983816051843140",
"relationTarget": "LogMeal" "relationTarget": "LogMeal"
},
{
"id": "12:4765038304548427459",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
}, },
{ {
"id": "15:291512798403320400", "id": "15:291512798403320400",
"lastPropertyId": "6:6625101003527710274", "lastPropertyId": "7:6675647182186603076",
"name": "Accuracy", "name": "Accuracy",
"properties": [ "properties": [
{ {
@ -702,13 +799,18 @@
"id": "6:6625101003527710274", "id": "6:6625101003527710274",
"name": "notes", "name": "notes",
"type": 9 "type": 9
},
{
"id": "7:6675647182186603076",
"name": "deleted",
"type": 1
} }
], ],
"relations": [] "relations": []
} }
], ],
"lastEntityId": "15:291512798403320400", "lastEntityId": "15:291512798403320400",
"lastIndexId": "24:4224983816051843140", "lastIndexId": "28:4563029809754152081",
"lastRelationId": "0:0", "lastRelationId": "0:0",
"lastSequenceId": "0:0", "lastSequenceId": "0:0",
"modelVersion": 5, "modelVersion": 5,

View File

@ -30,7 +30,7 @@ final _entities = <ModelEntity>[
ModelEntity( ModelEntity(
id: const IdUid(2, 1467758525778521891), id: const IdUid(2, 1467758525778521891),
name: 'Basal', name: 'Basal',
lastPropertyId: const IdUid(5, 3908367275335317130), lastPropertyId: const IdUid(6, 3409466778841164684),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -59,14 +59,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(1, 8279975749291974737), indexId: const IdUid(1, 8279975749291974737),
relationTarget: 'BasalProfile') relationTarget: 'BasalProfile'),
ModelProperty(
id: const IdUid(6, 3409466778841164684),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(3, 3613736032926903785), id: const IdUid(3, 3613736032926903785),
name: 'BasalProfile', name: 'BasalProfile',
lastPropertyId: const IdUid(4, 6719547342639071472), lastPropertyId: const IdUid(5, 8140071977687660397),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -88,6 +93,11 @@ final _entities = <ModelEntity>[
id: const IdUid(4, 6719547342639071472), id: const IdUid(4, 6719547342639071472),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(5, 8140071977687660397),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
@ -95,7 +105,7 @@ final _entities = <ModelEntity>[
ModelEntity( ModelEntity(
id: const IdUid(4, 3417770529060202389), id: const IdUid(4, 3417770529060202389),
name: 'Bolus', name: 'Bolus',
lastPropertyId: const IdUid(8, 7679622918986671917), lastPropertyId: const IdUid(9, 7440090146687096977),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -139,14 +149,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(2, 1936045997906240691), indexId: const IdUid(2, 1936045997906240691),
relationTarget: 'BolusProfile') relationTarget: 'BolusProfile'),
ModelProperty(
id: const IdUid(9, 7440090146687096977),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(5, 8812452529027052317), id: const IdUid(5, 8812452529027052317),
name: 'BolusProfile', name: 'BolusProfile',
lastPropertyId: const IdUid(4, 3030493484602726372), lastPropertyId: const IdUid(5, 8082994824481464395),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -168,6 +183,11 @@ final _entities = <ModelEntity>[
id: const IdUid(4, 3030493484602726372), id: const IdUid(4, 3030493484602726372),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(5, 8082994824481464395),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
@ -175,7 +195,7 @@ final _entities = <ModelEntity>[
ModelEntity( ModelEntity(
id: const IdUid(6, 752131069307970560), id: const IdUid(6, 752131069307970560),
name: 'LogEntry', name: 'LogEntry',
lastPropertyId: const IdUid(8, 6492273995038150006), lastPropertyId: const IdUid(9, 1692732373071965573),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -217,24 +237,19 @@ final _entities = <ModelEntity>[
id: const IdUid(8, 6492273995038150006), id: const IdUid(8, 6492273995038150006),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(9, 1692732373071965573),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[ backlinks: <ModelBacklink>[]),
ModelBacklink(
name: 'events', srcEntity: 'LogEvent', srcField: 'logEntry'),
ModelBacklink(
name: 'endedEvents',
srcEntity: 'LogEvent',
srcField: 'endLogEntry'),
ModelBacklink(
name: 'meals', srcEntity: 'LogMeal', srcField: 'logEntry'),
ModelBacklink(name: 'boli', srcEntity: 'LogBolus', srcField: 'logEntry')
]),
ModelEntity( ModelEntity(
id: const IdUid(7, 4303325892753185970), id: const IdUid(7, 4303325892753185970),
name: 'LogEvent', name: 'LogEvent',
lastPropertyId: const IdUid(8, 2514297323717317184), lastPropertyId: const IdUid(11, 2013538196800336796),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -282,14 +297,33 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(5, 1417691902662024007), indexId: const IdUid(5, 1417691902662024007),
relationTarget: 'LogEventType') relationTarget: 'LogEventType'),
ModelProperty(
id: const IdUid(9, 8477413048577624801),
name: 'deleted',
type: 1,
flags: 0),
ModelProperty(
id: const IdUid(10, 987218091728524211),
name: 'bolusProfileId',
type: 11,
flags: 520,
indexId: const IdUid(25, 2500612771974500993),
relationTarget: 'BolusProfile'),
ModelProperty(
id: const IdUid(11, 2013538196800336796),
name: 'basalProfileId',
type: 11,
flags: 520,
indexId: const IdUid(26, 4562998391990896273),
relationTarget: 'BasalProfile')
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(8, 8362795406595606110), id: const IdUid(8, 8362795406595606110),
name: 'LogEventType', name: 'LogEventType',
lastPropertyId: const IdUid(5, 7361377572496986196), lastPropertyId: const IdUid(8, 1869014400856897151),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -316,14 +350,33 @@ final _entities = <ModelEntity>[
id: const IdUid(5, 7361377572496986196), id: const IdUid(5, 7361377572496986196),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0) flags: 0),
ModelProperty(
id: const IdUid(6, 5428344494256722438),
name: 'deleted',
type: 1,
flags: 0),
ModelProperty(
id: const IdUid(7, 9194648252717310397),
name: 'bolusProfileId',
type: 11,
flags: 520,
indexId: const IdUid(27, 758221514459743282),
relationTarget: 'BolusProfile'),
ModelProperty(
id: const IdUid(8, 1869014400856897151),
name: 'basalProfileId',
type: 11,
flags: 520,
indexId: const IdUid(28, 4563029809754152081),
relationTarget: 'BasalProfile')
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(9, 411177866700467286), id: const IdUid(9, 411177866700467286),
name: 'LogMeal', name: 'LogMeal',
lastPropertyId: const IdUid(16, 7121997990741934484), lastPropertyId: const IdUid(17, 7341439841011629937),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -419,14 +472,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(12, 35287836658362611), indexId: const IdUid(12, 35287836658362611),
relationTarget: 'Accuracy') relationTarget: 'Accuracy'),
ModelProperty(
id: const IdUid(17, 7341439841011629937),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(10, 382130101578692012), id: const IdUid(10, 382130101578692012),
name: 'Meal', name: 'Meal',
lastPropertyId: const IdUid(13, 4890778480468380841), lastPropertyId: const IdUid(14, 3567196286623536415),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -503,14 +561,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(17, 9108886538013386415), indexId: const IdUid(17, 9108886538013386415),
relationTarget: 'Accuracy') relationTarget: 'Accuracy'),
ModelProperty(
id: const IdUid(14, 3567196286623536415),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(11, 3158200688796904913), id: const IdUid(11, 3158200688796904913),
name: 'MealCategory', name: 'MealCategory',
lastPropertyId: const IdUid(3, 3543757971350345683), lastPropertyId: const IdUid(4, 824435977543069541),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -527,6 +590,11 @@ final _entities = <ModelEntity>[
id: const IdUid(3, 3543757971350345683), id: const IdUid(3, 3543757971350345683),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(4, 824435977543069541),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
@ -534,7 +602,7 @@ final _entities = <ModelEntity>[
ModelEntity( ModelEntity(
id: const IdUid(12, 2111511899235985637), id: const IdUid(12, 2111511899235985637),
name: 'MealPortionType', name: 'MealPortionType',
lastPropertyId: const IdUid(3, 1950852666001613408), lastPropertyId: const IdUid(4, 5680236937391945907),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -551,6 +619,11 @@ final _entities = <ModelEntity>[
id: const IdUid(3, 1950852666001613408), id: const IdUid(3, 1950852666001613408),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(4, 5680236937391945907),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
@ -558,7 +631,7 @@ final _entities = <ModelEntity>[
ModelEntity( ModelEntity(
id: const IdUid(13, 1283034494527412242), id: const IdUid(13, 1283034494527412242),
name: 'MealSource', name: 'MealSource',
lastPropertyId: const IdUid(7, 5852853174931678667), lastPropertyId: const IdUid(8, 4547899751779962180),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -603,14 +676,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(21, 1931330716440762729), indexId: const IdUid(21, 1931330716440762729),
relationTarget: 'Accuracy') relationTarget: 'Accuracy'),
ModelProperty(
id: const IdUid(8, 4547899751779962180),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(14, 8033487006694871160), id: const IdUid(14, 8033487006694871160),
name: 'LogBolus', name: 'LogBolus',
lastPropertyId: const IdUid(11, 4818762109001810295), lastPropertyId: const IdUid(12, 4765038304548427459),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -673,14 +751,19 @@ final _entities = <ModelEntity>[
type: 11, type: 11,
flags: 520, flags: 520,
indexId: const IdUid(24, 4224983816051843140), indexId: const IdUid(24, 4224983816051843140),
relationTarget: 'LogMeal') relationTarget: 'LogMeal'),
ModelProperty(
id: const IdUid(12, 4765038304548427459),
name: 'deleted',
type: 1,
flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
backlinks: <ModelBacklink>[]), backlinks: <ModelBacklink>[]),
ModelEntity( ModelEntity(
id: const IdUid(15, 291512798403320400), id: const IdUid(15, 291512798403320400),
name: 'Accuracy', name: 'Accuracy',
lastPropertyId: const IdUid(6, 6625101003527710274), lastPropertyId: const IdUid(7, 6675647182186603076),
flags: 0, flags: 0,
properties: <ModelProperty>[ properties: <ModelProperty>[
ModelProperty( ModelProperty(
@ -712,6 +795,11 @@ final _entities = <ModelEntity>[
id: const IdUid(6, 6625101003527710274), id: const IdUid(6, 6625101003527710274),
name: 'notes', name: 'notes',
type: 9, type: 9,
flags: 0),
ModelProperty(
id: const IdUid(7, 6675647182186603076),
name: 'deleted',
type: 1,
flags: 0) flags: 0)
], ],
relations: <ModelRelation>[], relations: <ModelRelation>[],
@ -739,7 +827,7 @@ ModelDefinition getObjectBoxModel() {
final model = ModelInfo( final model = ModelInfo(
entities: _entities, entities: _entities,
lastEntityId: const IdUid(15, 291512798403320400), lastEntityId: const IdUid(15, 291512798403320400),
lastIndexId: const IdUid(24, 4224983816051843140), lastIndexId: const IdUid(28, 4563029809754152081),
lastRelationId: const IdUid(0, 0), lastRelationId: const IdUid(0, 0),
lastSequenceId: const IdUid(0, 0), lastSequenceId: const IdUid(0, 0),
retiredEntityUids: const [3095978685310268382], retiredEntityUids: const [3095978685310268382],
@ -767,12 +855,13 @@ ModelDefinition getObjectBoxModel() {
object.id = id; object.id = id;
}, },
objectToFB: (Basal object, fb.Builder fbb) { objectToFB: (Basal object, fb.Builder fbb) {
fbb.startTable(6); fbb.startTable(7);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addInt64(1, object.startTime.millisecondsSinceEpoch); fbb.addInt64(1, object.startTime.millisecondsSinceEpoch);
fbb.addInt64(2, object.endTime.millisecondsSinceEpoch); fbb.addInt64(2, object.endTime.millisecondsSinceEpoch);
fbb.addFloat64(3, object.units); fbb.addFloat64(3, object.units);
fbb.addInt64(4, object.basalProfile.targetId); fbb.addInt64(4, object.basalProfile.targetId);
fbb.addBool(5, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -782,6 +871,8 @@ ModelDefinition getObjectBoxModel() {
final object = Basal( final object = Basal(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 14, false),
startTime: DateTime.fromMillisecondsSinceEpoch( startTime: DateTime.fromMillisecondsSinceEpoch(
const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)), const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)),
endTime: DateTime.fromMillisecondsSinceEpoch( endTime: DateTime.fromMillisecondsSinceEpoch(
@ -805,11 +896,12 @@ ModelDefinition getObjectBoxModel() {
final nameOffset = fbb.writeString(object.name); final nameOffset = fbb.writeString(object.name);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(5); fbb.startTable(6);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, nameOffset); fbb.addOffset(1, nameOffset);
fbb.addBool(2, object.active); fbb.addBool(2, object.active);
fbb.addOffset(3, notesOffset); fbb.addOffset(3, notesOffset);
fbb.addBool(4, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -819,6 +911,8 @@ ModelDefinition getObjectBoxModel() {
final object = BasalProfile( final object = BasalProfile(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 12, false),
name: name:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
active: active:
@ -837,7 +931,7 @@ ModelDefinition getObjectBoxModel() {
object.id = id; object.id = id;
}, },
objectToFB: (Bolus object, fb.Builder fbb) { objectToFB: (Bolus object, fb.Builder fbb) {
fbb.startTable(9); fbb.startTable(10);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addInt64(1, object.startTime.millisecondsSinceEpoch); fbb.addInt64(1, object.startTime.millisecondsSinceEpoch);
fbb.addInt64(2, object.endTime.millisecondsSinceEpoch); fbb.addInt64(2, object.endTime.millisecondsSinceEpoch);
@ -846,6 +940,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(5, object.mgPerDl); fbb.addInt64(5, object.mgPerDl);
fbb.addFloat64(6, object.mmolPerL); fbb.addFloat64(6, object.mmolPerL);
fbb.addInt64(7, object.bolusProfile.targetId); fbb.addInt64(7, object.bolusProfile.targetId);
fbb.addBool(8, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -855,6 +950,8 @@ ModelDefinition getObjectBoxModel() {
final object = Bolus( final object = Bolus(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 20, false),
startTime: DateTime.fromMillisecondsSinceEpoch( startTime: DateTime.fromMillisecondsSinceEpoch(
const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)), const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)),
endTime: DateTime.fromMillisecondsSinceEpoch( endTime: DateTime.fromMillisecondsSinceEpoch(
@ -884,11 +981,12 @@ ModelDefinition getObjectBoxModel() {
final nameOffset = fbb.writeString(object.name); final nameOffset = fbb.writeString(object.name);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(5); fbb.startTable(6);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, nameOffset); fbb.addOffset(1, nameOffset);
fbb.addBool(2, object.active); fbb.addBool(2, object.active);
fbb.addOffset(3, notesOffset); fbb.addOffset(3, notesOffset);
fbb.addBool(4, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -898,6 +996,8 @@ ModelDefinition getObjectBoxModel() {
final object = BolusProfile( final object = BolusProfile(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 12, false),
name: name:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
active: active:
@ -910,20 +1010,7 @@ ModelDefinition getObjectBoxModel() {
LogEntry: EntityDefinition<LogEntry>( LogEntry: EntityDefinition<LogEntry>(
model: _entities[4], model: _entities[4],
toOneRelations: (LogEntry object) => [], toOneRelations: (LogEntry object) => [],
toManyRelations: (LogEntry object) => { toManyRelations: (LogEntry object) => {},
RelInfo<LogEvent>.toOneBacklink(
6, object.id, (LogEvent srcObject) => srcObject.logEntry):
object.events,
RelInfo<LogEvent>.toOneBacklink(7, object.id,
(LogEvent srcObject) => srcObject.endLogEntry):
object.endedEvents,
RelInfo<LogMeal>.toOneBacklink(
10, object.id, (LogMeal srcObject) => srcObject.logEntry):
object.meals,
RelInfo<LogBolus>.toOneBacklink(
9, object.id, (LogBolus srcObject) => srcObject.logEntry):
object.boli
},
getId: (LogEntry object) => object.id, getId: (LogEntry object) => object.id,
setId: (LogEntry object, int id) { setId: (LogEntry object, int id) {
object.id = id; object.id = id;
@ -931,7 +1018,7 @@ ModelDefinition getObjectBoxModel() {
objectToFB: (LogEntry object, fb.Builder fbb) { objectToFB: (LogEntry object, fb.Builder fbb) {
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(9); fbb.startTable(10);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addInt64(1, object.time.millisecondsSinceEpoch); fbb.addInt64(1, object.time.millisecondsSinceEpoch);
fbb.addInt64(2, object.mgPerDl); fbb.addInt64(2, object.mgPerDl);
@ -940,6 +1027,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(5, object.delayedBolusDuration); fbb.addInt64(5, object.delayedBolusDuration);
fbb.addFloat64(6, object.delayedBolusRate); fbb.addFloat64(6, object.delayedBolusRate);
fbb.addOffset(7, notesOffset); fbb.addOffset(7, notesOffset);
fbb.addBool(8, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -949,6 +1037,8 @@ ModelDefinition getObjectBoxModel() {
final object = LogEntry( final object = LogEntry(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 20, false),
time: DateTime.fromMillisecondsSinceEpoch( time: DateTime.fromMillisecondsSinceEpoch(
const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)), const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)),
mgPerDl: const fb.Int64Reader() mgPerDl: const fb.Int64Reader()
@ -963,36 +1053,18 @@ ModelDefinition getObjectBoxModel() {
.vTableGetNullable(buffer, rootOffset, 16), .vTableGetNullable(buffer, rootOffset, 16),
notes: const fb.StringReader() notes: const fb.StringReader()
.vTableGetNullable(buffer, rootOffset, 18)); .vTableGetNullable(buffer, rootOffset, 18));
InternalToManyAccess.setRelInfo(
object.events,
store,
RelInfo<LogEvent>.toOneBacklink(
6, object.id, (LogEvent srcObject) => srcObject.logEntry),
store.box<LogEntry>());
InternalToManyAccess.setRelInfo(
object.endedEvents,
store,
RelInfo<LogEvent>.toOneBacklink(
7, object.id, (LogEvent srcObject) => srcObject.endLogEntry),
store.box<LogEntry>());
InternalToManyAccess.setRelInfo(
object.meals,
store,
RelInfo<LogMeal>.toOneBacklink(
10, object.id, (LogMeal srcObject) => srcObject.logEntry),
store.box<LogEntry>());
InternalToManyAccess.setRelInfo(
object.boli,
store,
RelInfo<LogBolus>.toOneBacklink(
9, object.id, (LogBolus srcObject) => srcObject.logEntry),
store.box<LogEntry>());
return object; return object;
}), }),
LogEvent: EntityDefinition<LogEvent>( LogEvent: EntityDefinition<LogEvent>(
model: _entities[5], model: _entities[5],
toOneRelations: (LogEvent object) => toOneRelations: (LogEvent object) => [
[object.logEntry, object.endLogEntry, object.eventType], object.logEntry,
object.endLogEntry,
object.eventType,
object.bolusProfile,
object.basalProfile
],
toManyRelations: (LogEvent object) => {}, toManyRelations: (LogEvent object) => {},
getId: (LogEvent object) => object.id, getId: (LogEvent object) => object.id,
setId: (LogEvent object, int id) { setId: (LogEvent object, int id) {
@ -1001,7 +1073,7 @@ ModelDefinition getObjectBoxModel() {
objectToFB: (LogEvent object, fb.Builder fbb) { objectToFB: (LogEvent object, fb.Builder fbb) {
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(9); fbb.startTable(12);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addInt64(1, object.time.millisecondsSinceEpoch); fbb.addInt64(1, object.time.millisecondsSinceEpoch);
fbb.addInt64(2, object.endTime?.millisecondsSinceEpoch); fbb.addInt64(2, object.endTime?.millisecondsSinceEpoch);
@ -1010,6 +1082,9 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(5, object.logEntry.targetId); fbb.addInt64(5, object.logEntry.targetId);
fbb.addInt64(6, object.endLogEntry.targetId); fbb.addInt64(6, object.endLogEntry.targetId);
fbb.addInt64(7, object.eventType.targetId); fbb.addInt64(7, object.eventType.targetId);
fbb.addBool(8, object.deleted);
fbb.addInt64(9, object.bolusProfile.targetId);
fbb.addInt64(10, object.basalProfile.targetId);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1020,6 +1095,8 @@ ModelDefinition getObjectBoxModel() {
const fb.Int64Reader().vTableGetNullable(buffer, rootOffset, 8); const fb.Int64Reader().vTableGetNullable(buffer, rootOffset, 8);
final object = LogEvent( final object = LogEvent(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 20, false),
time: DateTime.fromMillisecondsSinceEpoch( time: DateTime.fromMillisecondsSinceEpoch(
const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)), const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)),
endTime: endTimeValue == null endTime: endTimeValue == null
@ -1038,11 +1115,18 @@ ModelDefinition getObjectBoxModel() {
object.eventType.targetId = object.eventType.targetId =
const fb.Int64Reader().vTableGet(buffer, rootOffset, 18, 0); const fb.Int64Reader().vTableGet(buffer, rootOffset, 18, 0);
object.eventType.attach(store); object.eventType.attach(store);
object.bolusProfile.targetId =
const fb.Int64Reader().vTableGet(buffer, rootOffset, 22, 0);
object.bolusProfile.attach(store);
object.basalProfile.targetId =
const fb.Int64Reader().vTableGet(buffer, rootOffset, 24, 0);
object.basalProfile.attach(store);
return object; return object;
}), }),
LogEventType: EntityDefinition<LogEventType>( LogEventType: EntityDefinition<LogEventType>(
model: _entities[6], model: _entities[6],
toOneRelations: (LogEventType object) => [], toOneRelations: (LogEventType object) =>
[object.bolusProfile, object.basalProfile],
toManyRelations: (LogEventType object) => {}, toManyRelations: (LogEventType object) => {},
getId: (LogEventType object) => object.id, getId: (LogEventType object) => object.id,
setId: (LogEventType object, int id) { setId: (LogEventType object, int id) {
@ -1052,12 +1136,15 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(6); fbb.startTable(9);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addBool(2, object.hasEndTime); fbb.addBool(2, object.hasEndTime);
fbb.addInt64(3, object.defaultReminderDuration); fbb.addInt64(3, object.defaultReminderDuration);
fbb.addOffset(4, notesOffset); fbb.addOffset(4, notesOffset);
fbb.addBool(5, object.deleted);
fbb.addInt64(6, object.bolusProfile.targetId);
fbb.addInt64(7, object.basalProfile.targetId);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1067,6 +1154,8 @@ ModelDefinition getObjectBoxModel() {
final object = LogEventType( final object = LogEventType(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 14, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
hasEndTime: hasEndTime:
@ -1075,7 +1164,12 @@ ModelDefinition getObjectBoxModel() {
.vTableGetNullable(buffer, rootOffset, 10), .vTableGetNullable(buffer, rootOffset, 10),
notes: const fb.StringReader() notes: const fb.StringReader()
.vTableGetNullable(buffer, rootOffset, 12)); .vTableGetNullable(buffer, rootOffset, 12));
object.bolusProfile.targetId =
const fb.Int64Reader().vTableGet(buffer, rootOffset, 16, 0);
object.bolusProfile.attach(store);
object.basalProfile.targetId =
const fb.Int64Reader().vTableGet(buffer, rootOffset, 18, 0);
object.basalProfile.attach(store);
return object; return object;
}), }),
LogMeal: EntityDefinition<LogMeal>( LogMeal: EntityDefinition<LogMeal>(
@ -1098,7 +1192,7 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(17); fbb.startTable(18);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addFloat64(2, object.carbsRatio); fbb.addFloat64(2, object.carbsRatio);
@ -1115,6 +1209,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(13, object.mealPortionType.targetId); fbb.addInt64(13, object.mealPortionType.targetId);
fbb.addInt64(14, object.portionSizeAccuracy.targetId); fbb.addInt64(14, object.portionSizeAccuracy.targetId);
fbb.addInt64(15, object.carbsRatioAccuracy.targetId); fbb.addInt64(15, object.carbsRatioAccuracy.targetId);
fbb.addBool(16, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1124,6 +1219,8 @@ ModelDefinition getObjectBoxModel() {
final object = LogMeal( final object = LogMeal(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 36, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
carbsRatio: const fb.Float64Reader() carbsRatio: const fb.Float64Reader()
@ -1181,7 +1278,7 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(14); fbb.startTable(15);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addFloat64(2, object.carbsRatio); fbb.addFloat64(2, object.carbsRatio);
@ -1195,6 +1292,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(10, object.mealPortionType.targetId); fbb.addInt64(10, object.mealPortionType.targetId);
fbb.addInt64(11, object.portionSizeAccuracy.targetId); fbb.addInt64(11, object.portionSizeAccuracy.targetId);
fbb.addInt64(12, object.carbsRatioAccuracy.targetId); fbb.addInt64(12, object.carbsRatioAccuracy.targetId);
fbb.addBool(13, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1204,6 +1302,8 @@ ModelDefinition getObjectBoxModel() {
final object = Meal( final object = Meal(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 30, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
carbsRatio: const fb.Float64Reader() carbsRatio: const fb.Float64Reader()
@ -1247,10 +1347,11 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(4); fbb.startTable(5);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addOffset(2, notesOffset); fbb.addOffset(2, notesOffset);
fbb.addBool(3, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1260,6 +1361,8 @@ ModelDefinition getObjectBoxModel() {
final object = MealCategory( final object = MealCategory(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 10, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
notes: const fb.StringReader() notes: const fb.StringReader()
@ -1279,10 +1382,11 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(4); fbb.startTable(5);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addOffset(2, notesOffset); fbb.addOffset(2, notesOffset);
fbb.addBool(3, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1292,6 +1396,8 @@ ModelDefinition getObjectBoxModel() {
final object = MealPortionType( final object = MealPortionType(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 10, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
notes: const fb.StringReader() notes: const fb.StringReader()
@ -1316,7 +1422,7 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(8); fbb.startTable(9);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addOffset(2, notesOffset); fbb.addOffset(2, notesOffset);
@ -1324,6 +1430,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(4, object.defaultMealPortionType.targetId); fbb.addInt64(4, object.defaultMealPortionType.targetId);
fbb.addInt64(5, object.defaultCarbsRatioAccuracy.targetId); fbb.addInt64(5, object.defaultCarbsRatioAccuracy.targetId);
fbb.addInt64(6, object.defaultPortionSizeAccuracy.targetId); fbb.addInt64(6, object.defaultPortionSizeAccuracy.targetId);
fbb.addBool(7, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1333,6 +1440,8 @@ ModelDefinition getObjectBoxModel() {
final object = MealSource( final object = MealSource(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 18, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
notes: const fb.StringReader() notes: const fb.StringReader()
@ -1363,7 +1472,7 @@ ModelDefinition getObjectBoxModel() {
objectToFB: (LogBolus object, fb.Builder fbb) { objectToFB: (LogBolus object, fb.Builder fbb) {
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(12); fbb.startTable(13);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addFloat64(1, object.units); fbb.addFloat64(1, object.units);
fbb.addFloat64(2, object.carbs); fbb.addFloat64(2, object.carbs);
@ -1375,6 +1484,7 @@ ModelDefinition getObjectBoxModel() {
fbb.addInt64(8, object.logEntry.targetId); fbb.addInt64(8, object.logEntry.targetId);
fbb.addInt64(9, object.rate.targetId); fbb.addInt64(9, object.rate.targetId);
fbb.addInt64(10, object.meal.targetId); fbb.addInt64(10, object.meal.targetId);
fbb.addBool(11, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1384,6 +1494,8 @@ ModelDefinition getObjectBoxModel() {
final object = LogBolus( final object = LogBolus(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 26, false),
units: units:
const fb.Float64Reader().vTableGet(buffer, rootOffset, 6, 0), const fb.Float64Reader().vTableGet(buffer, rootOffset, 6, 0),
carbs: const fb.Float64Reader() carbs: const fb.Float64Reader()
@ -1421,13 +1533,14 @@ ModelDefinition getObjectBoxModel() {
final valueOffset = fbb.writeString(object.value); final valueOffset = fbb.writeString(object.value);
final notesOffset = final notesOffset =
object.notes == null ? null : fbb.writeString(object.notes!); object.notes == null ? null : fbb.writeString(object.notes!);
fbb.startTable(7); fbb.startTable(8);
fbb.addInt64(0, object.id); fbb.addInt64(0, object.id);
fbb.addOffset(1, valueOffset); fbb.addOffset(1, valueOffset);
fbb.addBool(2, object.forCarbsRatio); fbb.addBool(2, object.forCarbsRatio);
fbb.addBool(3, object.forPortionSize); fbb.addBool(3, object.forPortionSize);
fbb.addInt64(4, object.confidenceRating); fbb.addInt64(4, object.confidenceRating);
fbb.addOffset(5, notesOffset); fbb.addOffset(5, notesOffset);
fbb.addBool(6, object.deleted);
fbb.finish(fbb.endTable()); fbb.finish(fbb.endTable());
return object.id; return object.id;
}, },
@ -1437,6 +1550,8 @@ ModelDefinition getObjectBoxModel() {
final object = Accuracy( final object = Accuracy(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
deleted: const fb.BoolReader()
.vTableGet(buffer, rootOffset, 16, false),
value: value:
const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''), const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''),
forCarbsRatio: forCarbsRatio:
@ -1474,6 +1589,10 @@ class Basal_ {
/// see [Basal.basalProfile] /// see [Basal.basalProfile]
static final basalProfile = static final basalProfile =
QueryRelationToOne<Basal, BasalProfile>(_entities[0].properties[4]); QueryRelationToOne<Basal, BasalProfile>(_entities[0].properties[4]);
/// see [Basal.deleted]
static final deleted =
QueryBooleanProperty<Basal>(_entities[0].properties[5]);
} }
/// [BasalProfile] entity fields to define ObjectBox queries. /// [BasalProfile] entity fields to define ObjectBox queries.
@ -1493,6 +1612,10 @@ class BasalProfile_ {
/// see [BasalProfile.notes] /// see [BasalProfile.notes]
static final notes = static final notes =
QueryStringProperty<BasalProfile>(_entities[1].properties[3]); QueryStringProperty<BasalProfile>(_entities[1].properties[3]);
/// see [BasalProfile.deleted]
static final deleted =
QueryBooleanProperty<BasalProfile>(_entities[1].properties[4]);
} }
/// [Bolus] entity fields to define ObjectBox queries. /// [Bolus] entity fields to define ObjectBox queries.
@ -1525,6 +1648,10 @@ class Bolus_ {
/// see [Bolus.bolusProfile] /// see [Bolus.bolusProfile]
static final bolusProfile = static final bolusProfile =
QueryRelationToOne<Bolus, BolusProfile>(_entities[2].properties[7]); QueryRelationToOne<Bolus, BolusProfile>(_entities[2].properties[7]);
/// see [Bolus.deleted]
static final deleted =
QueryBooleanProperty<Bolus>(_entities[2].properties[8]);
} }
/// [BolusProfile] entity fields to define ObjectBox queries. /// [BolusProfile] entity fields to define ObjectBox queries.
@ -1544,6 +1671,10 @@ class BolusProfile_ {
/// see [BolusProfile.notes] /// see [BolusProfile.notes]
static final notes = static final notes =
QueryStringProperty<BolusProfile>(_entities[3].properties[3]); QueryStringProperty<BolusProfile>(_entities[3].properties[3]);
/// see [BolusProfile.deleted]
static final deleted =
QueryBooleanProperty<BolusProfile>(_entities[3].properties[4]);
} }
/// [LogEntry] entity fields to define ObjectBox queries. /// [LogEntry] entity fields to define ObjectBox queries.
@ -1578,6 +1709,10 @@ class LogEntry_ {
/// see [LogEntry.notes] /// see [LogEntry.notes]
static final notes = static final notes =
QueryStringProperty<LogEntry>(_entities[4].properties[7]); QueryStringProperty<LogEntry>(_entities[4].properties[7]);
/// see [LogEntry.deleted]
static final deleted =
QueryBooleanProperty<LogEntry>(_entities[4].properties[8]);
} }
/// [LogEvent] entity fields to define ObjectBox queries. /// [LogEvent] entity fields to define ObjectBox queries.
@ -1612,6 +1747,18 @@ class LogEvent_ {
/// see [LogEvent.eventType] /// see [LogEvent.eventType]
static final eventType = static final eventType =
QueryRelationToOne<LogEvent, LogEventType>(_entities[5].properties[7]); QueryRelationToOne<LogEvent, LogEventType>(_entities[5].properties[7]);
/// see [LogEvent.deleted]
static final deleted =
QueryBooleanProperty<LogEvent>(_entities[5].properties[8]);
/// see [LogEvent.bolusProfile]
static final bolusProfile =
QueryRelationToOne<LogEvent, BolusProfile>(_entities[5].properties[9]);
/// see [LogEvent.basalProfile]
static final basalProfile =
QueryRelationToOne<LogEvent, BasalProfile>(_entities[5].properties[10]);
} }
/// [LogEventType] entity fields to define ObjectBox queries. /// [LogEventType] entity fields to define ObjectBox queries.
@ -1635,6 +1782,18 @@ class LogEventType_ {
/// see [LogEventType.notes] /// see [LogEventType.notes]
static final notes = static final notes =
QueryStringProperty<LogEventType>(_entities[6].properties[4]); QueryStringProperty<LogEventType>(_entities[6].properties[4]);
/// see [LogEventType.deleted]
static final deleted =
QueryBooleanProperty<LogEventType>(_entities[6].properties[5]);
/// see [LogEventType.bolusProfile]
static final bolusProfile = QueryRelationToOne<LogEventType, BolusProfile>(
_entities[6].properties[6]);
/// see [LogEventType.basalProfile]
static final basalProfile = QueryRelationToOne<LogEventType, BasalProfile>(
_entities[6].properties[7]);
} }
/// [LogMeal] entity fields to define ObjectBox queries. /// [LogMeal] entity fields to define ObjectBox queries.
@ -1698,6 +1857,10 @@ class LogMeal_ {
/// see [LogMeal.carbsRatioAccuracy] /// see [LogMeal.carbsRatioAccuracy]
static final carbsRatioAccuracy = static final carbsRatioAccuracy =
QueryRelationToOne<LogMeal, Accuracy>(_entities[7].properties[15]); QueryRelationToOne<LogMeal, Accuracy>(_entities[7].properties[15]);
/// see [LogMeal.deleted]
static final deleted =
QueryBooleanProperty<LogMeal>(_entities[7].properties[16]);
} }
/// [Meal] entity fields to define ObjectBox queries. /// [Meal] entity fields to define ObjectBox queries.
@ -1750,6 +1913,10 @@ class Meal_ {
/// see [Meal.carbsRatioAccuracy] /// see [Meal.carbsRatioAccuracy]
static final carbsRatioAccuracy = static final carbsRatioAccuracy =
QueryRelationToOne<Meal, Accuracy>(_entities[8].properties[12]); QueryRelationToOne<Meal, Accuracy>(_entities[8].properties[12]);
/// see [Meal.deleted]
static final deleted =
QueryBooleanProperty<Meal>(_entities[8].properties[13]);
} }
/// [MealCategory] entity fields to define ObjectBox queries. /// [MealCategory] entity fields to define ObjectBox queries.
@ -1765,6 +1932,10 @@ class MealCategory_ {
/// see [MealCategory.notes] /// see [MealCategory.notes]
static final notes = static final notes =
QueryStringProperty<MealCategory>(_entities[9].properties[2]); QueryStringProperty<MealCategory>(_entities[9].properties[2]);
/// see [MealCategory.deleted]
static final deleted =
QueryBooleanProperty<MealCategory>(_entities[9].properties[3]);
} }
/// [MealPortionType] entity fields to define ObjectBox queries. /// [MealPortionType] entity fields to define ObjectBox queries.
@ -1780,6 +1951,10 @@ class MealPortionType_ {
/// see [MealPortionType.notes] /// see [MealPortionType.notes]
static final notes = static final notes =
QueryStringProperty<MealPortionType>(_entities[10].properties[2]); QueryStringProperty<MealPortionType>(_entities[10].properties[2]);
/// see [MealPortionType.deleted]
static final deleted =
QueryBooleanProperty<MealPortionType>(_entities[10].properties[3]);
} }
/// [MealSource] entity fields to define ObjectBox queries. /// [MealSource] entity fields to define ObjectBox queries.
@ -1812,6 +1987,10 @@ class MealSource_ {
/// see [MealSource.defaultPortionSizeAccuracy] /// see [MealSource.defaultPortionSizeAccuracy]
static final defaultPortionSizeAccuracy = static final defaultPortionSizeAccuracy =
QueryRelationToOne<MealSource, Accuracy>(_entities[11].properties[6]); QueryRelationToOne<MealSource, Accuracy>(_entities[11].properties[6]);
/// see [MealSource.deleted]
static final deleted =
QueryBooleanProperty<MealSource>(_entities[11].properties[7]);
} }
/// [LogBolus] entity fields to define ObjectBox queries. /// [LogBolus] entity fields to define ObjectBox queries.
@ -1858,6 +2037,10 @@ class LogBolus_ {
/// see [LogBolus.meal] /// see [LogBolus.meal]
static final meal = static final meal =
QueryRelationToOne<LogBolus, LogMeal>(_entities[12].properties[10]); QueryRelationToOne<LogBolus, LogMeal>(_entities[12].properties[10]);
/// see [LogBolus.deleted]
static final deleted =
QueryBooleanProperty<LogBolus>(_entities[12].properties[11]);
} }
/// [Accuracy] entity fields to define ObjectBox queries. /// [Accuracy] entity fields to define ObjectBox queries.
@ -1884,4 +2067,8 @@ class Accuracy_ {
/// see [Accuracy.notes] /// see [Accuracy.notes]
static final notes = static final notes =
QueryStringProperty<Accuracy>(_entities[13].properties[5]); QueryStringProperty<Accuracy>(_entities[13].properties[5]);
/// see [Accuracy.deleted]
static final deleted =
QueryBooleanProperty<Accuracy>(_entities[13].properties[6]);
} }

View File

@ -19,10 +19,10 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
refresh(); reload();
} }
void refresh({String? message}) { void reload({String? message}) {
setState(() { setState(() {
_accuracies = Accuracy.getAll(); _accuracies = Accuracy.getAll();
}); });
@ -42,7 +42,7 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
void onDelete(Accuracy accuracy) { void onDelete(Accuracy accuracy) {
Accuracy.remove(accuracy.id); Accuracy.remove(accuracy.id);
refresh(); reload();
} }
void handleDeleteAction(Accuracy accuracy) async { void handleDeleteAction(Accuracy accuracy) async {
@ -60,13 +60,13 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
void handleToggleForPortionSizeAction(Accuracy accuracy) async { void handleToggleForPortionSizeAction(Accuracy accuracy) async {
accuracy.forPortionSize = !accuracy.forPortionSize; accuracy.forPortionSize = !accuracy.forPortionSize;
Accuracy.put(accuracy); Accuracy.put(accuracy);
refresh(); reload();
} }
void handleToggleForCarbsRatioAction(Accuracy accuracy) async { void handleToggleForCarbsRatioAction(Accuracy accuracy) async {
accuracy.forCarbsRatio = !accuracy.forCarbsRatio; accuracy.forCarbsRatio = !accuracy.forCarbsRatio;
Accuracy.put(accuracy); Accuracy.put(accuracy);
refresh(); reload();
} }
@override @override
@ -75,7 +75,7 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
appBar: AppBar( appBar: AppBar(
title: const Text('Accuracies'), title: const Text('Accuracies'),
actions: <Widget>[ actions: <Widget>[
IconButton(onPressed: refresh, icon: const Icon(Icons.refresh)) IconButton(onPressed: reload, icon: const Icon(Icons.refresh))
], ],
), ),
drawer: const Navigation(currentLocation: AccuracyListScreen.routeName), drawer: const Navigation(currentLocation: AccuracyListScreen.routeName),
@ -96,7 +96,7 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
builder: (context) => builder: (context) =>
AccuracyDetailScreen(id: accuracy.id), AccuracyDetailScreen(id: accuracy.id),
), ),
).then((message) => refresh(message: message)); ).then((message) => reload(message: message));
}, },
title: Text(accuracy.value), title: Text(accuracy.value),
leading: Row( leading: Row(
@ -154,7 +154,7 @@ class _AccuracyListScreenState extends State<AccuracyListScreen> {
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const AccuracyDetailScreen(), builder: (context) => const AccuracyDetailScreen(),
), ),
).then((message) => refresh(message: message)); ).then((message) => reload(message: message));
}, },
child: const Icon(Icons.add), child: const Icon(Icons.add),
), ),

View File

@ -108,10 +108,10 @@ class _BasalListScreenState extends State<BasalListScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return widget.basalRates.isNotEmpty ? SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
widget.basalRates.isNotEmpty ? ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: widget.basalRates.length, itemCount: widget.basalRates.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -149,11 +149,11 @@ class _BasalListScreenState extends State<BasalListScreen> {
), ),
); );
}, },
) : const Center( ),
child: Text('You have not created any Basal Rates yet!'),
),
], ],
), ),
): const Center(
child: Text('You have not created any Basal Rates yet!'),
); );
} }
} }

View File

@ -105,11 +105,11 @@ class _BolusListScreenState extends State<BolusListScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return widget.bolusRates.isNotEmpty ? SingleChildScrollView(
padding: const EdgeInsets.only(top: 10.0), padding: const EdgeInsets.only(top: 10.0),
child: Column( child: Column(
children: [ children: [
widget.bolusRates.isNotEmpty ? ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: widget.bolusRates.length, itemCount: widget.bolusRates.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -148,11 +148,11 @@ class _BolusListScreenState extends State<BolusListScreen> {
), ),
); );
}, },
) : const Center( ),
child: Text('You have not created any Bolus Rates yet!'),
),
], ],
), ),
); ) : const Center(
child: Text('You have not created any Bolus Rates yet!'),
);
} }
} }

View File

@ -2,26 +2,23 @@ import 'package:diameter/components/dialogs.dart';
import 'package:diameter/config.dart'; import 'package:diameter/config.dart';
import 'package:diameter/models/log_entry.dart'; import 'package:diameter/models/log_entry.dart';
import 'package:diameter/models/log_event.dart'; import 'package:diameter/models/log_event.dart';
import 'package:diameter/screens/log/log_entry/log_event_detail.dart';
import 'package:diameter/screens/log/log_entry/log_event_list.dart';
import 'package:diameter/utils/date_time_utils.dart'; import 'package:diameter/utils/date_time_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:diameter/navigation.dart';
class ActiveLogEventListScreen extends StatefulWidget { class ActiveEventListScreen extends StatefulWidget {
static const String routeName = '/active-log-events'; static const String routeName = '/active-log-events';
const ActiveEventListScreen({Key? key}) : super(key: key);
final int endLogEntryId;
final Function()? onSetEndTime;
const ActiveLogEventListScreen(
{Key? key, this.endLogEntryId = 0, this.onSetEndTime})
: super(key: key);
@override @override
_ActiveLogEventListScreenState createState() => _ActiveEventListScreenState createState() => _ActiveEventListScreenState();
_ActiveLogEventListScreenState();
} }
class _ActiveLogEventListScreenState extends State<ActiveLogEventListScreen> {
List<LogEvent> _activeLogEvents = []; class _ActiveEventListScreenState extends State<ActiveEventListScreen> {
List<LogEvent> _activeEvents = [];
@override @override
void initState() { void initState() {
@ -31,7 +28,7 @@ class _ActiveLogEventListScreenState extends State<ActiveLogEventListScreen> {
void reload({String? message}) { void reload({String? message}) {
setState(() { setState(() {
_activeLogEvents = LogEvent.getAllOngoing(); _activeEvents = LogEvent.getAllActiveForTime(DateTime.now());
}); });
setState(() { setState(() {
@ -47,104 +44,35 @@ class _ActiveLogEventListScreenState extends State<ActiveLogEventListScreen> {
}); });
} }
void onStop(LogEvent event) async {
event.endTime = DateTime.now();
event.endLogEntry.target =
LogEntry.get(widget.endLogEntryId) ?? LogEntry(time: DateTime.now());
LogEvent.put(event);
reload();
if (widget.onSetEndTime != null) {
widget.onSetEndTime!();
}
}
void handleStopAction(LogEvent event) async { void handleAddNewEvent() async {
if (showConfirmationDialogOnStopEvent) { Navigator.push(
Dialogs.showConfirmationDialog( context,
context: context, MaterialPageRoute(
onConfirm: () => onStop(event), builder: (context) {
message: 'Are you sure you want to end this Event?', return const LogEventDetailScreen();
); },
} else { ),
onStop(event); ).then((message) => reload(message: message));
}
}
void onDelete(LogEvent event) {
LogEvent.remove(event.id);
reload(message: 'Event deleted');
}
void handleDeleteAction(LogEvent event) async {
if (showConfirmationDialogOnDelete) {
Dialogs.showConfirmationDialog(
context: context,
onConfirm: () => onDelete(event),
message: 'Are you sure you want to delete this Event?',
);
} else {
onDelete(event);
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return Scaffold(
padding: const EdgeInsets.only(top: 10.0), appBar: AppBar(
child: Column( title: const Text('Active Events'),
children: [ actions: <Widget>[
AppBar( IconButton(onPressed: reload, icon: const Icon(Icons.refresh))
title: const Text('Active Events'),
primary: false,
automaticallyImplyLeading: false,
actions: [
IconButton(icon: const Icon(Icons.refresh), onPressed: reload),
],
),
_activeLogEvents.isNotEmpty ?
ListView.builder(
shrinkWrap: true,
itemCount: _activeLogEvents.length,
itemBuilder: (context, index) {
final event = _activeLogEvents[index];
return ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Text(event.eventType.target?.value ?? ''),
),
],
),
subtitle: Text(
'${DateTimeUtils.displayDateTime(event.time)}${event.hasEndTime ? ' - ${DateTimeUtils.displayDateTime(event.endTime)}' : ''}'),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(
Icons.delete,
color: Colors.blue,
),
onPressed: () => handleStopAction(event),
),
IconButton(
icon: const Icon(
Icons.delete,
color: Colors.blue,
),
onPressed: () => handleDeleteAction(event),
),
],
),
);
},
) : const Center(
child: Text('There are no currently ongoing events!'),
),
], ],
), ),
drawer:
const Navigation(currentLocation: ActiveEventListScreen.routeName),
body: LogEventListScreen(activeEvents: _activeEvents),
floatingActionButton: FloatingActionButton(
onPressed: handleAddNewEvent,
child: const Icon(Icons.add),
),
); );
} }
} }

View File

@ -52,7 +52,7 @@ class _LogBolusDetailScreenState extends State<LogBolusDetailScreen> {
reload(); reload();
_logEntry = LogEntry.get(widget.logEntryId); _logEntry = LogEntry.get(widget.logEntryId);
_logMeals = _logEntry?.meals ?? []; _logMeals = LogMeal.getAllForEntry(widget.logEntryId);
if (widget.id != 0) { if (widget.id != 0) {
_unitsController.text = _logBolus!.units.toString(); _unitsController.text = _logBolus!.units.toString();
@ -91,9 +91,9 @@ class _LogBolusDetailScreenState extends State<LogBolusDetailScreen> {
void onChangeCarbs() { void onChangeCarbs() {
setState(() { setState(() {
if (_rate != null && !_setManually) { if (_rate != null && !_setManually) {
_unitsController.text = _unitsController.text = ((double.tryParse(_carbsController.text) ?? 0) /
((double.tryParse(_carbsController.text) ?? 0) / (_rate!.carbs / _rate!.units)) (_rate!.carbs / _rate!.units))
.toString(); .toString();
} }
}); });
} }
@ -196,7 +196,6 @@ class _LogBolusDetailScreenState extends State<LogBolusDetailScreen> {
selectedItem: _meal, selectedItem: _meal,
label: 'Meal', label: 'Meal',
items: _logMeals, items: _logMeals,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
onSelectMeal(value); onSelectMeal(value);

View File

@ -69,7 +69,7 @@ class _LogBolusListScreenState extends State<LogBolusListScreen> {
} }
} }
void handleEditMealAction(int mealId) { void handleEditMealAction(int mealId) {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -86,23 +86,25 @@ class _LogBolusListScreenState extends State<LogBolusListScreen> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: widget.logEntry.boli.isNotEmpty child: widget.logBoli.isNotEmpty
? ListView.builder( ? ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: widget.logEntry.boli.length, itemCount: widget.logBoli.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final bolus = widget.logEntry.boli[index]; final bolus = widget.logBoli[index];
return ListTile( return ListTile(
onTap: () => handleEditAction(bolus), onTap: () => handleEditAction(bolus),
title: title: Text(
Text(
'${bolus.units} U per ${bolus.carbs}${nutritionMeasurement == NutritionMeasurement.grams ? ' g' : ' oz'} carbs/${glucoseMeasurement == GlucoseMeasurement.mgPerDl ? bolus.mgPerDl : bolus.mmolPerL} ${glucoseMeasurement == GlucoseMeasurement.mgPerDl ? 'mg/dl' : 'mmol/l'}'), '${bolus.units} U per ${bolus.carbs}${nutritionMeasurement == NutritionMeasurement.grams ? ' g' : ' oz'} carbs/${glucoseMeasurement == GlucoseMeasurement.mgPerDl ? bolus.mgPerDl : bolus.mmolPerL} ${glucoseMeasurement == GlucoseMeasurement.mgPerDl ? 'mg/dl' : 'mmol/l'}'),
trailing: Row( trailing: Row(
children: [ children: [
bolus.meal.target != null ? IconButton( bolus.meal.target != null
icon: const Icon(Icons.restaurant), ? IconButton(
onPressed: () => handleEditMealAction(bolus.meal.targetId), icon: const Icon(Icons.restaurant),
) : Container(), onPressed: () =>
handleEditMealAction(bolus.meal.targetId),
)
: Container(),
const SizedBox(width: 24), const SizedBox(width: 24),
IconButton( IconButton(
icon: const Icon( icon: const Icon(

View File

@ -32,6 +32,7 @@ class _LogEntryScreenState extends State<LogEntryScreen> {
LogEntry? _logEntry; LogEntry? _logEntry;
List<LogMeal> _logMeals = []; List<LogMeal> _logMeals = [];
List<LogEvent> _logEvents = []; List<LogEvent> _logEvents = [];
List<LogEvent> _activeEvents = [];
List<LogBolus> _logBoli = []; List<LogBolus> _logBoli = [];
bool _isNew = true; bool _isNew = true;
bool _isSaving = false; bool _isSaving = false;
@ -119,9 +120,10 @@ class _LogEntryScreenState extends State<LogEntryScreen> {
if (widget.id != 0) { if (widget.id != 0) {
setState(() { setState(() {
_logEntry = LogEntry.get(widget.id); _logEntry = LogEntry.get(widget.id);
_logMeals = _logEntry?.meals ?? []; _logMeals = LogMeal.getAllForEntry(widget.id);
_logEvents = _logEntry?.events ?? []; _logEvents = LogEvent.getAllForEntry(widget.id);
_logBoli = _logEntry?.boli ?? []; _activeEvents = LogEvent.getAllActiveForTime(_logEntry?.time).where((event) => !_logEvents.any((logEvent) => logEvent.id == event.id)).toList();
_logBoli = LogBolus.getAllForEntry(widget.id);
}); });
_isNew = _logEntry == null; _isNew = _logEntry == null;
} }
@ -490,7 +492,10 @@ class _LogEntryScreenState extends State<LogEntryScreen> {
tabs.add(LogBolusListScreen( tabs.add(LogBolusListScreen(
logEntry: _logEntry!, logBoli: _logBoli, reload: reload)); logEntry: _logEntry!, logBoli: _logBoli, reload: reload));
tabs.add(LogEventListScreen( tabs.add(LogEventListScreen(
logEntry: _logEntry!, logEvents: _logEvents, reload: reload)); logEntry: _logEntry!,
logEvents: _logEvents,
activeEvents: _activeEvents,
reload: reload));
} }
return Scaffold( return Scaffold(

View File

@ -3,6 +3,8 @@ import 'package:diameter/components/dialogs.dart';
import 'package:diameter/components/dropdown.dart'; import 'package:diameter/components/dropdown.dart';
import 'package:diameter/components/forms.dart'; import 'package:diameter/components/forms.dart';
import 'package:diameter/config.dart'; import 'package:diameter/config.dart';
import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/models/bolus_profile.dart';
import 'package:diameter/models/log_entry.dart'; import 'package:diameter/models/log_entry.dart';
import 'package:diameter/models/log_event.dart'; import 'package:diameter/models/log_event.dart';
import 'package:diameter/models/log_event_type.dart'; import 'package:diameter/models/log_event_type.dart';
@ -29,23 +31,37 @@ class _LogEventDetailScreenState extends State<LogEventDetailScreen> {
bool _isNew = true; bool _isNew = true;
bool _isSaving = false; bool _isSaving = false;
List<BolusProfile> _bolusProfiles = [];
List<BasalProfile> _basalProfiles = [];
final GlobalKey<FormState> _logEventForm = GlobalKey<FormState>(); final GlobalKey<FormState> _logEventForm = GlobalKey<FormState>();
final _reminderDurationController = TextEditingController(text: '');
final _notesController = TextEditingController(text: '');
LogEventType? _eventType; LogEventType? _eventType;
bool _hasEndTime = false; bool _hasEndTime = false;
final _notesController = TextEditingController(text: ''); BolusProfile? _bolusProfile;
BasalProfile? _basalProfile;
List<LogEventType> _logEventTypes = []; List<LogEventType> _logEventTypes = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
reload(); reload();
_bolusProfiles = BolusProfile.getAll();
_basalProfiles = BasalProfile.getAll();
if (_logEvent != null) { if (_logEvent != null) {
_reminderDurationController.text =
(_logEvent!.reminderDuration ?? '').toString();
_hasEndTime = _logEvent!.hasEndTime;
_notesController.text = _logEvent!.notes ?? ''; _notesController.text = _logEvent!.notes ?? '';
_eventType = _logEvent!.eventType.target; _eventType = _logEvent!.eventType.target;
_hasEndTime = _logEvent!.hasEndTime; _basalProfile = _logEvent!.basalProfile.target;
_bolusProfile = _logEvent!.bolusProfile.target;
} }
_logEventTypes = LogEventType.getAll(); _logEventTypes = LogEventType.getAll();
@ -60,6 +76,23 @@ class _LogEventDetailScreenState extends State<LogEventDetailScreen> {
_isNew = _logEvent == null; _isNew = _logEvent == null;
} }
void onSelectEventType(LogEventType eventType) {
setState(() {
_eventType = eventType;
_hasEndTime = eventType.hasEndTime;
if (eventType.basalProfile.target != null) {
_basalProfile = eventType.basalProfile.target;
}
if (eventType.bolusProfile.target != null) {
_bolusProfile = eventType.bolusProfile.target;
}
if (eventType.defaultReminderDuration != null) {
_reminderDurationController.text =
eventType.defaultReminderDuration.toString();
}
});
}
void handleSaveAction() async { void handleSaveAction() async {
setState(() { setState(() {
_isSaving = true; _isSaving = true;
@ -67,12 +100,19 @@ class _LogEventDetailScreenState extends State<LogEventDetailScreen> {
if (_logEventForm.currentState!.validate()) { if (_logEventForm.currentState!.validate()) {
LogEvent event = LogEvent( LogEvent event = LogEvent(
id: widget.id, id: widget.id,
time: LogEntry.get(widget.logEntryId)!.time, time: LogEntry.get(widget.logEntryId)?.time ?? DateTime.now(),
hasEndTime: _hasEndTime, hasEndTime: _hasEndTime,
reminderDuration: int.tryParse(_reminderDurationController.text),
notes: _notesController.text, notes: _notesController.text,
); );
event.logEntry.targetId = widget.logEntryId; if (widget.logEntryId != 0) {
event.logEntry.targetId = widget.logEntryId;
} else {
event.logEntry.target = LogEntry(time: DateTime.now());
}
event.eventType.target = _eventType; event.eventType.target = _eventType;
event.basalProfile.target = _basalProfile;
event.bolusProfile.target = _bolusProfile;
LogEvent.put(event); LogEvent.put(event);
Navigator.pop(context, '${_isNew ? 'New' : ''} Event Saved'); Navigator.pop(context, '${_isNew ? 'New' : ''} Event Saved');
} }
@ -119,11 +159,10 @@ class _LogEventDetailScreenState extends State<LogEventDetailScreen> {
selectedItem: _eventType, selectedItem: _eventType,
label: 'Event Type', label: 'Event Type',
items: _logEventTypes, items: _logEventTypes,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { if (value != null) {
_eventType = value; onSelectEventType(value);
}); }
}, },
), ),
BooleanFormField( BooleanFormField(
@ -135,6 +174,38 @@ class _LogEventDetailScreenState extends State<LogEventDetailScreen> {
}, },
label: 'has end time', label: 'has end time',
), ),
Column(
children: _hasEndTime ? [
TextFormField(
controller: _reminderDurationController,
keyboardType: const TextInputType.numberWithOptions(),
decoration: InputDecoration(
labelText: 'Default Reminder Duration',
suffixText: ' min',
enabled: _hasEndTime,
),
),
AutoCompleteDropdownButton<BolusProfile>(
selectedItem: _bolusProfile,
label: 'Bolus Profile',
items: _bolusProfiles,
onChanged: (value) {
setState(() {
_bolusProfile = value;
});
},
),
AutoCompleteDropdownButton<BasalProfile>(
selectedItem: _basalProfile,
label: 'Basal Profile',
items: _basalProfiles,
onChanged: (value) {
setState(() {
_basalProfile = value;
});
},
)
] : []),
TextFormField( TextFormField(
controller: _notesController, controller: _notesController,
decoration: const InputDecoration( decoration: const InputDecoration(

View File

@ -7,12 +7,13 @@ import 'package:diameter/utils/date_time_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class LogEventListScreen extends StatefulWidget { class LogEventListScreen extends StatefulWidget {
final LogEntry logEntry; final LogEntry? logEntry;
final List<LogEvent> logEvents; final List<LogEvent> logEvents;
final Function() reload; final List<LogEvent> activeEvents;
final Function()? reload;
const LogEventListScreen( const LogEventListScreen(
{Key? key, required this.logEntry, this.logEvents = const [], required this.reload}) {Key? key, this.logEntry, this.logEvents = const [], this.activeEvents = const [], this.reload})
: super(key: key); : super(key: key);
@override @override
@ -21,7 +22,9 @@ class LogEventListScreen extends StatefulWidget {
class _LogEventListScreenState extends State<LogEventListScreen> { class _LogEventListScreenState extends State<LogEventListScreen> {
void reload({String? message}) { void reload({String? message}) {
widget.reload(); if (widget.reload != null) {
widget.reload!();
}
setState(() { setState(() {
if (message != null) { if (message != null) {
@ -41,7 +44,7 @@ class _LogEventListScreenState extends State<LogEventListScreen> {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => LogEventDetailScreen( builder: (context) => LogEventDetailScreen(
logEntryId: widget.logEntry.id, logEntryId: widget.logEntry?.id ?? 0,
id: event.id, id: event.id,
), ),
), ),
@ -65,21 +68,42 @@ class _LogEventListScreenState extends State<LogEventListScreen> {
} }
} }
void onStop(LogEvent event) async {
event.endTime = DateTime.now();
event.endLogEntry.target =
LogEntry.get(widget.logEntry?.id ?? 0) ?? LogEntry(time: DateTime.now());
LogEvent.put(event);
reload(message: 'Event ended');
}
void handleStopAction(LogEvent event) async {
if (showConfirmationDialogOnStopEvent) {
Dialogs.showConfirmationDialog(
context: context,
onConfirm: () => onStop(event),
message: 'Are you sure you want to end this Event?',
confirmationLabel: 'END EVENT',
);
} else {
onStop(event);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded( Expanded(
child: (widget.logEntry.events.isNotEmpty || child: (widget.logEvents.isNotEmpty ||
widget.logEntry.endedEvents.isNotEmpty) widget.activeEvents.isNotEmpty)
? ListView.builder( ? ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: widget.logEntry.events.length + itemCount: widget.logEvents.length +
widget.logEntry.endedEvents.length, widget.activeEvents.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final event = (widget.logEntry.events + final event = (widget.logEvents +
widget.logEntry.endedEvents)[index]; widget.activeEvents)[index];
return ListTile( return ListTile(
onTap: () { onTap: () {
handleEditAction(event); handleEditAction(event);
@ -96,6 +120,14 @@ class _LogEventListScreenState extends State<LogEventListScreen> {
trailing: Row( trailing: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
event.hasEndTime && event.endTime == null ? IconButton(
icon: const Icon(
Icons.stop,
color: Colors.blue,
),
onPressed: () => handleStopAction(event),
) : Container(),
const SizedBox(width: 24),
IconButton( IconButton(
icon: const Icon( icon: const Icon(
Icons.delete, Icons.delete,
@ -107,9 +139,9 @@ class _LogEventListScreenState extends State<LogEventListScreen> {
), ),
); );
}) })
: const Center( : Center(
child: Text( child: Text(widget.logEntry == null ? 'There are no active Events!'
'You have not added any Events to this Log Entry yet!'), : 'You have not added any Events to this Log Entry yet!'),
), ),
), ),
], ],

View File

@ -286,7 +286,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _meal, selectedItem: _meal,
label: 'Meal', label: 'Meal',
items: _meals, items: _meals,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
onSelectMeal(value); onSelectMeal(value);
@ -297,7 +296,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _mealSource, selectedItem: _mealSource,
label: 'Meal Source', label: 'Meal Source',
items: _mealSources, items: _mealSources,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mealSource = value; _mealSource = value;
@ -308,7 +306,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _mealCategory, selectedItem: _mealCategory,
label: 'Meal Category', label: 'Meal Category',
items: _mealCategories, items: _mealCategories,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mealCategory = value; _mealCategory = value;
@ -319,7 +316,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _mealPortionType, selectedItem: _mealPortionType,
label: 'Meal Portion Type', label: 'Meal Portion Type',
items: _mealPortionTypes, items: _mealPortionTypes,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mealPortionType = value; _mealPortionType = value;
@ -386,8 +382,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _portionSizeAccuracy, selectedItem: _portionSizeAccuracy,
label: 'Portion Size Accuracy', label: 'Portion Size Accuracy',
items: _portionSizeAccuracies, items: _portionSizeAccuracies,
// getItemValue: (item) => item.objectId,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_portionSizeAccuracy = value; _portionSizeAccuracy = value;
@ -428,7 +422,6 @@ class _LogMealDetailScreenState extends State<LogMealDetailScreen> {
selectedItem: _carbsRatioAccuracy, selectedItem: _carbsRatioAccuracy,
label: 'Carbs Ratio Accuracy', label: 'Carbs Ratio Accuracy',
items: _carbsRatioAccuracies, items: _carbsRatioAccuracies,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_carbsRatioAccuracy = value; _carbsRatioAccuracy = value;

View File

@ -69,12 +69,12 @@ class _LogMealListScreenState extends State<LogMealListScreen> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: widget.logEntry.meals.isNotEmpty child: widget.logMeals.isNotEmpty
? ListView.builder( ? ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: widget.logEntry.meals.length, itemCount: widget.logMeals.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final meal = widget.logEntry.meals[index]; final meal = widget.logMeals[index];
return ListTile( return ListTile(
onTap: () => handleEditAction(meal), onTap: () => handleEditAction(meal),
title: Row( title: Row(

View File

@ -1,7 +1,10 @@
import 'package:diameter/components/detail.dart'; import 'package:diameter/components/detail.dart';
import 'package:diameter/components/dialogs.dart'; import 'package:diameter/components/dialogs.dart';
import 'package:diameter/components/dropdown.dart';
import 'package:diameter/components/forms.dart'; import 'package:diameter/components/forms.dart';
import 'package:diameter/config.dart'; import 'package:diameter/config.dart';
import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/models/bolus_profile.dart';
import 'package:diameter/models/log_event_type.dart'; import 'package:diameter/models/log_event_type.dart';
import 'package:diameter/navigation.dart'; import 'package:diameter/navigation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -21,12 +24,17 @@ class _LogEventTypeDetailScreenState extends State<LogEventTypeDetailScreen> {
bool _isNew = true; bool _isNew = true;
bool _isSaving = false; bool _isSaving = false;
List<BolusProfile> _bolusProfiles = [];
List<BasalProfile> _basalProfiles = [];
final GlobalKey<FormState> _logEventTypeForm = GlobalKey<FormState>(); final GlobalKey<FormState> _logEventTypeForm = GlobalKey<FormState>();
final _valueController = TextEditingController(text: ''); final _valueController = TextEditingController(text: '');
final _defaultReminderDurationController = TextEditingController(text: ''); final _defaultReminderDurationController = TextEditingController(text: '');
final _notesController = TextEditingController(text: ''); final _notesController = TextEditingController(text: '');
bool _hasEndTime = false; bool _hasEndTime = false;
BolusProfile? _bolusProfile;
BasalProfile? _basalProfile;
@override @override
void initState() { void initState() {
@ -34,12 +42,17 @@ class _LogEventTypeDetailScreenState extends State<LogEventTypeDetailScreen> {
reload(); reload();
_bolusProfiles = BolusProfile.getAll();
_basalProfiles = BasalProfile.getAll();
if (_logEventType != null) { if (_logEventType != null) {
_valueController.text = _logEventType!.value; _valueController.text = _logEventType!.value;
_defaultReminderDurationController.text = _defaultReminderDurationController.text =
(_logEventType!.defaultReminderDuration ?? '').toString(); (_logEventType!.defaultReminderDuration ?? '').toString();
_notesController.text = _logEventType!.notes ?? '';
_hasEndTime = _logEventType!.hasEndTime; _hasEndTime = _logEventType!.hasEndTime;
_notesController.text = _logEventType!.notes ?? '';
_basalProfile = _logEventType!.basalProfile.target;
_bolusProfile = _logEventType!.bolusProfile.target;
} }
} }
@ -57,16 +70,18 @@ class _LogEventTypeDetailScreenState extends State<LogEventTypeDetailScreen> {
_isSaving = true; _isSaving = true;
}); });
if (_logEventTypeForm.currentState!.validate()) { if (_logEventTypeForm.currentState!.validate()) {
bool isNew = _logEventType == null; LogEventType eventType = LogEventType(
LogEventType.put(LogEventType(
id: widget.id, id: widget.id,
value: _valueController.text, value: _valueController.text,
notes: _notesController.text, notes: _notesController.text,
defaultReminderDuration: defaultReminderDuration:
int.tryParse(_defaultReminderDurationController.text), int.tryParse(_defaultReminderDurationController.text),
hasEndTime: _hasEndTime, hasEndTime: _hasEndTime,
)); );
Navigator.pop(context, '${isNew ? 'New' : ''} Log Event Type Saved'); eventType.basalProfile.target = _basalProfile;
eventType.bolusProfile.target = _bolusProfile;
LogEventType.put(eventType);
Navigator.pop(context, '${_isNew ? 'New' : ''} Log Event Type Saved');
} }
setState(() { setState(() {
_isSaving = false; _isSaving = false;
@ -135,15 +150,38 @@ class _LogEventTypeDetailScreenState extends State<LogEventTypeDetailScreen> {
}); });
}, },
), ),
TextFormField( Column(
controller: _defaultReminderDurationController, children: _hasEndTime ? [
keyboardType: const TextInputType.numberWithOptions(), TextFormField(
decoration: InputDecoration( controller: _defaultReminderDurationController,
labelText: 'Default Reminder Duration', keyboardType: const TextInputType.numberWithOptions(),
suffixText: ' min', decoration: InputDecoration(
enabled: _hasEndTime, labelText: 'Default Reminder Duration',
), suffixText: ' min',
enabled: _hasEndTime,
),
),
AutoCompleteDropdownButton<BolusProfile>(
selectedItem: _bolusProfile,
label: 'Bolus Profile',
items: _bolusProfiles,
onChanged: (value) {
setState(() {
_bolusProfile = value;
});
},
), ),
AutoCompleteDropdownButton<BasalProfile>(
selectedItem: _basalProfile,
label: 'Basal Profile',
items: _basalProfiles,
onChanged: (value) {
setState(() {
_basalProfile = value;
});
},
),
] : []),
TextFormField( TextFormField(
controller: _notesController, controller: _notesController,
decoration: const InputDecoration( decoration: const InputDecoration(
@ -152,7 +190,7 @@ class _LogEventTypeDetailScreenState extends State<LogEventTypeDetailScreen> {
), ),
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
), ),
], ]
), ),
], ],
), ),

View File

@ -255,7 +255,6 @@ class _MealDetailScreenState extends State<MealDetailScreen> {
selectedItem: _mealSource, selectedItem: _mealSource,
label: 'Meal Source', label: 'Meal Source',
items: _mealSources, items: _mealSources,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
onSelectMealSource(value); onSelectMealSource(value);
@ -266,7 +265,6 @@ class _MealDetailScreenState extends State<MealDetailScreen> {
selectedItem: _mealCategory, selectedItem: _mealCategory,
label: 'Meal Category', label: 'Meal Category',
items: _mealCategories, items: _mealCategories,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mealCategory = value; _mealCategory = value;
@ -277,7 +275,6 @@ class _MealDetailScreenState extends State<MealDetailScreen> {
selectedItem: _mealPortionType, selectedItem: _mealPortionType,
label: 'Meal Portion Type', label: 'Meal Portion Type',
items: _mealPortionTypes, items: _mealPortionTypes,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mealPortionType = value; _mealPortionType = value;
@ -344,7 +341,6 @@ class _MealDetailScreenState extends State<MealDetailScreen> {
selectedItem: _portionSizeAccuracy, selectedItem: _portionSizeAccuracy,
label: 'Portion Size Accuracy', label: 'Portion Size Accuracy',
items: _portionSizeAccuracies, items: _portionSizeAccuracies,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_portionSizeAccuracy = value; _portionSizeAccuracy = value;
@ -385,7 +381,6 @@ class _MealDetailScreenState extends State<MealDetailScreen> {
selectedItem: _carbsRatioAccuracy, selectedItem: _carbsRatioAccuracy,
label: 'Carbs Ratio Accuracy', label: 'Carbs Ratio Accuracy',
items: _carbsRatioAccuracies, items: _carbsRatioAccuracies,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_carbsRatioAccuracy = value; _carbsRatioAccuracy = value;

View File

@ -151,7 +151,6 @@ class _MealSourceDetailScreenState extends State<MealSourceDetailScreen> {
selectedItem: _defaultCarbsRatioAccuracy, selectedItem: _defaultCarbsRatioAccuracy,
label: 'Default Carbs Ratio Accuracy', label: 'Default Carbs Ratio Accuracy',
items: _carbsRatioAccuracies, items: _carbsRatioAccuracies,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_defaultCarbsRatioAccuracy = value; _defaultCarbsRatioAccuracy = value;
@ -162,7 +161,6 @@ class _MealSourceDetailScreenState extends State<MealSourceDetailScreen> {
selectedItem: _defaultPortionSizeAccuracy, selectedItem: _defaultPortionSizeAccuracy,
label: 'Default Portion Size Accuracy', label: 'Default Portion Size Accuracy',
items: _portionSizeAccuracies, items: _portionSizeAccuracies,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_defaultPortionSizeAccuracy = value; _defaultPortionSizeAccuracy = value;
@ -173,7 +171,6 @@ class _MealSourceDetailScreenState extends State<MealSourceDetailScreen> {
selectedItem: _defaultMealCategory, selectedItem: _defaultMealCategory,
label: 'Default Meal Category', label: 'Default Meal Category',
items: _mealCategories, items: _mealCategories,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_defaultMealCategory = value; _defaultMealCategory = value;
@ -184,7 +181,6 @@ class _MealSourceDetailScreenState extends State<MealSourceDetailScreen> {
selectedItem: _defaultMealPortionType, selectedItem: _defaultMealPortionType,
label: 'Default Meal Portion Type', label: 'Default Meal Portion Type',
items: _mealPortionTypes, items: _mealPortionTypes,
renderItem: (item) => item.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_defaultMealPortionType = value; _defaultMealPortionType = value;

View File

@ -135,7 +135,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
selectedItem: nutritionMeasurement, selectedItem: nutritionMeasurement,
label: 'Preferred Nutrition Measurement', label: 'Preferred Nutrition Measurement',
items: NutritionMeasurement.values, items: NutritionMeasurement.values,
renderItem: (item) => item.toString().split('.')[1],
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
Settings.setNutritionMeasurement(value); Settings.setNutritionMeasurement(value);
@ -149,7 +148,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
selectedItem: glucoseMeasurement, selectedItem: glucoseMeasurement,
label: 'Preferred Glucose Measurement', label: 'Preferred Glucose Measurement',
items: GlucoseMeasurement.values, items: GlucoseMeasurement.values,
renderItem: (item) => item.toString().split('.')[1],
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
Settings.setGlucoseMeasurement(value); Settings.setGlucoseMeasurement(value);