Skip to content

Commit

Permalink
Merge pull request #172 from WithPeace/feat/#171-홈_화면_리뉴얼
Browse files Browse the repository at this point in the history
Feat/#171 홈 화면 리뉴얼
  • Loading branch information
rhkrwngud445 authored Oct 9, 2024
2 parents b85cd48 + 99df02a commit 79dd786
Show file tree
Hide file tree
Showing 76 changed files with 2,361 additions and 686 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
applicationId = "com.withpeace.withpeace"
targetSdk = 34
versionCode = 11
versionName = "2.1.1"
versionCode = 14
versionName = "2.2.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -58,6 +58,7 @@ dependencies {
implementation(project(":feature:policydetail"))
implementation(project(":feature:policybookmarks"))
implementation(project(":feature:disablepolicy"))
implementation(project(":feature:policylist"))
implementation(project(":core:ui"))
implementation(project(":core:interceptor"))
implementation(project(":core:data"))
Expand Down
29 changes: 14 additions & 15 deletions app/src/main/java/com/withpeace/withpeace/MainBottomNavigation.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.withpeace.withpeace

import android.util.Log
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.material3.NavigationBar
Expand All @@ -19,10 +18,11 @@ import androidx.navigation.navOptions
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.feature.home.navigation.HOME_ROUTE
import com.withpeace.withpeace.feature.home.navigation.navigateHome
import com.withpeace.withpeace.feature.policylist.navigation.POLICY_LIST_ROUTE
import com.withpeace.withpeace.feature.policylist.navigation.navigateToPolicyList
import com.withpeace.withpeace.feature.postlist.navigation.POST_LIST_ROUTE
import com.withpeace.withpeace.feature.postlist.navigation.POST_LIST_ROUTE_WITH_ARGUMENT
import com.withpeace.withpeace.feature.postlist.navigation.navigateToPostList
import com.withpeace.withpeace.feature.registerpost.navigation.REGISTER_POST_ROUTE
import com.withpeace.withpeace.feature.registerpost.navigation.navigateToRegisterPost
import com.withpeace.withpeace.navigation.MY_PAGE_NESTED_ROUTE

