Skip to content
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
4 changes: 1 addition & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ dependencies {
implementation(project(":core:domain"))
implementation(project(":core:analytics"))
implementation(project(":core:designsystem"))
implementation(project(":feature:search"))
testImplementation(project(":core:testing"))

implementation("com.google.android.play:app-update:2.1.0")
implementation("com.google.android.play:app-update-ktx:2.1.0")
}
49 changes: 0 additions & 49 deletions app/src/main/java/com/withpeace/withpeace/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.google.android.gms.tasks.Task
import com.google.android.play.core.appupdate.AppUpdateInfo
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability
import com.withpeace.withpeace.core.analytics.AnalyticsHelper
import com.withpeace.withpeace.core.analytics.LocalAnalyticsHelper
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
Expand All @@ -57,8 +50,6 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var analyticsHelper: AnalyticsHelper

private val appUpdateManager by lazy { AppUpdateManagerFactory.create(this) }

private val updateActivityResultLauncher =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult ->
if (result.resultCode != RESULT_OK) {
Expand Down Expand Up @@ -172,32 +163,7 @@ class MainActivity : ComponentActivity() {
}
}
}
private fun compulsionUpdate() {
val appUpdateInfoTask: Task<AppUpdateInfo> = appUpdateManager.appUpdateInfo

appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
startUpdateFlow(appUpdateManager, appUpdateInfo)
} else {
Toast.makeText(this, "앱을 사용하려면 업데이트가 필요해요!", Toast.LENGTH_LONG).show()
// redirectToPlayStore()
}
}
}

private fun startUpdateFlow(appUpdateManager: AppUpdateManager, appUpdateInfo: AppUpdateInfo) {
try {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
updateActivityResultLauncher,
AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(),
)
} catch (e: Exception) {
e.printStackTrace()
}
}

