Skip to content

Commit

Permalink
Merge pull request #378 from 6QuizOnTheBlock/and/feat#373-matching_gr…
Browse files Browse the repository at this point in the history
…oup_invite

And/feat#373 matching group invite
  • Loading branch information
TRASALBY authored May 19, 2024
2 parents 1cdf8b8 + 2783c2c commit 189094c
Show file tree
Hide file tree
Showing 19 changed files with 772 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.sixkids.model

import kotlinx.serialization.Serializable

@Serializable
data class MemberSimple(
val id: Long = 0L,
val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
object NetworkModule {

private const val BASE_URL = "https://k10d107.p.ssafy.io/api/"
private const val BASE_URL = "http://192.168.219.140:8080/api/"

@Qualifier
@Retention(AnnotationRetention.BINARY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ class OrganizationRepositoryImpl @Inject constructor(
override suspend fun tagGreeting(orgId: Long, memberId: Long): Int {
return organizationRemoteDataSource.tagGreeting(orgId, memberId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.sixkids.feature.signin.navigation.navigateSignIn
import com.sixkids.feature.signin.navigation.navigateSignUp
import com.sixkids.feature.signin.navigation.navigateSignUpPhoto
import com.sixkids.model.GroupType
import com.sixkids.model.MemberSimple
import com.sixkids.student.board.navigation.StudentBoardRoute
import com.sixkids.student.board.navigation.navigateStudentBoard
import com.sixkids.student.board.navigation.navigateStudentBoardDetail
Expand All @@ -33,6 +34,7 @@ import com.sixkids.student.navigation.navigatePopupToStudentChallengeHistory
import com.sixkids.student.navigation.navigateStudentChallengeHistory
import com.sixkids.student.navigation.navigateStudentGroupCreate
import com.sixkids.student.navigation.navigateStudentGroupJoin
import com.sixkids.student.navigation.navigateStudentMatchedGroupCreate
import com.sixkids.student.relay.navigation.RelayRoute
import com.sixkids.student.relay.navigation.navigateStudentRelayAnswer
import com.sixkids.student.relay.navigation.navigateStudentRelayCreate
Expand Down Expand Up @@ -275,6 +277,13 @@ class MainNavigator(
)
}

fun navigateStudentMatchedGroupCreate(challengeId: Long, members: List<MemberSimple>) {
navController.navigateStudentMatchedGroupCreate(
challengeId = challengeId,
members = members
)
}

fun navigateStudentGroupJoin(memberId: Long) {
navController.navigateStudentGroupJoin()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fun MainScreen(
studentChallengeNavGraph(
navigateChallengeDetail = navigator::navigateChallengeDetail,
navigateToCreateGroup = navigator::navigateStudentGroupCreate,
navigateToMatchedGroupCreate = navigator::navigateStudentMatchedGroupCreate,
navigateToJoinGroup = navigator::navigateStudentGroupJoin,
handleException = viewModel::handleException,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.sixkids.student.challeng.history
import androidx.paging.PagingData
import com.sixkids.model.Challenge
import com.sixkids.model.GroupType
import com.sixkids.model.MemberSimple
import com.sixkids.model.RunningChallengeByStudent
import com.sixkids.ui.base.SideEffect
import com.sixkids.ui.base.UiState
Expand All @@ -17,9 +18,17 @@ data class ChallengeHistoryState(
) : UiState

sealed interface ChallengeHistoryEffect : SideEffect {
data class NavigateToChallengeDetail(val challengeId: Long, val groupId: Long? = null) : ChallengeHistoryEffect
data class NavigateToCreateGroup(val challengeId: Long, val groupType: GroupType) : ChallengeHistoryEffect
data class NavigateToChallengeDetail(val challengeId: Long, val groupId: Long? = null) :
ChallengeHistoryEffect

data class NavigateToCreateGroup(val challengeId: Long, val groupType: GroupType) :
ChallengeHistoryEffect

data class NavigateToMathedGroupCreate(val challengeId: Long, val members: List<MemberSimple>) :
ChallengeHistoryEffect

data class NavigateToJoinGroup(val challengeId: Long) : ChallengeHistoryEffect
data object ShowGroupDialog : ChallengeHistoryEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : ChallengeHistoryEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) :
ChallengeHistoryEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.sixkids.designsystem.theme.Red
import com.sixkids.designsystem.theme.UlbanTheme
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.model.GroupType
import com.sixkids.model.MemberSimple
import com.sixkids.student.challeng.history.component.GroupParticipationDialog
import com.sixkids.student.challeng.history.component.UlbanStudentRunningChallengeAppBar
import com.sixkids.student.challenge.R
Expand All @@ -45,6 +46,7 @@ fun ChallengeRoute(
viewModel: ChallengeHistoryViewModel = hiltViewModel(),
navigateToDetail: (Long, Long?) -> Unit,
navigateToCreateGroup: (Long, GroupType) -> Unit,
navigateToMatchedGroupCreate: (Long, List<MemberSimple>) -> Unit,
navigateToJoinGroup: (Long) -> Unit,
handleException: (Throwable, () -> Unit) -> Unit
) {
Expand Down Expand Up @@ -81,6 +83,10 @@ fun ChallengeRoute(
)

is ChallengeHistoryEffect.NavigateToJoinGroup -> navigateToJoinGroup(sideEffect.challengeId)
is ChallengeHistoryEffect.NavigateToMathedGroupCreate -> navigateToMatchedGroupCreate(
sideEffect.challengeId,
sideEffect.members
)
}
}
}
Expand All @@ -89,6 +95,7 @@ fun ChallengeRoute(
uiState = uiState,
updateTotalCount = viewModel::updateTotalCount,
navigateToDetail = viewModel::navigateChallengeDetail,
navigateToMatchedGroupCrateOrJoin = viewModel::navigateToCrateOrJoinGroup,
showDialog = viewModel::showGroupDialog,
)

Expand All @@ -106,6 +113,7 @@ fun ChallengeHistoryScreen(
uiState: ChallengeHistoryState = ChallengeHistoryState(),
updateTotalCount: (Int) -> Unit = {},
navigateToDetail: (Long) -> Unit = {},
navigateToMatchedGroupCrateOrJoin: (Boolean) -> Unit = {},
showDialog: () -> Unit = {},
) {
val listState = rememberLazyListState()
Expand Down Expand Up @@ -139,7 +147,15 @@ fun ChallengeHistoryScreen(
bottomDescription = runningChallenge.content,
color = Red,
onClick = if (uiState.runningChallenge.createTime == null) {
showDialog
if (uiState.runningChallenge.type == GroupType.FREE) {
showDialog
} else {
{
navigateToMatchedGroupCrateOrJoin(
uiState.runningChallenge.leaderStatus ?: false
)
}
}
} else {
{}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,29 @@ class ChallengeHistoryViewModel @Inject constructor(
)
}

private fun navigateToMatchedGroupCreate(){
val runningChallenge = uiState.value.runningChallenge ?: return
postSideEffect(
ChallengeHistoryEffect.NavigateToMathedGroupCreate(
runningChallenge.challenge.id,
runningChallenge.memberNames
)
)
}

fun navigateToJoinGroup() = postSideEffect(
ChallengeHistoryEffect.NavigateToJoinGroup(organizationId)
)

fun updateTotalCount(totalCount: Int) {
intent { copy(totalChallengeCount = totalCount) }
}

fun navigateToCrateOrJoinGroup(leaderStatus: Boolean) {
if (leaderStatus) {
navigateToMatchedGroupCreate()
} else {
navigateToJoinGroup()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ fun UlbanStudentRunningChallengeAppBar(
text = teamDescription,
style = UlbanTypography.bodySmall
)
Text(
modifier = Modifier.padding(top = 12.dp),
text = runningTimeDescription,
style = UlbanTypography.titleSmall
)
// Text(
// modifier = Modifier.padding(top = 12.dp),
// text = runningTimeDescription,
// style = UlbanTypography.titleSmall
// )
}
},
color = color,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.sixkids.student.group.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.sixkids.designsystem.component.button.UlbanFilledButton
import com.sixkids.designsystem.theme.Cream
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.model.MemberSimple
import com.sixkids.student.challenge.R

@Composable
fun MatchedGroupWaiting(
leader: MemberSimple = MemberSimple(),
memberList: List<MemberSimple> = emptyList(),
waitingMemberList: List<MemberSimple> = emptyList(),
onDoneClick: () -> Unit = {},
onRemoveClick: (Long) -> Unit = {},
groupSize: Int = 0,
) {
Card(
modifier = Modifier
.padding(top = 16.dp)
.fillMaxWidth(),
shape = RoundedCornerShape(
topStart = 12.dp,
topEnd = 12.dp,
bottomStart = 0.dp,
bottomEnd = 0.dp
),
elevation = CardDefaults.cardElevation(16.dp),
colors = CardDefaults.cardColors(
containerColor = Cream
)
) {
val remainingMember = groupSize - memberList.size - 1
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text(
modifier = Modifier.padding(top = 16.dp),
text = if (remainingMember != 0) {
stringResource(R.string.need_to_waiting_friend_message, remainingMember)
} else {
stringResource(R.string.can_create_group)
},
style = UlbanTypography.bodyMedium
)

LazyRow(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
if (leader.id != 0L) {
item {
MemberIcon(
memberIconItem = MemberIconItem(
member = leader,
showX = false,
isActive = true
),
onRemoveClick = {}
)
}
}
items(memberList){
MemberIcon(
memberIconItem = MemberIconItem(
member = it,
showX = false,
isActive = true
),
onRemoveClick = onRemoveClick
)
}
items(waitingMemberList){
MemberIcon(
memberIconItem = MemberIconItem(
member = it,
showX = false,
isActive = false
)
)
}
}
UlbanFilledButton(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.done),
onClick = onDoneClick,
enabled = remainingMember == 0
)
}
}
}


@Preview(showBackground = true)
@Composable
fun MatchedGroupWaitingPreview() {
MatchedGroupWaiting(
leader = MemberSimple(
id = 1,
name = "leader",
photo = ""
),
waitingMemberList = List(4) {
MemberSimple(
id = it.toLong(),
name = "member $it",
photo = "",
)
},
groupSize = 5
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.sixkids.designsystem.theme.Cream
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.model.MemberSimple
import com.sixkids.designsystem.R as DesignSystemR
Expand Down Expand Up @@ -85,7 +85,9 @@ fun MemberIcon(
Text(
text = memberIconItem.member.name,
style = UlbanTypography.bodyMedium,
modifier = Modifier.padding(4.dp)
modifier = Modifier.padding(4.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sixkids.student.group.create
package com.sixkids.student.group.create.free

import com.sixkids.model.MemberSimple
import com.sixkids.ui.base.SideEffect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sixkids.student.group.create
package com.sixkids.student.group.create.free

import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sixkids.student.group.create
package com.sixkids.student.group.create.free

import android.Manifest
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.sixkids.student.group.create.matched

import com.sixkids.model.MemberSimple
import com.sixkids.ui.base.SideEffect
import com.sixkids.ui.base.UiState

data class MatchedCreateGroupState(
val isLoading: Boolean = false,
val isScanning: Boolean = false,
val foundMembers: List<MemberSimple> = emptyList(),
val showMembers: Array<MemberSimple?> = Array(5) { null },
val selectedMembers: List<MemberSimple> = emptyList(),
val waitingMembers: List<MemberSimple> = emptyList(),
val groupSize: Int = 0,
val leader: MemberSimple = MemberSimple(),
val roomKey: String = "",
) : UiState


sealed interface MatchedCreateGroupEffect : SideEffect {
data object NavigateToChallengeHistory :
MatchedCreateGroupEffect
data class HandleException(
val throwable: Throwable,
val retryAction: () -> Unit
) : MatchedCreateGroupEffect

}
Loading

0 comments on commit 189094c

Please sign in to comment.