@Composable
Expand Down Expand Up @@ -79,8 +79,8 @@ private fun NavController.navigateToTabScreen(bottomTab: BottomTab) {

when (bottomTab) {
BottomTab.HOME -> navigateHome(tabNavOptions)
BottomTab.POST -> navigateToPostList(tabNavOptions)
BottomTab.REGISTER_POST -> navigateToRegisterPost()
BottomTab.POLICY -> navigateToPolicyList(tabNavOptions)
BottomTab.POST -> navigateToPostList(navOptions = tabNavOptions)
BottomTab.MY_PAGE -> navigate(MY_PAGE_NESTED_ROUTE, tabNavOptions)
}
}
Expand All @@ -97,17 +97,17 @@ enum class BottomTab(
contentDescription = R.string.home,
HOME_ROUTE,
),
POLICY(
iconUnSelectedResId = R.drawable.ic_bottom_policy,
iconSelectedResId = R.drawable.ic_bottom_policy_select,
contentDescription = R.string.youth_policy,
POLICY_LIST_ROUTE,
),
POST(
iconUnSelectedResId = R.drawable.ic_bottom_post,
iconSelectedResId = R.drawable.ic_bottom_post_select,
iconUnSelectedResId = R.drawable.ic_bottom_community,
iconSelectedResId = R.drawable.ic_bottom_community_select,
contentDescription = R.string.post,
POST_LIST_ROUTE,
),
REGISTER_POST(
iconUnSelectedResId = R.drawable.ic_upload,
iconSelectedResId = R.drawable.ic_upload,
contentDescription = R.string.register,
REGISTER_POST_ROUTE,
POST_LIST_ROUTE_WITH_ARGUMENT,
),
MY_PAGE(
iconUnSelectedResId = R.drawable.ic_bottom_my_page,
Expand All @@ -119,7 +119,6 @@ enum class BottomTab(

companion object {
operator fun contains(route: String): Boolean {
if (route == REGISTER_POST_ROUTE) return false
return entries.map { it.route }.contains(route)
}
}
Expand Down
43 changes: 40 additions & 3 deletions app/src/main/java/com/withpeace/withpeace/navigation/NavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.navOptions
Expand All @@ -13,12 +14,10 @@ import com.app.profileeditor.navigation.navigateProfileEditor
import com.app.profileeditor.navigation.profileEditorNavGraph
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarState
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarType
import com.withpeace.withpeace.feature.disablepolicy.navigation.DISABLE_POLICY_ID_ARGUMENT
import com.withpeace.withpeace.feature.disablepolicy.navigation.disabledPolicyNavGraph
import com.withpeace.withpeace.feature.disablepolicy.navigation.navigateDisabledPolicy
import com.withpeace.withpeace.feature.gallery.navigation.galleryNavGraph
import com.withpeace.withpeace.feature.gallery.navigation.navigateToGallery
import com.withpeace.withpeace.feature.home.navigation.HOME_ROUTE
import com.withpeace.withpeace.feature.home.navigation.homeNavGraph
import com.withpeace.withpeace.feature.home.navigation.navigateHome
import com.withpeace.withpeace.feature.login.navigation.LOGIN_ROUTE
Expand All @@ -32,11 +31,13 @@ import com.withpeace.withpeace.feature.policyconsent.navigation.navigateToPolicy
import com.withpeace.withpeace.feature.policyconsent.navigation.policyConsentGraph
import com.withpeace.withpeace.feature.policydetail.navigation.navigateToPolicyDetail
import com.withpeace.withpeace.feature.policydetail.navigation.policyDetailNavGraph
import com.withpeace.withpeace.feature.policylist.navigation.policyListGraph
import com.withpeace.withpeace.feature.postdetail.navigation.POST_DETAIL_ROUTE_WITH_ARGUMENT
import com.withpeace.withpeace.feature.postdetail.navigation.navigateToPostDetail
import com.withpeace.withpeace.feature.postdetail.navigation.postDetailGraph
import com.withpeace.withpeace.feature.postlist.navigation.POST_LIST_DELETED_POST_ID_ARGUMENT
import com.withpeace.withpeace.feature.postlist.navigation.POST_LIST_ROUTE
import com.withpeace.withpeace.feature.postlist.navigation.navigateToPostList
import com.withpeace.withpeace.feature.postlist.navigation.postListGraph
import com.withpeace.withpeace.feature.privacypolicy.navigation.navigateToPrivacyPolicy
import com.withpeace.withpeace.feature.privacypolicy.navigation.privacyPolicyGraph
Expand Down Expand Up @@ -191,7 +192,21 @@ fun WithpeaceNavHost(
)
},
onPolicyClick = {
navController.navigateToPolicyDetail(policyId = it)
navController.navigateToPolicyDetail(
policyId = it,
)
},
onPostClick = { // TODO 인스턴스가 존재할 때, argument 로딩안됨
navController.navigateToPostList(
it.name,
navOptions = navOptions {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
},
)
},
)
policyDetailNavGraph(
Expand Down Expand Up @@ -319,6 +334,28 @@ fun WithpeaceNavHost(
onAuthExpired = {
onAuthExpired(onShowSnackBar, navController)
},
onClickRegisterPost = {
navController.navigateToRegisterPost()
}
)
policyListGraph(
onShowSnackBar = { onShowSnackBar(SnackbarState(it)) },
onNavigationSnackBar = {
onShowSnackBar(
SnackbarState(
it,
SnackbarType.Navigator(
actionName = "목록 보러가기",
action = {
navController.navigatePolicyBookmarks()
},
),
),
)
},
onPolicyClick = {
navController.navigateToPolicyDetail(policyId = it)
},
)
}
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_bottom_community.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="27dp"
android:height="24dp"
android:viewportWidth="27"
android:viewportHeight="24">
<path
android:pathData="M8.75,9C8.75,8.586 9.086,8.25 9.5,8.25H17.5C17.914,8.25 18.25,8.586 18.25,9C18.25,9.414 17.914,9.75 17.5,9.75H9.5C9.086,9.75 8.75,9.414 8.75,9ZM8.75,13C8.75,12.586 9.086,12.25 9.5,12.25H14.5C14.914,12.25 15.25,12.586 15.25,13C15.25,13.414 14.914,13.75 14.5,13.75H9.5C9.086,13.75 8.75,13.414 8.75,13Z"
android:fillColor="#A7A7A7"
android:fillType="evenOdd"/>
<path
android:pathData="M8.5,2.65C6.242,2.65 4.575,4.433 4.575,6.428V14.323C4.575,16.318 6.242,18.101 8.5,18.101H9.575C10.718,18.101 11.796,18.658 12.491,19.609L13.5,20.987L14.509,19.609C15.204,18.658 16.282,18.101 17.425,18.101H18.5C20.758,18.101 22.425,16.318 22.425,14.323V6.428C22.425,4.433 20.758,2.65 18.5,2.65H8.5ZM3,6.428C3,3.43 5.462,1 8.5,1H18.5C21.538,1 24,3.43 24,6.428V14.323C24,17.321 21.538,19.751 18.5,19.751H17.425C16.772,19.751 16.156,20.069 15.759,20.613L14.311,22.591C13.911,23.136 13.089,23.136 12.689,22.591L11.241,20.613C10.844,20.069 10.228,19.751 9.575,19.751H8.5C5.462,19.751 3,17.321 3,14.323V6.428Z"
android:fillColor="#A7A7A7"
android:fillType="evenOdd"/>
</vector>
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/ic_bottom_community_select.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="27dp"
android:height="24dp"
android:viewportWidth="27"
android:viewportHeight="24">
<path
android:pathData="M15.129,20.472L14.587,21.388C14.104,22.204 12.897,22.204 12.413,21.388L11.871,20.472C11.451,19.762 11.241,19.406 10.903,19.21C10.565,19.013 10.14,19.006 9.29,18.991C8.034,18.97 7.247,18.893 6.587,18.619C5.98,18.368 5.429,17.999 4.965,17.535C4.501,17.071 4.132,16.52 3.881,15.913C3.5,14.995 3.5,13.83 3.5,11.5V10.5C3.5,7.227 3.5,5.59 4.237,4.388C4.649,3.715 5.214,3.149 5.887,2.737C7.09,2 8.728,2 12,2H15C18.273,2 19.91,2 21.113,2.737C21.785,3.149 22.351,3.715 22.763,4.387C23.5,5.59 23.5,7.228 23.5,10.5V11.5C23.5,13.83 23.5,14.995 23.12,15.913C22.869,16.52 22.5,17.071 22.036,17.535C21.571,18 21.02,18.368 20.413,18.619C19.753,18.893 18.966,18.969 17.71,18.991C16.86,19.006 16.435,19.013 16.097,19.21C15.759,19.406 15.549,19.761 15.129,20.472Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M9.5,9H17.5M9.5,13H14.5"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
</vector>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">청하</string>
<string name="home">홈</string>
<string name="post">게시판</string>
<string name="youth_policy">청년정책</string>
<string name="post">커뮤니티</string>
<string name="my_page">마이페이지</string>
<string name="register">등록</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.withpeace.withpeace.core.data.mapper

