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)
|
||||
}
|
||||
|
||||
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 {
|
||||
return if (isMAndAbove()) {
|
||||
(getSystemService(Context.POWER_SERVICE) as PowerManager).isIgnoringBatteryOptimizations(
|
||||
|
||||
@@ -53,6 +53,7 @@ import coil.request.ImageRequest
|
||||
import com.aurora.Constants
|
||||
import com.aurora.Constants.URL_TOS
|
||||
import com.aurora.extensions.accentColor
|
||||
import com.aurora.extensions.backgroundColor
|
||||
import com.aurora.extensions.browse
|
||||
import com.aurora.extensions.darkenColor
|
||||
import com.aurora.extensions.getStyledAttributeColor
|
||||
@@ -93,15 +94,15 @@ class MoreDialogFragment : DialogFragment() {
|
||||
setContent {
|
||||
AuroraTheme {
|
||||
if (isSystemInDarkTheme()) {
|
||||
primaryColor = Color(darkenColor(requireContext().accentColor(), 0.25f))
|
||||
onPrimaryColor = Color(lightenColor(primaryColor.toArgb()))
|
||||
secondaryColor = Color(darkenColor(requireContext().accentColor(), 0.15f))
|
||||
onSecondaryColor = Color(lightenColor(primaryColor.toArgb()))
|
||||
primaryColor = Color(requireContext().backgroundColor())
|
||||
onPrimaryColor = Color(lightenColor(primaryColor.toArgb(), 0.85f))
|
||||
secondaryColor = Color(darkenColor(primaryColor.toArgb(), 0.75f))
|
||||
onSecondaryColor = Color(lightenColor(secondaryColor.toArgb(), 0.85f))
|
||||
} else {
|
||||
primaryColor = Color(lightenColor(requireContext().accentColor(), 0.85f))
|
||||
onPrimaryColor = Color(darkenColor(primaryColor.toArgb()))
|
||||
secondaryColor = Color(lightenColor(requireContext().accentColor(), 0.95f))
|
||||
onSecondaryColor = Color(darkenColor(primaryColor.toArgb()))
|
||||
onPrimaryColor = Color(darkenColor(primaryColor.toArgb(), 0.15f))
|
||||
secondaryColor = Color(lightenColor(primaryColor.toArgb(), 0.75f))
|
||||
onSecondaryColor = Color(darkenColor(secondaryColor.toArgb(), 0.15f))
|
||||
}
|
||||
|
||||
Column(
|
||||
@@ -111,7 +112,7 @@ class MoreDialogFragment : DialogFragment() {
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(10.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(
|
||||
5.dp,
|
||||
4.dp,
|
||||
Alignment.CenterVertically
|
||||
)
|
||||
) {
|
||||
@@ -127,10 +128,10 @@ class MoreDialogFragment : DialogFragment() {
|
||||
modifier = Modifier
|
||||
.clip(
|
||||
RoundedCornerShape(
|
||||
topStart = 5.dp,
|
||||
topEnd = 5.dp,
|
||||
bottomStart = 20.dp,
|
||||
bottomEnd = 20.dp
|
||||
topStart = 2.dp,
|
||||
topEnd = 2.dp,
|
||||
bottomStart = 25.dp,
|
||||
bottomEnd = 25.dp
|
||||
)
|
||||
)
|
||||
.background(color = secondaryColor)
|
||||
@@ -138,14 +139,16 @@ class MoreDialogFragment : DialogFragment() {
|
||||
getOptions().fastForEach { option ->
|
||||
OptionItem(
|
||||
option = option,
|
||||
tintColor = onSecondaryColor
|
||||
tintColor = onPrimaryColor,
|
||||
textColor = onSecondaryColor
|
||||
)
|
||||
}
|
||||
}
|
||||
getExtraOptions().fastForEach { option ->
|
||||
OptionItem(
|
||||
option = option,
|
||||
tintColor = onPrimaryColor
|
||||
tintColor = onPrimaryColor,
|
||||
textColor = onPrimaryColor
|
||||
)
|
||||
}
|
||||
Footer(onPrimaryColor)
|
||||
@@ -207,10 +210,10 @@ class MoreDialogFragment : DialogFragment() {
|
||||
.fillMaxWidth()
|
||||
.clip(
|
||||
RoundedCornerShape(
|
||||
topStart = 20.dp,
|
||||
topEnd = 20.dp,
|
||||
bottomStart = 5.dp,
|
||||
bottomEnd = 5.dp
|
||||
topStart = 25.dp,
|
||||
topEnd = 25.dp,
|
||||
bottomStart = 2.dp,
|
||||
bottomEnd = 2.dp
|
||||
)
|
||||
)
|
||||
.background(color = backgroundColor)
|
||||
@@ -273,12 +276,16 @@ class MoreDialogFragment : DialogFragment() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun OptionItem(option: Option, tintColor: Color = Color.Black) {
|
||||
private fun OptionItem(
|
||||
option: Option,
|
||||
tintColor: Color = Color.Blue,
|
||||
textColor: Color = Color.Black
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { findNavController().navigate(option.destinationID) }
|
||||
.padding(15.dp),
|
||||
.padding(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start)
|
||||
) {
|
||||
@@ -293,7 +300,7 @@ class MoreDialogFragment : DialogFragment() {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = option.title),
|
||||
color = tintColor,
|
||||
color = textColor,
|
||||
fontSize = 15.sp,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user