Re-add debug menu button styling
This commit is contained in:
@@ -203,6 +203,14 @@ internal fun PreferenceItem(
|
||||
},
|
||||
)
|
||||
}
|
||||
is Preference.PreferenceItem.AnnotatedTextPreference -> {
|
||||
TextPreferenceWidget(
|
||||
title = item.title,
|
||||
subtitle = item.annotatedSubtitle,
|
||||
icon = item.icon,
|
||||
onPreferenceClick = item.onClick,
|
||||
)
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.kanade.presentation.more.settings
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import eu.kanade.domain.ui.model.AppTheme
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.core.preference.Preference as PreferenceData
|
||||
@@ -150,6 +151,21 @@ sealed class Preference {
|
||||
override val icon: ImageVector? = null
|
||||
override val onValueChanged: suspend (newValue: String) -> Boolean = { true }
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic [PreferenceItem] that only displays texts.
|
||||
*/
|
||||
data class AnnotatedTextPreference(
|
||||
override val title: String,
|
||||
val annotatedSubtitle: AnnotatedString,
|
||||
override val icon: ImageVector? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val onValueChanged: suspend (newValue: String) -> Boolean = { true },
|
||||
|
||||
val onClick: (() -> Unit)? = null,
|
||||
) : PreferenceItem<String>() {
|
||||
override val subtitle: String = annotatedSubtitle.text
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -35,6 +35,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.text.HtmlCompat
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.domain.UnsortedPreferences
|
||||
@@ -88,6 +89,7 @@ import exh.pref.DelegateSourcePreferences
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.util.toAnnotatedString
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import logcat.LogPriority
|
||||
@@ -729,9 +731,12 @@ class SettingsAdvancedScreen : SearchableSettings {
|
||||
stringResource(R.string.app_name),
|
||||
),
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
Preference.PreferenceItem.AnnotatedTextPreference(
|
||||
title = stringResource(R.string.open_debug_menu),
|
||||
subtitle = stringResource(R.string.open_debug_menu_summary), // todo make red
|
||||
annotatedSubtitle = remember {
|
||||
HtmlCompat.fromHtml(context.getString(R.string.open_debug_menu_summary), HtmlCompat.FROM_HTML_MODE_COMPACT)
|
||||
.toAnnotatedString()
|
||||
},
|
||||
onClick = { router.pushController(SettingsDebugController()) },
|
||||
),
|
||||
),
|
||||
|
||||
@@ -12,6 +12,10 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import eu.kanade.presentation.util.secondaryItemAlpha
|
||||
|
||||
@@ -58,6 +62,47 @@ fun TextPreferenceWidget(
|
||||
)
|
||||
}
|
||||
|
||||
// SY -->
|
||||
@Composable
|
||||
fun TextPreferenceWidget(
|
||||
modifier: Modifier = Modifier,
|
||||
title: String? = null,
|
||||
subtitle: AnnotatedString,
|
||||
icon: ImageVector? = null,
|
||||
iconTint: Color = MaterialTheme.colorScheme.primary,
|
||||
widget: @Composable (() -> Unit)? = null,
|
||||
onPreferenceClick: (() -> Unit)? = null,
|
||||
) {
|
||||
BasePreferenceWidget(
|
||||
modifier = modifier,
|
||||
title = title,
|
||||
subcomponent = {
|
||||
Text(
|
||||
text = subtitle,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = HorizontalPadding)
|
||||
.secondaryItemAlpha(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
maxLines = 10,
|
||||
)
|
||||
},
|
||||
icon = if (icon != null) {
|
||||
{
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
tint = iconTint,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
},
|
||||
onClick = onPreferenceClick,
|
||||
widget = widget,
|
||||
)
|
||||
}
|
||||
// SY <--
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun TextPreferenceWidgetPreview() {
|
||||
@@ -75,6 +120,19 @@ private fun TextPreferenceWidgetPreview() {
|
||||
subtitle = "Text preference summary",
|
||||
onPreferenceClick = {},
|
||||
)
|
||||
// SY -->
|
||||
TextPreferenceWidget(
|
||||
title = "Text preference",
|
||||
subtitle = buildAnnotatedString {
|
||||
append("Text preference ")
|
||||
|
||||
withStyle(SpanStyle(Color.Red)) {
|
||||
append("summary")
|
||||
}
|
||||
},
|
||||
onPreferenceClick = {},
|
||||
)
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user