Skip to content

Commit

Permalink
Merge pull request #123 from THT-Team/feature/TOP-94_my_page
Browse files Browse the repository at this point in the history
TOP-94 마이페이지
  • Loading branch information
cwj-c authored Apr 20, 2024
2 parents ec57f6a + 5825f74 commit d39590b
Show file tree
Hide file tree
Showing 43 changed files with 1,383 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tht.feature.tohot.component.chip
package com.example.compose_ui.component.chip

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
Expand All @@ -9,19 +9,31 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose_ui.component.text.p.ThtP2
import tht.feature.tohot.userData

/**
* decode 를 해서 전달주는 곳이 있고, 아닌곳이 있음
* decode 를 해서 전달주는 곳
* - MyPageInfoRows
*
* 모르는곳
* - ToHotUserInfoFullCard
*
* TODO: 모두 decode 해서 전달주도록?
*/
@Composable
fun ToHotEmojiChip(
modifier: Modifier = Modifier,
content: String,
emojiCode: String
) {
val code = Integer.decode("0x$emojiCode")
val emoji = String(Character.toChars(code))
val emoji = runCatching {
val code = Integer.decode("0x$emojiCode")
String(Character.toChars(code))
}.getOrNull() ?: emojiCode
ToHotChip(
modifier = modifier,
item = "$emoji $content"
Expand All @@ -45,7 +57,9 @@ fun ToHotChip(
.padding(vertical = 4.dp, horizontal = 8.dp),
text = item,
fontWeight = FontWeight.Medium,
color = Color(0xFFF9FAFA)
color = Color(0xFFF9FAFA),
overflow = TextOverflow.Ellipsis,
maxLines = 1
)
}
}
Expand All @@ -54,8 +68,8 @@ fun ToHotChip(
@Preview(showBackground = true, backgroundColor = 0xFFFFFFFF, name = "emojiChip")
private fun ToHotEmojiChipPreview() {
ToHotEmojiChip(
content = userData.interests.list.last().title,
emojiCode = userData.interests.list.last().emojiCode
content = "content",
emojiCode = "1F3E0"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import com.example.compose_ui.component.font.rememberPretendardFontStyle
import com.example.compose_ui.extensions.dpTextUnit

Expand All @@ -17,7 +18,9 @@ fun ThtP1(
fontWeight: FontWeight,
color: Color,
textAlign: TextAlign = TextAlign.Center,
shadow: Shadow? = null
shadow: Shadow? = null,
overflow: TextOverflow = TextOverflow.Clip,
maxLines: Int = Int.MAX_VALUE
) {
Text(
modifier = modifier,
Expand All @@ -29,6 +32,8 @@ fun ThtP1(
shadow = shadow
),
color = color,
overflow = overflow,
maxLines = maxLines
)
}

Expand All @@ -39,7 +44,9 @@ fun ThtP2(
fontWeight: FontWeight,
color: Color,
textAlign: TextAlign = TextAlign.Center,
includeFontPadding: Boolean = false
includeFontPadding: Boolean = false,
overflow: TextOverflow = TextOverflow.Clip,
maxLines: Int = Int.MAX_VALUE
) {
Text(
modifier = modifier,
Expand All @@ -51,5 +58,7 @@ fun ThtP2(
includeFontPadding = includeFontPadding
),
color = color,
overflow = overflow,
maxLines = maxLines
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fun ThtSubtitle1(
fontWeight: FontWeight,
color: Color,
textAlign: TextAlign = TextAlign.Center,
shadow: Shadow? = null
shadow: Shadow? = null,
maxLines: Int = Int.MAX_VALUE,
) {
Text(
modifier = modifier,
Expand All @@ -29,6 +30,7 @@ fun ThtSubtitle1(
shadow = shadow
),
color = color,
maxLines = maxLines
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fun ThtToolbar(
)
}
}
Spacer(modifier = Modifier.width(16.dp))
content()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tht.feature.signin.util
package tht.core.ui.util

import android.text.SpannableStringBuilder
import android.text.Spanned
Expand All @@ -12,13 +12,15 @@ import android.widget.TextView
* 기존 Api에서 U+를 제거하고 보내줬으니, 앞에 0x만 붙이면 됨
*/
object StringUtil {
fun parseEmoji(emojiCode: String): String? {
fun parseEmoji(emojiCode: String): String {
return try {
val code = Integer.decode("0x${emojiCode.removePrefix("U+")}")
String(Character.toChars(code))
} catch (e: Exception) {
e.printStackTrace()
null
}.let {
if (it.isNullOrBlank()) "" else it
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ object THTApiConstant {
object Chat {
const val CHAT_LIST = "/chat/rooms"
}

object Setting {
const val MY_PAGE = "/user"
}
}
5 changes: 5 additions & 0 deletions data/src/main/java/com/tht/tht/data/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.tht.tht.data.remote.datasource.dailyusercard.DailyUserCardDataSource
import com.tht.tht.data.remote.datasource.dailyusercard.DailyUserCardDataSourceImpl
import com.tht.tht.data.remote.datasource.login.LoginDataSource
import com.tht.tht.data.remote.datasource.login.LoginDataSourceImpl
import com.tht.tht.data.remote.datasource.setting.UserSettingDataSource
import com.tht.tht.data.remote.datasource.setting.UserSettingDataSourceImpl
import com.tht.tht.data.remote.datasource.signup.EmailDataSource
import com.tht.tht.data.remote.datasource.signup.EmailDataSourceImpl
import com.tht.tht.data.remote.datasource.signup.ImageDataSource
Expand Down Expand Up @@ -72,4 +74,7 @@ abstract class DataSourceModule {

@Binds
abstract fun bindSettingItemDataSource(impl: SettingItemDataSourceImpl): SettingItemDataSource

@Binds
abstract fun bindUserSettingDataSource(impl: UserSettingDataSourceImpl): UserSettingDataSource
}
5 changes: 5 additions & 0 deletions data/src/main/java/com/tht/tht/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import com.tht.tht.data.repository.RegionCodeRepositoryImpl
import com.tht.tht.data.repository.SettingRepositoryImpl
import com.tht.tht.data.repository.SignupRepositoryImpl
import com.tht.tht.data.repository.TokenRepositoryImpl
import com.tht.tht.data.repository.UserSettingRepositoryImpl
import com.tht.tht.domain.chat.repository.ChatRepository
import com.tht.tht.domain.dailyusercard.DailyUserCardRepository
import com.tht.tht.domain.email.repository.EmailRepository
import com.tht.tht.domain.image.ImageRepository
import com.tht.tht.domain.login.repository.LoginRepository
import com.tht.tht.domain.setting.repository.SettingRepository
import com.tht.tht.domain.setting.repository.UserSettingRepository
import com.tht.tht.domain.signup.repository.LocationRepository
import com.tht.tht.domain.signup.repository.RegionCodeRepository
import com.tht.tht.domain.signup.repository.SignupRepository
Expand Down Expand Up @@ -63,4 +65,7 @@ abstract class RepositoryModule {

@Binds
abstract fun bindSettingRepository(impl: SettingRepositoryImpl): SettingRepository

@Binds
abstract fun bindUserSettingRepository(impl: UserSettingRepositoryImpl): UserSettingRepository
}
7 changes: 7 additions & 0 deletions data/src/main/java/com/tht/tht/data/di/UseCaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import com.tht.tht.domain.image.UploadImageUseCase
import com.tht.tht.domain.login.repository.LoginRepository
import com.tht.tht.domain.login.usecase.LoginUseCase
import com.tht.tht.domain.setting.repository.SettingRepository
import com.tht.tht.domain.setting.repository.UserSettingRepository
import com.tht.tht.domain.setting.usecase.FetchAccountManageItemsUseCase
import com.tht.tht.domain.setting.usecase.FetchMyPageUserInfoUseCase
import com.tht.tht.domain.setting.usecase.FetchSettingManageItemsUseCase
import com.tht.tht.domain.signup.repository.LocationRepository
import com.tht.tht.domain.signup.repository.RegionCodeRepository
Expand Down Expand Up @@ -326,4 +328,9 @@ object UseCaseModule {
settingRepository: SettingRepository
): FetchAccountManageItemsUseCase =
FetchAccountManageItemsUseCase(settingRepository)

@Provides
fun provideFetchMyPageUserInfoUseCase(
userSettingRepository: UserSettingRepository
): FetchMyPageUserInfoUseCase = FetchMyPageUserInfoUseCase(userSettingRepository)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.tht.tht.data.remote.service.dailyusercard.DailyUserCardApiService
import com.tht.tht.data.remote.service.image.ImageService
import com.tht.tht.data.remote.service.image.ImageServiceImpl
import com.tht.tht.data.remote.service.location.RegionCodeApi
import com.tht.tht.data.remote.service.setting.MyPageUserInfoService
import com.tht.tht.data.remote.service.topic.DailyTopicApiService
import com.tht.tht.data.remote.service.user.AccessTokenRefreshService
import com.tht.tht.data.remote.service.user.UserBlockApiService
Expand Down Expand Up @@ -107,4 +108,10 @@ object ApiServiceModule {
fun provideUserDisActiveService(
@ThtAccessTokenRetrofit retrofit: Retrofit
): UserDisActiveService = retrofit.create(UserDisActiveService::class.java)

@Provides
@Singleton
fun provideMyPageUserInfoService(
@ThtAccessTokenRetrofit retrofit: Retrofit
): MyPageUserInfoService = retrofit.create(MyPageUserInfoService::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.tht.tht.data.remote.datasource.setting

import com.tht.tht.data.remote.response.setting.MyPageUserInfoResponse

interface UserSettingDataSource {
suspend fun fetchMyPageUserInfo(): MyPageUserInfoResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.tht.tht.data.remote.datasource.setting

import com.tht.tht.data.remote.mapper.toUnwrap
import com.tht.tht.data.remote.response.setting.MyPageUserInfoResponse
import com.tht.tht.data.remote.service.setting.MyPageUserInfoService
import javax.inject.Inject

class UserSettingDataSourceImpl @Inject constructor(
private val service: MyPageUserInfoService
) : UserSettingDataSource {

override suspend fun fetchMyPageUserInfo(): MyPageUserInfoResponse {
return service.fetchMyPageUserInfo().toUnwrap()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.tht.tht.data.remote.mapper

import com.tht.tht.data.remote.response.setting.MyPageUserInfoResponse
import com.tht.tht.domain.setting.model.MyPageUserInfoModel

fun MyPageUserInfoResponse.toModel(): MyPageUserInfoModel {
return MyPageUserInfoModel(
userUuid = userUuid,
username = username,
birth = "UnKnown",
gender = gender,
introduction = introduction,
preferredGender = preferGender,
height = tall,
smoke = smoking,
drink = drinking,
religion = religion,
userProfilePhotos = userProfilePhotos.map { it.toModel() },
idealTypeList = idealTypeList.map { it.toModel() },
interestsList = interestsList.map { it.toModel() }
)
}

fun MyPageUserInfoResponse.IdealType.toModel(): MyPageUserInfoModel.IdealType {
return MyPageUserInfoModel.IdealType(
emojiCode = emojiCode,
idx = idx,
name = name
)
}

fun MyPageUserInfoResponse.Interests.toModel(): MyPageUserInfoModel.Interests {
return MyPageUserInfoModel.Interests(
emojiCode = emojiCode,
idx = idx,
name = name
)
}

fun MyPageUserInfoResponse.UserProfilePhoto.toModel(): MyPageUserInfoModel.UserProfilePhoto {
return MyPageUserInfoModel.UserProfilePhoto(
priority = priority,
url = url
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.tht.tht.data.remote.response.setting

import com.google.gson.annotations.SerializedName

data class MyPageUserInfoResponse(
@SerializedName("address")
val address: String,
@SerializedName("age")
val age: Int,
@SerializedName("drinking")
val drinking: String,
@SerializedName("email")
val email: String,
@SerializedName("gender")
val gender: String,
@SerializedName("idealTypeList")
val idealTypeList: List<IdealType>,
@SerializedName("interestsList")
val interestsList: List<Interests>,
@SerializedName("introduction")
val introduction: String,
@SerializedName("phoneNumber")
val phoneNumber: String,
@SerializedName("prefer_gender")
val preferGender: String,
@SerializedName("religion")
val religion: String,
@SerializedName("smoking")
val smoking: String,
@SerializedName("tall")
val tall: Int,
@SerializedName("userProfilePhotos")
val userProfilePhotos: List<UserProfilePhoto>,
@SerializedName("userUuid")
val userUuid: String,
@SerializedName("username")
val username: String
) {
data class IdealType(
@SerializedName("emojiCode")
val emojiCode: String,
@SerializedName("idx")
val idx: Int,
@SerializedName("name")
val name: String
)

data class Interests(
@SerializedName("emojiCode")
val emojiCode: String,
@SerializedName("idx")
val idx: Int,
@SerializedName("name")
val name: String
)

data class UserProfilePhoto(
@SerializedName("priority")
val priority: Int,
@SerializedName("url")
val url: String
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tht.tht.data.remote.service.setting

import com.tht.tht.data.constant.THTApiConstant
import com.tht.tht.data.remote.response.base.ThtResponse
import com.tht.tht.data.remote.response.setting.MyPageUserInfoResponse
import retrofit2.http.GET

interface MyPageUserInfoService {
@GET(THTApiConstant.Setting.MY_PAGE)
suspend fun fetchMyPageUserInfo(): ThtResponse<MyPageUserInfoResponse>
}
Loading

0 comments on commit d39590b

Please sign in to comment.