Skip to content

Commit

Permalink
Merge pull request #369 from 6QuizOnTheBlock/and/feat#364-group_mapping
Browse files Browse the repository at this point in the history
And/feat#364 group mapping
  • Loading branch information
TRASALBY authored May 19, 2024
2 parents 3cf2d99 + 1b7d7fb commit e82b753
Show file tree
Hide file tree
Showing 22 changed files with 440 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
package com.sixkids.designsystem.component.checkbox

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.foundation.selection.selectable
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.sixkids.designsystem.theme.Blue
import com.sixkids.designsystem.theme.UlbanTypography

@Composable
fun TextCheckBox(
checked: Boolean = false,
onCheckedChange: (Boolean) -> Unit = {},
checkedColor: Color = Blue,
uncheckedColor: Color = Color.Black,
fun TextRadioButton(
selected: Boolean = false,
onClick: () -> Unit = { },
text: String = ""
) {
Row(
Modifier
.fillMaxWidth()
.selectable(
selected = selected,
onClick = onClick,
role = Role.RadioButton,
),
verticalAlignment = Alignment.CenterVertically
) {
// 익명 체크박스
Checkbox(
modifier = Modifier.scale(1.2f).requiredSize(30.dp),
checked = checked,
onCheckedChange = onCheckedChange,
colors = CheckboxDefaults.colors(
checkedColor = checkedColor,
uncheckedColor = uncheckedColor
)
RadioButton(
modifier = Modifier
.scale(1.2f)
.requiredSize(30.dp),
selected = selected,
onClick = null,
)
if(text.isNotEmpty()) {
Text(
Expand All @@ -50,7 +51,7 @@ fun TextCheckBox(
@Preview(showBackground = true)
@Composable
fun TextCheckBoxPreview() {
TextCheckBox(
text = "체크박스"
TextRadioButton(
text = "라디오버튼"
)
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package com.sixkids.designsystem.component.item

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
Expand Down Expand Up @@ -65,7 +61,9 @@ fun StudentSimpleCardItem(
)
Text(
text = name,
style = UlbanTypography.bodyMedium
style = UlbanTypography.bodyMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
if (score != null) {
Text(
Expand All @@ -92,4 +90,4 @@ fun StudentSimpleCardItemPreview() {
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.sixkids.model

data class GroupSimple(
val headCount: Int,
val leaderId: Int,
val leaderId: Long,
val students: List<Long>,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sixkids.data.api

import com.sixkids.data.model.response.GroupMatchingRoomResponse
import com.sixkids.data.model.response.GroupMatchingSuccessResponse
import com.sixkids.data.network.ApiResponse
import com.sixkids.data.network.ApiResult
import retrofit2.http.DELETE
Expand Down Expand Up @@ -36,4 +37,12 @@ interface GroupService {
suspend fun createGroup(
@Query("key") key: String,
): ApiResult<ApiResponse<Long>>

@GET("challenges/groups/matching")
suspend fun getMatchingGroup(
@Query("organizationId") organizationId: Long,
@Query("minCount") minCount: Int,
@Query("matchingType") matchingType: String,
@Query("members") members: List<Long>,
): ApiResult<ApiResponse<List<GroupMatchingSuccessResponse>>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ data class ChallengeCreateRequest(

data class GroupRequest(
val headCount: Int,
val leaderId: Int,
val leaderId: Long,
val students: List<Long>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sixkids.data.model.response

import com.sixkids.model.ChallengeGroup

data class GroupMatchingSuccessResponse(
val members: List<MemberSimpleResponse>,
val headCount: Int
)

internal fun GroupMatchingSuccessResponse.toModel(): ChallengeGroup =
ChallengeGroup(
headCount = headCount,
memberList = members.map { it.toModel() }
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ class GroupRepositoryImpl @Inject constructor(
groupDataSource.joinGroup(key, joinStatus)

override suspend fun createGroup(key: String): Long = groupDataSource.createGroup(key)

override suspend fun getMatchingGroup(
organizationId: Long,
minCount: Int,
matchingType: String,
members: List<Long>
) = groupDataSource.getMatchingGroup(organizationId, minCount, matchingType, members).map { it.toModel() }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sixkids.data.repository.group.remote

import com.sixkids.data.model.response.GroupMatchingRoomResponse
import com.sixkids.data.model.response.GroupMatchingSuccessResponse

interface GroupDataSource {
suspend fun createMatchingRoom(challengeId: Long): GroupMatchingRoomResponse
Expand All @@ -12,4 +13,11 @@ interface GroupDataSource {
suspend fun joinGroup(key: String, joinStatus: Boolean)

suspend fun createGroup(key: String): Long

suspend fun getMatchingGroup(
organizationId: Long,
minCount: Int,
matchingType: String,
members: List<Long>
): List<GroupMatchingSuccessResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.sixkids.data.repository.group.remote

import com.sixkids.data.api.GroupService
import com.sixkids.data.model.response.GroupMatchingRoomResponse
import com.sixkids.data.model.response.GroupMatchingSuccessResponse
import javax.inject.Inject

class GroupDataSourceImpl @Inject constructor(
Expand All @@ -21,4 +22,12 @@ class GroupDataSourceImpl @Inject constructor(

override suspend fun createGroup(key: String): Long =
groupService.createGroup(key).getOrThrow().data

override suspend fun getMatchingGroup(
organizationId: Long,
minCount: Int,
matchingType: String,
members: List<Long>
): List<GroupMatchingSuccessResponse> =
groupService.getMatchingGroup(organizationId, minCount, matchingType, members).getOrThrow().data
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sixkids.domain.repository

import com.sixkids.model.ChallengeGroup
import com.sixkids.model.MatchingRoom

interface GroupRepository {
Expand All @@ -12,4 +13,11 @@ interface GroupRepository {
suspend fun joinGroup(key: String, joinStatus: Boolean)

suspend fun createGroup(key: String): Long

suspend fun getMatchingGroup(
organizationId: Long,
minCount: Int,
matchingType: String,
members: List<Long>
): List<ChallengeGroup>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.sixkids.domain.usecase.group

import com.sixkids.domain.repository.GroupRepository
import javax.inject.Inject

class GetMatchingGroupUseCase @Inject constructor(
private val groupRepository: GroupRepository
) {
suspend operator fun invoke(
organizationId: Long,
minCount: Int,
matchingType: String,
members: List<Long>
) = runCatching {
groupRepository.getMatchingGroup(organizationId, minCount, matchingType, members)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ enum class ChallengeCreateStep {
INFO,
GROUP_TYPE,
MATCHING_TYPE,
CREATE,
MATCHING_SUCCESS,
RESULT,
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sixkids.designsystem.theme.UlbanTheme
import com.sixkids.model.ChallengeGroup
import com.sixkids.teacher.challenge.create.grouptype.GroupType
import com.sixkids.teacher.challenge.create.grouptype.GroupTypeRoute
import com.sixkids.teacher.challenge.create.info.InfoContentRoute
import com.sixkids.teacher.challenge.create.matching.GroupMatchingSettingRoute
import com.sixkids.teacher.challenge.create.matching.GroupMatchingSuccessRoute
import com.sixkids.teacher.challenge.create.matching.MatchingSource
import com.sixkids.teacher.challenge.create.matching.MatchingType
import com.sixkids.ui.SnackbarToken
import com.sixkids.ui.extension.collectWithLifecycle
import java.time.LocalDateTime
Expand Down Expand Up @@ -53,9 +58,13 @@ fun ChallengeCreateRoute(
updateEndTime = viewModel::updateEndTime,
updatePoint = viewModel::updatePoint,
updateCount = viewModel::updateCount,
updateMatchingMemberList = viewModel::updateMatchingMemberList,
updateMatchingType = viewModel::updateMatchingType,
updateGroupType = viewModel::updateGroupType,
updateGroupList = viewModel::updateGroupList,
onMoveNextStep = viewModel::moveNextStep,
onMovePrevStep = viewModel::movePrevStep,
onGetMatchingGroupList = viewModel::getMatchingGroupList,
onShowSnackbar = viewModel::onShowSnackbar,
createChallenge = viewModel::createChallenge,
)
Expand All @@ -71,7 +80,11 @@ fun ChallengeCreateScreen(
updatePoint: (String) -> Unit = {},
onShowSnackbar: (SnackbarToken) -> Unit = {},
updateCount: (String) -> Unit = {},
updateMatchingMemberList: (List<Long>) -> Unit = {},
updateMatchingType: (MatchingType) -> Unit = {},
updateGroupType: (GroupType) -> Unit = {},
updateGroupList: (List<ChallengeGroup>) -> Unit = {},
onGetMatchingGroupList: () -> (MatchingSource) = { MatchingSource() },
onMoveNextStep: () -> Unit = {},
onMovePrevStep: () -> Unit = {},
createChallenge: () -> Unit = {},
Expand Down Expand Up @@ -105,17 +118,27 @@ fun ChallengeCreateScreen(
ChallengeCreateStep.GROUP_TYPE -> GroupTypeRoute(
updateMinCount = updateCount,
updateGroupType = updateGroupType,
// moveNextStep = onMoveNextStep,
moveNextStep = {
onShowSnackbar(SnackbarToken("그룹 지정 로직은 미구현 입니다."))
},
moveNextStep = onMoveNextStep,
createChallenge = createChallenge,
onShowSnackbar = onShowSnackbar,
)

ChallengeCreateStep.MATCHING_TYPE -> TODO()
ChallengeCreateStep.CREATE -> TODO()
ChallengeCreateStep.RESULT -> TODO()
ChallengeCreateStep.MATCHING_TYPE -> GroupMatchingSettingRoute(
moveNextStep = onMoveNextStep,
onUpdateMatchingMemberList = updateMatchingMemberList,
onUpdateMatchingType = updateMatchingType,
onShowSnackbar = onShowSnackbar,
)

ChallengeCreateStep.MATCHING_SUCCESS -> GroupMatchingSuccessRoute(
onShowSnackbar = onShowSnackbar,
createChallenge = createChallenge,
updateGroupList = updateGroupList,
onGetMatchingGroupList = onGetMatchingGroupList,
)
else -> {

}
}
}

Expand Down
Loading

0 comments on commit e82b753

Please sign in to comment.