Remove dependency on Material 2
This commit is contained in:
parent
2943535c55
commit
960d7a72d2
6 changed files with 14 additions and 81 deletions
|
|
@ -67,7 +67,6 @@ dependencies {
|
|||
// compose dependencies
|
||||
implementation("androidx.compose.ui:ui:${composeVersion}")
|
||||
implementation("androidx.compose.ui:ui-tooling:${composeVersion}")
|
||||
implementation("androidx.compose.material:material:${composeVersion}")
|
||||
implementation("androidx.compose.material:material-icons-extended:${composeVersion}")
|
||||
implementation("androidx.compose.material3:material3:1.0.0-alpha14")
|
||||
implementation("androidx.paging:paging-compose:1.0.0-alpha15")
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Juby210 & zt
|
||||
* Licensed under the Open Software License version 3.0
|
||||
*/
|
||||
|
||||
package com.aliucord.manager.ui.components
|
||||
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.material.ListItem as M2ListItem
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun ListItem(
|
||||
modifier: Modifier = Modifier,
|
||||
icon: @Composable (() -> Unit)? = null,
|
||||
secondaryText: @Composable (() -> Unit)? = null,
|
||||
singleLineSecondaryText: Boolean = true,
|
||||
overlineText: @Composable (() -> Unit)? = null,
|
||||
trailing: @Composable (() -> Unit)? = null,
|
||||
text: @Composable () -> Unit
|
||||
) = M2ListItem(
|
||||
modifier = modifier,
|
||||
icon = icon,
|
||||
overlineText = if (overlineText != null) {
|
||||
{
|
||||
CompositionLocalProvider(
|
||||
LocalContentColor provides MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
LocalTextStyle provides MaterialTheme.typography.labelMedium
|
||||
) {
|
||||
overlineText()
|
||||
}
|
||||
}
|
||||
} else null,
|
||||
text = {
|
||||
CompositionLocalProvider(
|
||||
LocalContentColor provides MaterialTheme.colorScheme.onSurface,
|
||||
LocalTextStyle provides MaterialTheme.typography.bodyLarge
|
||||
) {
|
||||
text()
|
||||
}
|
||||
},
|
||||
secondaryText = if (secondaryText != null) {
|
||||
{
|
||||
CompositionLocalProvider(
|
||||
LocalContentColor provides MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
LocalTextStyle provides MaterialTheme.typography.bodyMedium
|
||||
) {
|
||||
secondaryText()
|
||||
}
|
||||
}
|
||||
} else null,
|
||||
trailing = trailing,
|
||||
singleLineSecondaryText = singleLineSecondaryText,
|
||||
)
|
||||
|
|
@ -6,12 +6,12 @@
|
|||
package com.aliucord.manager.ui.components.settings
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.aliucord.manager.preferences.Preference
|
||||
import com.aliucord.manager.ui.components.ListItem
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun PreferenceItem(
|
||||
icon: @Composable (() -> Unit)? = null,
|
||||
|
|
@ -19,13 +19,13 @@ fun PreferenceItem(
|
|||
description: @Composable (() -> Unit)? = null,
|
||||
preference: Preference<Boolean>
|
||||
) = ListItem(
|
||||
icon = icon,
|
||||
modifier = Modifier.clickable {
|
||||
preference.set(!preference.get())
|
||||
},
|
||||
text = title,
|
||||
secondaryText = description,
|
||||
trailing = {
|
||||
leadingContent = icon,
|
||||
headlineText = title,
|
||||
supportingText = description,
|
||||
trailingContent = {
|
||||
Switch(
|
||||
checked = preference.get(),
|
||||
onCheckedChange = preference::set
|
||||
|
|
|
|||
|
|
@ -6,26 +6,23 @@
|
|||
package com.aliucord.manager.ui.components.settings
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.preferences.Prefs
|
||||
import com.aliucord.manager.ui.components.ListItem
|
||||
import com.aliucord.manager.ui.theme.Theme
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ThemeSetting(
|
||||
onClick: () -> Unit,
|
||||
) = ListItem(
|
||||
modifier = Modifier.clickable { onClick() },
|
||||
text = { Text(stringResource(R.string.theme)) },
|
||||
secondaryText = { Text(stringResource(R.string.theme_setting_description)) },
|
||||
trailing = {
|
||||
headlineText = { Text(stringResource(R.string.theme)) },
|
||||
supportingText = { Text(stringResource(R.string.theme_setting_description)) },
|
||||
trailingContent = {
|
||||
FilledTonalButton(
|
||||
onClick = onClick
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ package com.aliucord.manager.ui.screens
|
|||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
|
|
@ -23,11 +21,10 @@ import androidx.paging.compose.collectAsLazyPagingItems
|
|||
import androidx.paging.compose.items
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.models.github.Commit
|
||||
import com.aliucord.manager.ui.components.ListItem
|
||||
import com.aliucord.manager.utils.Github
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Destination
|
||||
@Composable
|
||||
fun CommitsScreen() {
|
||||
|
|
@ -84,7 +81,7 @@ fun CommitsScreen() {
|
|||
ListItem(
|
||||
modifier = Modifier.clickable { localUriHandler.openUri(commitData.htmlUrl) },
|
||||
overlineText = { Text(commitData.sha.substring(0, 7)) },
|
||||
text = { Text("${commitData.commit.message.split("\n").first()} - ${commitData.author.name}") }
|
||||
headlineText = { Text("${commitData.commit.message.split("\n").first()} - ${commitData.author.name}") }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import androidx.compose.animation.shrinkVertically
|
|||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -24,7 +23,6 @@ import com.aliucord.manager.ui.components.settings.*
|
|||
import com.aliucord.manager.ui.viewmodels.SettingsViewModel
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterialApi::class)
|
||||
@Destination
|
||||
@Composable
|
||||
fun SettingsScreen() = Column(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue