Skip to content

Commit

Permalink
[MERGE] #37 -> develop
Browse files Browse the repository at this point in the history
[UI/#37] 캘린더뷰 / 스크랩 목록 뷰
  • Loading branch information
boiledEgg-s authored Jul 11, 2024
2 parents 0795434 + 7203b87 commit 3b3a723
Show file tree
Hide file tree
Showing 29 changed files with 664 additions and 222 deletions.
3 changes: 3 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ dependencies {
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

//ThirdPartyDependencies
implementation(libs.compose.coil)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package com.terning.core.designsystem.component.item

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
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.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.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.terning.core.R
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.noRippleClickable

@Composable
fun InternItem(
imageUrl: String,
title: String,
dateDeadline: String,
workingPeriod: String,
isScraped: Boolean,
modifier: Modifier = Modifier,
scrapId: Int = 0,
onScrapButtonClicked: (Int) -> Unit = {},
) {
Row(
modifier = modifier
.padding(10.dp)
.fillMaxSize(),
) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data(imageUrl)
.build(),
contentDescription = title,
Modifier
.fillMaxHeight()
.aspectRatio(1f)
.clip(RoundedCornerShape(5.dp))
.background(color = Grey300)
)
Column(
modifier = Modifier
.padding(start = 8.dp)
.fillMaxHeight()
) {
Text(
text = stringResource(id = R.string.intern_item_d_day, dateDeadline),
style = TerningTheme.typography.detail0,
color = TerningMain,
)

Text(
text = title,
style = TerningTheme.typography.title5,
color = Black,
softWrap = true,
modifier = modifier.padding(top = 3.dp),
)

Row(
modifier = Modifier.fillMaxHeight(),
verticalAlignment = Alignment.Bottom
) {
Text(
text = stringResource(R.string.intern_item_working_period),
style = TerningTheme.typography.detail3,
color = Grey400
)

Text(
text = stringResource(id = R.string.intern_item_working_period_month, workingPeriod),
style = TerningTheme.typography.detail3,
color = TerningMain,
modifier = modifier
.padding(start = 4.dp)
)
}
}

Box(modifier = Modifier.fillMaxSize()) {
Image(
painter = painterResource(
id =
if (isScraped)
R.drawable.ic_bookmark_filled
else
R.drawable.ic_bookmark_outlined
),
contentDescription = stringResource(id = R.string.intern_item_scrap),
modifier = modifier
.align(Alignment.BottomEnd)
.noRippleClickable {
onScrapButtonClicked(scrapId)
},
)
}
}
}

