Skip to content

Commit

Permalink
[chore] : reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
ham2174 committed Feb 12, 2024
1 parent 8e4a28e commit 0dd9b3c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ import androidx.compose.ui.res.painterResource
import com.moya.funch.icon.FunchIconAsset

@Composable
fun jobPainter(value: String): Painter =
when (value) {
"개발자" -> painterResource(id = FunchIconAsset.Job.developer_24)
"디자이너" -> painterResource(id = FunchIconAsset.Job.designer_24)
else -> throw IllegalArgumentException("Unknown Icon: $value")
}
fun jobPainter(value: String): Painter = when (value) {
"개발자" -> painterResource(id = FunchIconAsset.Job.developer_24)
"디자이너" -> painterResource(id = FunchIconAsset.Job.designer_24)
else -> throw IllegalArgumentException("Unknown Icon: $value")
}

@Composable
fun clubPainter(value: String): Painter =
when (value) {
"넥스터즈" -> painterResource(id = FunchIconAsset.Club.nexters_24)
"SOPT" -> painterResource(id = FunchIconAsset.Club.sopt_24)
"Depromeet" -> painterResource(id = FunchIconAsset.Club.depromeet_24)
else -> throw IllegalArgumentException("Unknown Icon: $value")
}
fun clubPainter(value: String): Painter = when (value) {
"넥스터즈" -> painterResource(id = FunchIconAsset.Club.nexters_24)
"SOPT" -> painterResource(id = FunchIconAsset.Club.sopt_24)
"Depromeet" -> painterResource(id = FunchIconAsset.Club.depromeet_24)
else -> throw IllegalArgumentException("Unknown Icon: $value")
}

@Composable
fun subwayLinePainter(value: String): Painter = // @Gun Hyung TODO : 신림역부터 도메인 Entity 추가 되는데로 수정
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import com.moya.funch.theme.FunchTheme
import com.moya.funch.theme.Gray400

