Confetti: Always emit from checkmark, not popup button

This commit is contained in:
2025-03-23 07:06:45 -05:00
parent fa670b19b7
commit 12cc70a51a
9 changed files with 29 additions and 28 deletions

View File

@@ -51,11 +51,11 @@ open class ListHabitsBehavior @Inject constructor(
screen.showHabitScreen(h)
}
fun onEdit(habit: Habit, timestamp: Timestamp?) {
fun onEdit(habit: Habit, timestamp: Timestamp?, x: Float, y: Float) {
val entry = habit.computedEntries.get(timestamp!!)
if (habit.type == HabitType.NUMERICAL) {
val oldValue = entry.value.toDouble() / 1000
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String, x: Float, y: Float ->
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String ->
val value = (newValue * 1000).roundToInt()
if (newValue != oldValue) {
if (
@@ -72,7 +72,7 @@ open class ListHabitsBehavior @Inject constructor(
entry.value,
entry.notes,
habit.color
) { newValue: Int, newNotes: String, x: Float, y: Float ->
) { newValue: Int, newNotes: String ->
if (newValue != entry.value && newValue == YES_MANUAL) screen.showConfetti(habit.color, x, y)
commandRunner.run(CreateRepetitionCommand(habitList, habit, timestamp, newValue, newNotes))
}
@@ -159,9 +159,7 @@ open class ListHabitsBehavior @Inject constructor(
fun interface NumberPickerCallback {
fun onNumberPicked(
newValue: Double,
notes: String,
x: Float,
y: Float
notes: String
)
fun onNumberPickerDismissed() {}
}
@@ -169,9 +167,7 @@ open class ListHabitsBehavior @Inject constructor(
fun interface CheckMarkDialogCallback {
fun onNotesSaved(
value: Int,
notes: String,
x: Float,
y: Float
notes: String
)
fun onNotesDismissed() {}
}

View File

@@ -98,7 +98,7 @@ class HistoryCardPresenter(
entry.value,
entry.notes,
habit.color
) { newValue, newNotes, _: Float, _: Float ->
) { newValue, newNotes ->
commandRunner.run(
CreateRepetitionCommand(
habitList,
@@ -135,7 +135,7 @@ class HistoryCardPresenter(
screen.showNumberPopup(
value = oldValue / 1000.0,
notes = entry.notes
) { newValue: Double, newNotes: String, _: Float, _: Float ->
) { newValue: Double, newNotes: String ->
val thousands = (newValue * 1000).roundToInt()
commandRunner.run(
CreateRepetitionCommand(

View File

@@ -78,13 +78,13 @@ class ListHabitsBehaviorTest : BaseUnitTest() {
@Test
fun testOnEdit() {
behavior.onEdit(habit2, getToday())
behavior.onEdit(habit2, getToday(), 0f, 0f)
verify(screen).showNumberPopup(
eq(0.1),
eq(""),
picker.capture()
)
picker.lastValue.onNumberPicked(100.0, "", 0f, 0f)
picker.lastValue.onNumberPicked(100.0, "")
val today = getTodayWithOffset()
assertThat(habit2.computedEntries.get(today).value, equalTo(100000))
}