Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into fix/#152-qa
  • Loading branch information
leeeyubin committed Jul 19, 2024
2 parents eb1f735 + d080386 commit eb2109b
Show file tree
Hide file tree
Showing 33 changed files with 857 additions and 564 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val Grey500 = Color(0xFF373737)
val Black = Color(0xFF171717)

// Main Color
val TerningMain = Color(0xFF1EA65E)
val TerningMain = Color(0xFF1EAC61)
val TerningMain2 = Color(0xFF179653)

// Sub Color
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 @@ -27,6 +27,12 @@ data class SearchResultResponseDto(
val title: String,
@SerialName("workingPeriod")
val workingPeriod: String,
@SerialName("startYearMonth")
val startYearMonth: String,
@SerialName("color")
val color: String?,
@SerialName("deadline")
val deadline: String,
)

fun toSearchResultEntity(): List<SearchResultModel> {
Expand All @@ -38,6 +44,9 @@ data class SearchResultResponseDto(
workingPeriod = it.workingPeriod,
companyImage = it.companyImage,
scrapId = it.scrapId,
deadline = it.deadline,
startYearMonth = it.startYearMonth,
color = it.color
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ data class SearchResultModel(
val workingPeriod: String,
val companyImage: String,
val scrapId: Long?,
val deadline: String,
val startYearMonth: String,
val color: String?,
)
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 @@ -198,7 +196,7 @@ private fun InternDialogContent(
contentAlignment = Alignment.Center
) {
ColorPalette(
initialColor = CalRed,
initialColor = selectedColor,
onColorSelected = { newColor ->
selectedColor = newColor
}
Expand All @@ -221,66 +219,37 @@ private fun InternDialogContent(
) {
InternInfoRow(
title = stringResource(id = com.terning.feature.R.string.intern_info_d_day),
value = scrapDetailModel?.title.orEmpty()
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
Loading

0 comments on commit eb2109b

Please sign in to comment.