mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
refactor(ui-components): deduplicate colors and move to settings folder
This commit is contained in:
parent
7741394c9c
commit
8df7f2992d
@ -33,6 +33,9 @@ fun NotificationCard(
|
||||
icon: ImageVector,
|
||||
actions: (@Composable () -> Unit)?
|
||||
) {
|
||||
val color =
|
||||
if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
|
||||
NotificationCardInstance(isWarning = isWarning) {
|
||||
Column(
|
||||
modifier = Modifier.padding(if (title != null) 20.dp else 16.dp),
|
||||
@ -43,7 +46,7 @@ fun NotificationCard(
|
||||
modifier = Modifier.size(36.dp),
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
tint = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
tint = color,
|
||||
)
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||
@ -51,12 +54,12 @@ fun NotificationCard(
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@ -65,12 +68,12 @@ fun NotificationCard(
|
||||
modifier = Modifier.size(24.dp),
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
tint = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
tint = color,
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -88,6 +91,9 @@ fun NotificationCard(
|
||||
onDismiss: (() -> Unit)? = null,
|
||||
primaryAction: (() -> Unit)? = null
|
||||
) {
|
||||
val color =
|
||||
if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
|
||||
NotificationCardInstance(isWarning = isWarning, onClick = primaryAction) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@ -100,7 +106,7 @@ fun NotificationCard(
|
||||
modifier = Modifier.size(if (title != null) 36.dp else 24.dp),
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
tint = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
tint = color,
|
||||
)
|
||||
if (title != null) {
|
||||
Column(
|
||||
@ -110,12 +116,12 @@ fun NotificationCard(
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@ -123,7 +129,7 @@ fun NotificationCard(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
color = color,
|
||||
)
|
||||
}
|
||||
if (onDismiss != null) {
|
||||
@ -131,7 +137,7 @@ fun NotificationCard(
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Close,
|
||||
contentDescription = stringResource(R.string.close),
|
||||
tint = if (isWarning) MaterialTheme.colorScheme.onError else MaterialTheme.colorScheme.onPrimaryContainer
|
||||
tint = color,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -144,28 +150,29 @@ fun NotificationCard(
|
||||
private fun NotificationCardInstance(
|
||||
isWarning: Boolean = false,
|
||||
onClick: (() -> Unit)? = null,
|
||||
content: (@Composable () -> Unit),
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val colors =
|
||||
CardDefaults.cardColors(containerColor = if (isWarning) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.primaryContainer)
|
||||
val modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.clip(RoundedCornerShape(24.dp))
|
||||
|
||||
if (onClick != null) {
|
||||
Card(
|
||||
onClick = onClick,
|
||||
colors = CardDefaults.cardColors(containerColor = (if (isWarning) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.primaryContainer)),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.clip(RoundedCornerShape(24.dp))
|
||||
colors = colors,
|
||||
modifier = modifier
|
||||
) {
|
||||
content.invoke()
|
||||
content()
|
||||
}
|
||||
} else {
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = (if (isWarning) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.primaryContainer)),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.clip(RoundedCornerShape(24.dp))
|
||||
colors = colors,
|
||||
modifier = modifier,
|
||||
) {
|
||||
content.invoke()
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.revanced.manager.domain.manager.base.Preference
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.manager.ui.component
|
||||
package app.revanced.manager.ui.component.settings
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ListItemColors
|
||||
@ -37,7 +37,7 @@ fun SettingsListItem(
|
||||
text = supportingContent,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.outline
|
||||
) else null
|
||||
)
|
||||
},
|
||||
leadingContent = leadingContent,
|
||||
trailingContent = trailingContent,
|
@ -38,7 +38,7 @@ import app.revanced.manager.R
|
||||
import app.revanced.manager.data.room.apps.installed.InstallType
|
||||
import app.revanced.manager.ui.component.AppInfo
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
import app.revanced.manager.ui.component.SegmentedButton
|
||||
import app.revanced.manager.ui.viewmodel.InstalledAppInfoViewModel
|
||||
import app.revanced.manager.util.PatchesSelection
|
||||
|
@ -8,11 +8,8 @@ import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
@ -28,7 +25,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.NotificationCard
|
||||
@ -40,7 +36,7 @@ import app.revanced.manager.ui.screen.settings.update.UpdatesSettingsScreen
|
||||
import app.revanced.manager.ui.viewmodel.SettingsViewModel
|
||||
import dev.olshevski.navigation.reimagined.*
|
||||
import org.koin.androidx.compose.getViewModel
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
|
||||
@SuppressLint("BatteryLife")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
|
@ -3,7 +3,6 @@ package app.revanced.manager.ui.screen.settings
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -39,7 +38,7 @@ import androidx.compose.ui.unit.dp
|
||||
import app.revanced.manager.BuildConfig
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
import app.revanced.manager.util.isDebuggable
|
||||
import app.revanced.manager.util.openUrl
|
||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||
|
@ -35,7 +35,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.GroupHeader
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.BooleanItem
|
||||
import app.revanced.manager.ui.viewmodel.AdvancedSettingsViewModel
|
||||
import org.koin.androidx.compose.getViewModel
|
||||
|
@ -22,7 +22,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.GroupHeader
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.BooleanItem
|
||||
import app.revanced.manager.ui.viewmodel.DownloadsViewModel
|
||||
import org.koin.androidx.compose.getViewModel
|
||||
|
@ -23,7 +23,7 @@ import app.revanced.manager.ui.component.settings.BooleanItem
|
||||
import app.revanced.manager.ui.theme.Theme
|
||||
import app.revanced.manager.ui.viewmodel.SettingsViewModel
|
||||
import org.koin.compose.koinInject
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
@ -39,7 +39,7 @@ import app.revanced.manager.ui.component.bundle.BundleSelector
|
||||
import app.revanced.manager.util.toast
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.androidx.compose.getViewModel
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
@ -10,10 +10,7 @@ import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Update
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -21,7 +18,7 @@ import androidx.compose.ui.unit.dp
|
||||
import app.revanced.manager.R
|
||||
import app.revanced.manager.ui.component.AppTopBar
|
||||
import app.revanced.manager.ui.component.NotificationCard
|
||||
import app.revanced.manager.ui.component.SettingsListItem
|
||||
import app.revanced.manager.ui.component.settings.SettingsListItem
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
Loading…
x
Reference in New Issue
Block a user