refactor: rename PatchOption to a generic label component
This commit is contained in:
parent
7477167d8d
commit
38e300ef38
5 changed files with 23 additions and 22 deletions
|
|
@ -1,37 +1,39 @@
|
|||
package com.aliucord.manager.ui.screens.patchopts.components.options
|
||||
package com.aliucord.manager.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.aliucord.manager.ui.util.thenIf
|
||||
|
||||
// TODO: rename this to a generic titled component
|
||||
@Composable
|
||||
fun PatchOption(
|
||||
fun Label(
|
||||
name: String,
|
||||
description: String?,
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
modifier = modifier,
|
||||
) {
|
||||
Text(
|
||||
text = name,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier
|
||||
.thenIf(description == null) { padding(bottom = 4.dp) },
|
||||
)
|
||||
|
||||
if (description != null) {
|
||||
Text(
|
||||
text = description,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.alpha(.7f),
|
||||
modifier = Modifier
|
||||
.alpha(.7f)
|
||||
.padding(bottom = 4.dp),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -25,10 +25,8 @@ import androidx.compose.ui.unit.dp
|
|||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import coil3.compose.AsyncImage
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.ui.components.InteractiveSlider
|
||||
import com.aliucord.manager.ui.components.MainActionButton
|
||||
import com.aliucord.manager.ui.components.*
|
||||
import com.aliucord.manager.ui.screens.iconopts.components.*
|
||||
import com.aliucord.manager.ui.screens.patchopts.components.options.PatchOption
|
||||
import com.aliucord.manager.ui.util.ColorSaver
|
||||
import dev.zt64.compose.pipette.CircularColorPicker
|
||||
import dev.zt64.compose.pipette.util.*
|
||||
|
|
@ -148,7 +146,7 @@ private fun CustomColorOptions(color: HSVColorState) {
|
|||
verticalArrangement = Arrangement.spacedBy(30.dp),
|
||||
modifier = Modifier.padding(horizontal = 15.dp)
|
||||
) {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.iconopts_colorpicker_title),
|
||||
description = stringResource(R.string.iconopts_colorpicker_desc),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
|
@ -169,7 +167,7 @@ private fun CustomColorOptions(color: HSVColorState) {
|
|||
)
|
||||
}
|
||||
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.iconopts_lightness_title),
|
||||
description = stringResource(R.string.iconopts_lightness_desc),
|
||||
) {
|
||||
|
|
@ -190,7 +188,7 @@ private fun CustomColorOptions(color: HSVColorState) {
|
|||
)
|
||||
}
|
||||
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.iconopts_hex_title),
|
||||
description = stringResource(R.string.iconopts_hex_desc),
|
||||
) {
|
||||
|
|
@ -237,7 +235,7 @@ private fun CustomImageOptions(
|
|||
),
|
||||
)
|
||||
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.iconopts_image_preview_title),
|
||||
description = stringResource(R.string.iconopts_image_preview_desc),
|
||||
modifier = Modifier.padding(top = 20.dp),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.aliucord.manager.ui.screens.patchopts.components.options.PatchOption
|
||||
import com.aliucord.manager.ui.components.Label
|
||||
|
||||
@Composable
|
||||
fun RadioSelectorItem(
|
||||
|
|
@ -39,7 +39,7 @@ fun RadioSelectorItem(
|
|||
interactionSource = interactionSource,
|
||||
)
|
||||
|
||||
PatchOption(
|
||||
Label(
|
||||
name = name,
|
||||
description = description,
|
||||
content = {},
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ import cafe.adriel.voyager.navigator.LocalNavigator
|
|||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.manager.InstallLogData
|
||||
import com.aliucord.manager.ui.components.Label
|
||||
import com.aliucord.manager.ui.components.back
|
||||
import com.aliucord.manager.ui.screens.log.components.LogAppBar
|
||||
import com.aliucord.manager.ui.screens.log.components.SelectableTextArea
|
||||
import com.aliucord.manager.ui.screens.patchopts.components.options.PatchOption
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
|
@ -69,7 +69,7 @@ fun LogScreenContent(
|
|||
.padding(vertical = 10.dp, horizontal = 22.dp)
|
||||
) {
|
||||
item("INSTALL_INFO") {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.log_section_install_info),
|
||||
description = null,
|
||||
) {
|
||||
|
|
@ -84,7 +84,7 @@ fun LogScreenContent(
|
|||
}
|
||||
|
||||
item("ENVIRONMENT_INFO") {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.log_section_env_info),
|
||||
description = null,
|
||||
) {
|
||||
|
|
@ -97,7 +97,7 @@ fun LogScreenContent(
|
|||
|
||||
if (data.errorStacktrace != null) {
|
||||
item("ERROR_STACKTRACE") {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.log_section_error),
|
||||
description = null,
|
||||
) {
|
||||
|
|
@ -110,7 +110,7 @@ fun LogScreenContent(
|
|||
}
|
||||
|
||||
item("LOG") {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = stringResource(R.string.log_section_log),
|
||||
description = null,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.material3.*
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.aliucord.manager.ui.components.Label
|
||||
import com.aliucord.manager.ui.components.ResetToDefaultButton
|
||||
|
||||
@Composable
|
||||
|
|
@ -19,7 +20,7 @@ fun TextPatchOption(
|
|||
modifier: Modifier = Modifier,
|
||||
extra: (@Composable ColumnScope.() -> Unit)? = null,
|
||||
) {
|
||||
PatchOption(
|
||||
Label(
|
||||
name = name,
|
||||
description = description,
|
||||
modifier = modifier,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue