-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 웹소설 여러 플랫폼 대응 #531
feat: 웹소설 여러 플랫폼 대응 #531
Changes from all commits
30cd09f
5eaa5cd
7c82cb1
5ed2c98
a6c13aa
1761be6
30ff06c
49a0a80
9e19705
fd4d3f6
64db10a
6b30393
ad09ef3
e8ed601
dfaf038
7743686
52313da
4823005
47515e1
7148332
3c4908b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.into.websoso.common.ui.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.platform.LocalView | ||
import com.into.websoso.common.util.getS3ImageUrl | ||
|
||
@Composable | ||
fun AdaptationImage( | ||
modifier: Modifier = Modifier, | ||
contentDescription: String? = null, | ||
imageUrl: String, | ||
contentScale: ContentScale = ContentScale.Fit, | ||
alignment: Alignment = Alignment.Center, | ||
) { | ||
val urlRegex = Regex("^(https?://).*") | ||
val formattedUrl = when (urlRegex.matches(imageUrl)) { | ||
true -> imageUrl | ||
false -> LocalView.current.getS3ImageUrl(imageUrl) | ||
} | ||
|
||
ExternalImage( | ||
modifier = modifier, | ||
contentDescription = contentDescription, | ||
imageUrl = formattedUrl, | ||
contentScale = contentScale, | ||
alignment = alignment, | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.into.websoso.common.ui.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import coil.compose.AsyncImage | ||
|
||
@Composable | ||
fun ExternalImage( | ||
modifier: Modifier = Modifier, | ||
contentDescription: String? = null, | ||
imageUrl: String, | ||
contentScale: ContentScale = ContentScale.Fit, | ||
alignment: Alignment = Alignment.Center, | ||
) { | ||
AsyncImage( | ||
modifier = modifier, | ||
contentDescription = contentDescription, | ||
model = imageUrl, | ||
contentScale = contentScale, | ||
alignment = alignment, | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.into.websoso.designsystem.theme | ||
|
||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
|
||
val Primary20 = Color(0xFFF5F7FF) | ||
val Primary50 = Color(0xFFF1EFFF) | ||
val Primary100 = Color(0xFF6A5DFD) | ||
val Primary200 = Color(0xFF240991) | ||
|
||
val Secondary50 = Color(0xFFFFAA8F) | ||
val Secondary100 = Color(0xFFFF675D) | ||
|
||
val White = Color(0xFFFFFFFF) | ||
val Gray20 = Color(0xFFFAFAFA) | ||
val Gray50 = Color(0xFFF4F5F8) | ||
val Gray70 = Color(0xFFDFDFE3) | ||
val Gray80 = Color(0xFFDDDDE3) | ||
val Gray100 = Color(0xFFCBCBD1) | ||
val Gray200 = Color(0xFFAEADB3) | ||
val Gray300 = Color(0xFF52515F) | ||
val Black = Color(0xFF111118) | ||
|
||
val GrayToast = Color(0xCC394258) | ||
val Black60 = Color(0x99000000) | ||
val Warning = Color(0xFFFF675D) | ||
|
||
val Transparent = Color(0x00000000) | ||
|
||
val BgGradientGray = Brush.linearGradient( | ||
colors = listOf( | ||
Color(0xCC070A25), | ||
Color(0xFF000215), | ||
), | ||
start = Offset(0f, 0f), | ||
end = Offset(0f, Float.POSITIVE_INFINITY), | ||
) | ||
|
||
val BgSelectedGradient = Brush.linearGradient( | ||
colors = listOf( | ||
Color(0xFF6341F0), | ||
Color(0xFFAD00FF), | ||
), | ||
start = Offset(0f, 0f), | ||
end = Offset(0f, Float.POSITIVE_INFINITY), | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.into.websoso.designsystem.theme | ||
|
||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.platform.LocalContext | ||
|
||
private val DarkColorScheme = darkColorScheme( | ||
primary = Primary100, | ||
onPrimary = White, | ||
primaryContainer = Primary200, | ||
onPrimaryContainer = Gray20, | ||
secondary = Secondary100, | ||
onSecondary = White, | ||
secondaryContainer = Secondary50, | ||
onSecondaryContainer = Gray50, | ||
tertiary = Gray300, | ||
onTertiary = White, | ||
background = Black, | ||
onBackground = Gray20, | ||
surface = Gray80, | ||
onSurface = Gray200, | ||
error = Warning, | ||
onError = White, | ||
) | ||
|
||
private val LightColorScheme = lightColorScheme( | ||
primary = Primary100, | ||
onPrimary = White, | ||
primaryContainer = Primary50, | ||
onPrimaryContainer = Gray20, | ||
secondary = Secondary100, | ||
onSecondary = White, | ||
secondaryContainer = Secondary50, | ||
onSecondaryContainer = Gray50, | ||
tertiary = Gray300, | ||
onTertiary = Black, | ||
background = White, | ||
onBackground = Gray300, | ||
surface = Gray20, | ||
onSurface = Gray70, | ||
error = Warning, | ||
onError = White, | ||
) | ||
|
||
private val LocalWebsosoTypography = staticCompositionLocalOf<WebsosoTypography> { | ||
error("No WebsosoTypography Provided") | ||
} | ||
|
||
object WebsosoTheme { | ||
val typography: WebsosoTypography | ||
@Composable get() = LocalWebsosoTypography.current | ||
} | ||
|
||
@Composable | ||
fun ProvideWebsosoTypography(typography: WebsosoTypography, content: @Composable () -> Unit) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 |
||
val provideTypography = remember { typography.copy() } | ||
provideTypography.update(typography) | ||
CompositionLocalProvider( | ||
LocalWebsosoTypography provides provideTypography, | ||
content = content, | ||
) | ||
} | ||
|
||
@Composable | ||
fun WebsosoTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit, | ||
) { | ||
val colorScheme = | ||
when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme | ||
else -> LightColorScheme | ||
} | ||
val typography = websosoTypography() | ||
|
||
ProvideWebsosoTypography(typography) { | ||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
content = content, | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.into.websoso.designsystem.theme | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.Font | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.into.websoso.R | ||
|
||
val PretendardBold = FontFamily(Font(R.font.pretendard_bold, FontWeight.Bold)) | ||
val PretendardSemiBold = FontFamily(Font(R.font.pretendard_semibold, FontWeight.SemiBold)) | ||
val PretendardMedium = FontFamily(Font(R.font.pretendard_medium, FontWeight.Medium)) | ||
val PretendardRegular = FontFamily(Font(R.font.pretendard_regular, FontWeight.Normal)) | ||
|
||
@Stable | ||
class WebsosoTypography internal constructor( | ||
headline: TextStyle, | ||
title1: TextStyle, | ||
title2: TextStyle, | ||
body1: TextStyle, | ||
body2: TextStyle, | ||
body3: TextStyle, | ||
caption: TextStyle, | ||
button: TextStyle, | ||
label: TextStyle, | ||
) { | ||
var headline: TextStyle by mutableStateOf(headline) | ||
private set | ||
var title1: TextStyle by mutableStateOf(title1) | ||
private set | ||
var title2: TextStyle by mutableStateOf(title2) | ||
private set | ||
var body1: TextStyle by mutableStateOf(body1) | ||
private set | ||
var body2: TextStyle by mutableStateOf(body2) | ||
private set | ||
var body3: TextStyle by mutableStateOf(body3) | ||
private set | ||
var caption: TextStyle by mutableStateOf(caption) | ||
private set | ||
var button: TextStyle by mutableStateOf(button) | ||
private set | ||
var label: TextStyle by mutableStateOf(label) | ||
private set | ||
|
||
fun copy( | ||
headline: TextStyle = this.headline, | ||
title1: TextStyle = this.title1, | ||
title2: TextStyle = this.title2, | ||
body1: TextStyle = this.body1, | ||
body2: TextStyle = this.body2, | ||
body3: TextStyle = this.body3, | ||
caption: TextStyle = this.caption, | ||
button: TextStyle = this.button, | ||
label: TextStyle = this.label, | ||
): WebsosoTypography = WebsosoTypography( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 |
||
headline, | ||
title1, | ||
title2, | ||
body1, | ||
body2, | ||
body3, | ||
caption, | ||
button, | ||
label, | ||
) | ||
|
||
fun update(other: WebsosoTypography) { | ||
headline = other.headline | ||
title1 = other.title1 | ||
title2 = other.title2 | ||
body1 = other.body1 | ||
body2 = other.body2 | ||
body3 = other.body3 | ||
caption = other.caption | ||
button = other.button | ||
label = other.label | ||
} | ||
} | ||
|
||
@Composable | ||
fun websosoTypography(): WebsosoTypography { | ||
val density = LocalDensity.current | ||
|
||
fun textStyle( | ||
fontFamily: FontFamily, | ||
fontWeight: FontWeight, | ||
fontSizeDp: Dp, | ||
lineHeightDp: Dp, | ||
): TextStyle { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-expression-body reported by reviewdog 🐶 |
||
return TextStyle( | ||
fontFamily = fontFamily, | ||
fontWeight = fontWeight, | ||
fontSize = with(density) { fontSizeDp.toSp() }, | ||
lineHeight = with(density) { lineHeightDp.toSp() }, | ||
) | ||
} | ||
|
||
return WebsosoTypography( | ||
headline = textStyle(PretendardBold, FontWeight.Bold, 24.dp, 32.dp), | ||
title1 = textStyle(PretendardSemiBold, FontWeight.SemiBold, 20.dp, 28.dp), | ||
title2 = textStyle(PretendardMedium, FontWeight.Medium, 18.dp, 25.dp), | ||
body1 = textStyle(PretendardRegular, FontWeight.Normal, 16.dp, 24.dp), | ||
body2 = textStyle(PretendardRegular, FontWeight.Normal, 14.dp, 21.dp), | ||
body3 = textStyle(PretendardRegular, FontWeight.Normal, 12.dp, 18.dp), | ||
caption = textStyle(PretendardRegular, FontWeight.Normal, 10.dp, 15.dp), | ||
button = textStyle(PretendardBold, FontWeight.Bold, 14.dp, 20.dp), | ||
label = textStyle(PretendardSemiBold, FontWeight.SemiBold, 13.dp, 19.dp), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected after opening parenthesis