Skip to content
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

Merged
merged 21 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
30cd09f
feat: 컴포즈 라이브러리 의존성 추가
junseo511 Jan 9, 2025
5eaa5cd
refactor: 플랫폼 로딩 로직 개선
junseo511 Jan 9, 2025
7c82cb1
feat: 클릭 관련 확장 컴포넌트 추가
junseo511 Jan 9, 2025
5ed2c98
feat: 플랫폼 연결 컴포즈로 전환
junseo511 Jan 9, 2025
a6c13aa
Merge branch 'develop' of https://github.com/Team-WSS/WSS-Android int…
junseo511 Jan 14, 2025
1761be6
refactor: 컴포즈 라이브러리를 버전 카탈로그로 이전
junseo511 Jan 14, 2025
30ff06c
refactor: 파일명 수정
junseo511 Jan 14, 2025
49a0a80
refactor: 불필요한 인자 제거
junseo511 Jan 14, 2025
9e19705
feat: 이미지 확장 컴포넌트 추가
junseo511 Jan 14, 2025
fd4d3f6
refactor: 불필요한 임포트 제거
junseo511 Jan 14, 2025
64db10a
Merge branch 'develop' of https://github.com/Team-WSS/WSS-Android int…
junseo511 Jan 14, 2025
6b30393
feat: 자동 이미지 검증 로직 추가
junseo511 Jan 14, 2025
ad09ef3
refactor: 불필요한 속성 제거
junseo511 Jan 15, 2025
e8ed601
refactor: 함수 이동
junseo511 Jan 15, 2025
dfaf038
feat: 웹소소 폰트 추가
junseo511 Jan 15, 2025
7743686
feat: 웹소소 컬러 추가
junseo511 Jan 15, 2025
52313da
feat: 웹소소 테마 추가
junseo511 Jan 15, 2025
4823005
refactor: 테마에서의 컬러 시스템 수정
junseo511 Jan 15, 2025
47515e1
refactor: 폰트 함수 분리
junseo511 Jan 15, 2025
7148332
refactor: 이미지 라이브러리 컴포넌트 분리
junseo511 Jan 15, 2025
3c4908b
Merge pull request #543 from Team-WSS/feat/542
junseo511 Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ android {
buildConfig = true
dataBinding = true
viewBinding = true
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.2"
}
}

Expand Down Expand Up @@ -102,4 +106,10 @@ dependencies {

implementation(libs.hilt.android)
kapt(libs.hilt.compiler)

val composeBom = libs.compose.bom
implementation(composeBom)
androidTestImplementation(composeBom)

implementation(libs.bundles.compose)
}
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,
)
}
19 changes: 19 additions & 0 deletions app/src/main/java/com/into/websoso/common/util/ExtentionFuction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import android.os.Parcelable
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.ListView
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.datastore.core.DataStore
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.preferences.SharedPreferencesMigration
Expand Down Expand Up @@ -112,3 +117,17 @@ fun Context.createDataStore(preferencesName: String): DataStore<Preferences> {
produceFile = { this.preferencesDataStoreFile(preferencesName) }
)
}

@Composable
fun Modifier.clickableWithoutRipple(
enabled: Boolean = true,
onClick: () -> Unit,
): Modifier {
val mutableInteractionSource = remember { MutableInteractionSource() }
return this.clickable(
enabled = enabled,
interactionSource = mutableInteractionSource,
indication = null,
onClick = onClick,
)
}
47 changes: 47 additions & 0 deletions app/src/main/java/com/into/websoso/designsystem/theme/Color.kt
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),
)
97 changes: 97 additions & 0 deletions app/src/main/java/com/into/websoso/designsystem/theme/Theme.kt
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) {

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

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 🐶
Parameter should start on a newline

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 before closing parenthesis

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,
)
}
}
117 changes: 117 additions & 0 deletions app/src/main/java/com/into/websoso/designsystem/theme/Type.kt
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(

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 before expression body

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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:function-expression-body reported by reviewdog 🐶
Function body should be replaced with body expression

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),
)
}
4 changes: 1 addition & 3 deletions app/src/main/java/com/into/websoso/ui/mapper/NovelMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.into.websoso.ui.normalExplore.model.NormalExploreModel.NovelModel
import com.into.websoso.ui.novelDetail.model.NovelDetailModel
import com.into.websoso.ui.novelInfo.model.KeywordModel
import com.into.websoso.ui.novelInfo.model.NovelInfoUiModel
import com.into.websoso.ui.novelInfo.model.Platform
import com.into.websoso.ui.novelInfo.model.PlatformModel
import com.into.websoso.ui.novelInfo.model.ReviewCountModel
import com.into.websoso.ui.novelInfo.model.UnifiedReviewCountModel
Expand Down Expand Up @@ -56,10 +55,9 @@ fun NovelInfoEntity.toUi() = NovelInfoUiModel(
)

fun NovelInfoEntity.PlatformEntity.toUi() = PlatformModel(
platform = Platform.fromPlatformName(platformName),
platformName = platformName,
platformImage = platformImage,
platformUrl = platformUrl,
isVisible = platformName.isNotEmpty(),
)

fun NovelInfoEntity.KeywordEntity.toUi() = KeywordModel(
Expand Down
Loading
Loading