Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/home-aiRecommendation #18

Merged
merged 16 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_cafe.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M160,840v-80h640v80L160,840ZM320,680q-66,0 -113,-47t-47,-113v-400h640q33,0 56.5,23.5T880,200v120q0,33 -23.5,56.5T800,400h-80v120q0,66 -47,113t-113,47L320,680ZM320,600h240q33,0 56.5,-23.5T640,520v-320L240,200v320q0,33 23.5,56.5T320,600ZM720,320h80v-120h-80v120ZM320,600h-80,400 -320Z"
android:fillColor="#5f6368"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_calm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M480,840q-18,0 -34.5,-6.5T416,814L163,560h113l197,197q2,2 3.5,2.5t3.5,0.5q2,0 3.5,-0.5t3.5,-2.5l267,-268q23,-23 35,-54.5t12,-64.5q-2,-69 -46,-118.5T645,202q-31,0 -59.5,12T536,249l-27,29q-5,6 -13,9.5t-16,3.5q-8,0 -16,-3.5t-14,-9.5l-27,-29q-21,-23 -49,-36t-60,-13q-54,0 -93.5,34.5T167,320L85,320q17,-85 79.5,-142.5T314,120q48,0 90.5,19t75.5,53q32,-34 74.5,-53t90.5,-19q100,0 167.5,74T880,370q0,49 -17,94t-51,80L543,814q-13,13 -29,19.5t-34,6.5ZM475,480L80,480v-80h555q17,0 28.5,-11.5T675,360q0,-17 -11.5,-28.5T635,320q-14,0 -25,7.5T596,349l-77,-21q11,-39 43,-63.5t73,-24.5q50,0 85,35t35,85q0,50 -35,85t-85,35h-47q3,10 5,19.5t2,20.5q0,50 -35,85t-85,35q-41,0 -73,-24.5T359,552l77,-21q3,14 14,21.5t25,7.5q17,0 28.5,-11.5T515,520q0,-17 -11.5,-28.5T475,480ZM484,480Z"
android:fillColor="#5f6368"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_meeting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M0,720v-63q0,-43 44,-70t116,-27q13,0 25,0.5t23,2.5q-14,21 -21,44t-7,48v65L0,720ZM240,720v-65q0,-32 17.5,-58.5T307,550q32,-20 76.5,-30t96.5,-10q53,0 97.5,10t76.5,30q32,20 49,46.5t17,58.5v65L240,720ZM780,720v-65q0,-26 -6.5,-49T754,563q11,-2 22.5,-2.5t23.5,-0.5q72,0 116,26.5t44,70.5v63L780,720ZM325,640h311q-10,-20 -55.5,-35T480,590q-55,0 -100.5,15T325,640ZM160,520q-33,0 -56.5,-23.5T80,440q0,-34 23.5,-57t56.5,-23q34,0 57,23t23,57q0,33 -23,56.5T160,520ZM800,520q-33,0 -56.5,-23.5T720,440q0,-34 23.5,-57t56.5,-23q34,0 57,23t23,57q0,33 -23,56.5T800,520ZM480,480q-50,0 -85,-35t-35,-85q0,-51 35,-85.5t85,-34.5q51,0 85.5,34.5T600,360q0,50 -34.5,85T480,480ZM480,400q17,0 28.5,-11.5T520,360q0,-17 -11.5,-28.5T480,320q-17,0 -28.5,11.5T440,360q0,17 11.5,28.5T480,400ZM481,640ZM480,360Z"
android:fillColor="#5f6368"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_pet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M180,485q-42,0 -71,-29t-29,-71q0,-42 29,-71t71,-29q42,0 71,29t29,71q0,42 -29,71t-71,29ZM360,325q-42,0 -71,-29t-29,-71q0,-42 29,-71t71,-29q42,0 71,29t29,71q0,42 -29,71t-71,29ZM600,325q-42,0 -71,-29t-29,-71q0,-42 29,-71t71,-29q42,0 71,29t29,71q0,42 -29,71t-71,29ZM780,485q-42,0 -71,-29t-29,-71q0,-42 29,-71t71,-29q42,0 71,29t29,71q0,42 -29,71t-71,29ZM266,885q-45,0 -75.5,-34.5T160,769q0,-52 35.5,-91t70.5,-77q29,-31 50,-67.5t50,-68.5q22,-26 51,-43t63,-17q34,0 63,16t51,42q28,32 49.5,69t50.5,69q35,38 70.5,77t35.5,91q0,47 -30.5,81.5T694,885q-54,0 -107,-9t-107,-9q-54,0 -107,9t-107,9Z"
android:fillColor="#5f6368"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_restaurant.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M240,880v-366q-54,-14 -87,-57t-33,-97v-280h80v240h40v-240h80v240h40v-240h80v280q0,54 -33,97t-87,57v366h-80ZM640,880v-381q-54,-18 -87,-75.5T520,293q0,-89 47,-151t113,-62q66,0 113,62.5T840,294q0,73 -33,130t-87,75v381h-80Z"
android:fillColor="#5f6368"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_walk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M260,120q-45,0 -72.5,50T160,280q0,63 17.5,111.5T210,464l110,-22q13,-32 26.5,-73t13.5,-89q0,-60 -27.5,-110T260,120ZM315,640q19,0 32,-14t13,-39q0,-17 -8,-35t-16,-32l-96,20q0,40 17.5,70t57.5,30ZM700,320q-45,0 -72.5,50T600,480q0,48 13.5,88.5T640,642l110,22q15,-24 32.5,-72T800,480q0,-60 -27.5,-110T700,320ZM645,840q40,0 57.5,-30t17.5,-70l-96,-20q-8,14 -16,32t-8,35q0,20 12.5,36.5T645,840ZM315,720q-77,0 -117,-57t-38,-128l-18,-27q-11,-17 -36.5,-77T80,280q0,-103 51,-171.5T260,40q85,0 132.5,75.5T440,280q0,58 -16,107t-28,79l8,13q8,14 22,44.5t14,63.5q0,57 -35.5,95T315,720ZM645,920q-54,0 -89.5,-38T520,787q0,-33 14,-63.5t22,-44.5l8,-13q-12,-30 -28,-79t-16,-107q0,-89 47.5,-164.5T700,240q78,0 129,68.5T880,480q0,91 -25.5,150.5T818,707l-18,28q1,71 -38.5,128T645,920Z"
android:fillColor="#5f6368"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ sealed interface HomeRoute : Route {

@Serializable
data object Story : HomeRoute

@Serializable
data class AiRecommendation(val episodes: kotlin.collections.List<String>) : HomeRoute
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ sealed class HomeIntent : UiIntent {
val end: EpisodeLatLng,
val shouldSort: Boolean = false,
) : HomeIntent()
data class NavigateToAiRecommendation(val episodes: List<String>) : HomeIntent()
}
101 changes: 62 additions & 39 deletions feature/home/src/main/java/com/boostcamp/mapisode/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ internal fun HomeRoute(
onTextMarkerClick: (EpisodeLatLng) -> Unit = {},
onEpisodeClick: (String) -> Unit = {},
onListFabClick: (String) -> Unit = {},
onAiRecommendationClick: (List<String>) -> Unit = {},
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val context = LocalContext.current
Expand Down Expand Up @@ -212,6 +213,10 @@ internal fun HomeRoute(
cameraPositionState.position = CameraPosition(sideEffect.position, DEFAULT_ZOOM)
loadEpisodesInBounds(cameraPositionState)
}

is HomeSideEffect.NavigateToAiRecommendation -> {
onAiRecommendationClick(sideEffect.episodes)
}
}
}
}
Expand Down Expand Up @@ -271,6 +276,9 @@ internal fun HomeRoute(
viewModel.onIntent(HomeIntent.SelectGroup(groupId))
viewModel.onIntent(HomeIntent.ShowBottomSheet)
},
onAiRecommendationClick = { episodes ->
viewModel.onIntent(HomeIntent.NavigateToAiRecommendation(episodes))
},
)
}

