Skip to content

Commit

Permalink
✨ 전체 뱃지 페이지 UI 구현 (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-j0y authored Sep 12, 2024
1 parent 8c0a5a7 commit 3e61023
Show file tree
Hide file tree
Showing 24 changed files with 744 additions and 13 deletions.
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,
) {
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"
)
)
}
}
Loading

0 comments on commit 3e61023

Please sign in to comment.