@Preview(showBackground = true)
@Composable
fun InternItemPreview() {
TerningPointTheme {
Box(
modifier = Modifier
.height(height = 92.dp)
.fillMaxWidth(),
){
InternItem(
imageUrl = "",
title = "test title",
dateDeadline = "3",
workingPeriod = "6",
isScraped = true
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.terning.core.designsystem.component.box
package com.terning.core.designsystem.component.item

import androidx.compose.foundation.background
import androidx.compose.foundation.border
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.terning.feature.calendar.component
package com.terning.core.designsystem.component.topappbar

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand All @@ -15,19 +15,21 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.getStringAsTitle
import com.terning.core.extension.noRippleClickable
import com.terning.feature.R
import java.time.LocalDate

@Composable
fun CalendarTopBar(
fun CalendarTopAppBar(
modifier: Modifier = Modifier,
date: LocalDate,
isWeekExpanded: Boolean,
isListExpanded: Boolean,
onListButtonClicked: () -> Unit,
onMonthNavigationButtonClicked: (Int) -> Unit,
Expand All @@ -47,24 +49,28 @@ fun CalendarTopBar(
modifier = Modifier.align(Alignment.Center),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(id = R.drawable.ic_calendar_previous),
contentDescription = stringResource(id = R.string.calendar_button_description_previous),
tint = Grey300,
modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(-1) }
)
if(!isWeekExpanded || isListExpanded) {
Icon(
painter = painterResource(id = R.drawable.ic_calendar_previous),
contentDescription = stringResource(id = R.string.calendar_button_description_previous),
tint = Grey300,
modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(-1) }
)
}
Text(
text = date.getStringAsTitle(),
style = TerningTheme.typography.title2,
color = Black,
modifier = Modifier.padding(horizontal = 8.dp)
)
Icon(
painter = painterResource(id = R.drawable.ic_calendar_next),
contentDescription = stringResource(id = R.string.calendar_button_description_next),
tint = Grey300,
modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(1) }
)
if(!isWeekExpanded || isListExpanded) {
Icon(
painter = painterResource(id = R.drawable.ic_calendar_next),
contentDescription = stringResource(id = R.string.calendar_button_description_next),
tint = Grey300,
modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(1) }
)
}
}
Box(
modifier = Modifier
Expand All @@ -80,7 +86,7 @@ fun CalendarTopBar(
),
contentDescription = stringResource(id = R.string.calendar_button_description_list),
modifier = Modifier.noRippleClickable { onListButtonClicked() },
tint = if (isListExpanded) Color.Green else Color.LightGray,
tint = if (isListExpanded) TerningMain else Grey300,
)
}
}
Expand All @@ -90,9 +96,11 @@ fun CalendarTopBar(
@Composable
fun CalendarTopBarPreview() {
TerningPointTheme {
CalendarTopBar(
CalendarTopAppBar(
date = LocalDate.now(),
isListExpanded = false,
isWeekExpanded = false
,
onListButtonClicked = {},
onMonthNavigationButtonClicked = {}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.terning.core.extension

import java.time.LocalDate
import java.time.format.TextStyle
import java.util.Locale

fun LocalDate.getStringAsTitle(): String =
"${year}${monthValue.toString().padStart(2, '0')}"

fun LocalDate.getWeekIndexContainingSelectedDate(): Int = dayOfMonth / 7
fun LocalDate.getDateStringInKorean(): String =
"${monthValue}${dayOfMonth}${dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN)}"

fun LocalDate.getWeekIndexContainingSelectedDate(inDays: Int): Int = (inDays + dayOfMonth - 1) / 7

fun LocalDate.isToday(): Boolean = this == LocalDate.now()
13 changes: 13 additions & 0 deletions core/src/main/res/drawable/ic_bookmark_filled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M16,3H8C6.895,3 6,3.895 6,5V21L11.375,16.7C11.741,16.408 12.259,16.408 12.625,16.7L18,21V5C18,3.895 17.105,3 16,3Z"
android:strokeLineJoin="round"
android:strokeWidth="2.04"
android:fillColor="#1EAC61"
android:strokeColor="#1EAC61"
android:strokeLineCap="round"/>
</vector>
13 changes: 13 additions & 0 deletions core/src/main/res/drawable/ic_bookmark_outlined.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M16,3H8C6.895,3 6,3.895 6,5V21L11.375,16.7C11.741,16.408 12.259,16.408 12.625,16.7L18,21V5C18,3.895 17.105,3 16,3Z"
android:strokeLineJoin="round"
android:strokeWidth="2.04"
android:fillColor="#00000000"
android:strokeColor="#ADADAD"
android:strokeLineCap="round"/>
</vector>
11 changes: 11 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
<!-- button-->
<string name="button_preview">button</string>

<!-- Intern Item-->
<string name="intern_item_working_period">근무기간</string>
<string name="intern_item_working_period_month">%s개월</string>
<string name="intern_item_d_day">D-%s</string>
<string name="intern_item_scrap">스크랩</string>

<!-- Calendar-->
<string name="calendar_button_description_previous">previous</string>
<string name="calendar_button_description_next">next</string>
<string name="calendar_button_description_list">list</string>

<!-- 정렬 버튼 + 바텀시트 -->
<string name="sort_by_earliest">채용 마감 이른순</string>
<string name="sort_by_shortest">짧은 근무 기간순</string>
Expand Down
Loading

0 comments on commit 3b3a723

Please sign in to comment.