Skip to content

Commit

Permalink
refactor(intg): save left and right entries
Browse files Browse the repository at this point in the history
This will be used for continuous evaluation
  • Loading branch information
lemredd committed Dec 23, 2022
1 parent 1511b9a commit 49c830f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/CalculatorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import OperationalButton from "@/CalculatorContainer/OperationalButton.vue"
// EntryScreen data and mutators
const entryValue = ref("0")
const leftEntry = ref("")
const rightEntry = ref("")
const mustResetOnNextEntry = ref(false)
const isEntryValueEmpty = computed(() => entryValue.value === "0")
Expand All @@ -25,12 +27,16 @@ function appendToEntryScreen(valueToAppend: string|number) {
}
// EvaluationScreen data and mutators
const operation = ref("")
const evaluationValue = ref("")
const isEvaluationValueEmpty = computed(() => evaluationValue.value === "")
function appendToEvaluationScreen(valueToAppend: PossibleButtonValues) {
const isEvaluating = valueToAppend === "="
mustResetOnNextEntry.value = true
if (!isEvaluating && !leftEntry.value) leftEntry.value = entryValue.value
if (isEvaluating && !rightEntry.value) rightEntry.value = entryValue.value
if (!isEvaluationValueEmpty.value) evaluationValue.value += ` ${entryValue.value} ${valueToAppend}`
else evaluationValue.value = `${entryValue.value} ${valueToAppend}`
}
Expand Down

0 comments on commit 49c830f

Please sign in to comment.