Skip to content

Commit

Permalink
fix #11 - 실행 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyyho committed Dec 17, 2024
1 parent 1b2f1c7 commit 949ccfc
Show file tree
Hide file tree
Showing 30 changed files with 514 additions and 279 deletions.
18 changes: 18 additions & 0 deletions app/src/main/java/org/sopt/and/core/ContentType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.and.core

import androidx.annotation.StringRes
import org.sopt.and.R

enum class ContentType(
@StringRes val titleResId: Int
) {
NEW_CLASSIC(R.string.type_new_classic),
DRAMA(R.string.type_drama),
ENTERTAINMENT(R.string.type_entertainment),
MOVIE(R.string.type_movie),
ANIMATION(R.string.type_animation),
ABROAD_SERIES(R.string.type_abroad_series),
INFORMATION_CULTURE(R.string.type_information_culture),
KIDS(R.string.type_kids),
MOVIE_PLUS(R.string.type_movie_plus),
}
41 changes: 41 additions & 0 deletions app/src/main/java/org/sopt/and/core/component/CloseTopBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.sopt.and.core.component

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.sp
import org.sopt.and.R
import org.sopt.and.ui.theme.WavveBg

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CloseTopBar(
title: String,
onCloseClicked: () -> Unit) {
CenterAlignedTopAppBar(
title = {
Text(text = title, fontSize = 20.sp)
},
actions = {
IconButton(onClick = onCloseClicked) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = stringResource(R.string.close_top_bar_icon_description_close),
tint = White
)
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = WavveBg,
titleContentColor = White
)
)
}
44 changes: 44 additions & 0 deletions app/src/main/java/org/sopt/and/core/component/HomeTobBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.sopt.and.core.component

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import org.sopt.and.R
import org.sopt.and.ui.theme.WavveBg


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeTopBar(
onLiveButtonClick: () -> Unit
) {
TopAppBar(
title = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.wavve_logo),
contentDescription = stringResource(R.string.back_button_top_bar_icon_description_logo),
tint = White
)
},
actions = {
IconButton(onClick = onLiveButtonClick) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_cast_24),
contentDescription = stringResource(R.string.common_top_bar_icon_description_live),
tint = White
)
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = WavveBg,
titleContentColor = White
)
)
}
44 changes: 44 additions & 0 deletions app/src/main/java/org/sopt/and/core/component/HomeTopBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.sopt.and.core.component

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import org.sopt.and.R
import org.sopt.and.ui.theme.WavveBg


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeTopBar(
onLiveButtonClick: () -> Unit
) {
TopAppBar(
title = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.wavve_logo),
contentDescription = stringResource(R.string.back_button_top_bar_icon_description_logo),
tint = White
)
},
actions = {
IconButton(onClick = onLiveButtonClick) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_cast_24),
contentDescription = stringResource(R.string.common_top_bar_icon_description_live),
tint = White
)
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = WavveBg,
titleContentColor = White
)
)
}
8 changes: 8 additions & 0 deletions app/src/main/java/org/sopt/and/data/common/APICallType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.and.data.common


object APICallType {
const val REGISTER_USER = "registerUser"
const val LOGIN_USER = "loginUser"
const val GET_MY_HOBBY = "getMyHobby"
}

This file was deleted.

13 changes: 0 additions & 13 deletions app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt

This file was deleted.

13 changes: 0 additions & 13 deletions app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt

This file was deleted.

6 changes: 3 additions & 3 deletions app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.and.data.api.UserService
import org.sopt.and.data.datasource.MyHobbyDataSource
import org.sopt.and.data.datasource.SignInDataSource
import org.sopt.and.data.datasource.SignUpDataSource
import org.sopt.and.data.repositoryimpl.MyHobbyRepositoryImpl
import org.sopt.and.data.repositoryimpl.SignInRepositoryImpl
Expand All @@ -21,13 +21,13 @@ object RepositoryModule {

@Provides
@Singleton
fun provideUserRegisterRepository(userService: SignUpDataSource): SignUpRepository {
fun provideUserRegisterRepository(userService: UserService): SignUpRepository {
return SignUpRepositoryImpl(userService)
}

@Provides
@Singleton
fun provideUserLoginRepository(userService: SignInDataSource): SignInRepository {
fun provideUserLoginRepository(userService: UserService): SignInRepository {
return SignInRepositoryImpl(userService)
}

Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/org/sopt/and/data/mapper/ErrorMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sopt.and.data.mapper

import org.sopt.and.data.common.APICallType

object ErrorMapper {
private val errorMapByApi = mapOf(
APICallType.REGISTER_USER to mapOf(
Pair(400, "01") to "잘못된 요청입니다.",
Pair(400, "01") to "아이디, 비밀번호, 취미를 올바르게 입력해주세요.",
Pair(404, null) to "잘못된 요청입니다.",
Pair(409, "00") to "중복된 아이디입니다."
),
APICallType.LOGIN_USER to mapOf(
Pair(400, "01") to "비밀번호를 올바르게 입력해주세요.",
Pair(400, "02") to "비밀번호를 올바르게 입력해주세요.",
Pair(403, "01") to "아이디 혹은 비밀번호가 틀렸습니다.",
Pair(404, "00") to "잘못된 요청입니다."
),
APICallType.GET_MY_HOBBY to mapOf(
Pair(401, "00") to "잘못된 요청입니다.",
Pair(403, "00") to "잘못된 요청입니다.",
Pair(404, "00") to "잘못된 요청입니다."
),

)
fun getErrorMessage(apiName: String, statusCode: Int?, errorCode: String?): String {
val apiErrorMap = errorMapByApi[apiName]
val message = apiErrorMap?.get(Pair(statusCode, errorCode))

return message ?: "알 수 없는 에러"
}
}
23 changes: 14 additions & 9 deletions app/src/main/java/org/sopt/and/data/mapper/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.sopt.and.data.model.request.SignUpRequestDto
import org.sopt.and.data.model.response.MyHobbyResponseResultDto
import org.sopt.and.data.model.response.SignInResponseDto
import org.sopt.and.data.model.response.SignUpResponseDto
import org.sopt.and.domain.entity.UserData
import org.sopt.and.domain.model.MyHobbyEntity
import org.sopt.and.domain.model.SignInInformationEntity
import org.sopt.and.domain.model.SignInResponseEntity
Expand Down Expand Up @@ -34,14 +35,18 @@ object Mapper {
)
}

fun toSignInRequestDto(signInInformationEntity: SignInInformationEntity) = SignInRequestDto(
username = signInInformationEntity.username,
password = signInInformationEntity.password
fun UserData.toUserLoginRequestDto(): SignInRequestDto = SignInRequestDto(
username = this.username,
password = this.password
)

fun toSignUpRequestDto(signUpInformationEntity: SignUpInformationEntity) = SignUpRequestDto(
username = signUpInformationEntity.username,
password = signUpInformationEntity.password,
hobby = signUpInformationEntity.hobby
)
}
fun UserData.toRegisterRequestDto(): SignUpRequestDto {
return SignUpRequestDto(
username = this.username,
password = this.password,
hobby = this.hobby
)
}

}

25 changes: 25 additions & 0 deletions app/src/main/java/org/sopt/and/data/model/BaseResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.sopt.and.data.model

import kotlinx.serialization.Serializable
import org.sopt.and.domain.entity.BaseResult

@Serializable
sealed class BaseResponse<out T> {
data class Success<out T>(val data: T) : BaseResponse<T>()
data class Failure(
val statusCode: Int?,
val errorCode: String?,
val message: String
) : BaseResponse<Nothing>()
}
@Serializable
data class ErrorResponse(
val code: String
)

fun <T> BaseResponse<T>.toBaseResult(): BaseResult<T> {
return when (this) {
is BaseResponse.Success -> BaseResult.Success(this.data)
is BaseResponse.Failure -> BaseResult.Error(this.message, this.errorCode)
}
}
Loading

0 comments on commit 949ccfc

Please sign in to comment.