[#29] Disable swap button on invalid score.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
closed [#29]
This commit is contained in:
@@ -103,7 +103,7 @@ internal class PreviewViewModel : ICounterViewModel {
|
||||
override var teamNameB: String = "Team B"
|
||||
override var currentScoreA: String = ""
|
||||
override var currentScoreB: String = "45"
|
||||
override var enableSubmit: Boolean = false
|
||||
override var isValidRound: Boolean = false
|
||||
override var isAFocused: Boolean = false
|
||||
override var isBFocused: Boolean = false
|
||||
override var requestFocusA: FocusRequester = FocusRequester()
|
||||
|
||||
@@ -23,7 +23,7 @@ interface IKeyBoardViewModel {
|
||||
|
||||
val currentScoreA: String
|
||||
val currentScoreB: String
|
||||
val enableSubmit: Boolean
|
||||
val isValidRound: Boolean
|
||||
val isAFocused: Boolean
|
||||
val isBFocused: Boolean
|
||||
val requestFocusA: FocusRequester
|
||||
@@ -87,7 +87,7 @@ class CounterViewModel @Inject constructor(
|
||||
override var currentScoreB by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var enableSubmit by mutableStateOf(false)
|
||||
override var isValidRound by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var isAFocused by mutableStateOf(false)
|
||||
@@ -194,7 +194,7 @@ class CounterViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
override fun updateSubmitButton() {
|
||||
enableSubmit = isValidTichuRound()
|
||||
isValidRound = isValidTichuRound()
|
||||
}
|
||||
|
||||
override fun submitClicked() {
|
||||
@@ -203,7 +203,7 @@ class CounterViewModel @Inject constructor(
|
||||
}
|
||||
currentScoreA = ""
|
||||
currentScoreB = ""
|
||||
enableSubmit = false
|
||||
isValidRound = false
|
||||
}
|
||||
|
||||
override fun digitClicked(digit: String) {
|
||||
|
||||
@@ -32,7 +32,7 @@ fun KeyBoardView(viewModel: IKeyBoardViewModel) {
|
||||
viewModel.currentScoreB,
|
||||
viewModel.requestFocusA,
|
||||
viewModel.requestFocusB,
|
||||
viewModel.enableSubmit,
|
||||
viewModel.isValidRound,
|
||||
viewModel.isAFocused,
|
||||
viewModel.isBFocused,
|
||||
{ viewModel.updateFocusStateA(it) },
|
||||
@@ -53,7 +53,7 @@ fun KeyboardView(
|
||||
scoreB: String,
|
||||
requestFocusA: FocusRequester,
|
||||
requestFocusB: FocusRequester,
|
||||
enableSubmit: Boolean,
|
||||
isValidScore: Boolean,
|
||||
focusStateA: Boolean,
|
||||
focusStateB: Boolean,
|
||||
updateFocusStateA: (Boolean) -> Unit,
|
||||
@@ -85,7 +85,7 @@ fun KeyboardView(
|
||||
shape = MaterialTheme.shapes.extraSmall
|
||||
) {
|
||||
Column {
|
||||
IconButton(onClick = onSwapClicked) {
|
||||
IconButton(onClick = onSwapClicked, enabled = isValidScore) {
|
||||
Icon(Icons.Outlined.SwapHoriz, null)
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ fun KeyboardView(
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardIconButton(Icons.Outlined.Check, enableSubmit) {
|
||||
KeyboardIconButton(Icons.Outlined.Check, isValidScore) {
|
||||
submitClicked()
|
||||
}
|
||||
}
|
||||
@@ -323,11 +323,11 @@ fun KeyboardViewPreview() {
|
||||
AppTheme {
|
||||
Surface {
|
||||
KeyboardView(
|
||||
"1",
|
||||
"3511",
|
||||
"10",
|
||||
"190",
|
||||
FocusRequester(),
|
||||
FocusRequester(),
|
||||
enableSubmit = false,
|
||||
isValidScore = false,
|
||||
focusStateA = true,
|
||||
focusStateB = false,
|
||||
updateFocusStateA = {},
|
||||
|
||||
Reference in New Issue
Block a user