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

[UI/#60] 홈 뷰 / 홈 뷰 기본 UI 로직 구현 #68

Merged
merged 22 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5d04ced
[FEAT/#60] 유저 이름 길이에 따른 줄바꿈 구현
Hyobeen-Park Jul 12, 2024
a878eb3
Merge remote-tracking branch 'origin/develop' into ui/#60-home-ui-logic
Hyobeen-Park Jul 12, 2024
2e76fb2
[FEAT/#60] 필터링 없을 때 뷰 구현
Hyobeen-Park Jul 12, 2024
5dacfd4
[FEAT/#60] 필터링 유무에 따른 맞춤 공고 구현
Hyobeen-Park Jul 12, 2024
aed880c
[FEAT/#60] 필터링 정보 구현
Hyobeen-Park Jul 12, 2024
03bc5d2
[FEAT/#60] 바텀시트 추가
Hyobeen-Park Jul 12, 2024
d5ff213
[CHORE/#60] 필터 정보 함수화
Hyobeen-Park Jul 12, 2024
4b3f1d6
[FEAT/#60] 오늘 마감 공고 구현
Hyobeen-Park Jul 12, 2024
96eed7d
[FEAT/#60] 스크랩 공고 데이터 받아오기 구현
Hyobeen-Park Jul 12, 2024
f456b24
[FEAT/#60] 맞춤 공고 로직 구현
Hyobeen-Park Jul 12, 2024
675c11f
[FEAT/#60] 맞춤 공고 없을 때 구현
Hyobeen-Park Jul 12, 2024
63590a5
[CHORE/#60] 함수화 및 코드 정리
Hyobeen-Park Jul 12, 2024
523d270
Merge remote-tracking branch 'origin/develop' into ui/#60-home-ui-logic
Hyobeen-Park Jul 12, 2024
89769fd
[CHORE/#60] 패딩 수정
Hyobeen-Park Jul 12, 2024
de9ea12
Merge remote-tracking branch 'origin/develop' into ui/#60-home-ui-logic
Hyobeen-Park Jul 12, 2024
ad9ccc2
[CHORE/#60] 고정dp 제거
Hyobeen-Park Jul 12, 2024
525eb00
[CHORE/#60] 페이징 제거
Hyobeen-Park Jul 12, 2024
da6dc18
[CHORE/#60] ScrapBox backgroud shape 추가
Hyobeen-Park Jul 12, 2024
3544847
[CHORE/#60] mutableIntStateOf, collectAsStateWithLifecycle로 수정
Hyobeen-Park Jul 12, 2024
65a97f5
[MOD/#60] list -> data class로 수정
Hyobeen-Park Jul 12, 2024
56d273b
[CHORE/#60] 이름 줄바꿈 기준 상수화
Hyobeen-Park Jul 13, 2024
238ae15
[MOD/#60] null 처리 수정
Hyobeen-Park Jul 13, 2024
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.terning.core.designsystem.component.item

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -22,7 +19,6 @@ import com.terning.core.designsystem.theme.CalPink
import com.terning.core.designsystem.theme.CalPurple
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White

/**
Expand Down Expand Up @@ -53,7 +49,11 @@ fun ScrapBox(
.shadow(
elevation = elevation,
RoundedCornerShape(cornerRadius),
).background(scrapColor)
)
.background(
color = scrapColor,
shape = RoundedCornerShape(cornerRadius)
)
) {
Box(
modifier = Modifier
Expand Down
255 changes: 164 additions & 91 deletions feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Row
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.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -20,12 +19,15 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.terning.core.designsystem.component.bottomsheet.SortingBottomSheet
import com.terning.core.designsystem.component.button.SortingButton
import com.terning.core.designsystem.component.item.InternItem
Expand All @@ -37,24 +39,35 @@ import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White
import com.terning.core.extension.customShadow
import com.terning.feature.R
import com.terning.feature.home.home.component.HomeFilteringEmptyIntern
import com.terning.feature.home.home.component.HomeFilteringScreen
import com.terning.feature.home.home.component.HomeRecommendEmptyIntern
import com.terning.feature.home.home.component.HomeTodayEmptyIntern
import com.terning.feature.home.home.component.HomeTodayIntern
import com.terning.feature.home.home.model.RecommendInternData
import com.terning.feature.home.home.model.UserNameState
import com.terning.feature.home.home.model.UserScrapState

const val NAME_START_LENGTH = 7
const val NAME_END_LENGTH = 12

@Composable
fun HomeRoute() {
val currentSortBy: MutableState<Int> = remember {
mutableStateOf(0)
mutableIntStateOf(0)
}

HomeScreen(currentSortBy)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun HomeScreen(
currentSortBy: MutableState<Int>,
modifier: Modifier = Modifier,
viewModel: HomeViewModel = hiltViewModel(),
) {
val userNameState = viewModel.userName
val userScrapState by viewModel.scrapData.collectAsStateWithLifecycle()
val recommendInternData by viewModel.recommendInternData.collectAsStateWithLifecycle()
var sheetState by remember { mutableStateOf(false) }

if (sheetState) {
Expand All @@ -73,110 +86,170 @@ fun HomeScreen(
LogoTopAppBar()
}
) { paddingValues ->
LazyColumn(
Column(
modifier = Modifier
.fillMaxSize()
.padding(top = paddingValues.calculateTopPadding()),
contentPadding = PaddingValues(2.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
item {
Column(
modifier = Modifier
.padding(bottom = 16.dp)
) {
Text(
text = stringResource(
id = R.string.home_today_title, "남지우"
),
LazyColumn(
contentPadding = PaddingValues(
top = 2.dp,
bottom = 20.dp,
),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
item {
Column(
modifier = Modifier
.padding(top = 11.dp, bottom = 19.dp)
.padding(horizontal = 24.dp),
style = TerningTheme.typography.title1,
color = Black,
)
HomeTodayIntern()
.padding(bottom = 16.dp)
) {
ShowMainTitleWithName(userNameState)
ShowTodayIntern(userScrapState = userScrapState)
}
}
}
stickyHeader {
Column(
modifier = Modifier
.background(White)
) {
Text(
text = stringResource(id = R.string.home_recommend_sub_title),
style = TerningTheme.typography.detail2,
color = Black,
modifier = Modifier
.padding(top = 9.dp)
.padding(horizontal = 24.dp),
)

Text(
text = stringResource(id = R.string.home_recommend_main_title),
style = TerningTheme.typography.title1,
color = Black,
modifier = Modifier
.padding(top = 5.dp)
.padding(horizontal = 24.dp),
)

HomeFilteringScreen(
grade = 3,
period = 1,
startYear = 2024,
startMonth = 7,
)

HorizontalDivider(
thickness = 4.dp,
color = Grey150,
modifier = Modifier
.fillMaxWidth(),
)

Row(
stickyHeader {
Column(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
.background(White)
) {
SortingButton(
sortBy = currentSortBy.value,
onCLick = { sheetState = true },
ShowRecommendTitle()
ShowInternFilter(userNameState = userNameState)

HorizontalDivider(
thickness = 4.dp,
color = Grey150,
modifier = Modifier
.padding(vertical = 4.dp)
.fillMaxWidth(),
)
Spacer(modifier = Modifier.padding(9.dp))

Row(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
) {
SortingButton(
sortBy = currentSortBy.value,
onCLick = { sheetState = true },
modifier = Modifier
.padding(vertical = 4.dp)
)
Spacer(modifier = Modifier.padding(9.dp))
}
}
}

if (userNameState.internFilter != null && recommendInternData.isNotEmpty()) {
items(recommendInternData.size) { index ->
ShowRecommendIntern(recommendInternData[index])
}
}
}

items(itemCount) {
Box(
modifier = modifier
.height(92.dp)
if (userNameState.internFilter == null) {
HomeFilteringEmptyIntern(
modifier = Modifier
.padding(horizontal = 24.dp)
.customShadow(
color = Grey200,
shadowRadius = 10.dp,
shadowWidth = 2.dp
)
.background(
color = White,
shape = RoundedCornerShape(10.dp)
)
) {
InternItem(
imageUrl = "https://reqres.in/img/faces/7-image.jpg",
title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용",
dateDeadline = "2",
workingPeriod = "2",
isScraped = false,
)
}
.fillMaxSize()
)
} else if (recommendInternData.isEmpty()) {
HomeRecommendEmptyIntern()
}
}
}
}

private const val itemCount = 10
@Composable
private fun ShowMainTitleWithName(userNameState: UserNameState) {
Text(
text = stringResource(
id = R.string.home_today_title,
if (userNameState.userName.length in NAME_START_LENGTH..NAME_END_LENGTH) "\n" + userNameState.userName
else userNameState.userName
),
modifier = Modifier
.padding(top = 11.dp, bottom = 19.dp)
.padding(horizontal = 24.dp),
style = TerningTheme.typography.title1,
color = Black,
)
}

@Composable
private fun ShowTodayIntern(userScrapState: UserScrapState) {
if (userScrapState.isScrapExist) {
if (userScrapState.scrapData == null) {
HomeTodayEmptyIntern(isButtonExist = true)
} else {
HomeTodayIntern(userScrapState.scrapData)
}
} else {
HomeTodayEmptyIntern(isButtonExist = false)
}
}

@Composable
private fun ShowRecommendTitle() {
Text(
text = stringResource(id = R.string.home_recommend_sub_title),
style = TerningTheme.typography.detail2,
color = Black,
modifier = Modifier
.padding(top = 9.dp)
Comment on lines +196 to +198
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifier = Modifier
.padding(top = 9.dp)
.padding(horizontal = 24.dp),
modifier = Modifier
.padding(top = 9.dp, horizontal = 24.dp)

이렇게도 가능할 것 같네요..!!

.padding(horizontal = 24.dp),
)

Text(
text = stringResource(id = R.string.home_recommend_main_title),
style = TerningTheme.typography.title1,
color = Black,
modifier = Modifier
.padding(top = 5.dp)
.padding(horizontal = 24.dp),
)
}

@Composable
private fun ShowInternFilter(userNameState: UserNameState) {
if (userNameState.internFilter == null) {
HomeFilteringScreen(
grade = R.string.home_recommend_no_filtering_hyphen,
period = R.string.home_recommend_no_filtering_hyphen,
startYear = R.string.home_recommend_no_filtering_hyphen,
startMonth = R.string.home_recommend_no_filtering_hyphen
)
} else {
with(userNameState.internFilter) {
HomeFilteringScreen(
grade = grade,
period = workingPeriod,
startYear = startYear,
startMonth = startMonth,
)
}
}
}

@Composable
private fun ShowRecommendIntern(recommendInternData: RecommendInternData) {
Box(
modifier = Modifier
.padding(horizontal = 24.dp)
.customShadow(
color = Grey200,
shadowRadius = 10.dp,
shadowWidth = 2.dp
)
.background(
color = White,
shape = RoundedCornerShape(10.dp)
)
) {
InternItem(
imageUrl = recommendInternData.imgUrl,
title = recommendInternData.title,
dateDeadline = recommendInternData.dDay.toString(),
workingPeriod = recommendInternData.workingPeriod.toString(),
isScraped = recommendInternData.isScrapped,
)
}
}
Loading
Loading