Skip to content

Commit

Permalink
[feat] : 홈 화면 컬렉션 카드 추가 및 네비게이션 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ham2174 committed Feb 27, 2024
1 parent cb1b29b commit ece04f8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/com/moya/funch/navigation/FunchNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.moya.funch.collection.navigation.collectionScreen
import com.moya.funch.collection.navigation.navigateToCollection
import com.moya.funch.match.navigation.matchingScreen
import com.moya.funch.match.navigation.navigateToMatching
import com.moya.funch.onboarding.navigation.ON_BOARDING_ROUTE
Expand All @@ -25,10 +27,12 @@ fun FunchNavHost(hasProfile: Boolean, navController: NavHostController = remembe
)
homeScreen(
onNavigateToMatching = ::onNavigateToMatching,
onNavigateToMyProfile = ::onNavigateToMyProfile
onNavigateToMyProfile = ::onNavigateToMyProfile,
onNavigateToCollection = ::navigateToCollection
)
matchingScreen(onClose = { popBackStack(HOME_ROUTE, false) })
onBoardingScreen(onNavigateToCreateProfile = ::navigateToCreateProfile)
collectionScreen(onNavigateToHome = ::onNavigateToHome)
}
}
}
Expand Down
46 changes: 41 additions & 5 deletions feature/home/src/main/java/com/moya/funch/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private val brush = Brush.horizontalGradient(
internal fun HomeRoute(
viewModel: HomeViewModel = hiltViewModel(),
onNavigateToMyProfile: () -> Unit,
onNavigateToMatching: (String) -> Unit
onNavigateToMatching: (String) -> Unit,
onNavigateToCollection: () -> Unit
) {
val homeModel by viewModel.homeModel.collectAsStateWithLifecycle()
val matched by viewModel.matched.collectAsStateWithLifecycle(false)
Expand Down Expand Up @@ -115,7 +116,8 @@ internal fun HomeRoute(
matchingCode = homeModel.matchingCode,
onMatchingCodeChange = viewModel::setMatchingCode,
matchProfile = viewModel::matchProfile,
onNavigateToMyProfile = onNavigateToMyProfile
onNavigateToMyProfile = onNavigateToMyProfile,
onNavigateToCollection = onNavigateToCollection
)
}

Expand All @@ -127,7 +129,8 @@ internal fun HomeScreen(
matchingCode: String,
onMatchingCodeChange: (String) -> Unit,
matchProfile: () -> Unit,
onNavigateToMyProfile: () -> Unit
onNavigateToMyProfile: () -> Unit,
onNavigateToCollection: () -> Unit
) {
val focusManager = LocalFocusManager.current
Column(
Expand Down Expand Up @@ -166,6 +169,9 @@ internal fun HomeScreen(
ProfileViewCounterCard(
viewCount = viewCount
)
CollectionCard(
onNavigateToCollection = onNavigateToCollection
)
}
}

Expand All @@ -174,7 +180,7 @@ private fun HomeTopBar(onClickFeedBack: () -> Unit) {
FunchTopBar(
modifier = Modifier.padding(bottom = 8.dp),
leadingIcon = null,
onClickTrailingIcon = onClickFeedBack
onClickTrailingIcon = onClickFeedBack,
)
}

Expand Down Expand Up @@ -349,6 +355,35 @@ private fun ProfileViewCounterCard(viewCount: Int) {
}
}

@Composable
private fun CollectionCard(modifier: Modifier = Modifier, onNavigateToCollection: () -> Unit) {
Column(
modifier = modifier
.background(
color = Gray800,
shape = FunchTheme.shapes.medium
)
.clip(FunchTheme.shapes.medium)
.clickableSingle(onClick = onNavigateToCollection)
.padding(
vertical = 11.5.dp,
horizontal = 24.dp
),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(space = 8.dp)
) {
Image(
painter = painterResource(id = FunchIconAsset.Etc.trophy_40),
contentDescription = ""
)
Text(
text = stringResource(id = R.string.collection_card_caption),
style = FunchTheme.typography.b,
color = Gray400
)
}
}

@Preview(
"Home UI",
showBackground = true,
Expand All @@ -373,7 +408,8 @@ private fun Preview1() {
matchingCode = text,
onMatchingCodeChange = { text = it },
matchProfile = {},
onNavigateToMyProfile = {}
onNavigateToMyProfile = {},
onNavigateToCollection = {}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ fun NavController.onNavigateToHome() = navigate(HOME_ROUTE) {
popUpTo(graph.id)
}

fun NavGraphBuilder.homeScreen(onNavigateToMyProfile: () -> Unit, onNavigateToMatching: (String) -> Unit) {
fun NavGraphBuilder.homeScreen(
onNavigateToMyProfile: () -> Unit,
onNavigateToMatching: (String) -> Unit,
onNavigateToCollection: () -> Unit
) {
composable(route = HOME_ROUTE) {
HomeRoute(
onNavigateToMatching = onNavigateToMatching,
onNavigateToMyProfile = onNavigateToMyProfile
onNavigateToMyProfile = onNavigateToMyProfile,
onNavigateToCollection = onNavigateToCollection
)
}
}
1 change: 1 addition & 0 deletions feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<string name="my_profile_card_caption">내 프로필</string>
<string name="profile_view_counter_caption">내 프로필을</string>
<string name="profile_view_counter_card_subtitle">%d명이 조회했어요</string>
<string name="collection_card_caption">수집 도감</string>
</resources>

0 comments on commit ece04f8

Please sign in to comment.