Skip to content

Commit

Permalink
Merge pull request #379 from 6QuizOnTheBlock/and/design#377-student_a…
Browse files Browse the repository at this point in the history
…pp_detail

And/design#377 student app detail
  • Loading branch information
ghddbwns9808 authored May 19, 2024
2 parents 149c26d + 7df6d6b commit a946e3b
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fun MainScreen(
navigateToStudentAnnounceDetail = navigator::navigateStudentAnnounceDetail,
navigateToTagHello = { },
navigateToRank = navigator::navigateRank,
navigateToChatting = navigator::navigateChatting,
navigateToChatting = navigator::navigateStudentChatting,
navigateBack = navigator::popBackStack,
navigateToGreetingSender = navigator::navigateGreetingSender,
navigateToGreetingReceiver = navigator::navigateGreetingReceiver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import com.sixkids.designsystem.theme.BlueDark
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.designsystem.R as UlbanRes

@Composable
fun CommentCount(
count: Int
) {
Row {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = ImageVector.vectorResource(id = UlbanRes.drawable.ic_chat_bubble),
contentDescription = null
contentDescription = null,
tint = BlueDark
)
Text(
text = count.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ fun PostItem(
text = title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = UlbanTypography.titleLarge
style = UlbanTypography.titleMedium
)
Spacer(modifier = Modifier.height(10.dp))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.Top
verticalAlignment = Alignment.CenterVertically
) {
if (commentCount > 0){
CommentCount(count = commentCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import com.sixkids.designsystem.component.appbar.UlbanDefaultAppBar
import com.sixkids.designsystem.R as UlbanRes
import com.sixkids.designsystem.component.appbar.UlbanDetailAppBar
import com.sixkids.designsystem.component.button.EditFAB
Expand Down Expand Up @@ -98,12 +99,11 @@ fun StudentBoardMainScreen(
Column(

) {
UlbanDetailAppBar(
UlbanDefaultAppBar(
leftIcon = UlbanRes.drawable.board,
title = stringResource(id = R.string.student_board_main_post),
content = stringResource(id = R.string.student_board_main_post),
topDescription = "",
bottomDescription = "",
body = postState.classString.replace("\n", " "),
color = Blue
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import com.sixkids.designsystem.component.appbar.UlbanDefaultAppBar
import com.sixkids.designsystem.component.appbar.UlbanDetailAppBar
import com.sixkids.designsystem.component.screen.LoadingScreen
import com.sixkids.designsystem.theme.Orange
Expand Down Expand Up @@ -84,15 +85,12 @@ fun StudentAnnounceListScreen(
modifier = modifier
.fillMaxSize()
) {
Column(

) {
UlbanDetailAppBar(
Column {
UlbanDefaultAppBar(
leftIcon = UlbanRes.drawable.announce,
title = stringResource(id = R.string.student_home_main_announce),
content = stringResource(id = R.string.student_home_main_announce),
topDescription = "",
bottomDescription = studentAnnounceListState.classString,
body = studentAnnounceListState.classString.replace("\n", " "),
color = Orange
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.sixkids.domain.usecase.organization.GetSelectedOrganizationIdUseCase
import com.sixkids.domain.usecase.organization.LoadSelectedOrganizationNameUseCase
import com.sixkids.domain.usecase.post.GetPostListUseCase
import com.sixkids.model.Post
import com.sixkids.model.PostCategory
Expand All @@ -16,7 +17,8 @@ import javax.inject.Inject
@HiltViewModel
class StudentAnnounceListViewModel @Inject constructor(
private val getPostListUseCase: GetPostListUseCase,
private val getSelectedOrganizationIdUseCase: GetSelectedOrganizationIdUseCase
private val getSelectedOrganizationIdUseCase: GetSelectedOrganizationIdUseCase,
private val loadSelectedOrganizationNameUseCase: LoadSelectedOrganizationNameUseCase
): BaseViewModel<StudentAnnounceListState, StudentAnnounceListEffect>(StudentAnnounceListState()){
private var organizationId: Int? = null

Expand All @@ -26,6 +28,12 @@ class StudentAnnounceListViewModel @Inject constructor(
viewModelScope.launch {
intent { copy(isLoding = true) }

loadSelectedOrganizationNameUseCase().onSuccess {
intent { copy(classString = it) }
}.onFailure {
intent { copy(classString = "") }
}

if (organizationId == null){
organizationId = getSelectedOrganizationIdUseCase().getOrNull()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import com.sixkids.designsystem.theme.OrangeText
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.designsystem.R as UlbanRes

@Composable
fun CommentCount(
count: Int
) {
Row {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = ImageVector.vectorResource(id = UlbanRes.drawable.ic_chat_bubble),
contentDescription = null
contentDescription = null,
tint = OrangeText
)
Text(
text = count.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ fun PostItem(
onClick: () -> Unit = {}
) {
Column(
modifier = modifier.clickable { onClick() }
modifier = modifier.padding(bottom = 8.dp).clickable { onClick() }
) {
Text(
text = title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = UlbanTypography.titleLarge
style = UlbanTypography.titleMedium
)
Spacer(modifier = Modifier.height(10.dp))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.Top
verticalAlignment = Alignment.CenterVertically
) {
if (commentCount > 0){
CommentCount(count = commentCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -62,7 +63,7 @@ fun StudentChattingRoute(
onBackClick: () -> Unit,
onShowSnackBar: (SnackbarToken) -> Unit
) {
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

viewModel.sideEffect.collectWithLifecycle { sideEffect ->
when (sideEffect) {
Expand Down Expand Up @@ -106,7 +107,7 @@ fun StudentChattingScreen(
Column {
TopSection(
uiState.organizationName,
uiState.memberCount, onBackClick
onBackClick
)

ChatSection(
Expand All @@ -132,7 +133,6 @@ fun StudentChattingScreen(
@Composable
fun TopSection(
organizationName: String = "",
memberCount: Int = 0,
onBackClick: () -> Unit = {}
) {
Row(
Expand All @@ -148,15 +148,11 @@ fun TopSection(
)

Text(
text = "구미 초등학교 3학년 1반",
text = organizationName.replace("\n", " "),
style = UlbanTypography.titleSmall,
modifier = Modifier.padding(10.dp, 0.dp)
)

Text(
text = "21",
style = UlbanTypography.titleSmall.copy(color = Gray),
)
}
}

Expand Down Expand Up @@ -323,11 +319,6 @@ fun InputSection(
.padding(6.dp),
verticalAlignment = Alignment.Bottom
) {
Icon(
painter = painterResource(id = R.drawable.ic_camera),
contentDescription = "photo",
modifier = Modifier.size(30.dp)
)

UlbanBasicTextField(
text = msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.sixkids.domain.usecase.chatting.GetChattingHistoryUseCase
import com.sixkids.domain.usecase.organization.GetSelectedOrganizationIdUseCase
import com.sixkids.domain.usecase.organization.LoadSelectedOrganizationNameUseCase
import com.sixkids.domain.usecase.user.GetATKUseCase
import com.sixkids.domain.usecase.user.LoadUserInfoUseCase
import com.sixkids.model.Chat
Expand Down Expand Up @@ -38,6 +39,7 @@ private const val TAG = "D107"
class StudentChattingViewModel @Inject constructor(
private val getATKUseCase: GetATKUseCase,
private val getSelectedOrganizationIdUseCase: GetSelectedOrganizationIdUseCase,
private val loadSelectedOrganizationNameUseCase: LoadSelectedOrganizationNameUseCase,
private val loadUserInfoUseCase: LoadUserInfoUseCase,
private val getChattingHistoryUseCase: GetChattingHistoryUseCase
) : BaseViewModel<StudentChattingState, StudentChattingSideEffect>(
Expand All @@ -58,6 +60,16 @@ class StudentChattingViewModel @Inject constructor(

var originalChatList: Flow<PagingData<Chat>>? = null

init {
viewModelScope.launch {
loadSelectedOrganizationNameUseCase().onSuccess {
Log.d(TAG, "initStomp1: $it")
intent { copy(organizationName = it) }
}.onFailure {
Log.d(TAG, "initStomp1: $it")
}
}
}
@SuppressLint("CheckResult")
fun initStomp() {
viewModelScope.launch {
Expand All @@ -67,8 +79,6 @@ class StudentChattingViewModel @Inject constructor(
originalChatList =
getChattingHistoryUseCase(roomId).cachedIn(viewModelScope)



} catch (e: Exception) {
Log.d(TAG, "initStomp: ${e.message}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sixkids.designsystem.component.item.StudentSimpleCardItem
import com.sixkids.designsystem.theme.Blue
import com.sixkids.designsystem.theme.BlueText
import com.sixkids.designsystem.theme.Orange
import com.sixkids.designsystem.theme.OrangeText
import com.sixkids.designsystem.theme.Purple
import com.sixkids.designsystem.theme.PurpleText
import com.sixkids.designsystem.theme.UlbanTypography
import com.sixkids.designsystem.theme.Yellow
import com.sixkids.designsystem.theme.YellowText
import com.sixkids.designsystem.theme.component.card.ContentVerticalCard
import com.sixkids.model.MemberSimple
import com.sixkids.model.MemberSimpleWithScore
Expand Down Expand Up @@ -112,20 +116,23 @@ fun StudentHomeMainScreen(
.fillMaxSize()
.padding(20.dp)
) {
Spacer(modifier = Modifier.height(10.dp))

StudentMainInfo(
name = studentHomeMainState.studentName,
imageUrlString = studentHomeMainState.studentImageUrl,
classString = studentHomeMainState.studentClass,
exp = studentHomeMainState.studentExp
)
Spacer(modifier = Modifier.height(20.dp))
Spacer(modifier = Modifier.weight(1f))
Row {
ContentVerticalCard(
cardModifier = Modifier
.weight(1f)
.aspectRatio(1f)
.padding(end = 10.dp),
cardColor = Orange,
textColor = OrangeText,
imageDrawable = UlbanRes.drawable.announce,
text = stringResource(id = R.string.student_home_main_announce),
onClick = announceCardOnClick
Expand All @@ -136,6 +143,7 @@ fun StudentHomeMainScreen(
.aspectRatio(1f)
.padding(start = 10.dp),
cardColor = Blue,
textColor = BlueText,
imageDrawable = UlbanRes.drawable.tag_hello,
text = stringResource(id = R.string.student_home_main_hi),
onClick = showGreetingDialog
Expand All @@ -144,7 +152,8 @@ fun StudentHomeMainScreen(
Spacer(modifier = Modifier.height(20.dp))
Text(
text = stringResource(id = R.string.student_home_main_best_friends),
style = UlbanTypography.bodyMedium
style = UlbanTypography.titleSmall,
modifier = Modifier.padding(start = 15.dp)
)
Spacer(modifier = Modifier.height(10.dp))
Row(
Expand Down Expand Up @@ -174,6 +183,7 @@ fun StudentHomeMainScreen(
.aspectRatio(1f)
.padding(end = 10.dp),
cardColor = Purple,
textColor = PurpleText,
imageDrawable = UlbanRes.drawable.chat,
text = stringResource(id = R.string.student_home_main_chatting),
onClick = chattingCardOnClick
Expand All @@ -184,11 +194,13 @@ fun StudentHomeMainScreen(
.aspectRatio(1f)
.padding(start = 10.dp),
cardColor = Yellow,
textColor = YellowText,
imageDrawable = UlbanRes.drawable.rank,
text = stringResource(id = R.string.student_home_main_rank),
onClick = rankCardOnClick
)
}
Spacer(modifier = Modifier.weight(1f))
}
}

Expand Down
Loading

0 comments on commit a946e3b

Please sign in to comment.