Skip to content

Commit

Permalink
[AN] 모임 UI 피드백 개선 (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinuemong authored Oct 10, 2024
1 parent 2a27660 commit 37f9a1e
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 214 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.presentation.ui.club.modify.bottom
package com.happy.friendogly.presentation.ui.club.common.bottom

import android.os.Bundle
import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ interface ClubDetailActionHandler {
fun closeDetail()

fun openMenu()

fun openSelectState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.happy.friendogly.presentation.dialog.PetAddAlertDialog
import com.happy.friendogly.presentation.ui.chatlist.chat.ChatActivity
import com.happy.friendogly.presentation.ui.club.common.ClubChangeStateIntent
import com.happy.friendogly.presentation.ui.club.common.MessageHandler
import com.happy.friendogly.presentation.ui.club.common.bottom.ClubRecruitmentBottomSheet
import com.happy.friendogly.presentation.ui.club.common.handleError
import com.happy.friendogly.presentation.ui.club.common.model.clubfilter.ClubFilter
import com.happy.friendogly.presentation.ui.club.detail.adapter.DetailProfileAdapter
Expand Down Expand Up @@ -136,6 +137,9 @@ class ClubDetailActivity :
}

ClubDetailEvent.Navigation.NavigateToRegisterPet -> openRegisterPetDialog()

ClubDetailEvent.Navigation.NavigateSelectState -> openSelectState()
ClubDetailEvent.SaveReLoadState -> putLoadState()
}
}

Expand Down Expand Up @@ -178,6 +182,14 @@ class ClubDetailActivity :
)
}

private fun openSelectState() {
val bottomSheet =
ClubRecruitmentBottomSheet { state ->
viewModel.submitClubStateModify(state)
}
bottomSheet.show(supportFragmentManager, "TAG")
}

