Skip to content

Commit

Permalink
feat: 미션 조회 관련 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Apr 24, 2024
1 parent 36bffab commit 2f92e3d
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ interface RestAPI {
@Query("size") size: Int?,
@Query("date") date: String?,
@Query("memberId") memberId: String?,
@Query("type") type: String? = null,
@Query("sort") sort: String? = "DESC",
): ApiResponse<Pagination<Post>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class GetFeedPageSource @Inject constructor(
date = arguments.get("date"),
memberId = arguments.get("memberId"),
page = loadParams.key ?: 1,
size = loadParams.loadSize
size = loadParams.loadSize,
type = null,
)
return posts.mapSuccess {
Pagination<MainFeedUiState>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class GetPostPagingSource @Inject constructor(
date = null,
memberId = arguments.get("memberId"),
page = loadParams.key ?: 1,
size = loadParams.loadSize
size = loadParams.loadSize,
type = arguments.get("type"),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,9 @@ fun SurvivalFeedTab(
writerName = item.authorName,
time = gapBetweenNow(time = item.createdAt),
onTap = { onTapContent(item.postId) },
isMission = false,
)
}


}
}
}
Expand Down Expand Up @@ -246,6 +245,7 @@ fun MissionFeedTab(
writerName = item.authorName,
time = gapBetweenNow(time = item.createdAt),
onTap = { onTapContent(item.postId) },
isMission = true,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.no5ing.bbibbi.presentation.feature.view.main.home

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -9,6 +10,7 @@ import androidx.compose.foundation.layout.Spacer
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.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -19,9 +21,11 @@ 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.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.no5ing.bbibbi.R
import com.no5ing.bbibbi.presentation.component.MicroTextBubbleBox
import com.no5ing.bbibbi.presentation.theme.bbibbiScheme
import com.no5ing.bbibbi.presentation.theme.bbibbiTypo
Expand All @@ -33,6 +37,7 @@ fun HomePageFeedElement(
imageUrl: String,
writerName: String,
time: String,
isMission: Boolean,
onTap: () -> Unit = {},
) {
Column(
Expand All @@ -41,7 +46,9 @@ fun HomePageFeedElement(
.clickable { onTap() },
horizontalAlignment = Alignment.CenterHorizontally
) {
Box {
Box(
contentAlignment = Alignment.TopStart,
) {
AsyncImage(
model = asyncImagePainter(source = imageUrl),
contentDescription = null,
Expand All @@ -51,11 +58,17 @@ fun HomePageFeedElement(
.aspectRatio(1.0f)
.clip(RoundedCornerShape(24.dp))
)
// MicroTextBubbleBox(
// text = postContent,
// alignment = Alignment.BottomCenter,
// modifier = Modifier.padding(bottom = 10.dp)
// )
if (isMission) {
Box(
modifier = Modifier.padding(12.dp)
) {
Image(
painter = painterResource(id = R.drawable.mission_diamond),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
}
}

Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedStoryElemen
import com.no5ing.bbibbi.presentation.theme.bbibbiScheme
import com.no5ing.bbibbi.presentation.theme.bbibbiTypo
import com.no5ing.bbibbi.util.LocalSessionState
import com.no5ing.bbibbi.util.gapBetweenNow
import com.no5ing.bbibbi.util.gapUntilNext
import kotlinx.coroutines.flow.StateFlow

@Composable
Expand Down Expand Up @@ -113,6 +115,7 @@ fun StoryBarIcon(
isUploaded: Boolean,
rank: Int,
) {
val canUpload = gapUntilNext() > 0
Column(
modifier = Modifier
.width(64.dp)
Expand Down Expand Up @@ -174,7 +177,7 @@ fun StoryBarIcon(
)
}
}
if (member.shouldShowPickIcon && !isInDeferredPickState) {
if (member.shouldShowPickIcon && !isInDeferredPickState && canUpload) {
Box(
contentAlignment = Alignment.BottomEnd,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -197,7 +199,10 @@ fun WaitingMembersPop(
Box(modifier = Modifier.padding(bottom = 30.dp)) {
Box(
modifier = Modifier
.background(MaterialTheme.bbibbiScheme.mainYellow, shape = RoundedCornerShape(6.dp))
.background(
MaterialTheme.bbibbiScheme.mainYellow,
shape = RoundedCornerShape(12.dp)
)
.padding(
vertical = 10.dp,
horizontal = 14.dp
Expand All @@ -207,11 +212,20 @@ fun WaitingMembersPop(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
pickers.take(3).forEach {
MiniCircledIcon(
noImageLetter = it.displayName.first().toString(),
imageUrl = it.imageUrl,
)
val pickersShattered = pickers.take(3)
Row {
Box {
pickersShattered.reversed().forEachIndexed { rawIdx, it ->
MiniCircledIcon(
noImageLetter = it.displayName.first().toString(),
imageUrl = it.imageUrl,
modifier = Modifier.offset(
x = 16.dp * (pickersShattered.size - 1 - rawIdx)
)
)
}
}
Spacer(modifier = Modifier.width(16.dp.times(pickersShattered.size - 1)))
}
if(pickers.size == 1) {
Text(
Expand Down Expand Up @@ -267,53 +281,49 @@ fun MiniCircledIcon(
modifier: Modifier = Modifier,
noImageLetter: String,
imageUrl: String?,
opacity: Float = 1.0f,
backgroundColor: Color = MaterialTheme.bbibbiScheme.backgroundSecondary,
onTap: () -> Unit = {},
) {
Box {
Box(
modifier = modifier,
contentAlignment = Alignment.Center,
) {
Box(
modifier = Modifier
.size(24.dp)
.background(MaterialTheme.bbibbiScheme.mainYellow, CircleShape)
) {

}
if (imageUrl != null) {
AsyncImage(
model = asyncImagePainter(source = imageUrl),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = modifier
.size(24.dp)
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
.background(backgroundColor)
.border(
width = 2.dp,
color = MaterialTheme.bbibbiScheme.mainYellow,
shape = CircleShape
)
.clickable { onTap() },
alpha = opacity,
)
} else {
Box(
modifier = Modifier.clickable { onTap() },
contentAlignment = Alignment.Center,
) {
Box(
modifier = modifier
.size(24.dp)
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
.background(
MaterialTheme.bbibbiScheme
.backgroundHover
.copy(alpha = opacity)
)
.border(
width = 2.dp,
color = MaterialTheme.bbibbiScheme.mainYellow,
shape = CircleShape
.backgroundHover,
CircleShape
)
)
Box(modifier = Modifier.align(Alignment.Center)) {
Text(
text = noImageLetter,
fontSize = 8.sp,
color = MaterialTheme.bbibbiScheme.white.copy(alpha = opacity),
color = MaterialTheme.bbibbiScheme.white,
fontWeight = FontWeight.SemiBold,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.no5ing.bbibbi.presentation.component.snackBarWarning
import com.no5ing.bbibbi.presentation.feature.view.common.AlbumCameraSelectDialog
import com.no5ing.bbibbi.presentation.feature.view_model.members.ChangeProfileImageViewModel
import com.no5ing.bbibbi.presentation.feature.view_model.members.FamilyMemberViewModel
import com.no5ing.bbibbi.presentation.feature.view_model.post.FamilyMissionPostsViewModel
import com.no5ing.bbibbi.presentation.feature.view_model.post.FamilyPostsViewModel
import com.no5ing.bbibbi.util.LocalSessionState
import com.no5ing.bbibbi.util.LocalSnackbarHostState
Expand All @@ -51,6 +52,7 @@ fun ProfilePage(
familyMemberViewModel: FamilyMemberViewModel = hiltViewModel(),
profileImageChangeViewModel: ChangeProfileImageViewModel = hiltViewModel(),
familyPostsViewModel: FamilyPostsViewModel = hiltViewModel(),
familyMissionPostsViewModel: FamilyMissionPostsViewModel = hiltViewModel(),
memberState: State<APIResponse<Member>> = familyMemberViewModel.uiState.collectAsState(),
) {
val sessionState = LocalSessionState.current
Expand All @@ -60,6 +62,7 @@ fun ProfilePage(
val snackBarHost = LocalSnackbarHostState.current
LaunchedEffect(Unit) {
familyPostsViewModel.invoke(Arguments(arguments = mapOf("memberId" to memberId)))
familyMissionPostsViewModel.invoke(Arguments(arguments = mapOf("memberId" to memberId)))
familyMemberViewModel.invoke(Arguments(resourceId = memberId))
}
LaunchedEffect(changeableUriState.value) {
Expand Down Expand Up @@ -146,6 +149,7 @@ fun ProfilePage(
ProfilePageContent(
onTapContent = onTapPost,
postItemsState = familyPostsViewModel.uiState,
missionItemState = familyMissionPostsViewModel.uiState,
)
}
}
Expand All @@ -171,7 +175,8 @@ fun ProfilePagePreview() {
)
ProfilePageContent(
onTapContent = {},
postItemsState = MutableStateFlow(PagingData.empty())
postItemsState = MutableStateFlow(PagingData.empty()),
missionItemState = MutableStateFlow(PagingData.empty())
)
}
}
Expand Down
Loading

0 comments on commit 2f92e3d

Please sign in to comment.