mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-15 13:38:52 -06:00
Experimenting
This commit is contained in:
@@ -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 = -3
|
||||
|
||||
/**
|
||||
* Value indicating that the user has performed the habit at this timestamp.
|
||||
|
||||
@@ -60,19 +60,34 @@ 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 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,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val currentValue = habit.computedEntries.get(timestamp).value
|
||||
val nextValue = Entry.nextToggleValue(
|
||||
@@ -105,12 +120,25 @@ 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 {
|
||||
Entry(it.timestamp, max(0, it.value))
|
||||
}.map {
|
||||
when (it.value) {
|
||||
0 -> HistoryChart.Square.OFF
|
||||
else -> HistoryChart.Square.ON
|
||||
when {
|
||||
it.value == SKIP -> {
|
||||
HistoryChart.Square.HATCHED
|
||||
}
|
||||
it.value > 0 -> {
|
||||
HistoryChart.Square.ON
|
||||
}
|
||||
else -> {
|
||||
HistoryChart.Square.OFF
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user