improve yes/no dialog design

This commit is contained in:
Bindu
2021-10-03 04:36:49 -07:00
parent 71f400f587
commit 8036b10ee6
9 changed files with 224 additions and 28 deletions

View File

@@ -23,6 +23,7 @@ import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.models.Habit
import org.isoron.uhabits.core.models.HabitList
import org.isoron.uhabits.core.models.HabitType
import org.isoron.uhabits.core.models.PaletteColor
import org.isoron.uhabits.core.models.Timestamp
import org.isoron.uhabits.core.preferences.Preferences
import org.isoron.uhabits.core.tasks.ExportCSVTask
@@ -62,9 +63,12 @@ open class ListHabitsBehavior @Inject constructor(
}
} else {
screen.showCheckmarkDialog(
entry.notes
) { newNotes ->
commandRunner.run(CreateRepetitionCommand(habitList, habit, timestamp, entry.value, newNotes))
entry.value,
entry.notes,
timestamp.toDialogDateString(),
habit.color,
) { newValue, newNotes ->
commandRunner.run(CreateRepetitionCommand(habitList, habit, timestamp, newValue, newNotes))
}
}
}
@@ -148,7 +152,7 @@ open class ListHabitsBehavior @Inject constructor(
}
fun interface CheckMarkDialogCallback {
fun onNotesSaved(notes: String)
fun onNotesSaved(value: Int, notes: String)
fun onNotesDismissed() {}
}
@@ -164,7 +168,10 @@ open class ListHabitsBehavior @Inject constructor(
callback: NumberPickerCallback
)
fun showCheckmarkDialog(
value: Int,
notes: String,
dateString: String,
color: PaletteColor,
callback: CheckMarkDialogCallback
)

View File

@@ -90,13 +90,19 @@ class HistoryCardPresenter(
showNumberPicker(timestamp)
} else {
val entry = habit.computedEntries.get(timestamp)
screen.showCheckmarkDialog(entry.notes) { newNotes ->
screen.showCheckmarkDialog(
entry.value,
entry.notes,
timestamp.toDialogDateString(),
preferences,
habit.color,
) { newValue, newNotes ->
commandRunner.run(
CreateRepetitionCommand(
habitList,
habit,
timestamp,
entry.value,
newValue,
newNotes,
),
)
@@ -200,7 +206,11 @@ class HistoryCardPresenter(
callback: ListHabitsBehavior.NumberPickerCallback,
)
fun showCheckmarkDialog(
value: Int,
notes: String,
dateString: String,
preferences: Preferences,
color: PaletteColor,
callback: ListHabitsBehavior.CheckMarkDialogCallback,
)
}