@ -2,6 +2,7 @@ package com.whispercppdemo.ui.main
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
@ -19,6 +20,7 @@ fun MainScreen(viewModel: MainScreenViewModel) {
canTranscribe = viewModel . canTranscribe ,
isRecording = viewModel . isRecording ,
messageLog = viewModel . dataLog ,
onBenchmarkTapped = viewModel :: benchmark ,
onTranscribeSampleTapped = viewModel :: transcribeSample ,
onRecordTapped = viewModel :: toggleRecord
)
@ -30,6 +32,7 @@ private fun MainScreen(
canTranscribe : Boolean ,
isRecording : Boolean ,
messageLog : String ,
onBenchmarkTapped : ( ) -> Unit ,
onTranscribeSampleTapped : ( ) -> Unit ,
onRecordTapped : ( ) -> Unit
) {
@ -45,8 +48,11 @@ private fun MainScreen(
. padding ( innerPadding )
. padding ( 16. dp )
) {
Row ( horizontalArrangement = Arrangement . SpaceBetween ) {
Column ( verticalArrangement = Arrangement . SpaceBetween ) {
Row ( horizontalArrangement = Arrangement . SpaceBetween , modifier = Modifier . fillMaxWidth ( ) ) {
BenchmarkButton ( enabled = canTranscribe , onClick = onBenchmarkTapped )
TranscribeSampleButton ( enabled = canTranscribe , onClick = onTranscribeSampleTapped )
}
RecordButton (
enabled = canTranscribe ,
isRecording = isRecording ,
@ -60,8 +66,17 @@ private fun MainScreen(
@Composable
private fun MessageLog ( log : String ) {
SelectionContainer ( ) {
Text ( modifier = Modifier . verticalScroll ( rememberScrollState ( ) ) , text = log )
}
}
@Composable
private fun BenchmarkButton ( enabled : Boolean , onClick : ( ) -> Unit ) {
Button ( onClick = onClick , enabled = enabled ) {
Text ( " Benchmark " )
}
}
@Composable
private fun TranscribeSampleButton ( enabled : Boolean , onClick : ( ) -> Unit ) {