Merge pull request #55 from meowarex/dev

Improve Patch Option Style <3
This commit is contained in:
2026-06-25 01:28:34 +10:00
committed by GitHub
@@ -4,6 +4,7 @@ package com.meowarex.rlmobile.ui.screens.patchopts.components
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
@@ -115,6 +116,31 @@ fun PatchSelectionAccordion(
for (patch in specs) key(patch.id) { for (patch in specs) key(patch.id) {
val checked = isEnabled(patch) val checked = isEnabled(patch)
val lock = lockState(patch) val lock = lockState(patch)
val inlineToggles = patch.advancedOptions
.filterIsInstance<OptionSpec.Toggle>()
.filter { it.inline }
val hasSheetOptions = patch.advancedOptions.any { it !is OptionSpec.Toggle || !it.inline }
val hasSettings = patch.variants.isNotEmpty() || inlineToggles.isNotEmpty() || hasSheetOptions
// When a patch is enabled and has settings show a carded view of the settings
val carded = checked && hasSettings
Column(
modifier = if (carded) {
Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.background(MaterialTheme.colorScheme.primary.copy(alpha = 0.07f))
.border(
width = 1.5.dp,
color = MaterialTheme.colorScheme.primary.copy(alpha = 0.55f),
shape = MaterialTheme.shapes.medium,
)
.padding(horizontal = 12.dp, vertical = 4.dp)
} else {
Modifier.fillMaxWidth()
},
) {
PatchSwitchRow( PatchSwitchRow(
title = patch.title, title = patch.title,
description = patch.description, description = patch.description,
@@ -124,13 +150,15 @@ fun PatchSelectionAccordion(
onLockedTap = { lockInfo = LockInfo(patch, lock) }, onLockedTap = { lockInfo = LockInfo(patch, lock) },
) )
if (patch.variants.isNotEmpty()) { if (hasSettings) {
AnimatedVisibility(visible = checked) { AnimatedVisibility(visible = checked) {
Column( Column(
verticalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(start = 4.dp, end = 4.dp, top = 4.dp, bottom = 4.dp), .padding(bottom = 8.dp),
) { ) {
if (patch.variants.isNotEmpty()) {
val effective = patch.effectiveVariants { optionState.toggle(patch, it) } val effective = patch.effectiveVariants { optionState.toggle(patch, it) }
val resolved = patch.resolveVariantIndex(variantIndex(patch)) { val resolved = patch.resolveVariantIndex(variantIndex(patch)) {
optionState.toggle(patch, it) optionState.toggle(patch, it)
@@ -145,20 +173,7 @@ fun PatchSelectionAccordion(
}, },
) )
} }
}
}
val inlineToggles = patch.advancedOptions
.filterIsInstance<OptionSpec.Toggle>()
.filter { it.inline }
if (inlineToggles.isNotEmpty()) {
AnimatedVisibility(visible = checked) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 4.dp),
verticalArrangement = Arrangement.spacedBy(2.dp),
) {
for (option in inlineToggles) key(option.key) { for (option in inlineToggles) key(option.key) {
InlineToggleRow( InlineToggleRow(
title = option.title, title = option.title,
@@ -167,17 +182,10 @@ fun PatchSelectionAccordion(
onCheckedChange = { optionState.setToggle(patch, option, it) }, onCheckedChange = { optionState.setToggle(patch, option, it) },
) )
} }
}
}
}
val hasSheetOptions = patch.advancedOptions.any { it !is OptionSpec.Toggle || !it.inline }
if (hasSheetOptions) { if (hasSheetOptions) {
AnimatedVisibility(visible = checked) {
Box( Box(
modifier = Modifier modifier = Modifier.fillMaxWidth(),
.fillMaxWidth()
.padding(vertical = 4.dp),
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
) { ) {
AdvancedOptionsButton( AdvancedOptionsButton(
@@ -191,6 +199,9 @@ fun PatchSelectionAccordion(
} }
} }
} }
}
}
}
lockInfo?.let { info -> lockInfo?.let { info ->
PatchLockDialog( PatchLockDialog(