Portrait mode for counter.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,19 +1,78 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Counter(
|
fun Counter(viewModel: CounterViewModel) {
|
||||||
viewModel: CounterViewModel
|
|
||||||
) {
|
var orientation by remember { mutableStateOf(Configuration.ORIENTATION_PORTRAIT) }
|
||||||
Column() {
|
orientation = LocalConfiguration.current.orientation
|
||||||
|
|
||||||
|
if(orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
Landscape(viewModel)
|
||||||
|
} else {
|
||||||
|
Portrait(viewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Landscape(viewModel: CounterViewModel) {
|
||||||
|
Row {
|
||||||
|
Column(Modifier.weight(1f)) {
|
||||||
TeamNamesView(
|
TeamNamesView(
|
||||||
viewModel.teamNameA,
|
viewModel.teamNameA,
|
||||||
viewModel.teamNameB,
|
viewModel.teamNameB,
|
||||||
{ viewModel.updateNameA(it) },
|
{ viewModel.updateNameA(it) },
|
||||||
{ viewModel.updateNameB(it) })
|
{ viewModel.updateNameB(it) }
|
||||||
|
)
|
||||||
|
|
||||||
|
TeamScoresView(
|
||||||
|
viewModel.totalScoreA,
|
||||||
|
viewModel.totalScoreB
|
||||||
|
)
|
||||||
|
|
||||||
|
RoundListView(
|
||||||
|
viewModel.roundScoreList,
|
||||||
|
Modifier.weight(1f)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column(Modifier.weight(1f)) {
|
||||||
|
KeyboardView(
|
||||||
|
viewModel.currentScoreA,
|
||||||
|
viewModel.currentScoreB,
|
||||||
|
viewModel.requestFocusA,
|
||||||
|
viewModel.enableSubmit,
|
||||||
|
{ viewModel.updateFocusStateA(it) },
|
||||||
|
{ viewModel.updateFocusStateB(it) },
|
||||||
|
{ viewModel.digitClicked(it) },
|
||||||
|
{ viewModel.addSub100Clicked(it) },
|
||||||
|
{ viewModel.deleteClicked() },
|
||||||
|
{ viewModel.negateClicked() },
|
||||||
|
{ viewModel.submitClicked() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Portrait(viewModel: CounterViewModel) {
|
||||||
|
|
||||||
|
Column {
|
||||||
|
TeamNamesView(
|
||||||
|
viewModel.teamNameA,
|
||||||
|
viewModel.teamNameB,
|
||||||
|
{ viewModel.updateNameA(it) },
|
||||||
|
{ viewModel.updateNameB(it) }
|
||||||
|
)
|
||||||
|
|
||||||
TeamScoresView(
|
TeamScoresView(
|
||||||
viewModel.totalScoreA,
|
viewModel.totalScoreA,
|
||||||
@@ -38,6 +97,5 @@ fun Counter(
|
|||||||
{ viewModel.negateClicked() },
|
{ viewModel.negateClicked() },
|
||||||
{ viewModel.submitClicked() }
|
{ viewModel.submitClicked() }
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user