Created
August 23, 2020 09:20
-
-
Save Zambrella/428394a13a288054591aaa7286d1648f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntryListModel extends ChangeNotifier { | |
List<Entry2> entryList = <Entry2>[]; | |
void addNewEntry(EntryType entryType) { | |
entryList.add(Entry2(entryType)); | |
notifyListeners(); | |
} | |
void deleteEntry(String id) { | |
entryList.removeWhere((element) => element.id == id); | |
notifyListeners(); | |
} | |
} | |
class Entry2 { | |
Entry2(EntryType entryType) | |
: id = Uuid().v1(), | |
submitTime = DateTime.now() { | |
this.entryType = entryType; | |
if (entryType == EntryType.BowelMovement) { | |
entryValues.addAll([ | |
ValueClass(name: 'Bristol Scale', minValue: 1, maxValue: 7, inputType: InputType.Slider), | |
ValueClass(name: 'Discomfort', inputType: InputType.Slider), | |
ValueClass(name: 'Amount', inputType: InputType.Slider) | |
]); | |
} else if (entryType == EntryType.Symptom) { | |
entryValues.addAll([ | |
ValueClass(name: 'Strength', inputType: InputType.Slider), | |
ValueClass(name: 'Symptom Type', inputType: InputType.Picker) | |
]); | |
} else if (entryType == EntryType.Food) { | |
entryValues.addAll([ | |
ValueClass(name: 'Food Type', inputType: InputType.Picker), | |
ValueClass(name: 'Amount', inputType: InputType.Slider) | |
]); | |
} else if (entryType == EntryType.Emotion) { | |
entryValues.addAll([ | |
ValueClass(name: 'Emotion Type', inputType: InputType.Picker), | |
ValueClass(name: 'Emotion Strength', inputType: InputType.Picker) | |
]); | |
} else if (entryType == EntryType.Medication) { | |
entryValues.addAll([ | |
ValueClass(name: 'Medication Name', inputType: InputType.Text), | |
ValueClass(name: 'Medication Amount', inputType: InputType.Text), | |
ValueClass(name: 'Units', inputType: InputType.Text) | |
]); | |
} else if (entryType == EntryType.Sleep) { | |
entryValues.addAll([ | |
ValueClass(name: 'Hours', inputType: InputType.Text), | |
ValueClass(name: 'Quality', inputType: InputType.Slider), | |
]); | |
} | |
} | |
EntryType entryType; | |
String id; | |
DateTime submitTime; | |
List<ValueClass> entryValues = []; | |
void updateEntryValues(int index, int newValue) { | |
entryValues[index].value = newValue; | |
print("Value updates to $newValue"); | |
} | |
final Map<EntryType, String> entryTypeNames = { | |
EntryType.BowelMovement: 'Bowel Movement', | |
EntryType.Symptom: 'Symptom', | |
EntryType.Food: 'Food', | |
EntryType.Emotion: 'Emotion', | |
EntryType.Medication: 'Medication', | |
EntryType.Sleep: 'Sleep', | |
}; | |
final Map<SymptomType, String> symptomNames = { | |
SymptomType.StomachPain: 'Stomach Pain', | |
SymptomType.Headache: 'Headache', | |
SymptomType.Tiredness: 'Tiredness' | |
}; | |
} | |
class ValueClass { | |
InputType inputType; | |
String name; | |
int minValue; | |
int maxValue; | |
dynamic value; | |
ValueClass({@required this.name, this.minValue = 1, this.maxValue = 5, this.value = 4, @required this.inputType}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment