mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Confetti: Always emit from checkmark, not popup button
This commit is contained in:
@@ -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() {}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user