[#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 teamNameB: String = "Team B"
|
||||||
override var currentScoreA: String = ""
|
override var currentScoreA: String = ""
|
||||||
override var currentScoreB: String = "45"
|
override var currentScoreB: String = "45"
|
||||||
override var enableSubmit: Boolean = false
|
override var isValidRound: Boolean = false
|
||||||
override var isAFocused: Boolean = false
|
override var isAFocused: Boolean = false
|
||||||
override var isBFocused: Boolean = false
|
override var isBFocused: Boolean = false
|
||||||
override var requestFocusA: FocusRequester = FocusRequester()
|
override var requestFocusA: FocusRequester = FocusRequester()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface IKeyBoardViewModel {
|
|||||||
|
|
||||||
val currentScoreA: String
|
val currentScoreA: String
|
||||||
val currentScoreB: String
|
val currentScoreB: String
|
||||||
val enableSubmit: Boolean
|
val isValidRound: Boolean
|
||||||
val isAFocused: Boolean
|
val isAFocused: Boolean
|
||||||
val isBFocused: Boolean
|
val isBFocused: Boolean
|
||||||
val requestFocusA: FocusRequester
|
val requestFocusA: FocusRequester
|
||||||
@@ -87,7 +87,7 @@ class CounterViewModel @Inject constructor(
|
|||||||
override var currentScoreB by mutableStateOf("")
|
override var currentScoreB by mutableStateOf("")
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override var enableSubmit by mutableStateOf(false)
|
override var isValidRound by mutableStateOf(false)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override var isAFocused by mutableStateOf(false)
|
override var isAFocused by mutableStateOf(false)
|
||||||
@@ -194,7 +194,7 @@ class CounterViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateSubmitButton() {
|
override fun updateSubmitButton() {
|
||||||
enableSubmit = isValidTichuRound()
|
isValidRound = isValidTichuRound()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submitClicked() {
|
override fun submitClicked() {
|
||||||
@@ -203,7 +203,7 @@ class CounterViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
currentScoreA = ""
|
currentScoreA = ""
|
||||||
currentScoreB = ""
|
currentScoreB = ""
|
||||||
enableSubmit = false
|
isValidRound = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun digitClicked(digit: String) {
|
override fun digitClicked(digit: String) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fun KeyBoardView(viewModel: IKeyBoardViewModel) {
|
|||||||
viewModel.currentScoreB,
|
viewModel.currentScoreB,
|
||||||
viewModel.requestFocusA,
|
viewModel.requestFocusA,
|
||||||
viewModel.requestFocusB,
|
viewModel.requestFocusB,
|
||||||
viewModel.enableSubmit,
|
viewModel.isValidRound,
|
||||||
viewModel.isAFocused,
|
viewModel.isAFocused,
|
||||||
viewModel.isBFocused,
|
viewModel.isBFocused,
|
||||||
{ viewModel.updateFocusStateA(it) },
|
{ viewModel.updateFocusStateA(it) },
|
||||||
@@ -53,7 +53,7 @@ fun KeyboardView(
|
|||||||
scoreB: String,
|
scoreB: String,
|
||||||
requestFocusA: FocusRequester,
|
requestFocusA: FocusRequester,
|
||||||
requestFocusB: FocusRequester,
|
requestFocusB: FocusRequester,
|
||||||
enableSubmit: Boolean,
|
isValidScore: Boolean,
|
||||||
focusStateA: Boolean,
|
focusStateA: Boolean,
|
||||||
focusStateB: Boolean,
|
focusStateB: Boolean,
|
||||||
updateFocusStateA: (Boolean) -> Unit,
|
updateFocusStateA: (Boolean) -> Unit,
|
||||||
@@ -85,7 +85,7 @@ fun KeyboardView(
|
|||||||
shape = MaterialTheme.shapes.extraSmall
|
shape = MaterialTheme.shapes.extraSmall
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
IconButton(onClick = onSwapClicked) {
|
IconButton(onClick = onSwapClicked, enabled = isValidScore) {
|
||||||
Icon(Icons.Outlined.SwapHoriz, null)
|
Icon(Icons.Outlined.SwapHoriz, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ fun KeyboardView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column(Modifier.weight(1f)) {
|
Column(Modifier.weight(1f)) {
|
||||||
KeyboardIconButton(Icons.Outlined.Check, enableSubmit) {
|
KeyboardIconButton(Icons.Outlined.Check, isValidScore) {
|
||||||
submitClicked()
|
submitClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,11 +323,11 @@ fun KeyboardViewPreview() {
|
|||||||
AppTheme {
|
AppTheme {
|
||||||
Surface {
|
Surface {
|
||||||
KeyboardView(
|
KeyboardView(
|
||||||
"1",
|
"10",
|
||||||
"3511",
|
"190",
|
||||||
FocusRequester(),
|
FocusRequester(),
|
||||||
FocusRequester(),
|
FocusRequester(),
|
||||||
enableSubmit = false,
|
isValidScore = false,
|
||||||
focusStateA = true,
|
focusStateA = true,
|
||||||
focusStateB = false,
|
focusStateB = false,
|
||||||
updateFocusStateA = {},
|
updateFocusStateA = {},
|
||||||
|
|||||||
Reference in New Issue
Block a user