Skip to content

Commit

Permalink
Merge pull request #32 from SEONGGYU96/feature/disable_matching_butto…
Browse files Browse the repository at this point in the history
…n_on_participants

feat: Set enable to matching button depending on whether admin or not
  • Loading branch information
ethan-223 authored Feb 22, 2021
2 parents de6c511 + f9706cf commit 8012f08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -42,13 +45,18 @@ class ManittoRoomViewModel @ViewModelInject constructor(
val members : LiveData<List<ManittoRoomMember>>
get() = _members

private val _isAdmin = MutableLiveData(false)
val isAdmin: LiveData<Boolean>
get() = _isAdmin

fun refreshManittoRoomInfo() {
roomRequest.getManittoRoomData(roomId, object: RoomRequest.GetManittoRoomCallback {
override fun onLoadManittoRoomData(manittoRoomData: ManittoRoomData) {
_roomName.value = manittoRoomData.roomName
_expiration.value = manittoRoomData.expiration
_members.value = manittoRoomData.members
_invitationCode = manittoRoomData.invitationCode
_isAdmin.value = userDataSource.getUserId() == manittoRoomData.creator.userId
}

override fun onFailed() {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_waiting_room.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@

<string name="waitingroom_cardview_title">참여자</string>
<string name="waitingroom_copy_invitation_code">참여 코드 복사</string>
<string name="waitingroom_notice_owner">방장 산타는 참여자가 다 모이면 하단 버튼을 눌러줘:)</string>
<string name="waitingroom_notice_admin">방장 산타는 참여자가 다 모이면 하단 버튼을 눌러줘:)</string>
<string name="waitingroom_notice_participant">참여자 산타는 방장 산타가 매칭하기를 누를 때까지 기다려줘:)</string>
<string name="waitingroom_bottombutton">마니또 랜덤 매칭하기</string>
<string name="manittoroom_description">오늘부터 %d일 후인 %d월 %d일\n%s %02d:%02d까지 진행되는 마니또</string>
<string name="waitingroom_snackbar_invitation_code">참여 코드가 복사되었습니다</string>
Expand Down

0 comments on commit 8012f08

Please sign in to comment.