Replace RepetitionList by Entries

This commit is contained in:
2020-12-24 20:35:33 -06:00
parent c904e22c0f
commit 3f74c77755
35 changed files with 192 additions and 1238 deletions

View File

@@ -52,7 +52,9 @@ class FrequencyCardPresenter(
) {
fun present() = FrequencyCardViewModel(
color = habit.color,
frequency = habit.originalEntries.weekdayFrequency,
frequency = habit.originalEntries.computeWeekdayFrequency(
isNumerical = habit.isNumerical
),
firstWeekday = firstWeekday,
)
}

View File

@@ -25,6 +25,7 @@ import android.widget.*
import kotlinx.coroutines.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
import org.isoron.uhabits.core.utils.*
import org.isoron.uhabits.databinding.*
import org.isoron.uhabits.utils.*
@@ -74,12 +75,16 @@ class OverviewCardPresenter(val habit: Habit) {
val scoreToday = scores.todayValue.toFloat()
val scoreLastMonth = scores.getValue(lastMonth).toFloat()
val scoreLastYear = scores.getValue(lastYear).toFloat()
val totalCount = habit.originalEntries.getKnown()
.filter { it.value == YES_MANUAL }
.count()
.toLong()
return@IO OverviewCardViewModel(
color = habit.color,
scoreToday = scoreToday,
scoreMonthDiff = scoreToday - scoreLastMonth,
scoreYearDiff = scoreToday - scoreLastYear,
totalCount = habit.originalEntries.totalCount,
totalCount = totalCount,
)
}
}

View File

@@ -44,7 +44,7 @@ class FrequencyWidget(
(widgetView.dataView as FrequencyChart).apply {
setFirstWeekday(firstWeekday)
setColor(habit.color.toThemedAndroidColor(context))
setFrequency(habit.originalEntries.weekdayFrequency)
setFrequency(habit.originalEntries.computeWeekdayFrequency(habit.isNumerical))
}
}