@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.Arrangement
2424import androidx.compose.foundation.layout.Column
2525import androidx.compose.foundation.layout.Row
2626import androidx.compose.foundation.layout.Spacer
27+ import androidx.compose.foundation.layout.fillMaxHeight
2728import androidx.compose.foundation.layout.fillMaxSize
2829import androidx.compose.foundation.layout.fillMaxWidth
2930import androidx.compose.foundation.layout.padding
@@ -58,6 +59,7 @@ import androidx.compose.ui.focus.FocusRequester
5859import androidx.compose.ui.focus.focusRequester
5960import androidx.compose.ui.graphics.Color
6061import androidx.compose.ui.graphics.vector.ImageVector
62+ import androidx.compose.ui.platform.LocalConfiguration
6163import androidx.compose.ui.platform.LocalContext
6264import androidx.compose.ui.res.stringResource
6365import androidx.compose.ui.text.font.FontStyle
@@ -152,66 +154,100 @@ fun ExportScreen(
152154 )
153155 }
154156 ) { innerPadding ->
155- Column (
156- modifier = Modifier
157- .padding(innerPadding)
158- .padding(16 .dp)
159- .fillMaxSize(),
160- verticalArrangement = Arrangement .spacedBy(16 .dp)
161- ) {
162- val focusRequester = remember { FocusRequester () }
163- OutlinedTextField (
164- value = filename.value,
165- onValueChange = onFilenameChange,
166- label = { Text (stringResource(R .string.filename)) },
167- singleLine = true ,
168- modifier = Modifier
169- .fillMaxWidth()
170- .focusRequester(focusRequester),
171- trailingIcon = {
172- if (filename.value.isNotEmpty()) {
173- IconButton (onClick = {
174- filename.value = " "
175- focusRequester.requestFocus()
176- }) {
177- Icon (Icons .Default .Clear , stringResource(R .string.clear_text))
178- }
179- }
180- },
181- )
182-
183- val pdf = uiState.generatedPdf
184-
185- // PDF infos
157+ val containerModifier = Modifier
158+ .padding(innerPadding)
159+ .padding(16 .dp)
160+ if (! isLandscape(LocalConfiguration .current)) {
186161 Column (
187- verticalArrangement = Arrangement .spacedBy(4 .dp)
162+ modifier = containerModifier.fillMaxSize(),
163+ verticalArrangement = Arrangement .spacedBy(16 .dp)
188164 ) {
189-
190- if (uiState.isGenerating) {
191- Text (stringResource(R .string.creating_pdf), fontStyle = FontStyle .Italic )
192- } else if (pdf != null ) {
193- val context = LocalContext .current
194- val formattedFileSize = formatFileSize(pdf.sizeInBytes, context)
195- Text (text = pageCountText(pdf.pageCount))
196- Text (
197- text = stringResource(R .string.file_size, formattedFileSize),
198- color = MaterialTheme .colorScheme.onSurface.copy(alpha = 0.6f )
199- )
165+ TextFieldAndPdfInfos (filename, onFilenameChange, uiState, onOpen)
166+ Spacer (Modifier .weight(1f )) // push buttons down
167+ MainActions (uiState, onShare, onSave, onCloseScan)
168+ }
169+ } else {
170+ Row (
171+ modifier = containerModifier.fillMaxHeight(),
172+ horizontalArrangement = Arrangement .spacedBy(16 .dp)
173+ ) {
174+ Column (
175+ modifier = Modifier .weight(1f ),
176+ verticalArrangement = Arrangement .spacedBy(16 .dp)
177+ ) {
178+ TextFieldAndPdfInfos (filename, onFilenameChange, uiState, onOpen)
179+ }
180+ Column (modifier = Modifier .weight(1f )) {
181+ MainActions (uiState, onShare, onSave, onCloseScan)
200182 }
201183 }
202184
203- if (uiState.saveDirectoryName != null ) {
204- SavePdfBar (onOpen, uiState.saveDirectoryName)
205- }
206- if (uiState.errorMessage != null ) {
207- ErrorBar (uiState.errorMessage)
208- }
185+ }
186+ }
187+ }
209188
210- Spacer (Modifier .weight(1f )) // push buttons down
189+ @Composable
190+ private fun TextFieldAndPdfInfos (
191+ filename : MutableState <String >,
192+ onFilenameChange : (String ) -> Unit ,
193+ uiState : PdfGenerationUiState ,
194+ onOpen : () -> Unit ,
195+ ) {
196+ FilenameTextField (filename, onFilenameChange)
197+
198+ val pdf = uiState.generatedPdf
211199
212- MainActions (uiState, onShare, onSave, onCloseScan)
200+ // PDF infos
201+ Column (
202+ verticalArrangement = Arrangement .spacedBy(4 .dp)
203+ ) {
204+
205+ if (uiState.isGenerating) {
206+ Text (stringResource(R .string.creating_pdf), fontStyle = FontStyle .Italic )
207+ } else if (pdf != null ) {
208+ val context = LocalContext .current
209+ val formattedFileSize = formatFileSize(pdf.sizeInBytes, context)
210+ Text (text = pageCountText(pdf.pageCount))
211+ Text (
212+ text = stringResource(R .string.file_size, formattedFileSize),
213+ color = MaterialTheme .colorScheme.onSurface.copy(alpha = 0.6f )
214+ )
213215 }
214216 }
217+
218+ if (uiState.saveDirectoryName != null ) {
219+ SavePdfBar (onOpen, uiState.saveDirectoryName)
220+ }
221+ if (uiState.errorMessage != null ) {
222+ ErrorBar (uiState.errorMessage)
223+ }
224+ }
225+
226+ @Composable
227+ private fun FilenameTextField (
228+ filename : MutableState <String >,
229+ onFilenameChange : (String ) -> Unit ,
230+ ) {
231+ val focusRequester = remember { FocusRequester () }
232+ OutlinedTextField (
233+ value = filename.value,
234+ onValueChange = onFilenameChange,
235+ label = { Text (stringResource(R .string.filename)) },
236+ singleLine = true ,
237+ modifier = Modifier
238+ .fillMaxWidth()
239+ .focusRequester(focusRequester),
240+ trailingIcon = {
241+ if (filename.value.isNotEmpty()) {
242+ IconButton (onClick = {
243+ filename.value = " "
244+ focusRequester.requestFocus()
245+ }) {
246+ Icon (Icons .Default .Clear , stringResource(R .string.clear_text))
247+ }
248+ }
249+ },
250+ )
215251}
216252
217253@Composable
@@ -378,6 +414,19 @@ fun ExportScreenPreviewWithError() {
378414 )
379415}
380416
417+ @Preview(showBackground = true , widthDp = 720 , heightDp = 360 )
418+ @Composable
419+ fun PreviewExportScreenAfterSaveHorizontal () {
420+ val file = File (" fake.pdf" )
421+ ExportPreviewToCustomize (
422+ uiState = PdfGenerationUiState (
423+ generatedPdf = GeneratedPdf (file, 442897L , 3 ),
424+ savedFileUri = file.toUri(),
425+ saveDirectoryName = " Downloads" ,
426+ ),
427+ )
428+ }
429+
381430@Composable
382431fun ExportPreviewToCustomize (uiState : PdfGenerationUiState ) {
383432 MyScanTheme {
@@ -393,4 +442,3 @@ fun ExportPreviewToCustomize(uiState: PdfGenerationUiState) {
393442 )
394443 }
395444}
396-
0 commit comments