Tweak categories view
- Remove Compose top app bar behaviour since it's kind of jank -- we'll probably just remove the scrolling behaviour everywhere - Tap title to rename - Focus in textfield when opening dialogs (cherry picked from commit 0b78028cf660e2f576ee30f8315b657eca1f39cd) # Conflicts: # app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt # app/src/main/java/eu/kanade/presentation/category/components/CategoryTopAppBar.kt # app/src/main/java/eu/kanade/presentation/library/components/LibraryGridCover.kt
This commit is contained in:
parent
74b360f798
commit
af83f81034
@ -3,13 +3,9 @@ package eu.kanade.presentation.category
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.category.components.CategoryContent
|
||||
@ -36,15 +32,10 @@ fun CategoryScreen(
|
||||
navigateUp: () -> Unit,
|
||||
) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val topAppBarScrollState = rememberTopAppBarScrollState()
|
||||
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(topAppBarScrollState)
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
modifier = Modifier.statusBarsPadding(),
|
||||
topBar = {
|
||||
CategoryTopAppBar(
|
||||
topAppBarScrollBehavior = topAppBarScrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
title = stringResource(id = R.string.action_edit_categories),
|
||||
)
|
||||
|
@ -3,12 +3,9 @@ package eu.kanade.presentation.category
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.category.components.CategoryCreateDialog
|
||||
@ -34,15 +31,11 @@ fun SortTagScreen(
|
||||
navigateUp: () -> Unit,
|
||||
) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val topAppBarScrollState = rememberTopAppBarScrollState()
|
||||
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(topAppBarScrollState)
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.statusBarsPadding(),
|
||||
topBar = {
|
||||
CategoryTopAppBar(
|
||||
topAppBarScrollBehavior = topAppBarScrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
title = stringResource(id = R.string.action_edit_tags),
|
||||
)
|
||||
|
@ -3,12 +3,9 @@ package eu.kanade.presentation.category
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.category.components.CategoryCreateDialog
|
||||
@ -35,15 +32,11 @@ fun SourceCategoryScreen(
|
||||
navigateUp: () -> Unit,
|
||||
) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val topAppBarScrollState = rememberTopAppBarScrollState()
|
||||
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(topAppBarScrollState)
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.statusBarsPadding(),
|
||||
topBar = {
|
||||
CategoryTopAppBar(
|
||||
topAppBarScrollBehavior = topAppBarScrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
title = stringResource(id = R.string.action_edit_categories),
|
||||
)
|
||||
|
@ -3,12 +3,9 @@ package eu.kanade.presentation.category
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.category.components.CategoryCreateDialog
|
||||
@ -34,15 +31,11 @@ fun SourceRepoScreen(
|
||||
navigateUp: () -> Unit,
|
||||
) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val topAppBarScrollState = rememberTopAppBarScrollState()
|
||||
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(topAppBarScrollState)
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.statusBarsPadding(),
|
||||
topBar = {
|
||||
CategoryTopAppBar(
|
||||
topAppBarScrollBehavior = topAppBarScrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
title = stringResource(R.string.action_edit_repos),
|
||||
)
|
||||
|
@ -5,11 +5,16 @@ import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.components.TextButton
|
||||
import eu.kanade.tachiyomi.R
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
fun CategoryCreateDialog(
|
||||
@ -21,6 +26,8 @@ fun CategoryCreateDialog(
|
||||
// SY <--
|
||||
) {
|
||||
val (name, onNameChange) = remember { mutableStateOf("") }
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
confirmButton = {
|
||||
@ -28,12 +35,12 @@ fun CategoryCreateDialog(
|
||||
onCreate(name)
|
||||
onDismissRequest()
|
||||
},) {
|
||||
Text(text = stringResource(id = R.string.action_add))
|
||||
Text(text = stringResource(R.string.action_add))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismissRequest) {
|
||||
Text(text = stringResource(id = R.string.action_cancel))
|
||||
Text(text = stringResource(R.string.action_cancel))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
@ -47,10 +54,12 @@ fun CategoryCreateDialog(
|
||||
}
|
||||
// SY <--
|
||||
OutlinedTextField(
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester),
|
||||
value = name,
|
||||
onValueChange = onNameChange,
|
||||
label = {
|
||||
Text(text = stringResource(id = R.string.name))
|
||||
Text(text = stringResource(R.string.name))
|
||||
},
|
||||
)
|
||||
// SY -->
|
||||
@ -58,6 +67,12 @@ fun CategoryCreateDialog(
|
||||
// SY <--
|
||||
},
|
||||
)
|
||||
|
||||
LaunchedEffect(focusRequester) {
|
||||
// TODO: https://issuetracker.google.com/issues/204502668
|
||||
delay(100)
|
||||
focusRequester.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@ -67,6 +82,7 @@ fun CategoryRenameDialog(
|
||||
category: String,
|
||||
) {
|
||||
val (name, onNameChange) = remember { mutableStateOf(category) }
|
||||
val focusRequester = remember { FocusRequester.Default }
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
confirmButton = {
|
||||
@ -74,27 +90,35 @@ fun CategoryRenameDialog(
|
||||
onRename(name)
|
||||
onDismissRequest()
|
||||
},) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
Text(text = stringResource(android.R.string.ok))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismissRequest) {
|
||||
Text(text = stringResource(id = R.string.action_cancel))
|
||||
Text(text = stringResource(R.string.action_cancel))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.action_rename_category))
|
||||
Text(text = stringResource(R.string.action_rename_category))
|
||||
},
|
||||
text = {
|
||||
OutlinedTextField(
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester),
|
||||
value = name,
|
||||
onValueChange = onNameChange,
|
||||
label = {
|
||||
Text(text = stringResource(id = R.string.name))
|
||||
Text(text = stringResource(R.string.name))
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
LaunchedEffect(focusRequester) {
|
||||
// TODO: https://issuetracker.google.com/issues/204502668
|
||||
delay(100)
|
||||
focusRequester.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
@ -20,7 +20,7 @@ fun CategoryFloatingActionButton(
|
||||
onCreate: () -> Unit,
|
||||
) {
|
||||
ExtendedFloatingActionButton(
|
||||
text = { Text(text = stringResource(id = R.string.action_add)) },
|
||||
text = { Text(text = stringResource(R.string.action_add)) },
|
||||
icon = { Icon(imageVector = Icons.Outlined.Add, contentDescription = "") },
|
||||
onClick = onCreate,
|
||||
modifier = Modifier
|
||||
|
@ -1,7 +1,9 @@
|
||||
package eu.kanade.presentation.category.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||
@ -35,11 +37,17 @@ fun CategoryListItem(
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onRename() }
|
||||
.padding(start = horizontalPadding, top = horizontalPadding, end = horizontalPadding),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(imageVector = Icons.Outlined.Label, contentDescription = "")
|
||||
Text(text = category.name, modifier = Modifier.padding(start = horizontalPadding))
|
||||
Text(
|
||||
text = category.name,
|
||||
modifier = Modifier
|
||||
.padding(start = horizontalPadding),
|
||||
)
|
||||
}
|
||||
Row {
|
||||
IconButton(
|
||||
|
@ -6,14 +6,12 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.SmallTopAppBar
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
@Composable
|
||||
fun CategoryTopAppBar(
|
||||
topAppBarScrollBehavior: TopAppBarScrollBehavior,
|
||||
navigateUp: () -> Unit,
|
||||
title: String,
|
||||
) {
|
||||
@ -29,6 +27,5 @@ fun CategoryTopAppBar(
|
||||
title = {
|
||||
Text(text = title)
|
||||
},
|
||||
scrollBehavior = topAppBarScrollBehavior,
|
||||
)
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ fun SortTagContent(
|
||||
index = index,
|
||||
canMoveUp = index != 0,
|
||||
canMoveDown = index != tags.lastIndex,
|
||||
onMoveUp = onMoveUp,
|
||||
onMoveDown = onMoveDown,
|
||||
onDelete = { state.dialog = SortTagPresenter.Dialog.Delete(it) },
|
||||
onMoveUp = { onMoveUp(tag, index) },
|
||||
onMoveDown = { onMoveDown(tag, index) },
|
||||
onDelete = { state.dialog = SortTagPresenter.Dialog.Delete(tag) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.presentation.category.components.genre
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||
@ -24,15 +25,16 @@ fun SortTagListItem(
|
||||
index: Int,
|
||||
canMoveUp: Boolean,
|
||||
canMoveDown: Boolean,
|
||||
onMoveUp: (String, Int) -> Unit,
|
||||
onMoveDown: (String, Int) -> Unit,
|
||||
onDelete: (String) -> Unit,
|
||||
onMoveUp: () -> Unit,
|
||||
onMoveDown: () -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
) {
|
||||
ElevatedCard(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = horizontalPadding, top = horizontalPadding, end = horizontalPadding),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
@ -41,19 +43,19 @@ fun SortTagListItem(
|
||||
}
|
||||
Row {
|
||||
IconButton(
|
||||
onClick = { onMoveUp(tag, index) },
|
||||
onClick = onMoveUp,
|
||||
enabled = canMoveUp,
|
||||
) {
|
||||
Icon(imageVector = Icons.Outlined.ArrowDropUp, contentDescription = "")
|
||||
}
|
||||
IconButton(
|
||||
onClick = { onMoveDown(tag, index) },
|
||||
onClick = onMoveDown,
|
||||
enabled = canMoveDown,
|
||||
) {
|
||||
Icon(imageVector = Icons.Outlined.ArrowDropDown, contentDescription = "")
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
IconButton(onClick = { onDelete(tag) }) {
|
||||
IconButton(onClick = onDelete) {
|
||||
Icon(imageVector = Icons.Outlined.Delete, contentDescription = "")
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ fun SourceRepoContent(
|
||||
SourceRepoListItem(
|
||||
modifier = Modifier.animateItemPlacement(),
|
||||
repo = repo,
|
||||
onDelete = { state.dialog = RepoPresenter.Dialog.Delete(it) },
|
||||
onDelete = { state.dialog = RepoPresenter.Dialog.Delete(repo) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.presentation.category.components.repo
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
@ -19,13 +20,14 @@ import eu.kanade.presentation.util.horizontalPadding
|
||||
fun SourceRepoListItem(
|
||||
modifier: Modifier,
|
||||
repo: String,
|
||||
onDelete: (String) -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
) {
|
||||
ElevatedCard(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = horizontalPadding, top = horizontalPadding, end = horizontalPadding),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
@ -34,7 +36,7 @@ fun SourceRepoListItem(
|
||||
}
|
||||
Row {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
IconButton(onClick = { onDelete(repo) }) {
|
||||
IconButton(onClick = onDelete) {
|
||||
Icon(imageVector = Icons.Outlined.Delete, contentDescription = "")
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package eu.kanade.presentation.category.components.sources
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
@ -20,14 +22,16 @@ import eu.kanade.presentation.util.horizontalPadding
|
||||
fun SourceCategoryListItem(
|
||||
modifier: Modifier,
|
||||
category: String,
|
||||
onRename: (String) -> Unit,
|
||||
onDelete: (String) -> Unit,
|
||||
onRename: () -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
) {
|
||||
ElevatedCard(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onRename() }
|
||||
.padding(start = horizontalPadding, top = horizontalPadding, end = horizontalPadding),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
@ -36,10 +40,10 @@ fun SourceCategoryListItem(
|
||||
}
|
||||
Row {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
IconButton(onClick = { onRename(category) }) {
|
||||
IconButton(onClick = onRename) {
|
||||
Icon(imageVector = Icons.Outlined.Edit, contentDescription = "")
|
||||
}
|
||||
IconButton(onClick = { onDelete(category) }) {
|
||||
IconButton(onClick = onDelete) {
|
||||
Icon(imageVector = Icons.Outlined.Delete, contentDescription = "")
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ fun LibraryGridCover(
|
||||
) {
|
||||
if (isLocal) {
|
||||
Badge(
|
||||
text = stringResource(id = R.string.local_source_badge),
|
||||
text = stringResource(R.string.local_source_badge),
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
||||
)
|
||||
|
@ -103,7 +103,7 @@ fun LibraryListItem(
|
||||
}
|
||||
if (item.isLocal) {
|
||||
Badge(
|
||||
text = stringResource(id = R.string.local_source_badge),
|
||||
text = stringResource(R.string.local_source_badge),
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
||||
)
|
||||
|
@ -228,7 +228,7 @@ fun ExpandableMangaDescription(
|
||||
mutableStateOf(defaultExpandState)
|
||||
}
|
||||
val desc =
|
||||
description.takeIf { !it.isNullOrBlank() } ?: stringResource(id = R.string.description_placeholder)
|
||||
description.takeIf { !it.isNullOrBlank() } ?: stringResource(R.string.description_placeholder)
|
||||
val trimmedDescription = remember(desc) {
|
||||
desc
|
||||
.replace(whitespaceLineRegex, "\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user