CameraScreen: rename button using page count e.g. "✓ 4 pages"
This commit is contained in:
@@ -30,7 +30,9 @@ import androidx.compose.foundation.background
|
|||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
@@ -43,7 +45,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState
|
|||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.Article
|
import androidx.compose.material.icons.filled.Done
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -53,6 +55,7 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
|
import androidx.compose.runtime.mutableLongStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
@@ -192,8 +195,8 @@ private fun CameraScreenScaffold(
|
|||||||
thumbnailCoords: MutableState<Offset>,
|
thumbnailCoords: MutableState<Offset>,
|
||||||
navigation: Navigation,
|
navigation: Navigation,
|
||||||
) {
|
) {
|
||||||
var tapCount by remember { mutableStateOf(0) }
|
var tapCount by remember { mutableLongStateOf(0) }
|
||||||
var lastTapTime by remember { mutableStateOf(0L) }
|
var lastTapTime by remember { mutableLongStateOf(0L) }
|
||||||
val tapThreshold = 500L
|
val tapThreshold = 500L
|
||||||
val onPageCountClick = {
|
val onPageCountClick = {
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
@@ -214,9 +217,14 @@ private fun CameraScreenScaffold(
|
|||||||
toAboutScreen = navigation.toAboutScreen,
|
toAboutScreen = navigation.toAboutScreen,
|
||||||
pageListState = pageListState,
|
pageListState = pageListState,
|
||||||
onBack = navigation.back,
|
onBack = navigation.back,
|
||||||
bottomBar = { Bar(cameraUiState.pageCount, onPageCountClick, onFinalizePressed) }
|
bottomBar = { Bar(cameraUiState.pageCount, onFinalizePressed) }
|
||||||
) {
|
) {
|
||||||
modifier -> CameraPreviewBox(cameraPreview, cameraUiState, onCapture, modifier)
|
modifier ->
|
||||||
|
CameraPreviewBox(
|
||||||
|
cameraPreview,
|
||||||
|
cameraUiState,
|
||||||
|
onCapture,
|
||||||
|
modifier.clickable(onClick = onPageCountClick))
|
||||||
}
|
}
|
||||||
if (cameraUiState.captureState is CaptureState.CapturePreview) {
|
if (cameraUiState.captureState is CaptureState.CapturePreview) {
|
||||||
CapturedImage(cameraUiState.captureState.processed.asImageBitmap(), thumbnailCoords)
|
CapturedImage(cameraUiState.captureState.processed.asImageBitmap(), thumbnailCoords)
|
||||||
@@ -407,21 +415,21 @@ fun MessageBox(inferenceTime: Long) {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun Bar(
|
private fun Bar(
|
||||||
pageCount: Int,
|
pageCount: Int,
|
||||||
onPageCountClick: () -> Unit,
|
|
||||||
onFinalizePressed: () -> Unit,
|
onFinalizePressed: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Text(
|
Row(
|
||||||
text = pageCountText(pageCount),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.clickable(onClick = onPageCountClick)
|
horizontalArrangement = Arrangement.End
|
||||||
)
|
) {
|
||||||
MainActionButton(
|
MainActionButton(
|
||||||
onClick = onFinalizePressed,
|
onClick = onFinalizePressed,
|
||||||
enabled = pageCount > 0,
|
enabled = pageCount > 0,
|
||||||
text = stringResource(R.string.document),
|
text = pageCountText(pageCount),
|
||||||
icon = Icons.AutoMirrored.Filled.Article,
|
icon = Icons.Default.Done,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user