@Composable
fun FunchSmallLabel(
modifier: Modifier = Modifier,
text: String
) {
fun FunchSmallLabel(modifier: Modifier = Modifier, text: String) {
Box(
modifier = Modifier
.width(52.dp)
Expand All @@ -31,10 +28,7 @@ fun FunchSmallLabel(
}

@Composable
fun FunchLargeLabel(
modifier: Modifier = Modifier,
text: String
) {
fun FunchLargeLabel(modifier: Modifier = Modifier, text: String) {
Box(
modifier = modifier
.width(52.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import com.moya.funch.entity.SubwayStation
import com.moya.funch.entity.profile.Profile
import com.moya.funch.uimodel.MbtiItem
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import javax.inject.Inject

data class MbtiState(
val eOrI: MbtiItem = MbtiItem.E,
Expand All @@ -25,13 +25,13 @@ data class MbtiState(

@HiltViewModel
internal class CreateProfileViewModel @Inject constructor(
//private val createUserProfileUseCase: CreateUserProfileUseCase
// private val createUserProfileUseCase: CreateUserProfileUseCase
) : ViewModel() {

private val _profile = MutableStateFlow(Profile())
val profile = _profile.asStateFlow()

private val _mbtiState = MutableStateFlow(MbtiState())
private val mbtiState = MutableStateFlow(MbtiState())

fun setNickname(nickname: String) {
_profile.value = _profile.value.copy(name = nickname)
Expand All @@ -54,32 +54,32 @@ internal class CreateProfileViewModel @Inject constructor(
fun setMbti(item: MbtiItem) {
viewModelScope.launch {
when (item) {
MbtiItem.E, MbtiItem.I -> _mbtiState.update { uiModel -> uiModel.copy(eOrI = item) }
MbtiItem.N, MbtiItem.S -> _mbtiState.update { uiModel -> uiModel.copy(nOrS = item) }
MbtiItem.T, MbtiItem.F -> _mbtiState.update { uiModel -> uiModel.copy(tOrF = item) }
MbtiItem.J, MbtiItem.P -> _mbtiState.update { uiModel -> uiModel.copy(jOrP = item) }
MbtiItem.E, MbtiItem.I -> mbtiState.update { uiModel -> uiModel.copy(eOrI = item) }
MbtiItem.N, MbtiItem.S -> mbtiState.update { uiModel -> uiModel.copy(nOrS = item) }
MbtiItem.T, MbtiItem.F -> mbtiState.update { uiModel -> uiModel.copy(tOrF = item) }
MbtiItem.J, MbtiItem.P -> mbtiState.update { uiModel -> uiModel.copy(jOrP = item) }
}
_profile.value = _profile.value.copy(
mbti = Mbti.valueOf(
_mbtiState.value.eOrI.name +
_mbtiState.value.nOrS.name +
_mbtiState.value.tOrF.name +
_mbtiState.value.jOrP.name
mbtiState.value.eOrI.name +
mbtiState.value.nOrS.name +
mbtiState.value.tOrF.name +
mbtiState.value.jOrP.name
)
)
}
}

fun isSelectMbti(mbtiItem: MbtiItem): Boolean {
return when (mbtiItem) {
MbtiItem.E -> _mbtiState.value.eOrI == MbtiItem.E
MbtiItem.I -> _mbtiState.value.eOrI == MbtiItem.I
MbtiItem.N -> _mbtiState.value.nOrS == MbtiItem.N
MbtiItem.S -> _mbtiState.value.nOrS == MbtiItem.S
MbtiItem.T -> _mbtiState.value.tOrF == MbtiItem.T
MbtiItem.F -> _mbtiState.value.tOrF == MbtiItem.F
MbtiItem.J -> _mbtiState.value.jOrP == MbtiItem.J
MbtiItem.P -> _mbtiState.value.jOrP == MbtiItem.P
MbtiItem.E -> mbtiState.value.eOrI == MbtiItem.E
MbtiItem.I -> mbtiState.value.eOrI == MbtiItem.I
MbtiItem.N -> mbtiState.value.nOrS == MbtiItem.N
MbtiItem.S -> mbtiState.value.nOrS == MbtiItem.S
MbtiItem.T -> mbtiState.value.tOrF == MbtiItem.T
MbtiItem.F -> mbtiState.value.tOrF == MbtiItem.F
MbtiItem.J -> mbtiState.value.jOrP == MbtiItem.J
MbtiItem.P -> mbtiState.value.jOrP == MbtiItem.P
}
}

Expand Down Expand Up @@ -110,7 +110,6 @@ internal class CreateProfileViewModel @Inject constructor(
}*/
}
}

}

private fun <T> List<T>.toggleElement(element: T): List<T> {
Expand Down
49 changes: 12 additions & 37 deletions feature/profile/src/main/java/com/moya/funch/CreateProflieScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ import com.moya.funch.uimodel.MbtiItem
import com.moya.funch.uimodel.ProfileLabel

@Composable
internal fun CreateProfileRoute(
onNavigateToHome: () -> Unit,
viewModel: CreateProfileViewModel = hiltViewModel()
) {
internal fun CreateProfileRoute(onNavigateToHome: () -> Unit, viewModel: CreateProfileViewModel = hiltViewModel()) {
val profile by viewModel.profile.collectAsStateWithLifecycle()

CreateProfileScreen(
Expand Down Expand Up @@ -106,7 +103,7 @@ fun CreateProfileScreen(
onNicknameChange: (String) -> Unit,
onSubwayStationChange: (String) -> Unit,
onNavigateToHome: () -> Unit,
onSendFeedback: () -> Unit,
onSendFeedback: () -> Unit
) {
val scrollState = rememberScrollState()
val backgroundColor = LocalBackgroundTheme.current.color
Expand All @@ -129,7 +126,7 @@ fun CreateProfileScreen(
)
}
},
containerColor = backgroundColor,
containerColor = backgroundColor
) { padding ->
Column(
modifier = Modifier
Expand Down Expand Up @@ -186,11 +183,7 @@ fun CreateProfileScreen(
private const val MAX_NICKNAME_LENGTH = 9

@Composable
private fun NicknameRow(
nickname: String,
onNicknameChange: (String) -> Unit,
isKeyboardVisible: (Boolean) -> Unit,
) {
private fun NicknameRow(nickname: String, onNicknameChange: (String) -> Unit, isKeyboardVisible: (Boolean) -> Unit) {
var isNicknameError by remember { mutableStateOf(false) }
val interactionSource = remember { MutableInteractionSource() }
val isFocused by interactionSource.collectIsFocusedAsState()
Expand Down Expand Up @@ -237,10 +230,7 @@ private fun NicknameRow(

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun JobRow(
profile: Profile,
onSelected: (Job) -> Unit
) {
private fun JobRow(profile: Profile, onSelected: (Job) -> Unit) {
Row {
FunchSmallLabel(text = "직군")
FlowRow(
Expand Down Expand Up @@ -286,9 +276,7 @@ private fun JobRow(

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun ClubRow(
onSelectClub: (Club) -> Unit
) {
private fun ClubRow(onSelectClub: (Club) -> Unit) {
Row {
FunchSmallLabel(text = "동아리")
FlowRow(
Expand Down Expand Up @@ -337,10 +325,7 @@ private fun ClubRow(
}

@Composable
private fun MbtiRow(
onSelectMbti: (MbtiItem) -> Unit,
isSelectMbti: (MbtiItem) -> Boolean,
) {
private fun MbtiRow(onSelectMbti: (MbtiItem) -> Unit, isSelectMbti: (MbtiItem) -> Boolean) {
val mbtiList = MbtiItem.entries.chunked(2)

Row {
Expand Down Expand Up @@ -371,11 +356,7 @@ private fun MbtiRow(
}

@Composable
private fun MbtiButton(
mbtiItem: MbtiItem,
isSelected: Boolean,
onSelected: (MbtiItem) -> Unit
) {
private fun MbtiButton(mbtiItem: MbtiItem, isSelected: Boolean, onSelected: (MbtiItem) -> Unit) {
Box(
modifier = Modifier
.size(48.dp)
Expand All @@ -389,7 +370,7 @@ private fun MbtiButton(
interactionSource = remember { MutableInteractionSource() },
indication = null
),
contentAlignment = Alignment.Center,
contentAlignment = Alignment.Center
) {
Text(
text = mbtiItem.name,
Expand All @@ -400,9 +381,7 @@ private fun MbtiButton(
}

@Composable
private fun BooldTypeRow(
onSelectBloodType: (Blood) -> Unit
) {
private fun BooldTypeRow(onSelectBloodType: (Blood) -> Unit) {
val bloodTypes = Blood.entries.filterNot { it == Blood.IDLE }.map { it.type }
var placeHolder by remember { mutableStateOf(bloodTypes[0]) }
var isDropDownMenuExpanded by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -439,7 +418,7 @@ private fun BooldTypeRow(
private fun SubwayRow(
subwayStation: String,
onSubwayStationChange: (String) -> Unit,
isKeyboardVisible: (Boolean) -> Unit,
isKeyboardVisible: (Boolean) -> Unit
) {
val isError by remember { mutableStateOf(false) }
val interactionSource = remember { MutableInteractionSource() }
Expand Down Expand Up @@ -478,11 +457,7 @@ private fun SubwayRow(
}

@Composable
private fun BottomBar(
backgroundColor: Color,
isCreateProfile: Boolean,
onNavigateToHome: () -> Unit
) {
private fun BottomBar(backgroundColor: Color, isCreateProfile: Boolean, onNavigateToHome: () -> Unit) {
Box(
modifier = Modifier
.background(color = backgroundColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.moya.funch.CreateProfileRoute
import com.moya.funch.CreateProfileScreen
import com.moya.funch.MyProfileRoute

const val PROFILE_GRAPH_ROUTE = "profile_graph"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.moya.funch.uimodel

enum class MbtiItem {
E, I,
N, S,
T, F,
J, P
E,
I,
N,
S,
T,
F,
J,
P
}

0 comments on commit 0dd9b3c

Please sign in to comment.