private fun openDogSelector(filters: List<ClubFilter>) {
val bottomSheet =
PetSelectBottomSheet(filters = filters) { dogs ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.happy.friendogly.presentation.ui.club.detail

import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter
Expand Down Expand Up @@ -47,7 +48,14 @@ fun TextView.bindDetailViewTypeStyle(clubDetailViewType: ClubDetailViewType?) {
ClubDetailViewType.RECRUITMENT,
ClubDetailViewType.MINE,
-> R.style.Theme_AppCompat_TextView_SemiBold_White_Size14

ClubDetailViewType.END_RECRUITMENT -> R.style.Theme_AppCompat_TextView_SemiBold_Gray07_Size14
}
this.setTextAppearance(textStyle)
}

@BindingAdapter("detailViewClubModifyVisible")
fun View.bindDetailViewClubModifyVisible(clubDetailViewType: ClubDetailViewType?) {
clubDetailViewType ?: return
this.visibility = if (clubDetailViewType == ClubDetailViewType.MINE) View.VISIBLE else View.GONE
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ sealed interface ClubDetailEvent {

data class OpenDetailMenu(val clubDetailViewType: ClubDetailViewType) : ClubDetailEvent

data object SaveReLoadState : ClubDetailEvent

sealed interface Navigation : ClubDetailEvent {
data class NavigateToChat(val chatRoomId: Long) : Navigation

data object NavigateToHome : Navigation

data object NavigateToRegisterPet : Navigation

data object NavigateSelectState : Navigation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.happy.friendogly.domain.fold
import com.happy.friendogly.domain.model.ClubState
import com.happy.friendogly.domain.usecase.GetClubUseCase
import com.happy.friendogly.domain.usecase.PatchClubUseCase
import com.happy.friendogly.domain.usecase.PostClubMemberUseCase
import com.happy.friendogly.firebase.analytics.AnalyticsHelper
import com.happy.friendogly.presentation.base.BaseViewModel
Expand All @@ -26,6 +28,7 @@ class ClubDetailViewModel
private val analyticsHelper: AnalyticsHelper,
private val getClubUseCase: GetClubUseCase,
private val postClubMemberUseCase: PostClubMemberUseCase,
private val patchClubUseCase: PatchClubUseCase,
) : BaseViewModel(), ClubDetailActionHandler {
val clubErrorHandler = ClubErrorHandler()

Expand Down Expand Up @@ -75,6 +78,10 @@ class ClubDetailViewModel
_clubDetailEvent.emit(ClubDetailEvent.OpenDetailMenu(detailViewType))
}

override fun openSelectState() {
_clubDetailEvent.emit(ClubDetailEvent.Navigation.NavigateSelectState)
}

fun joinClub(dogs: List<Long>) =
viewModelScope.launch {
analyticsHelper.logParticipateClick()
Expand All @@ -96,6 +103,25 @@ class ClubDetailViewModel
)
}

fun submitClubStateModify(newState: ClubState) =
viewModelScope.launch {
val club = club.value ?: return@launch
patchClubUseCase(
clubId = club.clubId,
title = club.title,
content = club.content,
state = newState,
).fold(
onSuccess = {
_club.value = club.copy(clubState = newState)
_clubDetailEvent.emit(ClubDetailEvent.SaveReLoadState)
},
onError = { error ->
clubErrorHandler.handle(error)
},
)
}

private fun requireRegisterUserPet() {
_clubDetailEvent.emit(ClubDetailEvent.Navigation.NavigateToRegisterPet)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fun TextView.bindMyLocation(userAddress: UserAddress?) {
}

@BindingAdapter("clubStateTextStyle")
fun TextView.bindClubStateTextStyle(clubState: ClubState) {
fun TextView.bindClubStateTextStyle(clubState: ClubState?) {
clubState ?: return
val textStyle =
when (clubState) {
ClubState.OPEN -> context.getColor(R.color.coral500)
Expand All @@ -48,7 +49,8 @@ fun TextView.bindClubStateTextStyle(clubState: ClubState) {
}

@BindingAdapter("clubStateText")
fun TextView.bindClubStateText(clubState: ClubState) {
fun TextView.bindClubStateText(clubState: ClubState?) {
clubState ?: return
this.text =
when (clubState) {
ClubState.OPEN -> context.getString(R.string.club_state_open)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import com.happy.friendogly.databinding.ActivityClubModifyBinding
import com.happy.friendogly.presentation.base.BaseActivity
import com.happy.friendogly.presentation.base.observeEvent
import com.happy.friendogly.presentation.ui.club.common.MessageHandler
import com.happy.friendogly.presentation.ui.club.common.bottom.ClubRecruitmentBottomSheet
import com.happy.friendogly.presentation.ui.club.common.handleError
import com.happy.friendogly.presentation.ui.club.modify.bottom.ClubRecruitmentBottomSheet
import com.happy.friendogly.presentation.utils.customOnFocusChangeListener
import com.happy.friendogly.presentation.utils.hideKeyboard
import com.happy.friendogly.presentation.utils.intentSerializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import com.happy.friendogly.R
import com.happy.friendogly.domain.model.ClubState

@BindingAdapter("selectModifyStateBackground")
fun View.bindSelectModifyStateBackground(clubState: ClubState) {
fun View.bindSelectModifyStateBackground(clubState: ClubState?) {
clubState ?: return
val backgroundTint =
if (clubState == ClubState.FULL) {
ContextCompat.getColorStateList(
Expand All @@ -26,7 +27,8 @@ fun View.bindSelectModifyStateBackground(clubState: ClubState) {
}

@BindingAdapter("selectModifyStateTypeStyle")
fun TextView.bindSelectModifyStateTypeStyle(clubState: ClubState) {
fun TextView.bindSelectModifyStateTypeStyle(clubState: ClubState?) {
clubState ?: return
val textStyle =
if (clubState == ClubState.FULL) {
R.style.Theme_AppCompat_TextView_SemiBold_Gray07_Size14
Expand All @@ -37,7 +39,8 @@ fun TextView.bindSelectModifyStateTypeStyle(clubState: ClubState) {
}

@BindingAdapter("selectModifyStateImageTint")
fun ImageView.bindSelectModifyStateImageTint(clubState: ClubState) {
fun ImageView.bindSelectModifyStateImageTint(clubState: ClubState?) {
clubState ?: return
val backgroundTint =
if (clubState == ClubState.FULL) {
ContextCompat.getColorStateList(
Expand Down
Loading

0 comments on commit 37f9a1e

Please sign in to comment.