diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt index b4401f707c..ca3efb421c 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt @@ -6,8 +6,10 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester @@ -22,7 +24,7 @@ fun CategoryCreateDialog( onDismissRequest: () -> Unit, onCreate: (String) -> Unit, ) { - val (name, onNameChange) = remember { mutableStateOf("") } + var name by remember { mutableStateOf("") } val focusRequester = remember { FocusRequester() } AlertDialog( @@ -48,7 +50,7 @@ fun CategoryCreateDialog( modifier = Modifier .focusRequester(focusRequester), value = name, - onValueChange = onNameChange, + onValueChange = { name = it }, label = { Text(text = stringResource(R.string.name)) }, @@ -70,7 +72,7 @@ fun CategoryRenameDialog( onRename: (String) -> Unit, category: Category, ) { - val (name, onNameChange) = remember { mutableStateOf(category.name) } + var name by remember { mutableStateOf(category.name) } val focusRequester = remember { FocusRequester() } AlertDialog( @@ -96,7 +98,7 @@ fun CategoryRenameDialog( modifier = Modifier .focusRequester(focusRequester), value = name, - onValueChange = onNameChange, + onValueChange = { name = it }, label = { Text(text = stringResource(R.string.name)) }, diff --git a/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt b/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt index 0756be4016..a0ed279d74 100644 --- a/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt +++ b/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt @@ -22,6 +22,7 @@ fun DropdownMenu( expanded: Boolean, onDismissRequest: () -> Unit, modifier: Modifier = Modifier, + offset: DpOffset = DpOffset(8.dp, (-56).dp), properties: PopupProperties = PopupProperties(focusable = true), content: @Composable ColumnScope.() -> Unit, ) { @@ -29,7 +30,7 @@ fun DropdownMenu( expanded = expanded, onDismissRequest = onDismissRequest, modifier = modifier.sizeIn(minWidth = 196.dp, maxWidth = 196.dp), - offset = DpOffset(8.dp, (-56).dp), + offset = offset, properties = properties, content = content, ) diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 2c36a648f8..f1b9ab6bf1 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -35,6 +35,7 @@ import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.hapticfeedback.HapticFeedbackType @@ -410,7 +411,7 @@ fun MangaScreenLargeImpl( val chapters = remember(state) { state.processedChapters.toList() } val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues() - val (topBarHeight, onTopBarHeightChanged) = remember { mutableStateOf(0) } + var topBarHeight by remember { mutableStateOf(0) } SwipeRefresh( refreshing = state.isRefreshingData, onRefresh = onRefresh, @@ -436,7 +437,7 @@ fun MangaScreenLargeImpl( modifier = Modifier.padding(insetPadding), topBar = { MangaToolbar( - modifier = Modifier.onSizeChanged { onTopBarHeightChanged(it.height) }, + modifier = Modifier.onSizeChanged { topBarHeight = it.height }, title = state.manga.title, titleAlphaProvider = { if (chapters.any { it.selected }) 1f else 0f }, backgroundAlphaProvider = { 1f }, diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaCoverDialog.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaCoverDialog.kt index b4be71bdea..88dcf66cee 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaCoverDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaCoverDialog.kt @@ -24,11 +24,14 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.core.view.updatePadding @@ -82,9 +85,15 @@ fun MangaCoverDialog( } if (onEditClick != null) { Box { - val (expanded, onExpand) = remember { mutableStateOf(false) } + var expanded by remember { mutableStateOf(false) } IconButton( - onClick = { if (isCustomCover) onExpand(true) else onEditClick(EditCoverAction.EDIT) }, + onClick = { + if (isCustomCover) { + expanded = true + } else { + onEditClick(EditCoverAction.EDIT) + } + }, ) { Icon( imageVector = Icons.Outlined.Edit, @@ -93,20 +102,21 @@ fun MangaCoverDialog( } DropdownMenu( expanded = expanded, - onDismissRequest = { onExpand(false) }, + onDismissRequest = { expanded = false }, + offset = DpOffset(8.dp, 0.dp), ) { DropdownMenuItem( text = { Text(text = stringResource(R.string.action_edit)) }, onClick = { onEditClick(EditCoverAction.EDIT) - onExpand(false) + expanded = false }, ) DropdownMenuItem( text = { Text(text = stringResource(R.string.action_delete)) }, onClick = { onEditClick(EditCoverAction.DELETE) - onExpand(false) + expanded = false }, ) } diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt index 14c0551f50..28f9060114 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt @@ -22,8 +22,10 @@ import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.res.stringResource @@ -157,15 +159,15 @@ fun MangaToolbar( } if (onClickEditCategory != null && onClickMigrate != null) { - val (moreExpanded, onMoreExpanded) = remember { mutableStateOf(false) } + var moreExpanded by remember { mutableStateOf(false) } Box { - IconButton(onClick = { onMoreExpanded(!moreExpanded) }) { + IconButton(onClick = { moreExpanded = !moreExpanded }) { Icon( imageVector = Icons.Outlined.MoreVert, contentDescription = stringResource(R.string.abc_action_menu_overflow_description), ) } - val onDismissRequest = { onMoreExpanded(false) } + val onDismissRequest = { moreExpanded = false } DropdownMenu( expanded = moreExpanded, onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/EditTextPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/EditTextPreferenceWidget.kt index e7f4e5f780..75c416826a 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/EditTextPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/EditTextPreferenceWidget.kt @@ -28,18 +28,18 @@ fun EditTextPreferenceWidget( value: String, onConfirm: suspend (String) -> Boolean, ) { - val (isDialogShown, showDialog) = remember { mutableStateOf(false) } + var isDialogShown by remember { mutableStateOf(false) } TextPreferenceWidget( title = title, subtitle = subtitle?.format(value), icon = icon, - onPreferenceClick = { showDialog(true) }, + onPreferenceClick = { isDialogShown = true }, ) if (isDialogShown) { val scope = rememberCoroutineScope() - val onDismissRequest = { showDialog(false) } + val onDismissRequest = { isDialogShown = false } var textFieldValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue(value)) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt index ad16c748db..41df13266c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt @@ -12,8 +12,10 @@ import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -36,18 +38,18 @@ fun ListPreferenceWidget( entries: Map, onValueChange: (T) -> Unit, ) { - val (isDialogShown, showDialog) = remember { mutableStateOf(false) } + var isDialogShown by remember { mutableStateOf(false) } TextPreferenceWidget( title = title, subtitle = subtitle, icon = icon, - onPreferenceClick = { showDialog(true) }, + onPreferenceClick = { isDialogShown = true }, ) if (isDialogShown) { AlertDialog( - onDismissRequest = { showDialog(false) }, + onDismissRequest = { isDialogShown = false }, title = { Text(text = title) }, text = { Box { @@ -61,7 +63,7 @@ fun ListPreferenceWidget( isSelected = isSelected, onSelected = { onValueChange(current.key!!) - showDialog(false) + isDialogShown = false }, ) } @@ -72,7 +74,7 @@ fun ListPreferenceWidget( } }, confirmButton = { - TextButton(onClick = { showDialog(false) }) { + TextButton(onClick = { isDialogShown = false }) { Text(text = stringResource(R.string.action_cancel)) } }, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/MultiSelectListPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/MultiSelectListPreferenceWidget.kt index 963e7ef795..23e5478928 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/MultiSelectListPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/MultiSelectListPreferenceWidget.kt @@ -11,8 +11,10 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.runtime.toMutableStateList import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -30,13 +32,13 @@ fun MultiSelectListPreferenceWidget( values: Set, onValuesChange: (Set) -> Unit, ) { - val (isDialogShown, showDialog) = remember { mutableStateOf(false) } + var isDialogShown by remember { mutableStateOf(false) } TextPreferenceWidget( title = preference.title, subtitle = preference.subtitleProvider(values, preference.entries), icon = preference.icon, - onPreferenceClick = { showDialog(true) }, + onPreferenceClick = { isDialogShown = true }, ) if (isDialogShown) { @@ -46,7 +48,7 @@ fun MultiSelectListPreferenceWidget( .toMutableStateList() } AlertDialog( - onDismissRequest = { showDialog(false) }, + onDismissRequest = { isDialogShown = false }, title = { Text(text = preference.title) }, text = { LazyColumn { @@ -91,14 +93,14 @@ fun MultiSelectListPreferenceWidget( TextButton( onClick = { onValuesChange(selected.toMutableSet()) - showDialog(false) + isDialogShown = false }, ) { Text(text = stringResource(android.R.string.ok)) } }, dismissButton = { - TextButton(onClick = { showDialog(false) }) { + TextButton(onClick = { isDialogShown = false }) { Text(text = stringResource(R.string.action_cancel)) } }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index e30cf52c76..dbddd98208 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -147,9 +147,9 @@ class DownloadController : navigateUp = router::popCurrentController, actions = { if (downloadList.isNotEmpty()) { - val (expanded, onExpanded) = remember { mutableStateOf(false) } + var expanded by remember { mutableStateOf(false) } Box { - IconButton(onClick = { onExpanded(!expanded) }) { + IconButton(onClick = { expanded = !expanded }) { Icon( imageVector = Icons.Outlined.MoreVert, contentDescription = stringResource(R.string.abc_action_menu_overflow_description), @@ -157,7 +157,7 @@ class DownloadController : } CascadeDropdownMenu( expanded = expanded, - onDismissRequest = { onExpanded(false) }, + onDismissRequest = { expanded = false }, ) { DropdownMenuItem( text = { Text(text = stringResource(R.string.action_reorganize_by)) }, @@ -169,14 +169,14 @@ class DownloadController : text = { Text(text = stringResource(R.string.action_newest)) }, onClick = { reorderQueue({ it.download.chapter.date_upload }, true) - onExpanded(false) + expanded = false }, ) DropdownMenuItem( text = { Text(text = stringResource(R.string.action_oldest)) }, onClick = { reorderQueue({ it.download.chapter.date_upload }, false) - onExpanded(false) + expanded = false }, ) }, @@ -188,14 +188,14 @@ class DownloadController : text = { Text(text = stringResource(R.string.action_asc)) }, onClick = { reorderQueue({ it.download.chapter.chapter_number }, false) - onExpanded(false) + expanded = false }, ) DropdownMenuItem( text = { Text(text = stringResource(R.string.action_desc)) }, onClick = { reorderQueue({ it.download.chapter.chapter_number }, true) - onExpanded(false) + expanded = false }, ) }, @@ -206,7 +206,7 @@ class DownloadController : text = { Text(text = stringResource(R.string.action_cancel_all)) }, onClick = { presenter.clearQueue(context) - onExpanded(false) + expanded = false }, ) }