MoreDialog: Improve colors
This commit is contained in:
committed by
Aayush Gupta
parent
c66f358524
commit
71aabe8509
@@ -134,6 +134,23 @@ fun Context.accentColor(): Int {
|
|||||||
return ContextCompat.getColor(this, color)
|
return ContextCompat.getColor(this, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.backgroundColor(): Int {
|
||||||
|
val color = when (Preferences.getInteger(this, Preferences.PREFERENCE_THEME_TYPE)) {
|
||||||
|
1 -> R.color.colorWhite
|
||||||
|
2 -> R.color.colorDarkBackground
|
||||||
|
3 -> R.color.colorBlack
|
||||||
|
4 -> R.color.colorDarkXBackground
|
||||||
|
5 -> R.color.colorDarkordBackground
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color == null) {
|
||||||
|
return getStyledAttributeColor(com.google.android.material.R.attr.colorSurface)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ContextCompat.getColor(this, color)
|
||||||
|
}
|
||||||
|
|
||||||
fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
||||||
return if (isMAndAbove()) {
|
return if (isMAndAbove()) {
|
||||||
(getSystemService(Context.POWER_SERVICE) as PowerManager).isIgnoringBatteryOptimizations(
|
(getSystemService(Context.POWER_SERVICE) as PowerManager).isIgnoringBatteryOptimizations(
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import coil.request.ImageRequest
|
|||||||
import com.aurora.Constants
|
import com.aurora.Constants
|
||||||
import com.aurora.Constants.URL_TOS
|
import com.aurora.Constants.URL_TOS
|
||||||
import com.aurora.extensions.accentColor
|
import com.aurora.extensions.accentColor
|
||||||
|
import com.aurora.extensions.backgroundColor
|
||||||
import com.aurora.extensions.browse
|
import com.aurora.extensions.browse
|
||||||
import com.aurora.extensions.darkenColor
|
import com.aurora.extensions.darkenColor
|
||||||
import com.aurora.extensions.getStyledAttributeColor
|
import com.aurora.extensions.getStyledAttributeColor
|
||||||
@@ -93,15 +94,15 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
setContent {
|
setContent {
|
||||||
AuroraTheme {
|
AuroraTheme {
|
||||||
if (isSystemInDarkTheme()) {
|
if (isSystemInDarkTheme()) {
|
||||||
primaryColor = Color(darkenColor(requireContext().accentColor(), 0.25f))
|
primaryColor = Color(requireContext().backgroundColor())
|
||||||
onPrimaryColor = Color(lightenColor(primaryColor.toArgb()))
|
onPrimaryColor = Color(lightenColor(primaryColor.toArgb(), 0.85f))
|
||||||
secondaryColor = Color(darkenColor(requireContext().accentColor(), 0.15f))
|
secondaryColor = Color(darkenColor(primaryColor.toArgb(), 0.75f))
|
||||||
onSecondaryColor = Color(lightenColor(primaryColor.toArgb()))
|
onSecondaryColor = Color(lightenColor(secondaryColor.toArgb(), 0.85f))
|
||||||
} else {
|
} else {
|
||||||
primaryColor = Color(lightenColor(requireContext().accentColor(), 0.85f))
|
primaryColor = Color(lightenColor(requireContext().accentColor(), 0.85f))
|
||||||
onPrimaryColor = Color(darkenColor(primaryColor.toArgb()))
|
onPrimaryColor = Color(darkenColor(primaryColor.toArgb(), 0.15f))
|
||||||
secondaryColor = Color(lightenColor(requireContext().accentColor(), 0.95f))
|
secondaryColor = Color(lightenColor(primaryColor.toArgb(), 0.75f))
|
||||||
onSecondaryColor = Color(darkenColor(primaryColor.toArgb()))
|
onSecondaryColor = Color(darkenColor(secondaryColor.toArgb(), 0.15f))
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -111,7 +112,7 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(10.dp),
|
.padding(10.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(
|
verticalArrangement = Arrangement.spacedBy(
|
||||||
5.dp,
|
4.dp,
|
||||||
Alignment.CenterVertically
|
Alignment.CenterVertically
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -127,10 +128,10 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(
|
.clip(
|
||||||
RoundedCornerShape(
|
RoundedCornerShape(
|
||||||
topStart = 5.dp,
|
topStart = 2.dp,
|
||||||
topEnd = 5.dp,
|
topEnd = 2.dp,
|
||||||
bottomStart = 20.dp,
|
bottomStart = 25.dp,
|
||||||
bottomEnd = 20.dp
|
bottomEnd = 25.dp
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.background(color = secondaryColor)
|
.background(color = secondaryColor)
|
||||||
@@ -138,14 +139,16 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
getOptions().fastForEach { option ->
|
getOptions().fastForEach { option ->
|
||||||
OptionItem(
|
OptionItem(
|
||||||
option = option,
|
option = option,
|
||||||
tintColor = onSecondaryColor
|
tintColor = onPrimaryColor,
|
||||||
|
textColor = onSecondaryColor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getExtraOptions().fastForEach { option ->
|
getExtraOptions().fastForEach { option ->
|
||||||
OptionItem(
|
OptionItem(
|
||||||
option = option,
|
option = option,
|
||||||
tintColor = onPrimaryColor
|
tintColor = onPrimaryColor,
|
||||||
|
textColor = onPrimaryColor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Footer(onPrimaryColor)
|
Footer(onPrimaryColor)
|
||||||
@@ -207,10 +210,10 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(
|
.clip(
|
||||||
RoundedCornerShape(
|
RoundedCornerShape(
|
||||||
topStart = 20.dp,
|
topStart = 25.dp,
|
||||||
topEnd = 20.dp,
|
topEnd = 25.dp,
|
||||||
bottomStart = 5.dp,
|
bottomStart = 2.dp,
|
||||||
bottomEnd = 5.dp
|
bottomEnd = 2.dp
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.background(color = backgroundColor)
|
.background(color = backgroundColor)
|
||||||
@@ -273,12 +276,16 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun OptionItem(option: Option, tintColor: Color = Color.Black) {
|
private fun OptionItem(
|
||||||
|
option: Option,
|
||||||
|
tintColor: Color = Color.Blue,
|
||||||
|
textColor: Color = Color.Black
|
||||||
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable { findNavController().navigate(option.destinationID) }
|
.clickable { findNavController().navigate(option.destinationID) }
|
||||||
.padding(15.dp),
|
.padding(12.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start)
|
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start)
|
||||||
) {
|
) {
|
||||||
@@ -293,7 +300,7 @@ class MoreDialogFragment : DialogFragment() {
|
|||||||
Text(
|
Text(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(id = option.title),
|
text = stringResource(id = option.title),
|
||||||
color = tintColor,
|
color = textColor,
|
||||||
fontSize = 15.sp,
|
fontSize = 15.sp,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user