Minor cleanup/fixes

- Add FAB collapsing in clear database screen (fixes #7935)
- Don't allow multiline category names to be entered
- Consolidate Downloaded Only / Incognito Mode banner components
- Fix see-through migrate screen sticky header
This commit is contained in:
arkon 2022-09-18 16:08:50 -04:00
parent b668364afb
commit 83871fc013
17 changed files with 68 additions and 71 deletions

View file

@ -40,10 +40,9 @@ import eu.kanade.presentation.browse.components.BrowseSourceComfortableGrid
import eu.kanade.presentation.browse.components.BrowseSourceCompactGrid
import eu.kanade.presentation.browse.components.BrowseSourceList
import eu.kanade.presentation.browse.components.BrowseSourceToolbar
import eu.kanade.presentation.components.DownloadedOnlyModeBanner
import eu.kanade.presentation.components.AppStateBanners
import eu.kanade.presentation.components.EmptyScreen
import eu.kanade.presentation.components.ExtendedFloatingActionButton
import eu.kanade.presentation.components.IncognitoModeBanner
import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.Scaffold
import eu.kanade.tachiyomi.R
@ -90,12 +89,8 @@ fun BrowseSourceScreen(
onSearch = { presenter.search() },
scrollBehavior = scrollBehavior,
)
if (downloadedOnlyMode) {
DownloadedOnlyModeBanner()
}
if (incognitoMode) {
IncognitoModeBanner()
}
AppStateBanners(downloadedOnlyMode, incognitoMode)
}
},
floatingActionButton = {
@ -140,7 +135,7 @@ fun BrowseSourceScreen(
)
},
label = {
Text(text = stringResource(id = R.string.popular))
Text(text = stringResource(R.string.popular))
},
)
if (presenter.source?.supportsLatest == true) {
@ -159,7 +154,7 @@ fun BrowseSourceScreen(
)
},
label = {
Text(text = stringResource(id = R.string.latest))
Text(text = stringResource(R.string.latest))
},
)
}
@ -176,7 +171,7 @@ fun BrowseSourceScreen(
)
},
label = {
Text(text = stringResource(id = R.string.action_filter))
Text(text = stringResource(R.string.action_filter))
},
)
}
@ -195,7 +190,7 @@ fun BrowseSourceFloatingActionButton(
AnimatedVisibility(visible = isVisible) {
ExtendedFloatingActionButton(
modifier = modifier,
text = { Text(text = stringResource(id = R.string.action_filter)) },
text = { Text(text = stringResource(R.string.action_filter)) },
icon = { Icon(Icons.Outlined.FilterList, contentDescription = "") },
onClick = onFabClick,
)

View file

@ -1,5 +1,6 @@
package eu.kanade.presentation.browse
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -84,7 +85,7 @@ fun MigrateSourceList(
stickyHeader(key = "header") {
Row(
modifier = Modifier
.animateItemPlacement()
.background(MaterialTheme.colorScheme.background)
.padding(start = horizontalPadding),
verticalAlignment = Alignment.CenterVertically,
) {
@ -109,14 +110,9 @@ fun MigrateSourceList(
}
}
item(key = "title") {
}
items(
items = list,
key = { (source, _) ->
source.id
},
key = { (source, _) -> source.id },
) { (source, count) ->
MigrateSourceItem(
modifier = Modifier.animateItemPlacement(),

View file

@ -102,7 +102,7 @@ fun BrowseSourceComfortableGridItem(
},
badgesStart = {
if (manga.favorite) {
Badge(text = stringResource(id = R.string.in_library))
Badge(text = stringResource(R.string.in_library))
}
},
)

View file

@ -113,7 +113,7 @@ fun BrowseSourceCompactGridItem(
},
badgesStart = {
if (manga.favorite) {
Badge(text = stringResource(id = R.string.in_library))
Badge(text = stringResource(R.string.in_library))
}
},
content = {

View file

@ -18,7 +18,7 @@ fun RemoveMangaDialog(
onDismissRequest = onDismissRequest,
dismissButton = {
TextButton(onClick = onDismissRequest) {
Text(text = stringResource(id = android.R.string.cancel))
Text(text = stringResource(android.R.string.cancel))
}
},
confirmButton = {
@ -28,11 +28,11 @@ fun RemoveMangaDialog(
onConfirm()
},
) {
Text(text = stringResource(id = R.string.action_remove))
Text(text = stringResource(R.string.action_remove))
}
},
title = {
Text(text = stringResource(id = R.string.are_you_sure))
Text(text = stringResource(R.string.are_you_sure))
},
text = {
Text(text = stringResource(R.string.remove_manga))

View file

@ -91,7 +91,7 @@ fun BrowseSourceListItem(
onLongClick = onLongClick,
badges = {
if (manga.favorite) {
Badge(text = stringResource(id = R.string.in_library))
Badge(text = stringResource(R.string.in_library))
}
},
content = {

View file

@ -85,24 +85,24 @@ fun BrowseSourceRegularToolbar(
AppBarActions(
actions = listOf(
AppBar.Action(
title = stringResource(id = R.string.action_search),
title = stringResource(R.string.action_search),
icon = Icons.Outlined.Search,
onClick = onSearchClick,
),
AppBar.Action(
title = stringResource(id = R.string.action_display_mode),
title = stringResource(R.string.action_display_mode),
icon = Icons.Filled.ViewModule,
onClick = { selectingDisplayMode = true },
),
if (isLocalSource) {
AppBar.Action(
title = stringResource(id = R.string.label_help),
title = stringResource(R.string.label_help),
icon = Icons.Outlined.Help,
onClick = onHelpClick,
)
} else {
AppBar.Action(
title = stringResource(id = R.string.action_web_view),
title = stringResource(R.string.action_web_view),
icon = Icons.Outlined.Public,
onClick = onWebViewClick,
)
@ -114,7 +114,7 @@ fun BrowseSourceRegularToolbar(
onDismissRequest = { selectingDisplayMode = false },
) {
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_display_comfortable_grid)) },
text = { Text(text = stringResource(R.string.action_display_comfortable_grid)) },
onClick = { onDisplayModeChange(LibraryDisplayMode.ComfortableGrid) },
trailingIcon = {
if (displayMode == LibraryDisplayMode.ComfortableGrid) {
@ -126,7 +126,7 @@ fun BrowseSourceRegularToolbar(
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_display_grid)) },
text = { Text(text = stringResource(R.string.action_display_grid)) },
onClick = { onDisplayModeChange(LibraryDisplayMode.CompactGrid) },
trailingIcon = {
if (displayMode == LibraryDisplayMode.CompactGrid) {
@ -138,7 +138,7 @@ fun BrowseSourceRegularToolbar(
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_display_list)) },
text = { Text(text = stringResource(R.string.action_display_list)) },
onClick = { onDisplayModeChange(LibraryDisplayMode.List) },
trailingIcon = {
if (displayMode == LibraryDisplayMode.List) {

View file

@ -51,6 +51,7 @@ fun CategoryCreateDialog(
label = {
Text(text = stringResource(R.string.name))
},
singleLine = true,
)
},
)
@ -98,6 +99,7 @@ fun CategoryRenameDialog(
label = {
Text(text = stringResource(R.string.name))
},
singleLine = true,
)
},
)

View file

@ -144,12 +144,7 @@ fun AppBar(
scrollBehavior = scrollBehavior,
)
if (downloadedOnlyMode) {
DownloadedOnlyModeBanner()
}
if (incognitoMode) {
IncognitoModeBanner()
}
AppStateBanners(downloadedOnlyMode, incognitoMode)
}
}

View file

@ -1,6 +1,7 @@
package eu.kanade.presentation.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
@ -13,7 +14,20 @@ import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.R
@Composable
fun DownloadedOnlyModeBanner() {
fun ColumnScope.AppStateBanners(
downloadedOnlyMode: Boolean,
incognitoMode: Boolean,
) {
if (downloadedOnlyMode) {
DownloadedOnlyModeBanner()
}
if (incognitoMode) {
IncognitoModeBanner()
}
}
@Composable
private fun DownloadedOnlyModeBanner() {
Text(
text = stringResource(R.string.label_downloaded_only),
modifier = Modifier
@ -27,7 +41,7 @@ fun DownloadedOnlyModeBanner() {
}
@Composable
fun IncognitoModeBanner() {
private fun IncognitoModeBanner() {
Text(
text = stringResource(R.string.pref_incognito_mode),
modifier = Modifier

View file

@ -76,12 +76,7 @@ fun TabbedScreen(
}
}
if (downloadedOnlyMode) {
DownloadedOnlyModeBanner()
}
if (incognitoMode) {
IncognitoModeBanner()
}
AppStateBanners(downloadedOnlyMode, incognitoMode)
HorizontalPager(
count = tabs.size,

View file

@ -13,8 +13,7 @@ import androidx.compose.ui.unit.dp
import com.google.accompanist.pager.PagerState
import eu.kanade.domain.category.model.Category
import eu.kanade.presentation.category.visualName
import eu.kanade.presentation.components.DownloadedOnlyModeBanner
import eu.kanade.presentation.components.IncognitoModeBanner
import eu.kanade.presentation.components.AppStateBanners
import eu.kanade.presentation.components.TabIndicator
import eu.kanade.presentation.components.TabText
import kotlinx.coroutines.launch
@ -51,11 +50,7 @@ fun LibraryTabs(
)
}
}
if (isDownloadOnly) {
DownloadedOnlyModeBanner()
}
if (isIncognitoMode) {
IncognitoModeBanner()
}
AppStateBanners(isDownloadOnly, isIncognitoMode)
}
}

View file

@ -28,9 +28,8 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.DownloadedOnlyModeBanner
import eu.kanade.presentation.components.AppStateBanners
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.presentation.components.IncognitoModeBanner
import eu.kanade.presentation.manga.DownloadAction
import eu.kanade.tachiyomi.R
@ -198,11 +197,6 @@ fun MangaAppBar(
),
)
if (downloadedOnlyMode) {
DownloadedOnlyModeBanner()
}
if (incognitoMode) {
IncognitoModeBanner()
}
AppStateBanners(downloadedOnlyMode, incognitoMode)
}
}

View file

@ -1,5 +1,6 @@
package eu.kanade.presentation.more.settings.database
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import eu.kanade.presentation.components.Scaffold
@ -7,7 +8,6 @@ import eu.kanade.presentation.more.settings.database.components.ClearDatabaseCon
import eu.kanade.presentation.more.settings.database.components.ClearDatabaseDeleteDialog
import eu.kanade.presentation.more.settings.database.components.ClearDatabaseFloatingActionButton
import eu.kanade.presentation.more.settings.database.components.ClearDatabaseToolbar
import eu.kanade.presentation.util.plus
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.setting.database.ClearDatabasePresenter
import eu.kanade.tachiyomi.util.system.toast
@ -18,6 +18,7 @@ fun ClearDatabaseScreen(
navigateUp: () -> Unit,
) {
val context = LocalContext.current
val lazyListState = rememberLazyListState()
Scaffold(
topBar = { scrollBehavior ->
ClearDatabaseToolbar(
@ -31,6 +32,7 @@ fun ClearDatabaseScreen(
floatingActionButton = {
ClearDatabaseFloatingActionButton(
isVisible = presenter.selection.isNotEmpty(),
lazyListState = lazyListState,
onClickDelete = {
presenter.dialog = ClearDatabasePresenter.Dialog.Delete(presenter.selection)
},
@ -40,6 +42,7 @@ fun ClearDatabaseScreen(
ClearDatabaseContent(
state = presenter,
contentPadding = paddingValues,
lazyListState = lazyListState,
onClickSelection = { source ->
presenter.toggleSelection(source)
},

View file

@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
@ -19,12 +20,14 @@ import eu.kanade.tachiyomi.R
fun ClearDatabaseContent(
state: ClearDatabaseState,
contentPadding: PaddingValues,
lazyListState: LazyListState,
onClickSelection: (Source) -> Unit,
) {
Crossfade(targetState = state.isEmpty.not()) { _state ->
when (_state) {
true -> FastScrollLazyColumn(
contentPadding = contentPadding + WindowInsets.navigationBars.asPaddingValues(),
state = lazyListState,
) {
items(state.items) { sourceWithCount ->
ClearDatabaseItem(

View file

@ -4,6 +4,7 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.Icon
@ -12,11 +13,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import eu.kanade.presentation.components.ExtendedFloatingActionButton
import eu.kanade.presentation.util.isScrolledToEnd
import eu.kanade.presentation.util.isScrollingUp
import eu.kanade.tachiyomi.R
@Composable
fun ClearDatabaseFloatingActionButton(
isVisible: Boolean,
lazyListState: LazyListState,
onClickDelete: () -> Unit,
) {
AnimatedVisibility(
@ -33,6 +37,7 @@ fun ClearDatabaseFloatingActionButton(
Icon(Icons.Outlined.Delete, contentDescription = "")
},
onClick = onClickDelete,
expanded = lazyListState.isScrollingUp() || lazyListState.isScrolledToEnd(),
)
}
}

View file

@ -174,20 +174,20 @@ class DownloadController :
onDismissRequest = { onExpanded(false) },
) {
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_reorganize_by)) },
text = { Text(text = stringResource(R.string.action_reorganize_by)) },
children = {
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_order_by_upload_date)) },
text = { Text(text = stringResource(R.string.action_order_by_upload_date)) },
children = {
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_newest)) },
text = { Text(text = stringResource(R.string.action_newest)) },
onClick = {
reorderQueue({ it.download.chapter.date_upload }, true)
onExpanded(false)
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_oldest)) },
text = { Text(text = stringResource(R.string.action_oldest)) },
onClick = {
reorderQueue({ it.download.chapter.date_upload }, false)
onExpanded(false)
@ -196,17 +196,17 @@ class DownloadController :
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_order_by_chapter_number)) },
text = { Text(text = stringResource(R.string.action_order_by_chapter_number)) },
children = {
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_asc)) },
text = { Text(text = stringResource(R.string.action_asc)) },
onClick = {
reorderQueue({ it.download.chapter.chapter_number }, false)
onExpanded(false)
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_desc)) },
text = { Text(text = stringResource(R.string.action_desc)) },
onClick = {
reorderQueue({ it.download.chapter.chapter_number }, true)
onExpanded(false)
@ -217,7 +217,7 @@ class DownloadController :
},
)
DropdownMenuItem(
text = { Text(text = stringResource(id = R.string.action_cancel_all)) },
text = { Text(text = stringResource(R.string.action_cancel_all)) },
onClick = {
presenter.clearQueue(context)
onExpanded(false)