import com.withpeace.withpeace.core.domain.model.post.RecentPost
import com.withpeace.withpeace.core.network.di.response.post.RecentPostResponse

fun RecentPostResponse.toDomain(): RecentPost {
return RecentPost(
id = postId, title = title, type = type.toDomain(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.withpeace.withpeace.core.data.mapper.youthpolicy

import com.withpeace.withpeace.core.domain.model.policy.PolicyClassification
import com.withpeace.withpeace.core.domain.model.policy.PolicyFilters
import com.withpeace.withpeace.core.domain.model.policy.PolicyRegion
import com.withpeace.withpeace.core.network.di.response.policy.UserPolicyFilterResponse

fun UserPolicyFilterResponse.toDomain(): PolicyFilters {
return PolicyFilters(
regions = region.map { name ->
PolicyRegion.entries.find { it.name == name } ?: PolicyRegion.기타
},
classifications = classification.map { name ->
PolicyClassification.entries.find { it.name == name } ?: PolicyClassification.ETC
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.withpeace.withpeace.core.domain.model.error.ResponseError
import com.withpeace.withpeace.core.domain.model.post.Post
import com.withpeace.withpeace.core.domain.model.post.PostDetail
import com.withpeace.withpeace.core.domain.model.post.PostTopic
import com.withpeace.withpeace.core.domain.model.post.RecentPost
import com.withpeace.withpeace.core.domain.model.post.RegisterPost
import com.withpeace.withpeace.core.domain.model.post.ReportType
import com.withpeace.withpeace.core.domain.repository.PostRepository
Expand Down Expand Up @@ -147,6 +148,13 @@ class DefaultPostRepository @Inject constructor(
}
}

override fun getRecentPost(onError: suspend (CheonghaError) -> Unit): Flow<List<RecentPost>> =
flow {
postService.getRecentPost().suspendMapSuccess {
emit(this.data.map { it.toDomain() })
}.handleApiFailure(onError)
}

private fun getImageRequestBodies(
imageUris: List<String>,
): List<MultipartBody.Part> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.withpeace.withpeace.core.analytics.AnalyticsEvent
import com.withpeace.withpeace.core.analytics.AnalyticsHelper
import com.withpeace.withpeace.core.data.analytics.event
import com.withpeace.withpeace.core.data.mapper.toDomain
import com.withpeace.withpeace.core.data.mapper.youthpolicy.toCode
import com.withpeace.withpeace.core.data.mapper.youthpolicy.toDomain
import com.withpeace.withpeace.core.data.util.convertToFile
import com.withpeace.withpeace.core.data.util.handleApiFailure
import com.withpeace.withpeace.core.datastore.dataStore.token.TokenPreferenceDataSource
Expand All @@ -15,6 +17,7 @@ import com.withpeace.withpeace.core.domain.model.SignUpInfo
import com.withpeace.withpeace.core.domain.model.error.CheonghaError
import com.withpeace.withpeace.core.domain.model.error.ClientError
import com.withpeace.withpeace.core.domain.model.error.ResponseError
import com.withpeace.withpeace.core.domain.model.policy.PolicyFilters
import com.withpeace.withpeace.core.domain.model.profile.ChangedProfile
import com.withpeace.withpeace.core.domain.model.profile.Nickname
import com.withpeace.withpeace.core.domain.model.profile.ProfileInfo
Expand Down Expand Up @@ -133,6 +136,25 @@ class DefaultUserRepository @Inject constructor(
}
}

override fun updatePolicyFilter(
policyFilters: PolicyFilters,
onError: suspend (CheonghaError) -> Unit,
): Flow<Unit> = flow {
userService.patchPolicyFilter(
region = policyFilters.regions.joinToString(",") { it.toCode() },
classification = policyFilters.classifications.joinToString(",") { it.toCode() },
).suspendMapSuccess {
emit(Unit)
}.handleApiFailure(onError)
}

override fun getPolicyFilter(onError: suspend (CheonghaError) -> Unit): Flow<PolicyFilters> =
flow {
userService.getPolicyFilter().suspendMapSuccess {
emit(this.data.toDomain())
}.handleApiFailure(onError)
}

override fun withdraw(onError: suspend (CheonghaError) -> Unit): Flow<Unit> =
flow {
userService.withdraw().suspendMapSuccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ class DefaultYouthPolicyRepository @Inject constructor(
}
}

override fun getRecommendPolicy(onError: suspend (CheonghaError) -> Unit): Flow<List<YouthPolicy>> =
flow {
youthPolicyService.getRecommendations().suspendMapSuccess {
emit(data.map { it.toDomain() })
}.handleApiFailure {
onErrorWithAuthExpired(it, onError)
}
}

override fun getHotPolicy(onError: suspend (CheonghaError) -> Unit): Flow<List<YouthPolicy>> =
flow {
youthPolicyService.getHots().suspendMapSuccess {
emit(data.map { it.toDomain() })
}.handleApiFailure {
onErrorWithAuthExpired(it, onError)
}
}

private suspend fun onErrorWithAuthExpired(
it: ResponseError,
onError: suspend (CheonghaError) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ val systemGray4 = Color(0xFF696969)
val systemError = Color(0xFFF0474B)
val systemSuccess = Color(0xFF3BD569)
val systemHyperLink = Color(0xFF20BCBB)
val gray3_70 = Color(0xB2ECECEF)
val toolTipBackground = Color(0xFFF9FBFB)

val snackbarBlack = Color(0xFF000000)

Expand All @@ -46,6 +48,8 @@ data class WithPeaceColor(
val SystemSuccess: Color = systemSuccess,
val SystemHyperLink: Color = systemHyperLink,
val SnackbarBlack: Color = snackbarBlack,
val Gray3_70: Color = gray3_70,
val ToolTipBackground: Color = toolTipBackground,
)

val lightColor = WithPeaceColor()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.withpeace.withpeace.core.domain.model.post

data class RecentPost(
val id: Long,
val title: String,
val type: PostTopic,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.withpeace.withpeace.core.domain.model.error.CheonghaError
import com.withpeace.withpeace.core.domain.model.post.Post
import com.withpeace.withpeace.core.domain.model.post.PostDetail
import com.withpeace.withpeace.core.domain.model.post.PostTopic
import com.withpeace.withpeace.core.domain.model.post.RecentPost
import com.withpeace.withpeace.core.domain.model.post.RegisterPost
import com.withpeace.withpeace.core.domain.model.post.ReportType
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -48,4 +49,8 @@ interface PostRepository {
reportType: ReportType,
onError: suspend (CheonghaError) -> Unit,
): Flow<Boolean>

fun getRecentPost(
onError: suspend (CheonghaError) -> Unit,
): Flow<List<RecentPost>>
}
Loading

0 comments on commit 79dd786

Please sign in to comment.