Dynamically select number of columns to display

This commit is contained in:
2019-04-03 05:50:42 -05:00
parent 33bae657a3
commit 5b2b554a7a
2 changed files with 53 additions and 35 deletions

View File

@@ -29,6 +29,7 @@ class MainScreenDataSource(val preferences: Preferences,
val checkmarks: MutableMap<Habit, CheckmarkList>,
val taskRunner: TaskRunner) {
val maxNumberOfButtons = 60
private val today = LocalDate(2019, 3, 30) /* TODO */
data class Data(val habits: List<Habit>,
@@ -51,8 +52,8 @@ class MainScreenDataSource(val preferences: Preferences,
val recentCheckmarks = filtered.associate { habit ->
val allValues = checkmarks.getValue(habit).getValuesUntil(today)
if (allValues.size <= 7) habit to allValues
else habit to allValues.subList(0, 7)
if (allValues.size <= maxNumberOfButtons) habit to allValues
else habit to allValues.subList(0, maxNumberOfButtons)
}
if (!preferences.showCompleted) {