Add back the "Share" button
This commit is contained in:
@@ -54,7 +54,7 @@ class MainActivity : ComponentActivity() {
|
||||
viewModel,
|
||||
onBackPressed = { viewModel.navigateTo(Screen.Camera) },
|
||||
onSavePressed = savePdf(viewModel, context),
|
||||
// TODO "on share"
|
||||
onSharePressed = sharePdf(viewModel, context),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -64,11 +64,13 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private fun createPdfAndShare(context: Context): (Bitmap) -> Unit = { bitmap ->
|
||||
private fun sharePdf(
|
||||
viewModel: MainViewModel,
|
||||
context: Context
|
||||
): () -> Unit = {
|
||||
val document = viewModel.createPdf()
|
||||
val outputDir = File(cacheDir, "pdfs").apply { mkdirs() }
|
||||
val outputFile = File(outputDir, "scan_${System.currentTimeMillis()}.pdf")
|
||||
val document = createPdfFromBitmaps(listOf(bitmap))
|
||||
var success = true
|
||||
try {
|
||||
FileOutputStream(outputFile).use { outputStream ->
|
||||
@@ -94,7 +96,6 @@ class MainActivity : ComponentActivity() {
|
||||
startActivity(Intent.createChooser(shareIntent, "Share PDF"))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private fun savePdf(
|
||||
viewModel: MainViewModel,
|
||||
|
||||
@@ -5,13 +5,21 @@ import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.compose.material3.BottomAppBar
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -38,7 +46,8 @@ import org.mydomain.myscan.MainViewModel
|
||||
fun FinalizeDocumentScreen(
|
||||
viewModel: MainViewModel = viewModel(),
|
||||
onBackPressed: () -> Unit,
|
||||
onSavePressed: () -> Unit
|
||||
onSavePressed: () -> Unit,
|
||||
onSharePressed: () -> Unit,
|
||||
) {
|
||||
val pageIds by viewModel.pageIds.collectAsStateWithLifecycle()
|
||||
Scaffold (
|
||||
@@ -50,16 +59,31 @@ fun FinalizeDocumentScreen(
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
Button(onClick = onSavePressed) {
|
||||
Text(text = "Save PDF")
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
BottomAppBar(
|
||||
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
Button(onClick = onSharePressed) {
|
||||
Icon(Icons.Default.Share, contentDescription = "Share")
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Share")
|
||||
}
|
||||
Button(onClick = onSavePressed) {
|
||||
Text("Save")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) { padding ->
|
||||
Column(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(padding)) {
|
||||
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user