Use Material3 native shapes

This commit is contained in:
Iamlooker 2022-04-11 09:05:19 +05:30
parent 93d52af7e7
commit ce3b419d81
7 changed files with 15 additions and 42 deletions

View File

@ -5,7 +5,6 @@ import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Done
import androidx.compose.material3.Icon
@ -21,7 +20,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.looker.droidify.database.entity.Repository
import com.looker.droidify.ui.compose.theme.LocalShapes
@OptIn(ExperimentalFoundationApi::class)
@Composable
@ -40,13 +38,13 @@ fun RepositoryItem(
modifier = modifier
.padding(horizontal = 8.dp, vertical = 4.dp)
.fillMaxWidth()
.clip(RoundedCornerShape(LocalShapes.current.large))
.clip(MaterialTheme.shapes.large)
.combinedClickable(
onClick = { onClick(repository) },
onLongClick = { onLongClick(repository) }
),
color = backgroundColor,
shape = RoundedCornerShape(LocalShapes.current.large)
shape = MaterialTheme.shapes.large
) {
Row(
modifier = Modifier.padding(

View File

@ -7,7 +7,7 @@ import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@ -15,7 +15,6 @@ import androidx.compose.ui.unit.dp
import com.looker.droidify.database.entity.Repository
import com.looker.droidify.entity.Screenshot
import com.looker.droidify.network.CoilDownloader
import com.looker.droidify.ui.compose.theme.LocalShapes
import com.looker.droidify.ui.compose.utils.NetworkImage
data class ScreenshotItem(
@ -54,7 +53,7 @@ fun ScreenshotList(
modifier = Modifier
.wrapContentWidth()
.requiredHeight(300.dp)
.clip(RoundedCornerShape(LocalShapes.current.large))
.clip(MaterialTheme.shapes.large)
.clickable { onScreenShotClick(it.screenShot) },
data = image
)

View File

@ -16,7 +16,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.looker.droidify.R
import com.looker.droidify.ui.compose.components.InstallButton
import com.looker.droidify.ui.compose.theme.LocalShapes
import com.looker.droidify.ui.compose.utils.*
import com.looker.droidify.utility.extension.text.formatSize
@ -32,7 +31,7 @@ fun Header(
) {
Surface(
modifier = modifier.fillMaxWidth(),
shape = RoundedCornerShape(LocalShapes.current.large)
shape = MaterialTheme.shapes.large
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,

View File

@ -1,15 +0,0 @@
package com.looker.droidify.ui.compose.theme
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Immutable
data class ShapeSize(
val small: Dp = 4.dp,
val medium: Dp = 8.dp,
val large: Dp = 16.dp,
)
val LocalShapes = staticCompositionLocalOf { ShapeSize() }

View File

@ -5,7 +5,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import com.looker.droidify.utility.isBlackTheme
@Composable
@ -14,8 +13,6 @@ fun AppTheme(
blackTheme: Boolean = isBlackTheme,
content: @Composable () -> Unit
) {
CompositionLocalProvider(LocalShapes provides ShapeSize()) {
MaterialTheme(
colorScheme = when {
darkTheme && blackTheme -> BlackColors
@ -24,7 +21,6 @@ fun AppTheme(
},
content = content
)
}
}
private val LightColors = lightColorScheme(

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.shape.CornerBasedShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
@ -18,7 +17,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import com.looker.droidify.ui.compose.theme.LocalShapes
@OptIn(ExperimentalFoundationApi::class)
@Composable
@ -26,7 +24,7 @@ fun ExpandableCard(
modifier: Modifier = Modifier,
preExpanded: Boolean = false,
backgroundColor: Color = MaterialTheme.colorScheme.background,
shape: CornerBasedShape = RoundedCornerShape(LocalShapes.current.large),
shape: CornerBasedShape = MaterialTheme.shapes.large,
onClick: () -> Unit = {},
expandedContent: @Composable () -> Unit = {},
mainContent: @Composable () -> Unit

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.rememberTransformableState
import androidx.compose.foundation.gestures.transformable
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
@ -19,7 +18,6 @@ import androidx.compose.ui.res.painterResource
import coil.compose.SubcomposeAsyncImage
import coil.compose.SubcomposeAsyncImageContent
import com.looker.droidify.R
import com.looker.droidify.ui.compose.theme.LocalShapes
@Composable
fun NetworkImage(
@ -27,7 +25,7 @@ fun NetworkImage(
data: String?,
contentScale: ContentScale = ContentScale.Crop,
backgroundColor: Color = MaterialTheme.colorScheme.surface,
shape: Shape = RoundedCornerShape(LocalShapes.current.medium)
shape: Shape = MaterialTheme.shapes.medium
) {
SubcomposeAsyncImage(
modifier = modifier.clip(shape),