Created
May 28, 2022 08:15
-
-
Save aqua30/8ec8ad5614f11aedb57dc9c9ef383899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun onKeyPress(key: Keypad) { | |
when(key) { | |
Keypad.KeyDelete -> { | |
/* when delete key is clicked */ | |
if (timeState.value.isDataEmpty()) | |
return | |
deleteTime() | |
} | |
Keypad.Key00 -> { | |
/* when double zero key is clicked */ | |
if (timeState.value.isDataEmpty() | |
|| timeState.value.isHoursHalfFull() | |
|| timeState.value.isDataFull() | |
) | |
return | |
addTime(Keypad.Key0.value) | |
addTime(Keypad.Key0.value) | |
} | |
Keypad.Key0 -> { | |
/* when zero key is clicked */ | |
if (timeState.value.isDataEmpty() | |
|| timeState.value.isDataFull() | |
) | |
return | |
addTime(key.value) | |
} | |
else -> { | |
/* when any num key is clicked */ | |
if (timeState.value.isDataFull()) | |
return | |
addTime(key.value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment