Skip to content

Commit

Permalink
Show "no page scanned yet" when no page was scanned instead of empty …
Browse files Browse the repository at this point in the history
…background
  • Loading branch information
Chrisimx committed Dec 24, 2024
1 parent 0019809 commit 46995b2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 51 deletions.
115 changes: 64 additions & 51 deletions app/src/main/java/io/github/chrisimx/scanbridge/ScanningActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ class ScanningActivity : ComponentActivity() {
Text(scanningViewModel.scanningActivityData.currentScansState[pagerState.currentPage].second.inputSource.toString())
}
}
} else if (!scanningViewModel.scanningActivityData.scanJobRunning) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(stringResource(R.string.no_scans_yet))
}
}

HorizontalPager(
Expand Down Expand Up @@ -541,65 +551,68 @@ class ScanningActivity : ComponentActivity() {
}
}

Box(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding), contentAlignment = Alignment.BottomCenter
) {
if (pagerState.currentPage < scanningViewModel.scanningActivityData.currentScansState.size) {
Box(
modifier = Modifier
.padding(10.dp)
.clip(
RoundedCornerShape(16.dp)
)
.background(MaterialTheme.colorScheme.inverseOnSurface),
.fillMaxSize()
.padding(innerPadding),
contentAlignment = Alignment.BottomCenter
) {
Row {
IconButton(onClick = {
if (scanningViewModel.scanningActivityData.currentScansState.size <= pagerState.currentPage) {
return@IconButton
}
Files.delete(Path(scanningViewModel.scanningActivityData.currentScansState[pagerState.currentPage].first))
scanningViewModel.removeScanAtIndex(pagerState.currentPage)
}) {
Icon(
Icons.Outlined.Delete,
contentDescription = stringResource(
R.string.delete_current_page
)
)
}
IconButton(onClick = {
scanningViewModel.swapTwoPages(
pagerState.currentPage,
pagerState.currentPage - 1
Box(
modifier = Modifier
.padding(10.dp)
.clip(
RoundedCornerShape(16.dp)
)
scrollScope.launch {
pagerState.animateScrollToPage(pagerState.currentPage - 1)
.background(MaterialTheme.colorScheme.inverseOnSurface),
) {
Row {
IconButton(onClick = {
if (scanningViewModel.scanningActivityData.currentScansState.size <= pagerState.currentPage) {
return@IconButton
}
Files.delete(Path(scanningViewModel.scanningActivityData.currentScansState[pagerState.currentPage].first))
scanningViewModel.removeScanAtIndex(pagerState.currentPage)
}) {
Icon(
Icons.Outlined.Delete,
contentDescription = stringResource(
R.string.delete_current_page
)
)
}
}) {
Icon(
Icons.AutoMirrored.Outlined.ArrowBack,
contentDescription = stringResource(
R.string.swap_with_previous_page
IconButton(onClick = {
scanningViewModel.swapTwoPages(
pagerState.currentPage,
pagerState.currentPage - 1
)
scrollScope.launch {
pagerState.animateScrollToPage(pagerState.currentPage - 1)
}
}) {
Icon(
Icons.AutoMirrored.Outlined.ArrowBack,
contentDescription = stringResource(
R.string.swap_with_previous_page
)
)
)
}
IconButton(onClick = {
scanningViewModel.swapTwoPages(
pagerState.currentPage,
pagerState.currentPage + 1
)
scrollScope.launch {
pagerState.animateScrollToPage(pagerState.currentPage + 1)
}
}) {
Icon(
Icons.AutoMirrored.Outlined.ArrowForward,
contentDescription = stringResource(
R.string.swap_with_next_page
IconButton(onClick = {
scanningViewModel.swapTwoPages(
pagerState.currentPage,
pagerState.currentPage + 1
)
)
scrollScope.launch {
pagerState.animateScrollToPage(pagerState.currentPage + 1)
}
}) {
Icon(
Icons.AutoMirrored.Outlined.ArrowForward,
contentDescription = stringResource(
R.string.swap_with_next_page
)
)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
<string name="export">Export</string>
<string name="retrieving_page">Retrieving page</string>
<string name="exporting">Exporting...</string>
<string name="no_scans_yet">No pages were scanned yet. Click the scan button :)</string>
</resources>

0 comments on commit 46995b2

Please sign in to comment.