Skip to content

Commit

Permalink
Jackfan0305/tppdev 45 logging new option in logger (#181)
Browse files Browse the repository at this point in the history
* - added ovulating egg svg

* - added ovulation to accordion

* - added ovulation as an selection

* Add- ovulating parameter to Symptoms constructor

* added ovulation to get getSymptomsFromCalendar

* Dummy function: calculateAverageOvulationLength

* added Ovulation (#180)

* added Ovulation

* fixed typo and icon

* fixed ovulation.svg

* added Ovulation to Setting's Preference (#182)

Co-authored-by: Merrick Liu <[email protected]>

* Added ovulation to calender (#183)

* added ovulation to calender

* fixed per comment

* - changed directory

* - changed to 'ovulation' for consistent naming scheme

* - added ovulation on calendar

* - tracking ovulation

---------

Co-authored-by: Merrick Liu <[email protected]>
Co-authored-by: Sataphon Obra <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent a6b26ac commit 164d89d
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 11 deletions.
21 changes: 20 additions & 1 deletion tpp-app/src/home/components/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ExpandArrow from "../../../assets/icons/arrow_accordion.svg";
import OptionPicker from "./OptionPicker";
import TimeInput from "./TimeInput";
import TextArea from "./TextArea";
import { FLOW_LEVEL, CRAMP_LEVEL, MOOD_LEVEL, EXERCISE_TYPE } from "../../services/utils/constants";
import { FLOW_LEVEL, CRAMP_LEVEL, MOOD_LEVEL, EXERCISE_TYPE, OVULATION } from "../../services/utils/constants";
import { ExerciseActivity } from "../../services/utils/models";

// ALL ICON IMPORTS
Expand Down Expand Up @@ -48,6 +48,10 @@ import CycleSports from "../../../assets/icons/symptoms/exercise/exercise-cycle-
import RacketSports from "../../../assets/icons/symptoms/exercise/exercise-racket-sports.svg";
import WinterSports from "../../../assets/icons/symptoms/exercise/exercise-winter-sports.svg";


//OVULATION ICONS
import OvulatingIcon from "../../../assets/icons/ovulation.svg";

const accordionData = {
flow: {
title: "Flow",
Expand Down Expand Up @@ -105,6 +109,13 @@ const accordionData = {
<WinterSports value={EXERCISE_TYPE.WINTER_SPORT} />,
],
},
ovulation:{
title: "Ovulation",
icon: OvulatingIcon,
options: [
<OvulatingIcon fill={"#000"} value={OVULATION.OVULATING} />,
]
},
notes: {
title: "Notes",
icon: NotesIcon,
Expand Down Expand Up @@ -212,6 +223,14 @@ export default class Accordion extends Component {
case "notes":
accContent = <TextArea onInput={this.props.setState} curVal={this.props.value} />;
break;
case "ovulation":
accContent = (
<OptionPicker
optionIcons={this.accordionType.options}
selectThis={this.props.setState}
curVal={this.props.value}
/>
);
default: // render empty accordion
break;
}
Expand Down
4 changes: 3 additions & 1 deletion tpp-app/src/home/components/DayComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
ExerciseWinterSportIcon,
ExerciseYogaIcon,
} from "../../services/utils/calendaricons";
import { OvulatingIcon } from "../../services/utils/calendaricons";
import { VIEWS } from "../../services/utils/constants";
import { FILTER_COLOURS, FILTER_TEXT_COLOURS } from "../../services/utils/constants";
import { CALENDAR_STACK_SCREENS } from "../CalendarNavigator";
Expand All @@ -55,7 +56,7 @@ export const DayComponent = ({ date, state, marking, selectedView, navigation })
// i.e. for flow it would be HEAVY/MEDIUM/LIGHT
// for sleep it will be a number etc.
let symptomAttribute = marking.symptoms ? marking.symptoms[viewKey] : null;

// If disabled
if (marking.disable) {
bgColor = FILTER_COLOURS.DISABLED;
Expand Down Expand Up @@ -229,5 +230,6 @@ const ICON_TYPES = {
exercisewatersports: ExerciseWaterSportIcon,
exercisewintersports: ExerciseWinterSportIcon,
exerciseyoga: ExerciseYogaIcon,
ovulationovulating : OvulatingIcon,
view: SafeAreaView,
};
16 changes: 11 additions & 5 deletions tpp-app/src/home/pages/LogSymptomsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ const DateArrow = ({ onPress, isRight }) => {
);
};

const symptoms = ["flow", "mood", "sleep", "cramps", "exercise", "notes"]; // order of symptom accordions
const symptoms = ["flow", "ovulation", "mood", "sleep", "cramps", "exercise", "notes"]; // order of symptom accordions

export default function LogSymptomsScreen({ navigation, route }) {
const initialPrefs = ["notes"];
const initialPrefs = ["ovulation", "notes"];
const [trackingPrefs, setPrefs] = useState(initialPrefs); // list of symptoms to track, default is always 'notes'
const [loaded, setLoaded] = useState(false);

Expand Down Expand Up @@ -113,6 +113,7 @@ export default function LogSymptomsScreen({ navigation, route }) {
const [crampsStr, setCramps] = useState(null);
const [exerciseObj, setExercise] = useState(null);
const [notesStr, setNotes] = useState(null);
const [isOvulating, setIsOvulating] = useState(null); // 'Ovulating' if true, null if false

const [submitting, setSubmitting] = useState(false);
const [isDirty, setDirty] = useState(false); // if there are changes to submit
Expand Down Expand Up @@ -140,6 +141,10 @@ export default function LogSymptomsScreen({ navigation, route }) {
state: exerciseObj,
setState: setExercise,
},
ovulation: {
state: isOvulating,
setState: setIsOvulating,
},
notes: {
state: notesStr,
setState: setNotes,
Expand All @@ -164,6 +169,7 @@ export default function LogSymptomsScreen({ navigation, route }) {
setSleep(initSymps.sleep);
setCramps(initSymps.cramps);
setExercise(initSymps.exercise);
setIsOvulating(initSymps.ovulation);
setNotes(initSymps.notes);

setSympFetch(false);
Expand Down Expand Up @@ -205,13 +211,13 @@ export default function LogSymptomsScreen({ navigation, route }) {
if (typeof notesStr === "string" && notesStr.length <= 0) {
setNotes(null);
}
}, [flowStr, moodStr, sleepMins, crampsStr, exerciseObj, notesStr]);
}, [flowStr, moodStr, sleepMins, crampsStr, exerciseObj, isOvulating, notesStr]);

// POST symptoms and close screen when submitting is true
useEffect(() => {
if (!submitting) return;

let finalSymps = new Symptoms(flowStr, moodStr, sleepMins, crampsStr, exerciseObj, notesStr);
let finalSymps = new Symptoms(flowStr, moodStr, sleepMins, crampsStr, exerciseObj, notesStr, isOvulating);
// If all symptoms are null, POST null instead of an empty Symptom object
let notEmpty = Object.values(finalSymps).some((symptom) => symptom !== null);
let submitSymp = notEmpty ? finalSymps : new Symptoms();
Expand Down Expand Up @@ -313,7 +319,7 @@ export default function LogSymptomsScreen({ navigation, route }) {
>
<CloseIcon fill={"#000000"} />
</TouchableOpacity>

{/* SWITCH AND DISPLAY DATE */}
<View style={styles.switchDate}>
{isNewDayValid(false, selectedDate) ? (
Expand Down
2 changes: 1 addition & 1 deletion tpp-app/src/services/CalendarService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const GETYearData = async (year) => {
let parsedYear = yearObject.map((month) => {
let parsedMonth = month.map((day) => {
return day
? new Symptoms(day["flow"], day["mood"], day["sleep"], day["cramps"], day["exercise"], day["notes"])
? new Symptoms(day["flow"], day["mood"], day["sleep"], day["cramps"], day["exercise"], day["notes"], day["ovulation"])
: new Symptoms();
});

Expand Down
1 change: 1 addition & 0 deletions tpp-app/src/services/SettingsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const GETAllTrackingPreferences = async () =>
TRACK_SYMPTOMS.SLEEP,
TRACK_SYMPTOMS.CRAMPS,
TRACK_SYMPTOMS.EXERCISE,
TRACK_SYMPTOMS.OVULATION,
]).then((values) => {
console.log("Got All Tracking Preferences");
resolve(values);
Expand Down
2 changes: 2 additions & 0 deletions tpp-app/src/services/utils/calendaricons.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ExerciseStrengthIcon from "../../../assets/icons/symptoms/exercise/exerci
import ExerciseWaterSportIcon from "../../../assets/icons/symptoms/exercise/exercise-water-sports.svg";
import ExerciseWinterSportIcon from "../../../assets/icons/symptoms/exercise/exercise-winter-sports.svg";
import ExerciseYogaIcon from "../../../assets/icons/symptoms/exercise/exercise-yoga.svg";
import OvulatingIcon from "../../../assets/icons/ovulation.svg";

export {
CrampsTerribleIcon,
Expand Down Expand Up @@ -56,4 +57,5 @@ export {
ExerciseWaterSportIcon,
ExerciseWinterSportIcon,
ExerciseYogaIcon,
OvulatingIcon
};
10 changes: 10 additions & 0 deletions tpp-app/src/services/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export const TRACK_SYMPTOMS = {
OVULATION: "trackOvulation",
};

export const OVULATION = {
OVULATING: "Ovulating",
}

export const FILTER_COLOURS = {
FLOW: {
HEAVY: "#D42629",
Expand Down Expand Up @@ -74,6 +78,9 @@ export const FILTER_COLOURS = {
LIGHT: "#467CCD",
LITTLE: "#92B8F0",
},
OVULATION: {
OVULATING: "#69DAC6",
},
DISABLED: "#EEEEEE",
NOFILTER: "#FFFFFF",
};
Expand Down Expand Up @@ -105,6 +112,9 @@ export const FILTER_TEXT_COLOURS = {
LIGHT: "#FFF",
LITTLE: "#000",
},
OVULATION:{
OVULATING: "#000",
},
DISABLED: "#AAAAAA",
NOFILTER: "#000000",
};
Expand Down
3 changes: 2 additions & 1 deletion tpp-app/src/services/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export const getSymptomsFromCalendar = (calendar, day, month, year) => {
rawSymptoms.sleep,
rawSymptoms.cramps,
rawSymptoms.exercise,
rawSymptoms.notes
rawSymptoms.notes,
rawSymptoms.ovulation
)
: new Symptoms();
} else {
Expand Down
4 changes: 2 additions & 2 deletions tpp-app/src/services/utils/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* The symptoms of each day
*/
export class Symptoms {
constructor(flow = null, mood = null, sleep = null, cramps = null, exercise = null, notes = null, ovulating = null) {
constructor(flow = null, mood = null, sleep = null, cramps = null, exercise = null, notes = null, ovulation = null) {
this.flow = flow;
this.mood = mood;
this.sleep = sleep;
this.cramps = cramps;
this.exercise = exercise;
this.notes = notes;
this.ovulating = ovulating;
this.ovulation = ovulation;
}
}

Expand Down

0 comments on commit 164d89d

Please sign in to comment.