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

✨ 전체 뱃지 페이지 UI 구현 #86

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions app/src/main/java/com/whyranoid/walkie/KoinModules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import com.whyranoid.presentation.viewmodel.SearchFriendViewModel
import com.whyranoid.presentation.viewmodel.SelectHistoryViewModel
import com.whyranoid.presentation.viewmodel.SignInViewModel
import com.whyranoid.presentation.viewmodel.SplashViewModel
import com.whyranoid.presentation.viewmodel.TotalBadgeViewModel
import com.whyranoid.presentation.viewmodel.UserPageViewModel
import com.whyranoid.presentation.viewmodel.challenge.ChallengeDetailViewModel
import com.whyranoid.presentation.viewmodel.challenge.ChallengeExitViewModel
Expand Down Expand Up @@ -130,6 +131,7 @@ val viewModelModule =
viewModel { CommunityScreenViewModel(get(), get(), get()) }
viewModel { FollowingViewModel(get(), get(), get(), get(), get(), get()) }
viewModel { SettingViewModel(get(), get()) }
viewModel { TotalBadgeViewModel(get(), get()) }
}

val repositoryModule =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.io.File

class AccountDataSourceImpl(private val accountService: AccountService) : AccountDataSource {
override suspend fun signUp(
name: String,
nickName: String,
profileUrl: String?,
authId: String,
Expand All @@ -23,6 +24,7 @@ class AccountDataSourceImpl(private val accountService: AccountService) : Accoun
return kotlin.runCatching {
val request = SignUpRequest(
userName = nickName,
name = name,
profileImg = profileUrl ?: "",
authId = authId,
agreeGps = agreeGps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.whyranoid.data.model.account

data class SignUpRequest(
val userName: String,
val name: String,
val profileImg: String,
val authId: String,
val agreeGps: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package com.whyranoid.data.model.account
import com.whyranoid.domain.model.account.UserInfo

data class UserInfoResponse (
val name: String,
val nickname: String,
val profileImg: String?
)

fun UserInfoResponse.toUserInfo() = UserInfo(
name = "", // TODO 수정
name = name,
nickname = nickname,
profileImg = profileImg
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AccountRepositoryImpl(
agreeSubscription: Boolean,
): Result<Long> {
return kotlin.runCatching {
accountDataSource.signUp(nickName, profileUrl, authId, agreeGps, agreeSubscription)
accountDataSource.signUp(userName, nickName, profileUrl, authId, agreeGps, agreeSubscription)
.onSuccess { uid ->
accountDataStore.updateUId(uid)
accountDataStore.updateAuthId(authId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.whyranoid.domain.model.account.UserInfo

interface AccountDataSource {
suspend fun signUp(
name: String,
nickName: String,
profileUrl: String?,
authId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.whyranoid.domain.model.challenge

import androidx.annotation.DrawableRes

data class BadgeInfo (
val id: Int,
@DrawableRes val image: Int,
val name: String,
val receivedAt: String = ""
)
2 changes: 1 addition & 1 deletion presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {

defaultConfig {
minSdk = 26
targetSdk = 33
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ import androidx.compose.ui.platform.LocalDensity
import com.whyranoid.presentation.theme.WalkieColor

@Composable
fun PlaceholderBadge() {
fun BadgePlaceHolder(
modifier: Modifier = Modifier
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
modifier = modifier
.size(48.dp)
.clip(CircleShape)
.background(WalkieColor.GrayDisable)
) {
val pxValue = LocalDensity.current.run { 2.dp.toPx() }
Canvas(modifier = Modifier.size(48.dp)) {
Canvas(modifier = modifier.size(48.dp)) {
drawCircle(
color = Color.Gray.copy(alpha = 0.3f),
style = Stroke(
Expand All @@ -44,6 +46,6 @@ fun PlaceholderBadge() {
@Preview
fun PlaceholderBadgePreview() {
WalkieTheme {
PlaceholderBadge()
BadgePlaceHolder()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.whyranoid.presentation.component.button

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.whyranoid.presentation.theme.WalkieTheme

@Composable
fun WalkieNormalButton(
buttonText: String,
onButtonClick: () -> Unit,
) {
Comment on lines +18 to +22
Copy link
Member

Choose a reason for hiding this comment

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

저희 혹시 버튼이 따로 컴포저블로 없었나요??!!
아니면 확장성이 좀 구려서 다시 만드셨남?..
(진짜 몰라서 물어봄..!)
감사해용

Copy link
Member Author

Choose a reason for hiding this comment

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

제가 확인했을 때는 없었던거 같아서 만들었어요. 당시 기억이 잘 안나네요 ㅎㅎ

Button(
onClick = {
onButtonClick()
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.Black,
disabledContentColor = Color.Black,
backgroundColor = Color(0xFFEEEEEE)
),
modifier = Modifier
.fillMaxWidth()
.height(34.dp),
shape = RoundedCornerShape(7.dp),
elevation = null
) {
Text(
text = buttonText,
style = TextStyle(
color = Color.Black,
fontSize = 14.sp
)
)
}
}

@Preview
@Composable
fun WalkieNormalButtonPreview() {
WalkieTheme {
WalkieNormalButton("전체 뱃지 보기") {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.whyranoid.presentation.reusable

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.whyranoid.domain.model.challenge.BadgeInfo
import com.whyranoid.presentation.R
import com.whyranoid.presentation.theme.WalkieTheme
import com.whyranoid.presentation.theme.WalkieTypography

@Composable
fun BadgeItem(
badgeInfo: BadgeInfo
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.size(54.dp)
.align(Alignment.CenterHorizontally)
) {
Image(
painter = painterResource(badgeInfo.image),
contentDescription = null
)
}

Spacer(
modifier = Modifier.height(4.dp)
)

Text(
text = badgeInfo.name,
textAlign = TextAlign.Center,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
style = WalkieTypography.Body2,
modifier = Modifier
.widthIn(max = 62.dp)
.heightIn(max = 24.dp)
)
}
}

@Preview
@Composable
private fun BadgePreview() {
WalkieTheme {
BadgeItem(
BadgeInfo(
1,
R.drawable.badge_test_2,
"test"
)
)
}
}
Comment on lines +60 to +72
Copy link
Member

Choose a reason for hiding this comment

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

프리뷰를 만들어야 하는 이유를 물어보면 승민님은 뭐라고 대답하실 것 같으세요??
저는 사실 그동안 프리뷰를 잘 안쓰다가

  • 보통 제가 테스트 화면 따로 만들어서 빌드가 빨라서 거기서 테스트 하면서 썼거든요.

근데 최근에 조금 규모가 큰 협업을 하면서 느꼈던게, 프리뷰가 없으니까 남이 만든 컴포저블을 나중에 확인하기가 너무 힘들어서, 프리뷰를 만들어야겠다고 생각했어요.

승민님은 혹시 다른 이유가 있으신가요? 아니면 비슷한 이유?

Copy link
Member Author

Choose a reason for hiding this comment

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

말씀하신 것처럼 협업을 위한 용도 + 다양한 엣지 케이스나 글자 크기 테스트가 필요한 경우에 씁니다. 보통 디자인 가이드는 글자 크기와 1줄인 것, 여러 줄인 것 모두 같이 나오니까 빌드마다 바꿔서 실행하기 힘드니까요.

Loading
Loading