Document screen: make "Add page" button more explicit
This commit is contained in:
@@ -55,7 +55,6 @@ import org.fairscan.app.ui.Navigation
|
|||||||
fun MyScaffold(
|
fun MyScaffold(
|
||||||
navigation: Navigation,
|
navigation: Navigation,
|
||||||
pageListState: CommonPageListState,
|
pageListState: CommonPageListState,
|
||||||
pageListButton: (@Composable () -> Unit)? = null,
|
|
||||||
bottomBar: @Composable () -> Unit,
|
bottomBar: @Composable () -> Unit,
|
||||||
onBack: (() -> Unit)? = null,
|
onBack: (() -> Unit)? = null,
|
||||||
content: @Composable (Modifier) -> Unit,
|
content: @Composable (Modifier) -> Unit,
|
||||||
@@ -63,7 +62,7 @@ fun MyScaffold(
|
|||||||
Box {
|
Box {
|
||||||
if (!isLandscape(LocalConfiguration.current)) {
|
if (!isLandscape(LocalConfiguration.current)) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
bottomBar = { DocumentBar(pageListState, bottomBar, Modifier, pageListButton) }
|
bottomBar = { DocumentBar(pageListState, bottomBar, Modifier) }
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
content(Modifier.padding(innerPadding).fillMaxSize())
|
content(Modifier.padding(innerPadding).fillMaxSize())
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ fun MyScaffold(
|
|||||||
modifier = Modifier.padding(innerPadding).fillMaxSize()
|
modifier = Modifier.padding(innerPadding).fillMaxSize()
|
||||||
) {
|
) {
|
||||||
content(Modifier.weight(2f))
|
content(Modifier.weight(2f))
|
||||||
DocumentBar(pageListState, bottomBar, Modifier.weight(1f), pageListButton)
|
DocumentBar(pageListState, bottomBar, Modifier.weight(1f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,6 @@ fun DocumentBar(
|
|||||||
pageListState: CommonPageListState,
|
pageListState: CommonPageListState,
|
||||||
buttonBar: @Composable () -> Unit,
|
buttonBar: @Composable () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
pageListButton: (@Composable () -> Unit)? = null,
|
|
||||||
) {
|
) {
|
||||||
val isLandscape = isLandscape(LocalConfiguration.current)
|
val isLandscape = isLandscape(LocalConfiguration.current)
|
||||||
Column(
|
Column(
|
||||||
@@ -115,17 +113,6 @@ fun DocumentBar(
|
|||||||
Modifier
|
Modifier
|
||||||
) {
|
) {
|
||||||
CommonPageList(pageListState, modifier = Modifier.fillMaxWidth())
|
CommonPageList(pageListState, modifier = Modifier.fillMaxWidth())
|
||||||
|
|
||||||
if (pageListButton != null) {
|
|
||||||
val alignment = if (isLandscape) Alignment.BottomEnd else Alignment.CenterEnd
|
|
||||||
Box(
|
|
||||||
Modifier
|
|
||||||
.align(alignment)
|
|
||||||
.padding(horizontal = 8.dp, vertical = 16.dp)
|
|
||||||
) {
|
|
||||||
pageListButton()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val color = MaterialTheme.colorScheme.surfaceContainerHigh
|
val color = MaterialTheme.colorScheme.surfaceContainerHigh
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package org.fairscan.app.ui.screens
|
|||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -32,11 +33,14 @@ 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.RotateLeft
|
import androidx.compose.material.icons.automirrored.filled.RotateLeft
|
||||||
import androidx.compose.material.icons.automirrored.filled.RotateRight
|
import androidx.compose.material.icons.automirrored.filled.RotateRight
|
||||||
import androidx.compose.material.icons.filled.Add
|
|
||||||
import androidx.compose.material.icons.filled.Done
|
import androidx.compose.material.icons.filled.Done
|
||||||
|
import androidx.compose.material.icons.outlined.Add
|
||||||
import androidx.compose.material.icons.outlined.Delete
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@@ -48,9 +52,11 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.geometry.Size
|
import androidx.compose.ui.geometry.Size
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
@@ -108,14 +114,7 @@ fun DocumentScreen(
|
|||||||
),
|
),
|
||||||
onBack = navigation.back,
|
onBack = navigation.back,
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
BottomBar(onExportClick)
|
BottomBar(onExportClick, navigation.toCameraScreen)
|
||||||
},
|
|
||||||
pageListButton = {
|
|
||||||
SecondaryActionButton(
|
|
||||||
icon = Icons.Default.Add,
|
|
||||||
onClick = navigation.toCameraScreen,
|
|
||||||
contentDescription = stringResource(R.string.add_page),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
) { modifier ->
|
) { modifier ->
|
||||||
DocumentPreview(
|
DocumentPreview(
|
||||||
@@ -221,12 +220,28 @@ fun RotationButtons(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun BottomBar(
|
private fun BottomBar(
|
||||||
onExportClick: () -> Unit,
|
onExportClick: () -> Unit,
|
||||||
|
onAddPageClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.End
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = onAddPageClick,
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = Color.Transparent,
|
||||||
|
contentColor = MaterialTheme.colorScheme.primary
|
||||||
|
),
|
||||||
|
border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary),
|
||||||
|
modifier = Modifier.weight(1f, fill = false),
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.Add, contentDescription = null)
|
||||||
|
Spacer(Modifier.width(4.dp))
|
||||||
|
Text(stringResource(R.string.add_page),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis)
|
||||||
|
}
|
||||||
MainActionButton(
|
MainActionButton(
|
||||||
onClick = onExportClick,
|
onClick = onExportClick,
|
||||||
icon = Icons.Default.Done,
|
icon = Icons.Default.Done,
|
||||||
|
|||||||
Reference in New Issue
Block a user