0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-29 14:33:01 +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.Color
import androidx.compose.ui.graphics.luminance import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.vanced.manager.ui.components.color.managerAccentColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable @Composable
fun ManagerThemedButton( fun ManagerThemedButton(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
backgroundColor: Color = managerAccentColor(),
onClick: () -> Unit, onClick: () -> Unit,
content: @Composable RowScope.() -> Unit content: @Composable RowScope.() -> Unit
) { ) {
@ -22,8 +25,9 @@ fun ManagerThemedButton(
onClick = onClick, onClick = onClick,
shape = MaterialTheme.shapes.medium, shape = MaterialTheme.shapes.medium,
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = backgroundColor,
contentColor = contentColor =
if (MaterialTheme.colors.primary.luminance() > 0.7) if (backgroundColor.luminance() > 0.7)
Color.Black Color.Black
else else
Color.White Color.White

View file

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

View file

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

View file

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

View file

@ -4,13 +4,15 @@ import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable @Composable
fun ThemedItemContentColorProvider( fun ThemedItemContentColorProvider(
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalContentColor provides contentColorForColor(MaterialTheme.colors.primary), LocalContentColor provides contentColorForColor(managerAccentColor()),
content = content content = content
) )
} }
@ -20,7 +22,7 @@ fun ThemedCardContentColorProvider(
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalContentColor provides contentColorForColor(MaterialTheme.colors.primaryVariant), LocalContentColor provides contentColorForColor(managerAccentColor()),
content = content content = content
) )
} }
@ -30,7 +32,7 @@ fun ThemedContentColorProvider(
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalContentColor provides MaterialTheme.colors.primary, LocalContentColor provides managerAccentColor(),
content = content 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.fillMaxWidth
import androidx.compose.foundation.layout.height 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.Composable
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.skydoves.colorpickerview.ColorEnvelope import com.skydoves.colorpickerview.ColorEnvelope
import com.skydoves.orchestra.colorpicker.ColorPicker import com.skydoves.orchestra.colorpicker.ColorPicker
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable @Composable
fun ManagerColorPicker( fun ManagerColorPicker(
@ -18,9 +22,10 @@ fun ManagerColorPicker(
ColorPicker( ColorPicker(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(400.dp), .height(300.dp),
onColorListener = { envelope, _ -> setColor(envelope) }, onColorListener = { envelope, _ -> setColor(envelope) },
children = {} children = {},
initialColor = managerAccentColor()
) )
onColorSelected(selectedColor.color.toLong()) onColorSelected(selectedColor.color.toLong())
} }

View file

@ -4,8 +4,10 @@ import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance import androidx.compose.ui.graphics.luminance
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable @Composable
fun contentColorForColor(color: Color) = fun contentColorForColor(color: Color) =
@ -15,7 +17,13 @@ fun contentColorForColor(color: Color) =
Color.White Color.White
@Composable @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 @Composable
fun managerTextColor(): Color = managerAnimatedColor(color = MaterialTheme.colors.onSurface) 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.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp 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.components.color.managerTextColor
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
@Composable @Composable
fun CheckboxItem( fun CheckboxItem(
@ -39,8 +41,8 @@ fun CheckboxItem(
toggle() toggle()
}, },
colors = CheckboxDefaults.colors( colors = CheckboxDefaults.colors(
MaterialTheme.colors.primary, checkedColor = managerAccentColor(),
Color.LightGray uncheckedColor = Color.LightGray
) )
) )
Text( Text(

View file

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

View file

@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEach 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.R
import com.vanced.manager.domain.model.App import com.vanced.manager.domain.model.App
import com.vanced.manager.ui.components.card.ManagerLinkCard 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.ManagerScrollableColumn
import com.vanced.manager.ui.components.layout.ScrollableItemRow 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.utils.defaultContentPaddingVertical
import com.vanced.manager.ui.viewmodel.HomeViewModel import com.vanced.manager.ui.viewmodel.HomeViewModel
import com.vanced.manager.ui.widgets.home.apps.card.AppCard import com.vanced.manager.ui.widgets.home.apps.card.AppCard
@ -39,7 +42,7 @@ fun HomeLayout() {
state = state, state = state,
refreshTriggerDistance = trigger, refreshTriggerDistance = trigger,
scale = true, 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.material.icons.filled.Share
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier 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.color.managerSurfaceColor
import com.vanced.manager.ui.components.layout.ManagerLazyColumn import com.vanced.manager.ui.components.layout.ManagerLazyColumn
import com.vanced.manager.ui.preferences.holder.managerAccentColorPref
import com.vanced.manager.util.logs import com.vanced.manager.util.logs
@Composable @Composable
@ -18,7 +21,7 @@ fun LogLayout() {
floatingActionButton = { floatingActionButton = {
FloatingActionButton( FloatingActionButton(
onClick = { /*TODO*/ }, onClick = { /*TODO*/ },
backgroundColor = MaterialTheme.colors.primary backgroundColor = managerAccentColor()
) { ) {
Icon( Icon(
imageVector = Icons.Default.Share, imageVector = Icons.Default.Share,

View file

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

View file

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

View file

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

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.Row
import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.LinearProgressIndicator import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier 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 @Composable
fun AppDownloadDialogProgress( fun AppDownloadDialogProgress(
@ -18,10 +20,10 @@ fun AppDownloadDialogProgress(
) { ) {
if (showProgress) { if (showProgress) {
when (installing) { when (installing) {
true -> LinearProgressIndicator(color = MaterialTheme.colors.primary) true -> LinearProgressIndicator(color = managerAccentColor())
false -> LinearProgressIndicator( false -> LinearProgressIndicator(
progress = progress, progress = progress,
color = MaterialTheme.colors.primary color = managerAccentColor()
) )
} }
Row { Row {

View file

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