mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Minor cleanup
This commit is contained in:
parent
64da16f58f
commit
9a75232ca4
12 changed files with 75 additions and 71 deletions
|
@ -9,8 +9,8 @@ class ToggleLanguage(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun await(language: String) {
|
fun await(language: String) {
|
||||||
val isEnabled = language in preferences.enabledLanguages().get()
|
val enabled = language in preferences.enabledLanguages().get()
|
||||||
if (isEnabled) {
|
if (enabled) {
|
||||||
preferences.enabledLanguages() -= language
|
preferences.enabledLanguages() -= language
|
||||||
} else {
|
} else {
|
||||||
preferences.enabledLanguages() += language
|
preferences.enabledLanguages() += language
|
||||||
|
|
|
@ -37,6 +37,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
|
@ -47,6 +48,7 @@ import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.browse.components.ExtensionIcon
|
import eu.kanade.presentation.browse.components.ExtensionIcon
|
||||||
|
import eu.kanade.presentation.components.DIVIDER_ALPHA
|
||||||
import eu.kanade.presentation.components.Divider
|
import eu.kanade.presentation.components.Divider
|
||||||
import eu.kanade.presentation.components.EmptyScreen
|
import eu.kanade.presentation.components.EmptyScreen
|
||||||
import eu.kanade.presentation.components.PreferenceRow
|
import eu.kanade.presentation.components.PreferenceRow
|
||||||
|
@ -76,7 +78,7 @@ fun ExtensionDetailsScreen(
|
||||||
|
|
||||||
val sources by presenter.sourcesState.collectAsState()
|
val sources by presenter.sourcesState.collectAsState()
|
||||||
|
|
||||||
val (showNsfwWarning, setShowNsfwWarning) = remember { mutableStateOf(false) }
|
var showNsfwWarning by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
||||||
|
@ -99,7 +101,7 @@ fun ExtensionDetailsScreen(
|
||||||
onClickUninstall = onClickUninstall,
|
onClickUninstall = onClickUninstall,
|
||||||
onClickAppInfo = onClickAppInfo,
|
onClickAppInfo = onClickAppInfo,
|
||||||
onClickAgeRating = {
|
onClickAgeRating = {
|
||||||
setShowNsfwWarning(true)
|
showNsfwWarning = true
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ fun ExtensionDetailsScreen(
|
||||||
if (showNsfwWarning) {
|
if (showNsfwWarning) {
|
||||||
NsfwWarningDialog(
|
NsfwWarningDialog(
|
||||||
onClickConfirm = {
|
onClickConfirm = {
|
||||||
setShowNsfwWarning(false)
|
showNsfwWarning = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -214,7 +216,7 @@ private fun DetailsHeader(
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
),
|
),
|
||||||
secondaryText = stringResource(R.string.ext_info_age_rating),
|
secondaryText = stringResource(R.string.ext_info_age_rating),
|
||||||
onCLick = onClickAgeRating,
|
onClick = onClickAgeRating,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,12 +258,12 @@ private fun InfoText(
|
||||||
primaryText: String,
|
primaryText: String,
|
||||||
primaryTextStyle: TextStyle = MaterialTheme.typography.bodyLarge,
|
primaryTextStyle: TextStyle = MaterialTheme.typography.bodyLarge,
|
||||||
secondaryText: String,
|
secondaryText: String,
|
||||||
onCLick: (() -> Unit)? = null,
|
onClick: (() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
|
||||||
val modifier = if (onCLick != null) {
|
val modifier = if (onClick != null) {
|
||||||
Modifier.clickable(interactionSource, indication = null) { onCLick() }
|
Modifier.clickable(interactionSource, indication = null) { onClick() }
|
||||||
} else Modifier
|
} else Modifier
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
|
@ -275,9 +277,9 @@ private fun InfoText(
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = secondaryText + if (onCLick != null) " ⓘ" else "",
|
text = secondaryText + if (onClick != null) " ⓘ" else "",
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5F),
|
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +290,7 @@ private fun InfoDivider() {
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(20.dp)
|
.height(20.dp)
|
||||||
.width(1.dp),
|
.width(1.dp),
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5F),
|
color = MaterialTheme.colorScheme.onSurface.copy(alpha = DIVIDER_ALPHA),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,11 +337,11 @@ fun NsfwWarningDialog(
|
||||||
) {
|
) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
text = {
|
text = {
|
||||||
Text(text = stringResource(id = R.string.ext_nsfw_warning))
|
Text(text = stringResource(R.string.ext_nsfw_warning))
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = onClickConfirm) {
|
TextButton(onClick = onClickConfirm) {
|
||||||
Text(text = stringResource(id = R.string.ext_nsfw_warning_dismiss))
|
Text(text = stringResource(android.R.string.ok))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = onClickConfirm,
|
onDismissRequest = onClickConfirm,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.kanade.presentation.browse
|
package eu.kanade.presentation.browse
|
||||||
|
|
||||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
|
||||||
import androidx.compose.animation.core.tween
|
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.asPaddingValues
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.navigationBars
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
|
@ -64,9 +62,9 @@ fun SourceFilterContent(
|
||||||
items = items,
|
items = items,
|
||||||
) { model ->
|
) { model ->
|
||||||
ExtensionFilterItem(
|
ExtensionFilterItem(
|
||||||
modifier = Modifier.animateItemPlacement(tween(1000, easing = LinearOutSlowInEasing)),
|
modifier = Modifier.animateItemPlacement(),
|
||||||
lang = model.lang,
|
lang = model.lang,
|
||||||
isEnabled = model.isEnabled,
|
enabled = model.enabled,
|
||||||
onClickItem = onClickLang,
|
onClickItem = onClickLang,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -77,14 +75,14 @@ fun SourceFilterContent(
|
||||||
fun ExtensionFilterItem(
|
fun ExtensionFilterItem(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
lang: String,
|
lang: String,
|
||||||
isEnabled: Boolean,
|
enabled: Boolean,
|
||||||
onClickItem: (String) -> Unit,
|
onClickItem: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
PreferenceRow(
|
PreferenceRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
title = LocaleHelper.getSourceDisplayName(lang, LocalContext.current),
|
title = LocaleHelper.getSourceDisplayName(lang, LocalContext.current),
|
||||||
action = {
|
action = {
|
||||||
Switch(checked = isEnabled, onCheckedChange = null)
|
Switch(checked = enabled, onCheckedChange = null)
|
||||||
},
|
},
|
||||||
onClick = { onClickItem(lang) },
|
onClick = { onClickItem(lang) },
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
|
@ -110,7 +111,8 @@ fun ExtensionContent(
|
||||||
onClickUpdateAll: () -> Unit,
|
onClickUpdateAll: () -> Unit,
|
||||||
onLaunched: () -> Unit,
|
onLaunched: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val (trustState, setTrustState) = remember { mutableStateOf<Extension.Untrusted?>(null) }
|
var trustState by remember { mutableStateOf<Extension.Untrusted?>(null) }
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||||
) {
|
) {
|
||||||
|
@ -137,7 +139,7 @@ fun ExtensionContent(
|
||||||
{
|
{
|
||||||
Button(onClick = { onClickUpdateAll() }) {
|
Button(onClick = { onClickUpdateAll() }) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.ext_update_all),
|
text = stringResource(R.string.ext_update_all),
|
||||||
style = LocalTextStyle.current.copy(
|
style = LocalTextStyle.current.copy(
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
|
@ -173,7 +175,7 @@ fun ExtensionContent(
|
||||||
onOpenExtension(it)
|
onOpenExtension(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Extension.Untrusted -> setTrustState(it)
|
is Extension.Untrusted -> { trustState = it }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongClickItem = onLongClickItem,
|
onLongClickItem = onLongClickItem,
|
||||||
|
@ -188,7 +190,7 @@ fun ExtensionContent(
|
||||||
onOpenExtension(it)
|
onOpenExtension(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Extension.Untrusted -> setTrustState(it)
|
is Extension.Untrusted -> { trustState = it }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -202,15 +204,15 @@ fun ExtensionContent(
|
||||||
if (trustState != null) {
|
if (trustState != null) {
|
||||||
ExtensionTrustDialog(
|
ExtensionTrustDialog(
|
||||||
onClickConfirm = {
|
onClickConfirm = {
|
||||||
onTrustExtension(trustState)
|
onTrustExtension(trustState!!)
|
||||||
setTrustState(null)
|
trustState = null
|
||||||
},
|
},
|
||||||
onClickDismiss = {
|
onClickDismiss = {
|
||||||
onUninstallExtension(trustState)
|
onUninstallExtension(trustState!!)
|
||||||
setTrustState(null)
|
trustState = null
|
||||||
},
|
},
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
setTrustState(null)
|
trustState = null
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -403,19 +405,19 @@ fun ExtensionTrustDialog(
|
||||||
) {
|
) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
title = {
|
title = {
|
||||||
Text(text = stringResource(id = R.string.untrusted_extension))
|
Text(text = stringResource(R.string.untrusted_extension))
|
||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Text(text = stringResource(id = R.string.untrusted_extension_message))
|
Text(text = stringResource(R.string.untrusted_extension_message))
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = onClickConfirm) {
|
TextButton(onClick = onClickConfirm) {
|
||||||
Text(text = stringResource(id = R.string.ext_trust))
|
Text(text = stringResource(R.string.ext_trust))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = onClickDismiss) {
|
TextButton(onClick = onClickDismiss) {
|
||||||
Text(text = stringResource(id = R.string.ext_uninstall))
|
Text(text = stringResource(R.string.ext_uninstall))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
|
|
|
@ -68,7 +68,7 @@ fun MigrateSourceList(
|
||||||
) {
|
) {
|
||||||
item(key = "title") {
|
item(key = "title") {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.migration_selection_prompt),
|
text = stringResource(R.string.migration_selection_prompt),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.animateItemPlacement()
|
.animateItemPlacement()
|
||||||
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
||||||
|
|
|
@ -84,14 +84,14 @@ fun SourcesFilterContent(
|
||||||
SourcesFilterHeader(
|
SourcesFilterHeader(
|
||||||
modifier = Modifier.animateItemPlacement(),
|
modifier = Modifier.animateItemPlacement(),
|
||||||
language = model.language,
|
language = model.language,
|
||||||
isEnabled = model.isEnabled,
|
enabled = model.enabled,
|
||||||
onClickItem = onClickLang,
|
onClickItem = onClickLang,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is FilterUiModel.Item -> SourcesFilterItem(
|
is FilterUiModel.Item -> SourcesFilterItem(
|
||||||
modifier = Modifier.animateItemPlacement(),
|
modifier = Modifier.animateItemPlacement(),
|
||||||
source = model.source,
|
source = model.source,
|
||||||
isEnabled = model.isEnabled,
|
enabled = model.enabled,
|
||||||
onClickItem = onClickSource,
|
onClickItem = onClickSource,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -103,14 +103,14 @@ fun SourcesFilterContent(
|
||||||
fun SourcesFilterHeader(
|
fun SourcesFilterHeader(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
language: String,
|
language: String,
|
||||||
isEnabled: Boolean,
|
enabled: Boolean,
|
||||||
onClickItem: (String) -> Unit,
|
onClickItem: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
PreferenceRow(
|
PreferenceRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
title = LocaleHelper.getSourceDisplayName(language, LocalContext.current),
|
title = LocaleHelper.getSourceDisplayName(language, LocalContext.current),
|
||||||
action = {
|
action = {
|
||||||
Switch(checked = isEnabled, onCheckedChange = null)
|
Switch(checked = enabled, onCheckedChange = null)
|
||||||
},
|
},
|
||||||
onClick = { onClickItem(language) },
|
onClick = { onClickItem(language) },
|
||||||
)
|
)
|
||||||
|
@ -120,7 +120,7 @@ fun SourcesFilterHeader(
|
||||||
fun SourcesFilterItem(
|
fun SourcesFilterItem(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
source: Source,
|
source: Source,
|
||||||
isEnabled: Boolean,
|
enabled: Boolean,
|
||||||
onClickItem: (Source) -> Unit,
|
onClickItem: (Source) -> Unit,
|
||||||
) {
|
) {
|
||||||
BaseSourceItem(
|
BaseSourceItem(
|
||||||
|
@ -129,7 +129,7 @@ fun SourcesFilterItem(
|
||||||
showLanguageInContent = false,
|
showLanguageInContent = false,
|
||||||
onClickItem = { onClickItem(source) },
|
onClickItem = { onClickItem(source) },
|
||||||
action = {
|
action = {
|
||||||
Checkbox(checked = isEnabled, onCheckedChange = null)
|
Checkbox(checked = enabled, onCheckedChange = null)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
|
@ -84,7 +85,8 @@ fun SourceList(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val (sourceState, setSourceState) = remember { mutableStateOf<Source?>(null) }
|
var sourceState by remember { mutableStateOf<Source?>(null) }
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.nestedScroll(nestedScrollConnection),
|
modifier = Modifier.nestedScroll(nestedScrollConnection),
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||||
|
@ -115,9 +117,7 @@ fun SourceList(
|
||||||
modifier = Modifier.animateItemPlacement(),
|
modifier = Modifier.animateItemPlacement(),
|
||||||
source = model.source,
|
source = model.source,
|
||||||
onClickItem = onClickItem,
|
onClickItem = onClickItem,
|
||||||
onLongClickItem = {
|
onLongClickItem = { sourceState = it },
|
||||||
setSourceState(it)
|
|
||||||
},
|
|
||||||
onClickLatest = onClickLatest,
|
onClickLatest = onClickLatest,
|
||||||
onClickPin = onClickPin,
|
onClickPin = onClickPin,
|
||||||
)
|
)
|
||||||
|
@ -127,16 +127,16 @@ fun SourceList(
|
||||||
|
|
||||||
if (sourceState != null) {
|
if (sourceState != null) {
|
||||||
SourceOptionsDialog(
|
SourceOptionsDialog(
|
||||||
source = sourceState,
|
source = sourceState!!,
|
||||||
onClickPin = {
|
onClickPin = {
|
||||||
onClickPin(sourceState)
|
onClickPin(sourceState!!)
|
||||||
setSourceState(null)
|
sourceState = null
|
||||||
},
|
},
|
||||||
onClickDisable = {
|
onClickDisable = {
|
||||||
onClickDisable(sourceState)
|
onClickDisable(sourceState!!)
|
||||||
setSourceState(null)
|
sourceState = null
|
||||||
},
|
},
|
||||||
onDismiss = { setSourceState(null) },
|
onDismiss = { sourceState = null },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ fun SourceItem(
|
||||||
if (source.supportsLatest) {
|
if (source.supportsLatest) {
|
||||||
TextButton(onClick = { onClickLatest(source) }) {
|
TextButton(onClick = { onClickLatest(source) }) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.latest),
|
text = stringResource(R.string.latest),
|
||||||
style = LocalTextStyle.current.copy(
|
style = LocalTextStyle.current.copy(
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
@ -227,7 +227,7 @@ fun SourceOptionsDialog(
|
||||||
)
|
)
|
||||||
if (source.id != LocalSource.ID) {
|
if (source.id != LocalSource.ID) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.action_disable),
|
text = stringResource(R.string.action_disable),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable(onClick = onClickDisable)
|
.clickable(onClick = onClickDisable)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
@ -21,13 +21,15 @@ import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.core.prefs.PreferenceMutableState
|
import eu.kanade.core.prefs.PreferenceMutableState
|
||||||
import eu.kanade.presentation.util.horizontalPadding
|
import eu.kanade.presentation.util.horizontalPadding
|
||||||
|
|
||||||
|
const val DIVIDER_ALPHA = 0.2f
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Divider(
|
fun Divider(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
androidx.compose.material3.Divider(
|
androidx.compose.material3.Divider(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f),
|
color = MaterialTheme.colorScheme.onSurface.copy(alpha = DIVIDER_ALPHA),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
|
@ -103,7 +104,7 @@ fun HistoryContent(
|
||||||
val relativeTime: Int = remember { preferences.relativeTime().get() }
|
val relativeTime: Int = remember { preferences.relativeTime().get() }
|
||||||
val dateFormat: DateFormat = remember { preferences.dateFormat() }
|
val dateFormat: DateFormat = remember { preferences.dateFormat() }
|
||||||
|
|
||||||
val (removeState, setRemoveState) = remember { mutableStateOf<HistoryWithRelations?>(null) }
|
var removeState by remember { mutableStateOf<HistoryWithRelations?>(null) }
|
||||||
|
|
||||||
val scrollState = rememberLazyListState()
|
val scrollState = rememberLazyListState()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
@ -130,7 +131,7 @@ fun HistoryContent(
|
||||||
history = value,
|
history = value,
|
||||||
onClickCover = { onClickCover(value) },
|
onClickCover = { onClickCover(value) },
|
||||||
onClickResume = { onClickResume(value) },
|
onClickResume = { onClickResume(value) },
|
||||||
onClickDelete = { setRemoveState(value) },
|
onClickDelete = { removeState = value },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
null -> {}
|
null -> {}
|
||||||
|
@ -141,10 +142,10 @@ fun HistoryContent(
|
||||||
if (removeState != null) {
|
if (removeState != null) {
|
||||||
RemoveHistoryDialog(
|
RemoveHistoryDialog(
|
||||||
onPositive = { all ->
|
onPositive = { all ->
|
||||||
onClickDelete(removeState, all)
|
onClickDelete(removeState!!, all)
|
||||||
setRemoveState(null)
|
removeState = null
|
||||||
},
|
},
|
||||||
onNegative = { setRemoveState(null) },
|
onNegative = { removeState = null },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ fun HistoryItem(
|
||||||
IconButton(onClick = onClickDelete) {
|
IconButton(onClick = onClickDelete) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Delete,
|
imageVector = Icons.Outlined.Delete,
|
||||||
contentDescription = stringResource(id = R.string.action_delete),
|
contentDescription = stringResource(R.string.action_delete),
|
||||||
tint = MaterialTheme.colorScheme.onSurface,
|
tint = MaterialTheme.colorScheme.onSurface,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -236,15 +237,15 @@ fun RemoveHistoryDialog(
|
||||||
onPositive: (Boolean) -> Unit,
|
onPositive: (Boolean) -> Unit,
|
||||||
onNegative: () -> Unit,
|
onNegative: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val (removeEverything, removeEverythingState) = remember { mutableStateOf(false) }
|
var removeEverything by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
title = {
|
title = {
|
||||||
Text(text = stringResource(id = R.string.action_remove))
|
Text(text = stringResource(R.string.action_remove))
|
||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
Text(text = stringResource(id = R.string.dialog_with_checkbox_remove_description))
|
Text(text = stringResource(R.string.dialog_with_checkbox_remove_description))
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 16.dp)
|
.padding(top = 16.dp)
|
||||||
|
@ -252,7 +253,7 @@ fun RemoveHistoryDialog(
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = null,
|
indication = null,
|
||||||
value = removeEverything,
|
value = removeEverything,
|
||||||
onValueChange = removeEverythingState,
|
onValueChange = { removeEverything = it },
|
||||||
),
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
@ -262,7 +263,7 @@ fun RemoveHistoryDialog(
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(start = 4.dp),
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
text = stringResource(id = R.string.dialog_with_checkbox_reset),
|
text = stringResource(R.string.dialog_with_checkbox_reset),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,12 +271,12 @@ fun RemoveHistoryDialog(
|
||||||
onDismissRequest = onNegative,
|
onDismissRequest = onNegative,
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = { onPositive(removeEverything) }) {
|
TextButton(onClick = { onPositive(removeEverything) }) {
|
||||||
Text(text = stringResource(id = R.string.action_remove))
|
Text(text = stringResource(R.string.action_remove))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = onNegative) {
|
TextButton(onClick = onNegative) {
|
||||||
Text(text = stringResource(id = R.string.action_cancel))
|
Text(text = stringResource(R.string.action_cancel))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,4 +24,4 @@ class ExtensionFilterController : ComposeController<ExtensionFilterPresenter>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class FilterUiModel(val lang: String, val isEnabled: Boolean)
|
data class FilterUiModel(val lang: String, val enabled: Boolean)
|
||||||
|
|
|
@ -29,6 +29,6 @@ class SourceFilterController : ComposeController<SourcesFilterPresenter>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class FilterUiModel {
|
sealed class FilterUiModel {
|
||||||
data class Header(val language: String, val isEnabled: Boolean) : FilterUiModel()
|
data class Header(val language: String, val enabled: Boolean) : FilterUiModel()
|
||||||
data class Item(val source: Source, val isEnabled: Boolean) : FilterUiModel()
|
data class Item(val source: Source, val enabled: Boolean) : FilterUiModel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,8 +273,7 @@
|
||||||
<string name="ext_info_language">Language</string>
|
<string name="ext_info_language">Language</string>
|
||||||
<string name="ext_info_age_rating">Age rating</string>
|
<string name="ext_info_age_rating">Age rating</string>
|
||||||
<string name="ext_nsfw_short">18+</string>
|
<string name="ext_nsfw_short">18+</string>
|
||||||
<string name="ext_nsfw_warning">May contain NSFW (18+) content</string>
|
<string name="ext_nsfw_warning">Sources from this extension may contain NSFW (18+) content</string>
|
||||||
<string name="ext_nsfw_warning_dismiss">Got it</string>
|
|
||||||
<string name="ext_install_service_notif">Installing extension…</string>
|
<string name="ext_install_service_notif">Installing extension…</string>
|
||||||
<string name="ext_installer_pref">Installer</string>
|
<string name="ext_installer_pref">Installer</string>
|
||||||
<string name="ext_installer_legacy">Legacy</string>
|
<string name="ext_installer_legacy">Legacy</string>
|
||||||
|
|
Loading…
Reference in a new issue