mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
all: migrate to M3
This commit is contained in:
parent
e57a476145
commit
72d7297818
13 changed files with 295 additions and 66 deletions
|
@ -7,7 +7,7 @@ import androidx.compose.ui.text.font.FontFamily
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import dev.msfjarvis.claw.common.R
|
||||
|
||||
actual val manropeFontFamily =
|
||||
actual val Manrope =
|
||||
FontFamily(
|
||||
Font(R.font.manrope_bold, FontWeight.Bold),
|
||||
Font(R.font.manrope_extrabold, FontWeight.ExtraBold),
|
||||
|
|
|
@ -7,7 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
|
|
@ -8,7 +8,7 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -66,6 +66,6 @@ private fun ProgressBar(
|
|||
modifier: Modifier,
|
||||
) {
|
||||
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator(color = MaterialTheme.colors.secondary)
|
||||
CircularProgressIndicator(color = MaterialTheme.colorScheme.secondary)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ import androidx.compose.foundation.shape.CircleShape
|
|||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.primarySurface
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -37,7 +37,11 @@ import dev.msfjarvis.claw.common.ui.NetworkImage
|
|||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
|
||||
@Composable
|
||||
@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class)
|
||||
@OptIn(
|
||||
ExperimentalMaterial3Api::class,
|
||||
ExperimentalMaterialApi::class,
|
||||
ExperimentalFoundationApi::class,
|
||||
)
|
||||
fun LobstersCard(
|
||||
post: SavedPost,
|
||||
isSaved: Boolean,
|
||||
|
@ -45,7 +49,7 @@ fun LobstersCard(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier.background(MaterialTheme.colors.primarySurface),
|
||||
modifier = modifier.background(MaterialTheme.colorScheme.background),
|
||||
onClick = { postActions.viewPost(post.url, post.commentsUrl) },
|
||||
) {
|
||||
Column(
|
||||
|
@ -163,7 +167,7 @@ fun SaveButton(
|
|||
Crossfade(targetState = isSaved) { saved ->
|
||||
Icon(
|
||||
painter = if (saved) heartIcon else heartBorderIcon,
|
||||
tint = MaterialTheme.colors.secondary,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
contentDescription = if (saved) "Remove from saved posts" else "Add to saved posts",
|
||||
modifier = modifier,
|
||||
)
|
||||
|
@ -176,7 +180,7 @@ fun CommentsButton(
|
|||
) {
|
||||
Icon(
|
||||
painter = commentIcon,
|
||||
tint = MaterialTheme.colors.secondary,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
contentDescription = "Open comments",
|
||||
modifier = modifier,
|
||||
)
|
||||
|
@ -199,11 +203,11 @@ fun TagRow(
|
|||
text = tag,
|
||||
modifier =
|
||||
Modifier.background(
|
||||
MaterialTheme.colors.secondary.copy(alpha = 0.75f),
|
||||
MaterialTheme.colorScheme.secondary.copy(alpha = 0.75f),
|
||||
RoundedCornerShape(8.dp)
|
||||
)
|
||||
.padding(vertical = 2.dp, horizontal = 6.dp),
|
||||
color = MaterialTheme.colors.onSecondary,
|
||||
color = MaterialTheme.colorScheme.onSecondary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package dev.msfjarvis.claw.common.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val md_theme_light_primary = Color(0xFFac3325)
|
||||
val md_theme_light_onPrimary = Color(0xFFffffff)
|
||||
val md_theme_light_primaryContainer = Color(0xFFffdad3)
|
||||
val md_theme_light_onPrimaryContainer = Color(0xFF410000)
|
||||
val md_theme_light_secondary = Color(0xFF775752)
|
||||
val md_theme_light_onSecondary = Color(0xFFffffff)
|
||||
val md_theme_light_secondaryContainer = Color(0xFFffdad3)
|
||||
val md_theme_light_onSecondaryContainer = Color(0xFF2c1511)
|
||||
val md_theme_light_tertiary = Color(0xFF705c2e)
|
||||
val md_theme_light_onTertiary = Color(0xFFffffff)
|
||||
val md_theme_light_tertiaryContainer = Color(0xFFfbdfa5)
|
||||
val md_theme_light_onTertiaryContainer = Color(0xFF261a00)
|
||||
val md_theme_light_error = Color(0xFFba1b1b)
|
||||
val md_theme_light_errorContainer = Color(0xFFffdad4)
|
||||
val md_theme_light_onError = Color(0xFFffffff)
|
||||
val md_theme_light_onErrorContainer = Color(0xFF410001)
|
||||
val md_theme_light_background = Color(0xFFfcfcfc)
|
||||
val md_theme_light_onBackground = Color(0xFF201a19)
|
||||
val md_theme_light_surface = Color(0xFFfcfcfc)
|
||||
val md_theme_light_onSurface = Color(0xFF201a19)
|
||||
val md_theme_light_surfaceVariant = Color(0xFFf5deda)
|
||||
val md_theme_light_onSurfaceVariant = Color(0xFF534341)
|
||||
val md_theme_light_outline = Color(0xFF867370)
|
||||
val md_theme_light_inverseOnSurface = Color(0xFFfbeeec)
|
||||
val md_theme_light_inverseSurface = Color(0xFF362f2e)
|
||||
|
||||
val md_theme_dark_primary = Color(0xFFffb4a6)
|
||||
val md_theme_dark_onPrimary = Color(0xFF690000)
|
||||
val md_theme_dark_primaryContainer = Color(0xFF8a1a10)
|
||||
val md_theme_dark_onPrimaryContainer = Color(0xFFffdad3)
|
||||
val md_theme_dark_secondary = Color(0xFFe7bdb6)
|
||||
val md_theme_dark_onSecondary = Color(0xFF442925)
|
||||
val md_theme_dark_secondaryContainer = Color(0xFF5d3f3a)
|
||||
val md_theme_dark_onSecondaryContainer = Color(0xFFffdad3)
|
||||
val md_theme_dark_tertiary = Color(0xFFdec48c)
|
||||
val md_theme_dark_onTertiary = Color(0xFF3e2e04)
|
||||
val md_theme_dark_tertiaryContainer = Color(0xFF564418)
|
||||
val md_theme_dark_onTertiaryContainer = Color(0xFFfbdfa5)
|
||||
val md_theme_dark_error = Color(0xFFffb4a9)
|
||||
val md_theme_dark_errorContainer = Color(0xFF930006)
|
||||
val md_theme_dark_onError = Color(0xFF680003)
|
||||
val md_theme_dark_onErrorContainer = Color(0xFFffdad4)
|
||||
val md_theme_dark_background = Color(0xFF201a19)
|
||||
val md_theme_dark_onBackground = Color(0xFFede0de)
|
||||
val md_theme_dark_surface = Color(0xFF201a19)
|
||||
val md_theme_dark_onSurface = Color(0xFFede0de)
|
||||
val md_theme_dark_surfaceVariant = Color(0xFF534341)
|
||||
val md_theme_dark_onSurfaceVariant = Color(0xFFd8c2be)
|
||||
val md_theme_dark_outline = Color(0xFFa08c89)
|
||||
val md_theme_dark_inverseOnSurface = Color(0xFF201a19)
|
||||
val md_theme_dark_inverseSurface = Color(0xFFede0de)
|
||||
|
||||
val seed = Color(0xFF6c0000)
|
||||
val error = Color(0xFFba1b1b)
|
|
@ -1,57 +1,87 @@
|
|||
package dev.msfjarvis.claw.common.theme
|
||||
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
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 androidx.compose.runtime.ProvidedValue
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
|
||||
expect val manropeFontFamily: FontFamily
|
||||
|
||||
val titleColor = Color(0xFF7395D9)
|
||||
|
||||
val lightColors =
|
||||
lightColors(
|
||||
primary = Color.White,
|
||||
secondary = Color(0xFF6C0000),
|
||||
background = Color.White,
|
||||
surface = Color.White,
|
||||
onPrimary = Color.DarkGray,
|
||||
onSecondary = Color.White,
|
||||
onBackground = Color.White,
|
||||
onSurface = Color.White,
|
||||
private val LightThemeColors =
|
||||
lightColorScheme(
|
||||
primary = md_theme_light_primary,
|
||||
onPrimary = md_theme_light_onPrimary,
|
||||
primaryContainer = md_theme_light_primaryContainer,
|
||||
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
||||
secondary = md_theme_light_secondary,
|
||||
onSecondary = md_theme_light_onSecondary,
|
||||
secondaryContainer = md_theme_light_secondaryContainer,
|
||||
onSecondaryContainer = md_theme_light_onSecondaryContainer,
|
||||
tertiary = md_theme_light_tertiary,
|
||||
onTertiary = md_theme_light_onTertiary,
|
||||
tertiaryContainer = md_theme_light_tertiaryContainer,
|
||||
onTertiaryContainer = md_theme_light_onTertiaryContainer,
|
||||
error = md_theme_light_error,
|
||||
errorContainer = md_theme_light_errorContainer,
|
||||
onError = md_theme_light_onError,
|
||||
onErrorContainer = md_theme_light_onErrorContainer,
|
||||
background = md_theme_light_background,
|
||||
onBackground = md_theme_light_onBackground,
|
||||
surface = md_theme_light_surface,
|
||||
onSurface = md_theme_light_onSurface,
|
||||
surfaceVariant = md_theme_light_surfaceVariant,
|
||||
onSurfaceVariant = md_theme_light_onSurfaceVariant,
|
||||
outline = md_theme_light_outline,
|
||||
inverseOnSurface = md_theme_light_inverseOnSurface,
|
||||
inverseSurface = md_theme_light_inverseSurface,
|
||||
)
|
||||
|
||||
val darkColors =
|
||||
darkColors(
|
||||
primary = Color.White,
|
||||
secondary = Color(0xFFD2362D),
|
||||
background = Color.Black,
|
||||
surface = Color.Black,
|
||||
onPrimary = Color.Black,
|
||||
onSecondary = Color.White,
|
||||
onBackground = Color.White,
|
||||
onSurface = Color.White,
|
||||
private val DarkThemeColors =
|
||||
darkColorScheme(
|
||||
primary = md_theme_dark_primary,
|
||||
onPrimary = md_theme_dark_onPrimary,
|
||||
primaryContainer = md_theme_dark_primaryContainer,
|
||||
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
|
||||
secondary = md_theme_dark_secondary,
|
||||
onSecondary = md_theme_dark_onSecondary,
|
||||
secondaryContainer = md_theme_dark_secondaryContainer,
|
||||
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
|
||||
tertiary = md_theme_dark_tertiary,
|
||||
onTertiary = md_theme_dark_onTertiary,
|
||||
tertiaryContainer = md_theme_dark_tertiaryContainer,
|
||||
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
|
||||
error = md_theme_dark_error,
|
||||
errorContainer = md_theme_dark_errorContainer,
|
||||
onError = md_theme_dark_onError,
|
||||
onErrorContainer = md_theme_dark_onErrorContainer,
|
||||
background = md_theme_dark_background,
|
||||
onBackground = md_theme_dark_onBackground,
|
||||
surface = md_theme_dark_surface,
|
||||
onSurface = md_theme_dark_onSurface,
|
||||
surfaceVariant = md_theme_dark_surfaceVariant,
|
||||
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
|
||||
outline = md_theme_dark_outline,
|
||||
inverseOnSurface = md_theme_dark_inverseOnSurface,
|
||||
inverseSurface = md_theme_dark_inverseSurface,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun LobstersTheme(
|
||||
darkTheme: Boolean,
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
providedValues: Array<ProvidedValue<*>> = emptyArray(),
|
||||
children: @Composable () -> Unit
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val colors =
|
||||
if (!darkTheme) {
|
||||
LightThemeColors
|
||||
} else {
|
||||
DarkThemeColors
|
||||
}
|
||||
CompositionLocalProvider(*providedValues) {
|
||||
MaterialTheme(
|
||||
colors = if (darkTheme) darkColors else lightColors,
|
||||
typography =
|
||||
Typography(
|
||||
defaultFontFamily = manropeFontFamily,
|
||||
),
|
||||
content = children,
|
||||
)
|
||||
MaterialTheme(colorScheme = colors, typography = AppTypography, content = content)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
package dev.msfjarvis.claw.common.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
expect val Manrope: FontFamily
|
||||
|
||||
val AppTypography =
|
||||
Typography(
|
||||
displayLarge =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 57.sp,
|
||||
lineHeight = 64.sp,
|
||||
letterSpacing = (-0.25).sp,
|
||||
),
|
||||
displayMedium =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 45.sp,
|
||||
lineHeight = 52.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
displaySmall =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 36.sp,
|
||||
lineHeight = 44.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
headlineLarge =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 32.sp,
|
||||
lineHeight = 40.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
headlineMedium =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 28.sp,
|
||||
lineHeight = 36.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
headlineSmall =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 24.sp,
|
||||
lineHeight = 32.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
titleLarge =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 22.sp,
|
||||
lineHeight = 28.sp,
|
||||
letterSpacing = 0.sp,
|
||||
),
|
||||
titleMedium =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.1.sp,
|
||||
),
|
||||
titleSmall =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 14.sp,
|
||||
lineHeight = 20.sp,
|
||||
letterSpacing = 0.1.sp,
|
||||
),
|
||||
labelLarge =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 14.sp,
|
||||
lineHeight = 20.sp,
|
||||
letterSpacing = 0.1.sp,
|
||||
),
|
||||
bodyLarge =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp,
|
||||
),
|
||||
bodyMedium =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 14.sp,
|
||||
lineHeight = 20.sp,
|
||||
letterSpacing = 0.25.sp,
|
||||
),
|
||||
bodySmall =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.W400,
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.4.sp,
|
||||
),
|
||||
labelMedium =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp,
|
||||
),
|
||||
labelSmall =
|
||||
TextStyle(
|
||||
fontFamily = Manrope,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 11.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp,
|
||||
),
|
||||
)
|
|
@ -6,7 +6,7 @@ import androidx.compose.ui.text.font.FontFamily
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.platform.Font
|
||||
|
||||
actual val manropeFontFamily =
|
||||
actual val Manrope =
|
||||
FontFamily(
|
||||
Font("font/manrope_bold.ttf", FontWeight.Bold),
|
||||
Font("font/manrope_extrabold.ttf", FontWeight.ExtraBold),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue