feat: icon options screen compose preview
This commit is contained in:
parent
6427c19783
commit
41de5c8b56
3 changed files with 63 additions and 5 deletions
|
|
@ -0,0 +1,59 @@
|
|||
package com.aliucord.manager.ui.previews.screens
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.tooling.preview.*
|
||||
import com.aliucord.manager.ui.components.ManagerTheme
|
||||
import com.aliucord.manager.ui.screens.iconopts.*
|
||||
import com.aliucord.manager.ui.screens.patchopts.PatchOptions.IconReplacement
|
||||
|
||||
// This preview has scrollable/interactable content that cannot be properly tested from an IDE preview
|
||||
|
||||
@Composable
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
private fun IconOptionsScreenPreview(
|
||||
@PreviewParameter(IconOptionsParametersProvider::class)
|
||||
parameters: IconOptionsParameters,
|
||||
) {
|
||||
var mode by remember { mutableStateOf(parameters.mode) }
|
||||
var color by remember { mutableStateOf(parameters.selectedColor.toHSVState()) }
|
||||
|
||||
DisposableEffect(parameters) {
|
||||
mode = parameters.mode
|
||||
color = parameters.selectedColor.toHSVState()
|
||||
|
||||
onDispose {}
|
||||
}
|
||||
|
||||
ManagerTheme {
|
||||
IconOptionsScreenContent(
|
||||
mode = mode,
|
||||
setMode = { mode = it },
|
||||
selectedColor = color,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private data class IconOptionsParameters(
|
||||
val mode: IconOptionsMode,
|
||||
val selectedColor: Color,
|
||||
)
|
||||
|
||||
private class IconOptionsParametersProvider : PreviewParameterProvider<IconOptionsParameters> {
|
||||
override val values = sequenceOf(
|
||||
IconOptionsParameters(
|
||||
mode = IconOptionsMode.Original,
|
||||
selectedColor = IconReplacement.Aliucord.color,
|
||||
),
|
||||
IconOptionsParameters(
|
||||
mode = IconOptionsMode.Aliucord,
|
||||
selectedColor = IconReplacement.Aliucord.color,
|
||||
),
|
||||
IconOptionsParameters(
|
||||
mode = IconOptionsMode.CustomColor,
|
||||
selectedColor = Color(0xFFFFB6C1),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
private fun HomeScreenLoadedPreview(
|
||||
@PreviewParameter(TextBannerParametersProvider::class)
|
||||
@PreviewParameter(HomeScreenParametersProvider::class)
|
||||
parameters: HomeScreenParameters,
|
||||
) {
|
||||
ManagerTheme {
|
||||
|
|
@ -46,7 +46,7 @@ private data class HomeScreenParameters(
|
|||
val supportedVersion: DiscordVersion,
|
||||
)
|
||||
|
||||
private class TextBannerParametersProvider : PreviewParameterProvider<HomeScreenParameters> {
|
||||
private class HomeScreenParametersProvider : PreviewParameterProvider<HomeScreenParameters> {
|
||||
private val stableVersion = DiscordVersion.Existing(DiscordVersion.Type.STABLE, "126.21", 126021)
|
||||
private val aliucordIconBytes =
|
||||
"/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADb/2wBDAKBueIx4ZKCMgoy0qqC+8P//8Nzc8P//////////////////////////////////////////////////////////2wBDAaq0tPDS8P//////////////////////////////////////////////////////////////////////////////wAARCAC9AL0DASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAIDAf/EACIQAQEAAgEFAAIDAAAAAAAAAAABAhEhAxIxQVETMiJhcf/EABcBAQEBAQAAAAAAAAAAAAAAAAABAgP/xAAZEQEBAQEBAQAAAAAAAAAAAAAAARECEjH/2gAMAwEAAhEDEQA/AMsce7/Gkkngk1NOoxboAIAAAAAAAAAAAAAAAAAAm4ys7NXVbJyx2LKoAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHZLfRcbJug4AABJugDtxs9OAAAAAAAAAAAAAA7jN0HccN81cxk9OityBZuaAVP459OyKBMifxwxw1dqAyBrYCpuEvhFmq1TnNwZsZgIyAAAAAAAANcJqM8ZutRrkAVoAAAAAAAAABnnNVLTObjNGKACAAAAAAL6c9rcxmsY6rcALdTYrlyk8kzlZeRGPTYThdzSlbC2TyMsruiW4vvimK+nedIkqwFaGN4rZnnP5DPSQEZAAAAAJ5BtPACug5n+tdAYi8sL6cmFqOeO9P2sk1NCtwYtk5Yb5gljNWH7Odt+NMce2IkjoCtiOp6WjqeIJfiAEYAAAACeYANgllnAroA5lbJxAdEzOe+FblDQAAAAcuUntyZW3iCaoAUT1PEUjOy8CX4gBGAAAAAACWzw0mf1mBLjYZS2eFTqfVa9O9TWv7Zu27u3EZtd7r9O/L64Brvdfrm79AHZ55asVY56mhZWjlykRc7Ui3pWWdqQGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHMbuOsZbLw0xy2LYoAQAAAAAAAAAAAAAAAAAARnlzqGWdnEQNSP/2Q=="
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.ui.components.BackButton
|
||||
import com.aliucord.manager.ui.screens.settings.SettingsScreen
|
||||
|
|
@ -16,9 +15,9 @@ fun IconOptionsAppBar() {
|
|||
navigationIcon = { BackButton() },
|
||||
title = { Text(stringResource(R.string.iconopts_screen_title)) },
|
||||
actions = {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val navigator = LocalNavigator.current
|
||||
|
||||
IconButton(onClick = { navigator.push(SettingsScreen()) }) {
|
||||
IconButton(onClick = { navigator?.push(SettingsScreen()) }) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_settings),
|
||||
contentDescription = stringResource(R.string.navigation_settings)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue