Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into fix/#154-home-firs…
Browse files Browse the repository at this point in the history
…t-qa
  • Loading branch information
Hyobeen-Park committed Jul 19, 2024
2 parents 931afbd + 3d821a1 commit 83d626b
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ fun ScrapCancelDialogContent(
) {
TerningLottieAnimation(
jsonString = "terning_scrap_cancel.json",
modifier = Modifier.fillMaxWidth().aspectRatio(1f)
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
)

Text(
Expand All @@ -69,19 +71,14 @@ fun ScrapCancelDialogContent(
top = 5.dp
)
)
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.BottomCenter
) {
RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = R.string.dialog_scrap_cancel_button,
onButtonClick = onClickScrapCancel,
modifier = Modifier.padding(bottom = 8.dp)
)
}
RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = R.string.dialog_scrap_cancel_button,
onButtonClick = onClickScrapCancel,
modifier = Modifier.padding(bottom = 8.dp, top = 40.dp)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -47,7 +48,8 @@ fun TerningBasicDialog(
) {
Box(
modifier = Modifier
.size(width = 300.dp, height = 472.dp)
.wrapContentSize()
.padding(horizontal = 27.dp)
.background(
color = White,
shape = RoundedCornerShape(20.dp)
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/com/terning/core/extension/LocalDateExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ fun LocalDate.getStringAsTitle(): String =
fun LocalDate.getDateStringInKorean(): String =
"${monthValue}${dayOfMonth}${dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN)}"

fun LocalDate.getFullDateStringInKorean(): String = "${year}${monthValue}${dayOfMonth}"

fun LocalDate.getDateAsMapString(): String {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
return format(formatter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -62,6 +63,17 @@ private fun CalendarScreen(
val lifecycleOwner = LocalLifecycleOwner.current
val calendarUiState by viewModel.uiState.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner)



val state by remember { mutableStateOf(CalendarState()) }

val listState = rememberLazyListState(
initialFirstVisibleItemIndex = state.getInitialPage()
)

var currentDate by rememberSaveable { mutableStateOf(YearMonth.now()) }
var currentPage by rememberSaveable { mutableIntStateOf(listState.firstVisibleItemIndex) }

LaunchedEffect(viewModel.calendarSideEffect, lifecycleOwner) {
viewModel.calendarSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle)
.collect { sideEffect ->
Expand All @@ -71,15 +83,6 @@ private fun CalendarScreen(
}
}

val state by remember { mutableStateOf(CalendarState()) }

val listState = rememberLazyListState(
initialFirstVisibleItemIndex = state.getInitialPage()
)

var currentDate by remember { mutableStateOf(YearMonth.now()) }
var currentPage by remember { mutableIntStateOf(listState.firstVisibleItemIndex) }

LaunchedEffect(key1 = listState) {
snapshotFlow { listState.firstVisibleItemIndex }
.distinctUntilChanged()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.terning.feature.calendar.calendar.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -9,13 +8,13 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
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.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
Expand All @@ -36,18 +35,14 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.terning.core.R
import com.terning.core.designsystem.component.button.RoundButton
import com.terning.core.designsystem.component.dialog.TerningBasicDialog
import com.terning.core.designsystem.component.item.ColorPalette
import com.terning.core.designsystem.theme.CalBlue2
import com.terning.core.designsystem.theme.CalGreen2
import com.terning.core.designsystem.theme.CalRed
import com.terning.core.designsystem.theme.Grey200
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey350
import com.terning.core.designsystem.theme.Grey500
import com.terning.core.designsystem.theme.TerningMain
Expand All @@ -57,26 +52,21 @@ import com.terning.core.designsystem.theme.White
import com.terning.core.extension.noRippleClickable
import com.terning.domain.entity.response.CalendarScrapDetailModel
import com.terning.feature.intern.component.InternInfoRow
import com.terning.feature.intern.model.InternViewState
import java.time.LocalDate

@Composable
fun CalendarDetailDialog(
deadline: String,
scrapDetailModel: CalendarScrapDetailModel?,
onDismissRequest: () -> Unit,
onClickChangeColorButton: (Color) -> Unit,
onClickNavigateButton: (Long) -> Unit,
) {
TerningBasicDialog(
onDismissRequest = onDismissRequest,
properties = DialogProperties(
usePlatformDefaultWidth = false,
decorFitsSystemWindows = true,
dismissOnBackPress = true,
dismissOnClickOutside = false,
)
onDismissRequest = onDismissRequest
) {
InternDialogContent(
deadline = deadline,
scrapDetailModel = scrapDetailModel,
onClickChangeColorButton = onClickChangeColorButton,
onClickNavigateButton = onClickNavigateButton
Expand All @@ -87,22 +77,30 @@ fun CalendarDetailDialog(

@Composable
private fun InternDialogContent(
deadline: String,
scrapDetailModel: CalendarScrapDetailModel?,
onClickChangeColorButton: (Color) -> Unit,
onClickNavigateButton: (Long) -> Unit
) {
var isPaletteOpen by remember { mutableStateOf(false) }
var selectedColor by remember {mutableStateOf(Color(android.graphics.Color.parseColor(scrapDetailModel?.color)))}
var selectedColor by remember {
mutableStateOf(
Color(
android.graphics.Color.parseColor(
scrapDetailModel?.color
)
)
)
}

Box(
modifier = Modifier
.fillMaxSize()
.wrapContentSize()
.padding(top = 32.dp),
contentAlignment = Alignment.TopCenter
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 11.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand All @@ -115,11 +113,11 @@ private fun InternDialogContent(
modifier = Modifier
.width(80.dp)
.aspectRatio(1f)
.clip(RoundedCornerShape(5.dp))
.clip(RoundedCornerShape(15.dp))
.border(
width = 1.dp,
color = TerningMain,
shape = RoundedCornerShape(size = 5.dp)
shape = RoundedCornerShape(size = 15.dp)
)
)
Text(
Expand Down Expand Up @@ -221,66 +219,37 @@ private fun InternDialogContent(
) {
InternInfoRow(
title = stringResource(id = com.terning.feature.R.string.intern_info_d_day),
value = scrapDetailModel?.deadLine.toString()
value = deadline
)
InternInfoRow(
title = stringResource(id = com.terning.feature.R.string.intern_info_working),
value = scrapDetailModel?.workingPeriod.orEmpty()
)
InternInfoRow(
title = stringResource(id = com.terning.feature.R.string.intern_info_start_date),
value = "${scrapDetailModel?.startYear?:LocalDate.now().year}" +
"${scrapDetailModel?.startMonth?:LocalDate.now().monthValue}"
value = "${scrapDetailModel?.startYear ?: LocalDate.now().year}" +
"${scrapDetailModel?.startMonth ?: LocalDate.now().monthValue}"
)
}
}
}
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.BottomCenter
) {
RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = if (isPaletteOpen) R.string.dialog_content_calendar_color_change
else R.string.dialog_scrap_move_to_intern,
onButtonClick = {
if (isPaletteOpen) {
onClickChangeColorButton(selectedColor)
isPaletteOpen = false
} else {
onClickNavigateButton(scrapDetailModel?.internshipAnnouncementId?:0)
}
},
modifier = Modifier.padding(bottom = 8.dp)
)
}
}
}
}

@Preview(showBackground = true)
@Composable
fun InternDialogContentPreview() {
TerningPointTheme {
CalendarDetailDialog(
onDismissRequest = {},
onClickChangeColorButton = {},
onClickNavigateButton = {},
scrapDetailModel = CalendarScrapDetailModel(
scrapId = 123,
internshipAnnouncementId = 123,
title = "테스트",
dDay = "asdas",
workingPeriod = "asdas",
startYear = 2023,
startMonth = 1,
isScrapped = true,
color = "0xFF4c3552",
companyImage = "",
deadLine = "sads"
RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = if (isPaletteOpen) R.string.dialog_content_calendar_color_change
else R.string.dialog_scrap_move_to_intern,
onButtonClick = {
if (isPaletteOpen) {
onClickChangeColorButton(selectedColor)
isPaletteOpen = false
} else {
onClickNavigateButton(scrapDetailModel?.internshipAnnouncementId ?: 0)
}
},
modifier = Modifier.padding(bottom = 8.dp)
)
)

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.terning.core.extension.getFullDateStringInKorean
import com.terning.feature.calendar.calendar.CalendarViewModel
import com.terning.feature.intern.navigation.navigateIntern

Expand All @@ -30,6 +31,7 @@ fun CalendarDialog(

if (uiState.isInternshipClicked) {
CalendarDetailDialog(
deadline = uiState.selectedDate.getFullDateStringInKorean(),
scrapDetailModel = uiState.internshipModel,
onDismissRequest = {viewModel.updateInternDialogVisible(false)},
onClickChangeColorButton = { newColor ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.extension.getDateAsMapString
import com.terning.core.extension.isToday
import com.terning.core.extension.noRippleClickable
import com.terning.domain.entity.response.CalendarScrapModel
import com.terning.feature.calendar.calendar.CalendarUiState
import com.terning.feature.calendar.month.component.CalendarDay
Expand Down Expand Up @@ -44,6 +45,12 @@ fun CalendarMonth(
Column(
modifier = Modifier
.weight(1f)
.fillMaxSize()
.noRippleClickable {
if(!day.isOutDate) {
onDateSelected(day.date)
}
}
.padding(top = 15.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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.designsystem.theme.White
import com.terning.core.extension.noRippleClickable
import com.terning.feature.calendar.month.model.DayClass
import java.time.LocalDate

Expand All @@ -31,7 +32,7 @@ fun CalendarDay(
dayData: DayClass,
isSelected: Boolean,
isToday: Boolean,
onDateSelected: (LocalDate) -> Unit
onDateSelected: (LocalDate) -> Unit = {}
) {
val backgroundColor =
if (isSelected) TerningMain else if (isToday) Grey200 else Color.Transparent
Expand All @@ -52,15 +53,11 @@ fun CalendarDay(
Box(
modifier = Modifier
.size(22.dp)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = {
if (!dayData.isOutDate) {
onDateSelected(dayData.date)
}
.noRippleClickable {
if (!dayData.isOutDate) {
onDateSelected(dayData.date)
}
)
}
.background(
color = backgroundColor,
shape = CircleShape
Expand Down
Loading

0 comments on commit 83d626b

Please sign in to comment.