Skip button on measurable dialog

This commit is contained in:
Jakub Kalinowski
2022-03-09 19:44:38 +01:00
parent 2523c8e15f
commit 5527fd3514
4 changed files with 24 additions and 39 deletions

View File

@@ -26,7 +26,7 @@ data class Entry(
/**
* Value indicating that the habit is not applicable for this timestamp.
*/
const val SKIP = -3
const val SKIP = -2
/**
* Value indicating that the user has performed the habit at this timestamp.

View File

@@ -60,34 +60,19 @@ class HistoryCardPresenter(
val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback()
if (habit.isNumerical) {
// val entries = habit.computedEntries
// val oldValue = entries.get(timestamp).value
// screen.showNumberPicker(oldValue / 1000.0, habit.unit) { newValue: Double ->
// val thousands = (newValue * 1000).roundToInt()
// commandRunner.run(
// CreateRepetitionCommand(
// habitList,
// habit,
// timestamp,
// thousands,
// ),
// )
// }
val currentValue = habit.computedEntries.get(timestamp).value
val nextValue = Entry.nextToggleValue(
value = currentValue,
isSkipEnabled = preferences.isSkipEnabled,
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
)
commandRunner.run(
CreateRepetitionCommand(
habitList,
habit,
timestamp,
nextValue,
),
)
val entries = habit.computedEntries
val oldValue = entries.get(timestamp).value
screen.showNumberPicker(oldValue / 1000.0, habit.unit) { newValue: Double ->
val thousands = (newValue * 1000).roundToInt()
commandRunner.run(
CreateRepetitionCommand(
habitList,
habit,
timestamp,
thousands,
),
)
}
} else {
val currentValue = habit.computedEntries.get(timestamp).value
val nextValue = Entry.nextToggleValue(
@@ -120,14 +105,6 @@ class HistoryCardPresenter(
val oldest = habit.computedEntries.getKnown().lastOrNull()?.timestamp ?: today
val entries = habit.computedEntries.getByInterval(oldest, today)
val series = if (habit.isNumerical) {
// entries.map {
// Entry(it.timestamp, max(0, it.value))
// }.map {
// when (it.value) {
// 0 -> HistoryChart.Square.OFF
// else -> HistoryChart.Square.ON
// }
// }
entries.map {
when {
it.value == SKIP -> {