Skip to content

Commit

Permalink
홈, 마이페이지의 내 체크리스트 화면 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
leesa-l committed Nov 20, 2023
1 parent 6252d4d commit 48382b3
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 108 deletions.
2 changes: 2 additions & 0 deletions presentation/home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ dependencies {
implementation(project(":domain"))
implementation(project(":presentation:resource"))
implementation(project(":presentation:deeplink"))
implementation(libs.compose.navigation)
implementation(libs.coil.compose)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.dkin.chevit.core.mvi.MVIComposeFragment
import com.dkin.chevit.presentation.deeplink.DeepLink
import com.dkin.chevit.presentation.deeplink.DeepLink.OnBoarding
import com.dkin.chevit.presentation.deeplink.deepLink
import com.dkin.chevit.presentation.home.MyPageEffect.NavigateToMyCheckList
import com.dkin.chevit.presentation.home.MyPageEffect.NavigateToNotificationSetting
import com.dkin.chevit.presentation.home.MyPageEffect.NavigateToOnBoarding
import com.dkin.chevit.presentation.home.MyPageEffect.NavigateToProfileSetting
Expand Down Expand Up @@ -94,7 +93,6 @@ class Home : MVIComposeFragment<HomeIntent, HomeState, HomeEffect>() {

private fun processEffect(effect: MyPageEffect) {
when (effect) {
NavigateToMyCheckList -> {}
NavigateToNotificationSetting -> {
val settingsIntent: Intent = Intent("android.settings.APP_NOTIFICATION_SETTINGS")
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ data class HomeState(
isProgress = true,
backgroundUrl = "",
),
CheckListItem(
id = "1",
title = "오사카, 일본",
date = "2023.07.10 ~ 2023.07.12",
isProgress = true,
backgroundUrl = "",
),
CheckListItem(
id = "2",
title = "토론토, 캐나다",
date = "2023.07.01 ~ 2023.07.10",
isProgress = true,
backgroundUrl = "",
),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import androidx.compose.ui.unit.dp
import com.dkin.chevit.presentation.home.component.BottomNavigation
import com.dkin.chevit.presentation.home.contents.HomeTabContents
import com.dkin.chevit.presentation.home.contents.SearchTabContents
import com.dkin.chevit.presentation.home.contents.TemplateTabContents
import com.dkin.chevit.presentation.home.contents.UserTabContents
import com.dkin.chevit.presentation.home.contents.template.TemplateTabContents
import com.dkin.chevit.presentation.home.contents.user.UserTabContents
import com.dkin.chevit.presentation.resource.ChevitTheme
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -55,6 +55,7 @@ fun HomeScreen(
templateViewModel = templateViewModel
)
HomeTab.USER -> UserTabContents(
homeViewModel = homeViewModel,
myViewModel = myPageViewModel,
versionName = versionName,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import javax.inject.Inject
@HiltViewModel
class HomeViewModel @Inject constructor() : MVIViewModel<HomeIntent, HomeState, HomeEffect>() {

override fun createInitialState(): HomeState = HomeState.empty()
override fun createInitialState(): HomeState = HomeState.dummy()

override suspend fun processIntent(intent: HomeIntent) {
when (intent) {
is HomeIntent.NoticeClicked -> {}
}
}

fun refreshMyCheckList() {
//todo mypage에서 내 체크리스트 이동 시 사용
}

fun onClickAddChecklist() {
setEffect { HomeEffect.NavigateToAddCheckList }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ data class MyPageState(
sealed interface MyPageEffect : ViewEffect {
object NavigateToProfileSetting : MyPageEffect

object NavigateToMyCheckList : MyPageEffect

object NavigateToTerms : MyPageEffect

object NavigateToNotificationSetting : MyPageEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ class MyPageViewModel @Inject constructor(
setEffect { MyPageEffect.NavigateToProfileSetting }
}

fun onClickMyCheckList() {
setEffect { MyPageEffect.NavigateToMyCheckList }
}

fun onClickTerms() {
setEffect { MyPageEffect.NavigateToTerms }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
package com.dkin.chevit.presentation.home.contents

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
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.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.dkin.chevit.presentation.home.HomeState
import com.dkin.chevit.presentation.home.HomeViewModel
import com.dkin.chevit.presentation.home.component.HomeTopBar
import com.dkin.chevit.presentation.home.contents.component.EmptyChecklist
import com.dkin.chevit.presentation.home.contents.component.MyChecklistItem
import com.dkin.chevit.presentation.resource.ChevitButtonFillLarge
import com.dkin.chevit.presentation.resource.ChevitTheme
import com.dkin.chevit.presentation.resource.icon.ChevitIcon
Expand Down Expand Up @@ -130,91 +122,20 @@ fun HomeTabContents(
val checkList = homeState.checkList
if (checkList.isEmpty()) {
Spacer(Modifier.height(24.dp))
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Image(
modifier = Modifier
.align(Alignment.Center)
.size(130.dp),
painter = painterResource(id = com.dkin.chevit.presentation.resource.R.drawable.ic_empty_checklist),
contentDescription = "",
)
}
Spacer(modifier = Modifier.height(12.dp))
Text(
modifier = Modifier.fillMaxWidth(),
text = "생성된 체크리스트가 없어요\n여행 일정을 추가해서 만들어 보아요!",
style = ChevitTheme.typhography.bodyLarge.copy(
color = ChevitTheme.colors.textSecondary,
),
textAlign = TextAlign.Center,
)
EmptyChecklist(modifier = Modifier.fillMaxWidth())
} else {
Spacer(Modifier.height(20.dp))
checkList.forEach {
CheckListContents(
MyChecklistItem(
item = it,
onClickLink = { id -> homeViewModel.onClickChecklist(id) },
onClickItem = { id -> homeViewModel.onClickChecklist(id) },
modifier = Modifier.fillMaxWidth(),
)
Spacer(modifier = Modifier.height(20.dp))
}
}
Spacer(modifier = Modifier.height(36.dp))
}
}
}
}

@Composable
private fun CheckListContents(
item: HomeState.CheckListItem,
onClickLink: (id: String) -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.fillMaxWidth()
.clip(RoundedCornerShape(12.dp))
// Todo 이미지로 배경 변경
.background(color = Color.Gray)
.padding(vertical = 12.5.dp, horizontal = 14.5.dp),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 26.dp),
contentAlignment = Alignment.CenterEnd,
) {
if (item.isProgress) {
Box(
modifier = Modifier
.clickable { onClickLink(item.id) }
.background(
color = ChevitTheme.colors.grey10,
shape = RoundedCornerShape(100.dp),
)
.border(
width = 1.dp,
color = ChevitTheme.colors.grey4,
shape = RoundedCornerShape(100.dp),
)
.padding(horizontal = 14.dp, vertical = 4.dp),
contentAlignment = Alignment.Center,
) {
Text(
text = "진행중",
style = ChevitTheme.typhography.bodySmall.copy(color = ChevitTheme.colors.white),
)
}
}
}
Text(
text = item.title,
style = ChevitTheme.typhography.headlineSmall.copy(color = ChevitTheme.colors.white),
)
Text(
text = item.date,
style = ChevitTheme.typhography.bodySmall.copy(color = ChevitTheme.colors.white),
)
}
Spacer(modifier = Modifier.height(20.dp))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.dkin.chevit.presentation.home.contents.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.dkin.chevit.presentation.resource.ChevitTheme
import com.dkin.chevit.presentation.resource.R

@Composable
fun EmptyChecklist(modifier: Modifier) {
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Column(
modifier = modifier.fillMaxWidth()
) {
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Image(
modifier = Modifier
.align(Alignment.Center)
.size(130.dp),
painter = painterResource(id = R.drawable.ic_empty_checklist),
contentDescription = "",
)
}
Spacer(modifier = Modifier.height(12.dp))
Text(
modifier = Modifier.fillMaxWidth(),
text = "생성된 체크리스트가 없어요\n여행 일정을 추가해서 만들어 보아요!",
style = ChevitTheme.typhography.bodyLarge.copy(
color = ChevitTheme.colors.textSecondary,
),
textAlign = TextAlign.Center,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.dkin.chevit.presentation.home.contents.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.dkin.chevit.presentation.home.HomeState
import com.dkin.chevit.presentation.resource.ChevitTheme

@Composable
fun MyChecklistItem(
item: HomeState.CheckListItem,
onClickItem: (id: String) -> Unit,
modifier: Modifier = Modifier,
) {
Box(modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(12.dp))
.background(color = ChevitTheme.colors.grey4)
.clickable { onClickItem(item.id) }
) {
AsyncImage(
modifier = Modifier.fillMaxWidth(),
model = ImageRequest.Builder(LocalContext.current)
.data(item.backgroundUrl)
.crossfade(true)
.build(),
contentDescription = "",
contentScale = ContentScale.FillWidth
)
Column(
modifier = modifier
.fillMaxWidth()
.padding(vertical = 12.5.dp, horizontal = 14.5.dp),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 26.dp),
contentAlignment = Alignment.CenterEnd,
) {
if (item.isProgress) {
Box(
modifier = Modifier
.background(
color = ChevitTheme.colors.grey10,
shape = RoundedCornerShape(100.dp),
)
.border(
width = 1.dp,
color = ChevitTheme.colors.grey4,
shape = RoundedCornerShape(100.dp),
)
.padding(horizontal = 14.dp, vertical = 4.dp),
contentAlignment = Alignment.Center,
) {
Text(
text = "진행중",
style = ChevitTheme.typhography.bodySmall.copy(color = ChevitTheme.colors.white),
)
}
}
}
Text(
text = item.title,
style = ChevitTheme.typhography.headlineSmall.copy(color = ChevitTheme.colors.white),
)
Text(
text = item.date,
style = ChevitTheme.typhography.bodySmall.copy(color = ChevitTheme.colors.white),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dkin.chevit.presentation.home.contents
package com.dkin.chevit.presentation.home.contents.template

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down
Loading

0 comments on commit 48382b3

Please sign in to comment.