Skip to content

Commit

Permalink
feat: 명예의 전당 기능 구현 [skip-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Apr 24, 2024
1 parent 2f92e3d commit 436d290
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class MainPageModel(
@Parcelize
data class NightMainPageModel(
val topBarElements: List<MainPageTopBarModel>,
val familyMemberMonthlyRanking: MainPageMonthlyRankingModel,
) : Parcelable, BaseModel()

@Parcelize
Expand All @@ -46,4 +47,23 @@ data class MainPageTopBarModel(
val displayRank: Int?,
val shouldShowBirthdayMark: Boolean,
val shouldShowPickIcon: Boolean,
) : Parcelable

@Parcelize
data class MainPageMonthlyRankingModel(
val month: Int,
val firstRanker: MainPageMonthlyRankerModel?,
val secondRanker: MainPageMonthlyRankerModel?,
val thirdRanker: MainPageMonthlyRankerModel?,
) : Parcelable {
fun isAllRankersNull(): Boolean {
return firstRanker == null && secondRanker == null && thirdRanker == null
}
}

@Parcelize
data class MainPageMonthlyRankerModel(
val profileImageUrl: String?,
val name: String,
val survivalCount: Int,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.no5ing.bbibbi.presentation.component.button

import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.no5ing.bbibbi.presentation.theme.bbibbiScheme
import com.no5ing.bbibbi.presentation.theme.bbibbiTypo

@Composable
fun FlatButton(
text: String,
modifier: Modifier = Modifier,
buttonColor: Color = MaterialTheme.bbibbiScheme.mainYellow,
textColor: Color = MaterialTheme.bbibbiScheme.backgroundPrimary,
contentPadding: PaddingValues = PaddingValues(
start = 24.dp,
top = 12.dp,
end = 24.dp,
bottom = 12.dp,
),
onClick: () -> Unit = {},
isActive: Boolean = true,
byPassCtaIgnore: Boolean = false,
) {
val opacityAlpha: Float by animateFloatAsState(
targetValue = if (isActive) 1f else 0.2f,
animationSpec = tween(
durationMillis = 130,
easing = LinearEasing,
), label = ""
)
Button(
shape = RoundedCornerShape(8.dp),
onClick = { if (isActive || byPassCtaIgnore) onClick() },
colors = ButtonDefaults.buttonColors(
containerColor = buttonColor.copy(
alpha = opacityAlpha
)
),
modifier = modifier,
contentPadding = contentPadding,
) {
Text(
text = text,
color = textColor,
style = MaterialTheme.bbibbiTypo.bodyOneBold,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ fun MainCalendarYearMonthBar(
.size(20.dp)
.clickable { it.showAlignBottom() }
)

}
}
if (statistics.isReady()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ import com.no5ing.bbibbi.presentation.component.BBiBBiPreviewSurface
import com.no5ing.bbibbi.presentation.component.BBiBBiSurface
import com.no5ing.bbibbi.presentation.component.BackToExitHandler
import com.no5ing.bbibbi.presentation.feature.view.common.CustomAlertDialog
import com.no5ing.bbibbi.presentation.feature.view_model.MainPageNightViewModel
import com.no5ing.bbibbi.presentation.feature.view_model.MainPageViewModel
import com.no5ing.bbibbi.presentation.theme.bbibbiScheme
import com.no5ing.bbibbi.util.gapUntilNext
import kotlinx.coroutines.flow.MutableStateFlow
import java.time.LocalDate

@Composable
fun HomePage(
mainPageViewModel: MainPageViewModel = hiltViewModel(),
mainPageNightViewModel: MainPageNightViewModel = hiltViewModel(),
postViewTypeState: MutableState<PostType> = remember { mutableStateOf(PostType.SURVIVAL) },
onTapLeft: () -> Unit = {},
onTapRight: () -> Unit = {},
Expand All @@ -44,12 +47,14 @@ fun HomePage(
onTapUpload: () -> Unit = {},
onTapInvite: () -> Unit = {},
onUnsavedPost: (Uri) -> Unit = {},
onTapViewPost: (LocalDate) -> Unit = {},
onTapPick: (MainPageTopBarModel) -> Unit = {},
) {
val postViewType by postViewTypeState
val mainPageState = mainPageViewModel.uiState.collectAsState()
val unsavedDialogUri = remember { mutableStateOf<Uri?>(null) }
val unsavedDialogEnabled = remember { mutableStateOf(false) }
val isDayTime = gapUntilNext() > 0
CustomAlertDialog(
enabledState = unsavedDialogEnabled,
title = stringResource(id = R.string.unsaved_post_dialog_title),
Expand All @@ -71,7 +76,11 @@ fun HomePage(
unsavedDialogUri.value = tempUri
unsavedDialogEnabled.value = true
}
mainPageViewModel.invoke(Arguments())
if(isDayTime) {
mainPageViewModel.invoke(Arguments())
} else {
mainPageNightViewModel.invoke(Arguments())
}
}

BBiBBiSurface(
Expand All @@ -89,18 +98,34 @@ fun HomePage(
onTapLeft = onTapLeft,
onTapRight = onTapRight
)
HomePageContent(
mainPageState = mainPageViewModel.uiState,
postViewTypeState = postViewTypeState,
onTapContent = onTapContent,
onTapProfile = onTapProfile,
onTapInvite = onTapInvite,
onTapPick = onTapPick,
onRefresh = {
mainPageViewModel.invoke(Arguments())
},
deferredPickStateSet = mainPageViewModel.deferredPickMembersSet
)
if (isDayTime) {
HomePageContent(
mainPageState = mainPageViewModel.uiState,
postViewTypeState = postViewTypeState,
onTapContent = onTapContent,
onTapProfile = onTapProfile,
onTapInvite = onTapInvite,
onTapPick = onTapPick,
onRefresh = {
mainPageViewModel.invoke(Arguments())
},
deferredPickStateSet = mainPageViewModel.deferredPickMembersSet
)
} else {
NightHomePageContent(
mainPageState = mainPageNightViewModel.uiState,
postViewTypeState = postViewTypeState,
onTapViewPost = onTapViewPost,
onTapProfile = onTapProfile,
onTapInvite = onTapInvite,
onTapPick = onTapPick,
onRefresh = {
mainPageNightViewModel.invoke(Arguments())
},
deferredPickStateSet = mainPageViewModel.deferredPickMembersSet
)
}

}
if (postViewType == PostType.SURVIVAL) {
HomePageSurvivalUploadButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fun HomePageContent(
.verticalScroll(state = scrollState)
) {
HomePageStoryBar(
mainPageState = mainPageState,
items = if (mainPageModel.isReady()) mainPageModel.data.topBarElements else emptyList(),
onTapProfile = onTapProfile,
onTapInvite = onTapInvite,
onTapPick = onTapPick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ import kotlinx.coroutines.flow.StateFlow

@Composable
fun HomePageStoryBar(
mainPageState: StateFlow<APIResponse<MainPageModel>>,
//mainPageState: StateFlow<APIResponse<MainPageModel>>,
items: List<MainPageTopBarModel>,
deferredPickStateSet: StateFlow<Set<String>>,
onTapProfile: (String) -> Unit = {},
onTapPick: (MainPageTopBarModel) -> Unit = {},
onTapInvite: () -> Unit = {},
) {
val meId = LocalSessionState.current.memberId
val mainPageModel by mainPageState.collectAsState()
// val mainPageModel by mainPageState.collectAsState()
val deferredPickSet = deferredPickStateSet.collectAsState()
val items = if (mainPageModel.isReady()) mainPageModel.data.topBarElements else emptyList()
// val items = if (mainPageModel.isReady()) mainPageModel.data.topBarElements else emptyList()

if (items.size == 1) {
HomePageNoFamilyBar(
Expand Down Expand Up @@ -206,7 +207,7 @@ fun StoryBarIcon(
}

@Composable
private fun getRankColor(rank: Int) = when (rank) {
fun getRankColor(rank: Int) = when (rank) {
0 -> MaterialTheme.bbibbiScheme.mainYellow
1 -> Color(0xff7FEC93)
2 -> Color(0xffFFC98D)
Expand Down
Loading

0 comments on commit 436d290

Please sign in to comment.