release/2.0 #21

Merged
fabian merged 137 commits from release/2.0 into master 2023-01-28 23:29:27 +01:00
Showing only changes of commit 45f11d5caf - Show all commits

View File

@@ -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() }
) )
} }
} }