diameter/lib/models/settings.dart

96 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:diameter/main.dart';
import 'package:objectbox/objectbox.dart';
enum GlucoseDisplayMode { activeOnly, bothForList, bothForDetail, both }
List<String> glucoseDisplayModeLabels = [
'activeOnly',
'bothForList',
'bothForDetail',
'both',
];
enum GlucoseMeasurement {
mgPerDl,
mmolPerL,
}
List<String> glucoseMeasurementSuffixes = [
'mg/dl',
'mmol/l',
];
List<String> glucoseMeasurementLabels = [
'mgPerDl',
'mmolPerL',
];
enum NutritionMeasurement {
grams,
ounces,
lbs,
}
List<String> nutritionMeasurementSuffixes = [
'g',
'oz',
'lbs',
];
List<String> nutritionMeasurementLabels = [
'grams',
'ounces',
'lbs',
];
@Entity(uid: 3989341091218179227)
class Settings {
static final Box<Settings> box = objectBox.store.box<Settings>();
// properties
int id;
NutritionMeasurement nutritionMeasurement;
GlucoseDisplayMode glucoseDisplayMode;
GlucoseMeasurement glucoseMeasurement;
String dateFormat;
String? longDateFormat;
String timeFormat;
String? longTimeFormat;
bool showConfirmationDialogOnCancel;
bool showConfirmationDialogOnDelete;
bool showConfirmationDialogOnStopEvent;
int lowGlucoseMgPerDl;
int moderateGlucoseMgPerDl;
int highGlucoseMgPerDl;
double lowGlucoseMmolPerL;
double moderateGlucoseMmolPerL;
double highGlucoseMmolPerDl;
// constructor
Settings({
this.id = 0,
this.nutritionMeasurement = NutritionMeasurement.grams,
this.glucoseDisplayMode = GlucoseDisplayMode.bothForList,
this.glucoseMeasurement = GlucoseMeasurement.mgPerDl,
this.dateFormat = 'MM/dd/yy',
this.longDateFormat = 'MMMM dd, yyyy',
this.timeFormat = 'HH:mm',
this.longTimeFormat = 'HH:mm:ss',
this.showConfirmationDialogOnCancel = true,
this.showConfirmationDialogOnDelete = true,
this.showConfirmationDialogOnStopEvent = true,
this.lowGlucoseMgPerDl = 80,
this.moderateGlucoseMgPerDl = 140,
this.highGlucoseMgPerDl = 240,
this.lowGlucoseMmolPerL = 4.44,
this.moderateGlucoseMmolPerL = 7.77,
this.highGlucoseMmolPerDl = 13.32,
});
// methods
static Settings get() => box.getAll().single;
static void put(Settings settings) => box.put(settings);
static void reset() {
box.removeAll();
box.put(Settings());
}
}