0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-26 05:05:15 +00:00

more accent color adjustments

This commit is contained in:
X1nto 2021-06-27 13:58:10 +04:00
parent ebfab7f498
commit 68c095924e
16 changed files with 113 additions and 63 deletions

View file

@ -10,10 +10,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.unit.dp
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun ManagerThemedButton(
modifier: Modifier = Modifier,
backgroundColor: Color = managerAccentColor(),
onClick: () -> Unit,
content: @Composable RowScope.() -> Unit
) {
@ -22,8 +25,9 @@ fun ManagerThemedButton(
onClick = onClick,
shape = MaterialTheme.shapes.medium,
colors = ButtonDefaults.buttonColors(
backgroundColor = backgroundColor,
contentColor =
if (MaterialTheme.colors.primary.luminance() > 0.7)
if (backgroundColor.luminance() > 0.7)
Color.Black
else
Color.White

View file

@ -1,18 +1,24 @@
package com.vanced.manager.ui.components.button
import androidx.annotation.StringRes
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.text.ManagerText
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun ManagerThemedTextButton(
modifier: Modifier = Modifier,
backgroundColor: Color = managerAccentColor(),
@StringRes stringId: Int,
onClick: () -> Unit
) {
ManagerThemedButton(
modifier = modifier,
backgroundColor = backgroundColor,
onClick = onClick
) {
ManagerText(stringId = stringId)

View file

@ -10,11 +10,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vanced.manager.ui.components.color.ThemedItemContentColorProvider
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
private val cardModifier = Modifier.sizeIn(
minHeight = 95.dp,
@ -52,7 +55,7 @@ private fun ManagerItemCardContent(
title: String,
@DrawableRes icon: Int? = null,
) {
val accentColor = MaterialTheme.colors.primary
val accentColor = managerAccentColor()
Canvas(modifier = Modifier.requiredSize(72.dp)) {
drawCircle(
color = accentColor,

View file

@ -14,11 +14,14 @@ import androidx.compose.material.icons.rounded.Done
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.vanced.manager.ui.components.card.ManagerCard
import com.vanced.manager.ui.components.color.contentColorForColor
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.color.managerAnimatedColor
import com.vanced.manager.ui.components.color.managerThemedCardColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@SuppressLint("UnusedTransitionTargetStateParameter")
@Composable
@ -26,7 +29,7 @@ fun ManagerCheckbox(
isChecked: Boolean,
onCheckedChange: (isChecked: Boolean) -> Unit
) {
val accentColor = MaterialTheme.colors.primary
val accentColor = managerAccentColor()
val transition = updateTransition(targetState = isChecked, label = "Checked")
val cardSize by transition.animateDp(
transitionSpec = {

View file

@ -4,13 +4,15 @@ import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun ThemedItemContentColorProvider(
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalContentColor provides contentColorForColor(MaterialTheme.colors.primary),
LocalContentColor provides contentColorForColor(managerAccentColor()),
content = content
)
}
@ -20,7 +22,7 @@ fun ThemedCardContentColorProvider(
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalContentColor provides contentColorForColor(MaterialTheme.colors.primaryVariant),
LocalContentColor provides contentColorForColor(managerAccentColor()),
content = content
)
}
@ -30,7 +32,7 @@ fun ThemedContentColorProvider(
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalContentColor provides MaterialTheme.colors.primary,
LocalContentColor provides managerAccentColor(),
content = content
)
}

View file

@ -2,13 +2,17 @@ package com.vanced.manager.ui.components.color
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.skydoves.colorpickerview.ColorEnvelope
import com.skydoves.orchestra.colorpicker.ColorPicker
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun ManagerColorPicker(
@ -18,9 +22,10 @@ fun ManagerColorPicker(
ColorPicker(
modifier = Modifier
.fillMaxWidth()
.height(400.dp),
.height(300.dp),
onColorListener = { envelope, _ -> setColor(envelope) },
children = {}
children = {},
initialColor = managerAccentColor()
)
onColorSelected(selectedColor.color.toLong())
}

View file

@ -4,8 +4,10 @@ import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun contentColorForColor(color: Color) =
@ -15,7 +17,13 @@ fun contentColorForColor(color: Color) =
Color.White
@Composable
fun managerThemedCardColor() = MaterialTheme.colors.primary.copy(alpha = 0.2f)
fun managerAccentColor(): Color {
val accentColor by managerAccentColorPref
return Color(accentColor)
}
@Composable
fun managerThemedCardColor() = managerAccentColor().copy(alpha = 0.2f)
@Composable
fun managerTextColor(): Color = managerAnimatedColor(color = MaterialTheme.colors.onSurface)

View file

@ -14,7 +14,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.color.managerTextColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun CheckboxItem(
@ -39,8 +41,8 @@ fun CheckboxItem(
toggle()
},
colors = CheckboxDefaults.colors(
MaterialTheme.colors.primary,
Color.LightGray
checkedColor = managerAccentColor(),
uncheckedColor = Color.LightGray
)
)
Text(

View file

@ -14,7 +14,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.color.managerTextColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun <T> RadiobuttonItem(
@ -38,8 +40,8 @@ fun <T> RadiobuttonItem(
selected = selected,
onClick = onClick,
colors = RadioButtonDefaults.colors(
MaterialTheme.colors.primary,
Color.LightGray
selectedColor = managerAccentColor(),
unselectedColor = Color.LightGray
)
)
Text(

View file

@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEach
@ -15,8 +16,10 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.vanced.manager.R
import com.vanced.manager.domain.model.App
import com.vanced.manager.ui.components.card.ManagerLinkCard
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.layout.ManagerScrollableColumn
import com.vanced.manager.ui.components.layout.ScrollableItemRow
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
import com.vanced.manager.ui.utils.defaultContentPaddingVertical
import com.vanced.manager.ui.viewmodel.HomeViewModel
import com.vanced.manager.ui.widgets.home.apps.card.AppCard
@ -39,7 +42,7 @@ fun HomeLayout() {
state = state,
refreshTriggerDistance = trigger,
scale = true,
contentColor = MaterialTheme.colors.primary
contentColor = managerAccentColor()
)
}
) {

View file

@ -7,8 +7,11 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Share
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.components.color.managerSurfaceColor
import com.vanced.manager.ui.components.layout.ManagerLazyColumn
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
import com.vanced.manager.util.logs
@Composable
@ -18,7 +21,7 @@ fun LogLayout() {
floatingActionButton = {
FloatingActionButton(
onClick = { /*TODO*/ },
backgroundColor = MaterialTheme.colors.primary
backgroundColor = managerAccentColor()
) {
Icon(
imageVector = Icons.Default.Share,

View file

@ -1,10 +1,11 @@
package com.vanced.manager.ui.theme
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
val accentColor = Color(managerAccentColorPref.value.value)
val accentColorVariant = accentColor.copy(alpha = 0.25f)
val primaryColor = Color(defAccentColor)
val primaryColorVariant = primaryColor.copy(alpha = 0.25f)
val darkOnSurface = Color(0xFFD5D5D5)

View file

@ -10,14 +10,14 @@ import com.vanced.manager.ui.preferences.holder.managerThemePref
const val defAccentColor = 0xFF0477E1
private val DarkColorPalette = darkColors(
primary = accentColor,
primaryVariant = accentColorVariant,
primary = primaryColor,
primaryVariant = primaryColorVariant,
onSurface = darkOnSurface
)
private val LightColorPalette = lightColors(
primary = accentColor,
primaryVariant = accentColorVariant,
primary = primaryColor,
primaryVariant = primaryColorVariant,
surface = lightSurface,
onSurface = lightOnSurface
)

View file

@ -27,44 +27,42 @@ fun AppActionCard(
showInstallationOptions: MutableState<Boolean>,
hasInstallationOptions: Boolean
) {
ThemedCardContentColorProvider {
Row(
modifier = Modifier.padding(horizontal = defaultContentPaddingHorizontal, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically
Row(
modifier = Modifier.padding(horizontal = defaultContentPaddingHorizontal, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
Column(
modifier = Modifier
.weight(1f)
.wrapContentWidth(Alignment.Start),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Column(
modifier = Modifier
.weight(1f)
.wrapContentWidth(Alignment.Start),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
ManagerText(stringId = R.string.app_versions)
AppVersionText(
stringId = R.string.app_version_latest,
version = appRemoteVersion
)
AppVersionText(
stringId = R.string.app_version_installed,
version = appInstalledVersion
)
ManagerText(stringId = R.string.app_versions)
AppVersionText(
stringId = R.string.app_version_latest,
version = appRemoteVersion
)
AppVersionText(
stringId = R.string.app_version_installed,
version = appInstalledVersion
)
}
Row(
modifier = Modifier
.weight(1f)
.padding(start = 4.dp)
.wrapContentWidth(Alignment.End)
) {
IconButton(icon = Icons.Outlined.Info, contentDescription = "App Info") {
showAppInfo.value = true
}
Row(
modifier = Modifier
.weight(1f)
.padding(start = 4.dp)
.wrapContentWidth(Alignment.End)
) {
IconButton(icon = Icons.Outlined.Info, contentDescription = "App Info") {
showAppInfo.value = true
}
IconButton(icon = Icons.Rounded.DeleteForever, contentDescription = "Uninstall") {}
IconButton(icon = Icons.Rounded.Launch, contentDescription = "Launch") {}
IconButton(icon = Icons.Rounded.Download, contentDescription = "Install") {
if (hasInstallationOptions) {
showInstallationOptions.value = true
} else {
showDownloadDialog.value = true
}
IconButton(icon = Icons.Rounded.DeleteForever, contentDescription = "Uninstall") {}
IconButton(icon = Icons.Rounded.Launch, contentDescription = "Launch") {}
IconButton(icon = Icons.Rounded.Download, contentDescription = "Install") {
if (hasInstallationOptions) {
showInstallationOptions.value = true
} else {
showDownloadDialog.value = true
}
}
}

View file

@ -3,11 +3,13 @@ package com.vanced.manager.ui.widgets.home.download
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable
fun AppDownloadDialogProgress(
@ -18,10 +20,10 @@ fun AppDownloadDialogProgress(
) {
if (showProgress) {
when (installing) {
true -> LinearProgressIndicator(color = MaterialTheme.colors.primary)
true -> LinearProgressIndicator(color = managerAccentColor())
false -> LinearProgressIndicator(
progress = progress,
color = MaterialTheme.colors.primary
color = managerAccentColor()
)
}
Row {

View file

@ -1,7 +1,9 @@
package com.vanced.manager.ui.widgets.settings
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import com.vanced.manager.R
import com.vanced.manager.ui.components.button.ManagerThemedTextButton
import com.vanced.manager.ui.components.color.ManagerColorPicker
import com.vanced.manager.ui.components.preference.DialogPreference
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@ -11,9 +13,15 @@ fun SettingsAccentColorItem() {
var localAccentColor by remember { mutableStateOf(managerAccentColorPref.value.value) }
DialogPreference(
preferenceTitleId = R.string.settings_preference_accent_color_title,
preferenceDescription = localAccentColor.toString(),
buttons = {
preferenceDescription = "#" + Integer.toHexString(localAccentColor.toInt()),
buttons = { isShown ->
ManagerThemedTextButton(
stringId = R.string.dialog_button_save,
backgroundColor = Color(localAccentColor)
) {
isShown.value = false
managerAccentColorPref.save(localAccentColor)
}
}
) {
ManagerColorPicker {