Expand All @@ -289,6 +297,7 @@ private fun HomeScreen(
onSwipeStart: () -> Unit = {},
onEpisodeClick: (String) -> Unit = {},
onGroupSelected: (String) -> Unit = {},
onAiRecommendationClick: (List<String>) -> Unit = {},
) {
val context = LocalContext.current
val eatIcon = remember { OverlayImage.fromResource(Design.drawable.ic_eat_marker_light) }
Expand Down Expand Up @@ -428,54 +437,68 @@ private fun HomeScreen(
}
}

if (state.isCardVisible) {
val pagerState = rememberPagerState(
initialPage = state.selectedEpisodeIndex,
initialPageOffsetFraction = 0f,
pageCount = { state.selectedEpisodes.size },
Spacer(modifier = Modifier.weight(1f))

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.BottomCenter,
) {
MapisodeFabOverlayButton(
onClick = { onAiRecommendationClick(state.episodes.map { it.id }) },
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(end = 20.dp, bottom = 20.dp),
)

LaunchedEffect(pagerState.currentPage) {
val currentEpisode = state.selectedEpisodes.getOrNull(pagerState.currentPage)
currentEpisode?.let { episode ->
val position = LatLng(episode.location.latitude, episode.location.longitude)
onSwipeStart()
cameraPositionState.position = CameraPosition(position, DEFAULT_ZOOM)
}
}
if (state.isCardVisible) {
val pagerState = rememberPagerState(
initialPage = state.selectedEpisodeIndex,
initialPageOffsetFraction = 0f,
pageCount = { state.selectedEpisodes.size },
)

LaunchedEffect(state.selectedEpisodes) {
if (pagerState.currentPage != state.selectedEpisodeIndex) {
pagerState.scrollToPage(state.selectedEpisodeIndex)
LaunchedEffect(pagerState.currentPage) {
val currentEpisode =
state.selectedEpisodes.getOrNull(pagerState.currentPage)
currentEpisode?.let { episode ->
val position =
LatLng(episode.location.latitude, episode.location.longitude)
onSwipeStart()
cameraPositionState.position = CameraPosition(position, DEFAULT_ZOOM)
}
}
}

Spacer(modifier = Modifier.weight(1f))
LaunchedEffect(state.selectedEpisodes) {
if (pagerState.currentPage != state.selectedEpisodeIndex) {
pagerState.scrollToPage(state.selectedEpisodeIndex)
}
}

HorizontalPager(
state = pagerState,
modifier = Modifier
.fillMaxWidth()
.align(Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
contentPadding = PaddingValues(horizontal = 20.dp),
pageSpacing = 10.dp,
) { page ->
val episode = state.selectedEpisodes[page]

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center,
) {
EpisodeCard(
episode = episode,
onClick = onEpisodeClick,
)
HorizontalPager(
state = pagerState,
modifier = Modifier
.fillMaxWidth()
.align(Alignment.BottomCenter),
verticalAlignment = Alignment.CenterVertically,
contentPadding = PaddingValues(horizontal = 20.dp),
pageSpacing = 10.dp,
) { page ->
val episode = state.selectedEpisodes[page]

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center,
) {
EpisodeCard(
episode = episode,
onClick = onEpisodeClick,
)
}
}
}

Spacer(modifier = Modifier.height(20.dp))
}

Spacer(modifier = Modifier.height(20.dp))
}

MapisodeModalBottomSheet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ sealed class HomeSideEffect : SideEffect {
data class NavigateToEpisode(val latLng: EpisodeLatLng) : HomeSideEffect()
data class NavigateToEpisodeDetail(val episodeId: String) : HomeSideEffect()
data class MoveCameraToPosition(val position: LatLng) : HomeSideEffect()
data class NavigateToAiRecommendation(val episodes: List<String>) : HomeSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class HomeViewModel @Inject constructor(
is HomeIntent.SelectGroup -> {
selectGroup(intent.groupId)
}

is HomeIntent.NavigateToAiRecommendation -> {
postSideEffect(HomeSideEffect.NavigateToAiRecommendation(intent.episodes))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.boostcamp.mapisode.home.ai

import com.boostcamp.mapisode.home.common.OptionType
import com.boostcamp.mapisode.ui.base.UiIntent

sealed class RecommendationIntent : UiIntent {
data class Initialize(val episodes: List<String>) : RecommendationIntent()
data class OptionClick(val optionId: OptionType) : RecommendationIntent()
data object ShowMapType : RecommendationIntent()
data object ShowListType : RecommendationIntent()
}
Loading
Loading