From f9706cf48ca6579f98829f85b1140218d79b2b8c Mon Sep 17 00:00:00 2001 From: KIM SEONGGYU Date: Mon, 22 Feb 2021 15:14:04 +0900 Subject: [PATCH] feat: Set enable to matching button depending on whether admin or not --- .../santamanitto/room/manittoroom/ManittoRoomViewModel.kt | 8 ++++++++ app/src/main/res/layout/fragment_waiting_room.xml | 3 ++- app/src/main/res/values/strings.xml | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/sopt/santamanitto/room/manittoroom/ManittoRoomViewModel.kt b/app/src/main/java/org/sopt/santamanitto/room/manittoroom/ManittoRoomViewModel.kt index 9129f51f..4ad312b5 100644 --- a/app/src/main/java/org/sopt/santamanitto/room/manittoroom/ManittoRoomViewModel.kt +++ b/app/src/main/java/org/sopt/santamanitto/room/manittoroom/ManittoRoomViewModel.kt @@ -7,8 +7,11 @@ import org.sopt.santamanitto.NetworkViewModel import org.sopt.santamanitto.room.manittoroom.network.ManittoRoomData import org.sopt.santamanitto.room.manittoroom.network.ManittoRoomMember import org.sopt.santamanitto.room.network.RoomRequest +import org.sopt.santamanitto.user.data.source.UserDataSource +import javax.inject.Named class ManittoRoomViewModel @ViewModelInject constructor( + @Named("cached") private val userDataSource: UserDataSource, private val roomRequest: RoomRequest ): NetworkViewModel() { @@ -42,6 +45,10 @@ class ManittoRoomViewModel @ViewModelInject constructor( val members : LiveData> get() = _members + private val _isAdmin = MutableLiveData(false) + val isAdmin: LiveData + get() = _isAdmin + fun refreshManittoRoomInfo() { roomRequest.getManittoRoomData(roomId, object: RoomRequest.GetManittoRoomCallback { override fun onLoadManittoRoomData(manittoRoomData: ManittoRoomData) { @@ -49,6 +56,7 @@ class ManittoRoomViewModel @ViewModelInject constructor( _expiration.value = manittoRoomData.expiration _members.value = manittoRoomData.members _invitationCode = manittoRoomData.invitationCode + _isAdmin.value = userDataSource.getUserId() == manittoRoomData.creator.userId } override fun onFailed() { diff --git a/app/src/main/res/layout/fragment_waiting_room.xml b/app/src/main/res/layout/fragment_waiting_room.xml index 9fd1a241..8670e499 100644 --- a/app/src/main/res/layout/fragment_waiting_room.xml +++ b/app/src/main/res/layout/fragment_waiting_room.xml @@ -121,7 +121,7 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/padding_createmission_cardview_horizontal" android:layout_marginBottom="@dimen/margin_waitingroom_notice_bottom" - android:text="@string/waitingroom_notice_owner" + android:text="@{viewModel.isAdmin() ? @string/waitingroom_notice_admin : @string/waitingroom_notice_participant}" android:textSize="@dimen/size_waitingroom_notice" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -136,6 +136,7 @@ android:id="@+id/santabottombutton_waitingroom" android:layout_width="match_parent" android:layout_height="wrap_content" + android:enabled="@{viewModel.isAdmin()}" android:layout_marginHorizontal="@dimen/padding_entire" android:layout_marginBottom="@dimen/margin_bottombutton_bottom" android:text="@string/waitingroom_bottombutton" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f11a523c..1c95b6ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,7 +72,8 @@ 참여자 참여 코드 복사 - 방장 산타는 참여자가 다 모이면 하단 버튼을 눌러줘:) + 방장 산타는 참여자가 다 모이면 하단 버튼을 눌러줘:) + 참여자 산타는 방장 산타가 매칭하기를 누를 때까지 기다려줘:) 마니또 랜덤 매칭하기 오늘부터 %d일 후인 %d월 %d일\n%s %02d:%02d까지 진행되는 마니또 참여 코드가 복사되었습니다