private fun redirectToPlayStore() {
val packageName = packageName
Expand All @@ -216,20 +182,5 @@ class MainActivity : ComponentActivity() {

override fun onResume() {
super.onResume()

appUpdateManager
.appUpdateInfo
.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability()
== UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
) {
// If an in-app update is already running, resume the update.
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
updateActivityResultLauncher,
AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(),
)
}
}
}
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/withpeace/withpeace/navigation/NavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import com.withpeace.withpeace.feature.registerpost.navigation.REGISTER_POST_ARG
import com.withpeace.withpeace.feature.registerpost.navigation.REGISTER_POST_ROUTE
import com.withpeace.withpeace.feature.registerpost.navigation.navigateToRegisterPost
import com.withpeace.withpeace.feature.registerpost.navigation.registerPostNavGraph
import com.withpeace.withpeace.feature.search.navigation.navigateToSearch
import com.withpeace.withpeace.feature.search.navigation.searchGraph
import com.withpeace.withpeace.feature.signup.navigation.navigateSignUp
import com.withpeace.withpeace.feature.signup.navigation.signUpNavGraph
import com.withpeace.withpeace.feature.termsofservice.navigation.navigateToTermsOfService
Expand Down Expand Up @@ -210,6 +212,16 @@ fun WithpeaceNavHost(
},
)
},
onSearchClick = {
navController.navigateToSearch()
},
)
searchGraph(
onShowSnackBar = {},
onAuthExpired = {},
onBackButtonClick = {
navController.popBackStack()
},
)
policyDetailNavGraph(
onShowSnackBar = { onShowSnackBar(SnackbarState(it)) },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
package com.withpeace.withpeace.core.ui.policy

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.designsystem.util.dropShadow
import com.withpeace.withpeace.core.ui.R
import com.withpeace.withpeace.core.ui.bookmark.BookmarkButton

@Composable
fun YouthPolicyCard(
modifier: Modifier,
youthPolicy: YouthPolicyUiModel,
onPolicyClick: (String) -> Unit,
onBookmarkClick: (id: String, isChecked: Boolean) -> Unit,
) {
Card(
modifier = modifier
.fillMaxWidth()
.background(
color = WithpeaceTheme.colors.SystemWhite,
shape = RoundedCornerShape(size = 10.dp),
)
.dropShadow(
color = Color(0x1A000000),
blurRadius = 4.dp,
spreadRadius = 2.dp,
borderRadius = 10.dp,
)
.clickable {
onPolicyClick(youthPolicy.id)
},
) {
ConstraintLayout(
modifier = modifier
.fillMaxWidth()
.background(WithpeaceTheme.colors.SystemWhite)
.padding(16.dp),
) {
val (
title, content,
region, ageRange, thumbnail, heart,
) = createRefs()

Text(
text = youthPolicy.title,
modifier.constrainAs(
title,
constrainBlock = {
top.linkTo(parent.top)
start.linkTo(parent.start)
end.linkTo(thumbnail.start, margin = 8.dp)
width = Dimension.fillToConstraints
},
),
color = WithpeaceTheme.colors.SystemBlack,
style = WithpeaceTheme.typography.homePolicyTitle,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
Text(
text = youthPolicy.content,
modifier = modifier
.constrainAs(
content,
constrainBlock = {
top.linkTo(title.bottom, margin = 8.dp)
start.linkTo(parent.start)
end.linkTo(thumbnail.start, margin = 8.dp)
width = Dimension.fillToConstraints
},
),
color = WithpeaceTheme.colors.SystemBlack,
style = WithpeaceTheme.typography.homePolicyContent,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
)
BookmarkButton(
isClicked = youthPolicy.isBookmarked,
modifier = modifier.constrainAs(
heart,
) {
top.linkTo(content.bottom, margin = 8.dp)
start.linkTo(parent.start)
bottom.linkTo(parent.bottom)
},
onClick = { isClicked ->
onBookmarkClick(youthPolicy.id, isClicked)
},
)

Text(
text = youthPolicy.region.name,
color = WithpeaceTheme.colors.MainPurple,
modifier = modifier
.constrainAs(
region,
constrainBlock = {
top.linkTo(heart.top)
start.linkTo(heart.end, margin = 8.dp)
bottom.linkTo(heart.bottom)
},
)
.background(
color = WithpeaceTheme.colors.SubPurple,
shape = RoundedCornerShape(size = 5.dp),
)
.padding(horizontal = 8.dp, vertical = 4.dp),
style = WithpeaceTheme.typography.Tag,
)

Text(
text = youthPolicy.ageInfo,
color = WithpeaceTheme.colors.SystemGray1,
modifier = modifier
.constrainAs(
ageRange,
constrainBlock = {
top.linkTo(region.top)
start.linkTo(region.end, margin = 8.dp)
bottom.linkTo(region.bottom)
},
)
.background(
color = WithpeaceTheme.colors.SystemGray3,
shape = RoundedCornerShape(size = 5.dp),
)
.padding(horizontal = 8.dp, vertical = 4.dp),
style = WithpeaceTheme.typography.Tag,
)

Image(
modifier = modifier
.size(57.dp)
.clip(RoundedCornerShape(10.dp))
.constrainAs(
ref = thumbnail,
constrainBlock = {
start.linkTo(title.end)
end.linkTo(parent.end)
top.linkTo(parent.top)
},
),
painter = painterResource(id = youthPolicy.classification.drawableResId),
contentDescription = stringResource(R.string.policy_classification_image),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.withpeace.withpeace.feature.policylist.uistate
package com.withpeace.withpeace.core.ui.policy

import com.withpeace.withpeace.core.domain.model.policy.YouthPolicy
import com.withpeace.withpeace.core.ui.policy.ClassificationUiModel
import com.withpeace.withpeace.core.ui.policy.RegionUiModel
import com.withpeace.withpeace.core.ui.policy.toDomain
import com.withpeace.withpeace.core.ui.policy.toUiModel

data class YouthPolicyUiModel(
val id: String,
Expand Down Expand Up @@ -39,5 +35,3 @@ fun YouthPolicyUiModel.toDomain(): YouthPolicy {
isBookmarked = isBookmarked,
)
}

// 오류처리(Response 값 확인)+ 에러 상황 처리 logout(home 포함)
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ import kotlinx.coroutines.launch
fun HomeRoute(
onShowSnackBar: (message: String) -> Unit = {},
viewModel: HomeViewModel = hiltViewModel(),
onNavigationSnackBar: (message: String) -> Unit = {},
onNavigationSnackBar: (message: String) -> Unit = {},
onPolicyClick: (String) -> Unit,
onPostClick: (PostTopicUiModel) -> Unit,
onSearchClick: () -> Unit,
) {
val selectingFilterUiState = viewModel.selectingFilters.collectAsStateWithLifecycle()
val recentPosts = viewModel.recentPostsUiState.collectAsStateWithLifecycle()
Expand All @@ -90,15 +91,16 @@ fun HomeRoute(
hotPolicyUiState = hotPolicies.value,
recommendPolicyUiState = recommendPolicies.value,
completedFilterState = completedFilterUiState.value,
onSearchClick = onSearchClick,
)
}

@Composable
fun HomeScreen(
modifier: Modifier = Modifier,
recentPosts: RecentPostsUiState,
hotPolicyUiState: HotPolicyUiState,
recommendPolicyUiState: RecommendPolicyUiState,
modifier: Modifier = Modifier,
selectedFilterUiState: PolicyFiltersUiModel,
onDismissRequest: () -> Unit,
onClassificationCheckChanged: (ClassificationUiModel) -> Unit,
Expand All @@ -109,10 +111,12 @@ fun HomeScreen(
onPostClick: (PostTopicUiModel) -> Unit,
onPolicyClick: (String) -> Unit,
completedFilterState: PolicyFiltersUiModel,
onSearchClick: () -> Unit = {},
) {
Column(modifier = modifier.fillMaxSize()) {
HomeHeader(
modifier = modifier,
onSearchClick = onSearchClick,
)
HorizontalDivider(
modifier = modifier.height(1.dp),
Expand Down Expand Up @@ -476,6 +480,7 @@ private fun ScrollSection(
@Composable
private fun HomeHeader(
modifier: Modifier,
onSearchClick: () -> Unit,
) {
Box(
modifier = modifier
Expand All @@ -486,19 +491,20 @@ private fun HomeHeader(
Image(
modifier = modifier
.align(Alignment.BottomCenter)
.size(47.dp),
.width(47.dp)
.padding(top = 8.dp),
painter = painterResource(id = R.drawable.ic_home_logo),
contentDescription = stringResource(R.string.cheongha_logo),
)
// Image(
// modifier = modifier
// .size(24.dp)
// .align(Alignment.CenterEnd)
// .clickable {
// showBottomSheet = true
// },
// painter = painterResource(id = R.drawable.ic_filter),
// contentDescription = stringResource(R.string.filter),
// )
Image(
painter = painterResource(R.drawable.ic_search),
contentDescription = "검색",
modifier = modifier
.align(Alignment.CenterEnd)
.padding(top = 16.dp)
.clickable {
onSearchClick()
},
)
}
}
Loading