Skip to content

Commit

Permalink
style: 코드 포맷 수정 & 린트 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
jinuemong committed Aug 20, 2024
1 parent 5e250dc commit f1e2df0
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ class ClubRepositoryImpl(
).mapCatching { it.toDomain() }

override suspend fun deleteClubMember(clubId: Long): Result<Unit> = source.deleteClubMember(clubId)

override suspend fun patchClub(
clubId: Long,
title: String,
content: String,
state: ClubState
): Result<Unit> =
state: ClubState,
): Result<Unit> =
source.patchClub(
clubId = clubId,
title = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ClubDataSource {

suspend fun patchClub(
clubId: Long,
title : String,
title: String,
content: String,
state: ClubStateDto,
): Result<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class PatchClubUseCase(private val repository: ClubRepository) {
title: String,
content: String,
state: ClubState,
): Result<Unit> = repository.patchClub(
clubId = clubId,
title = title,
content = content,
state = state,
)
): Result<Unit> =
repository.patchClub(
clubId = clubId,
title = title,
content = content,
state = state,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ fun TextView.bindClubStateTextStyle(clubState: ClubState) {
}

@BindingAdapter("clubStateText")
fun TextView.bindClubStateText(clubState: ClubState){
this.text = when(clubState){
ClubState.OPEN -> context.getString(R.string.club_state_open)
ClubState.CLOSED -> context.getString(R.string.club_state_closed)
ClubState.FULL -> context.getString(R.string.club_state_full)
}
fun TextView.bindClubStateText(clubState: ClubState) {
this.text =
when (clubState) {
ClubState.OPEN -> context.getString(R.string.club_state_open)
ClubState.CLOSED -> context.getString(R.string.club_state_closed)
ClubState.FULL -> context.getString(R.string.club_state_full)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.happy.friendogly.presentation.ui.club.modify

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
Expand All @@ -12,17 +11,16 @@ import com.happy.friendogly.presentation.base.BaseViewModel
import com.happy.friendogly.presentation.base.BaseViewModelFactory
import com.happy.friendogly.presentation.base.Event
import com.happy.friendogly.presentation.base.emit
import com.happy.friendogly.presentation.ui.club.menu.ClubMenuViewModel
import com.happy.friendogly.presentation.utils.addSourceList
import kotlinx.coroutines.launch

class ClubModifyViewModel(
private val patchClubUseCase: PatchClubUseCase,
): BaseViewModel(), ClubModifyActionHandler {
) : BaseViewModel(), ClubModifyActionHandler {
private val _modifyEvent: MutableLiveData<Event<ClubModifyEvent>> = MutableLiveData()
val modifyEvent: LiveData<Event<ClubModifyEvent>> get() = _modifyEvent

private var clubId: Long ?= null
private var clubId: Long? = null

private val _clubState: MutableLiveData<ClubState> = MutableLiveData(null)
val clubState: LiveData<ClubState> get() = _clubState
Expand Down Expand Up @@ -74,20 +72,21 @@ class ClubModifyViewModel(
submitClubModify()
}

private fun submitClubModify() = viewModelScope.launch{
patchClubUseCase(
clubId = clubId ?: return@launch,
title = clubTitle.value ?: return@launch,
content = clubContent.value ?: return@launch,
state = clubState.value ?: return@launch,
)
.onSuccess {
_modifyEvent.emit(ClubModifyEvent.Navigation.NavigateSubmit)
}
.onFailure {
_modifyEvent.emit(ClubModifyEvent.FailModify)
}
}
private fun submitClubModify() =
viewModelScope.launch {
patchClubUseCase(
clubId = clubId ?: return@launch,
title = clubTitle.value ?: return@launch,
content = clubContent.value ?: return@launch,
state = clubState.value ?: return@launch,
)
.onSuccess {
_modifyEvent.emit(ClubModifyEvent.Navigation.NavigateSubmit)
}
.onFailure {
_modifyEvent.emit(ClubModifyEvent.FailModify)
}
}

override fun openSelectState() {
if (isValidModifyState()) {
Expand All @@ -103,7 +102,7 @@ class ClubModifyViewModel(
fun factory(patchClubUseCase: PatchClubUseCase): ViewModelProvider.Factory {
return BaseViewModelFactory {
ClubModifyViewModel(
patchClubUseCase= patchClubUseCase,
patchClubUseCase = patchClubUseCase,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ interface ClubService {
suspend fun patchClub(
@Path("clubId") clubId: Long,
@Body request: ClubModifyRequest,
):BaseResponse<Unit>
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ class ClubDataSourceImpl(private val service: ClubService) : ClubDataSource {
clubId: Long,
title: String,
content: String,
state: ClubStateDto
state: ClubStateDto,
): Result<Unit> =
runCatching {
val request = ClubModifyRequest(
title = title,
content = content,
status = state.toRemote(),
)
val request =
ClubModifyRequest(
title = title,
content = content,
status = state.toRemote(),
)
service.patchClub(
clubId = clubId,
request = request,
)
}

}

0 comments on commit f1e2df0

Please sign in to comment.