From 0e5a01b895c90ebc1fa0c45db1db904055425cfe Mon Sep 17 00:00:00 2001 From: boiledegg Date: Thu, 18 Jul 2024 22:34:45 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[FEAT/#129]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EC=B7=A8=EC=86=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 40 ++++++++++++++++++- .../component/CalendarDetailDialog.kt | 20 +++++----- .../calendar/scrap/CalendarListScreen.kt | 7 ++-- .../calendar/scrap/component/CalendarScrap.kt | 1 + .../calendar/week/CalendarWeekScreen.kt | 2 +- 5 files changed, 55 insertions(+), 15 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt index addc7f1e1..d5aa2a905 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt @@ -1,14 +1,19 @@ package com.terning.feature.calendar.calendar +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState +import com.terning.domain.entity.request.ScrapRequestModel import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.domain.repository.CalendarRepository +import com.terning.domain.repository.ScrapRepository import com.terning.feature.R import com.terning.feature.calendar.month.CalendarMonthState import com.terning.feature.calendar.scrap.CalendarListState import com.terning.feature.calendar.week.CalendarWeekState +import com.terning.feature.intern.InternViewSideEffect +import com.terning.feature.intern.model.InternScrapState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow @@ -24,7 +29,8 @@ import javax.inject.Inject @HiltViewModel class CalendarViewModel @Inject constructor( - private val calendarRepository: CalendarRepository + private val calendarRepository: CalendarRepository, + private val scrapRepository: ScrapRepository ) : ViewModel() { private var _uiState: MutableStateFlow = MutableStateFlow( @@ -45,6 +51,10 @@ class CalendarViewModel @Inject constructor( private val _calendarWeekState = MutableStateFlow(CalendarWeekState()) val calendarWeekState = _calendarWeekState.asStateFlow() + private val _scrapState: MutableStateFlow = + MutableStateFlow(InternScrapState()) + val scrapState = _scrapState.asStateFlow() + private val _calendarSideEffect: MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() @@ -168,4 +178,32 @@ class CalendarViewModel @Inject constructor( } ) } + + fun deleteScrap(isFromWeekScreen: Boolean = true) = viewModelScope.launch { + _calendarWeekState.value.loadState + .takeIf { it is UiState.Success } + ?.let { ScrapRequestModel(_uiState.value.scrapId, null) }?.let { scrapRequestModel -> + Log.d("calendarViewModel", uiState.value.scrapId.toString()) + scrapRepository.deleteScrap( + scrapRequestModel + ).onSuccess { + runCatching { + if (isFromWeekScreen) { + getScrapWeekList() + } else { + getScrapMonth( + _uiState.value.selectedDate.year, + _uiState.value.selectedDate.monthValue + ) + } + }.onSuccess { + updateScrapCancelDialogVisible() + } + }.onFailure { + _calendarSideEffect.emit( + CalendarSideEffect.ShowToast(R.string.server_failure) + ) + } + } + } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt index a3118e705..7beaf5e9e 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt @@ -54,8 +54,8 @@ import com.terning.feature.intern.model.InternViewState @Composable fun CalendarDetailDialog( onDismissRequest: () -> Unit, - onClickColor: (Color) -> Unit, - onClickNavigate: () -> Unit, + onClickChangeColorButton: (Color) -> Unit, + onClickNavigateButton: (Long) -> Unit, ) { TerningBasicDialog( onDismissRequest = onDismissRequest, @@ -81,8 +81,8 @@ fun CalendarDetailDialog( isScrapped = true ), state = InternViewState(), - onClickColor = onClickColor, - onClickNavigate = onClickNavigate + onClickChangeColorButton = onClickChangeColorButton, + onClickNavigateButton = onClickNavigateButton ) } } @@ -92,8 +92,8 @@ fun CalendarDetailDialog( private fun InternDialogContent( scrapDetailModel: CalendarScrapDetailModel, state: InternViewState, - onClickColor: (Color) -> Unit, - onClickNavigate: () -> Unit + onClickChangeColorButton: (Color) -> Unit, + onClickNavigateButton: (Long) -> Unit ) { var isPaletteOpen by remember { mutableStateOf(false) } var selectedColor by remember {mutableStateOf(Color.Red)} @@ -254,10 +254,10 @@ private fun InternDialogContent( else R.string.dialog_scrap_move_to_intern, onButtonClick = { if (isPaletteOpen) { - onClickColor(selectedColor) + onClickChangeColorButton(selectedColor) isPaletteOpen = false } else { - onClickNavigate() + onClickNavigateButton(scrapDetailModel.internshipAnnouncementId) } }, modifier = Modifier.padding(bottom = 8.dp) @@ -273,8 +273,8 @@ fun InternDialogContentPreview() { TerningPointTheme { CalendarDetailDialog( onDismissRequest = {}, - onClickNavigate = {}, - onClickColor = {} + onClickChangeColorButton = {}, + onClickNavigateButton = {} ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 100446cb5..f2206b0d3 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme @@ -135,18 +136,18 @@ fun CalendarListScreen( CalendarCancelDialog( onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, onClickScrapCancel = { - viewModel.updateScrapCancelDialogVisible() + viewModel.deleteScrap() } ) } if (uiState.isInternshipClicked) { CalendarDetailDialog( onDismissRequest = {viewModel.updateInternDialogVisible(null)}, - onClickColor = { newColor -> + onClickChangeColorButton = { newColor -> Timber.tag("CalendarScreen") .d(": $newColor") }, - onClickNavigate = { + onClickNavigateButton = { viewModel.updateInternDialogVisible(null) } ) diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt index 7a93ba262..8d3e7fa72 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt @@ -26,6 +26,7 @@ fun CalendarScrap( elevation = 1.dp, ) { InternItem( + scrapId = scrap.scrapId, imageUrl = scrap.companyImage.orEmpty(), title = scrap.title, dateDeadline = scrap.dDay, diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index aaee1767d..d81029055 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -102,7 +102,7 @@ fun CalendarWeekScreen( CalendarCancelDialog( onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, onClickScrapCancel = { - viewModel.updateScrapCancelDialogVisible() + viewModel.deleteScrap() } ) } From 474a026ff5a178c5f23184bf429198d9d22adc2c Mon Sep 17 00:00:00 2001 From: boiledegg Date: Thu, 18 Jul 2024 22:50:20 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[FEAT/#129]=20=EA=B3=B5=EA=B3=A0=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4=EB=8F=99=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarRoute.kt | 1 + .../calendar/calendar/CalendarViewModel.kt | 12 ++++++++++-- .../component/CalendarDetailDialog.kt | 2 +- .../calendar/scrap/CalendarListScreen.kt | 11 +++++------ .../calendar/week/CalendarWeekScreen.kt | 19 +++++++++++++------ 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index e00b6f54a..bbd5e8bbc 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -165,6 +165,7 @@ private fun CalendarScreen( CalendarWeekScreen( uiState = calendarUiState, viewModel = viewModel, + navController = navController, modifier = Modifier .fillMaxSize(), ) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt index d5aa2a905..ddc017e77 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt @@ -3,6 +3,7 @@ package com.terning.feature.calendar.calendar import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.google.devtools.ksp.symbol.Visibility import com.terning.core.state.UiState import com.terning.domain.entity.request.ScrapRequestModel import com.terning.domain.entity.response.CalendarScrapDetailModel @@ -101,10 +102,17 @@ class CalendarViewModel @Inject constructor( } } - fun updateInternDialogVisible(scrapDetailModel: CalendarScrapDetailModel?) { + fun updateInternDialogVisible(visibility: Boolean = false) { + _uiState.update { currentState -> + currentState.copy( + isInternshipClicked = visibility + ) + } + } + + fun updateIntershipModel(scrapDetailModel: CalendarScrapDetailModel?) { _uiState.update { currentState -> currentState.copy( - isInternshipClicked = !currentState.isInternshipClicked, internshipModel = scrapDetailModel ) } diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt index 7beaf5e9e..3c4859bcc 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt @@ -156,7 +156,7 @@ private fun InternDialogContent( Row( modifier = Modifier .background( - color = if (state.selectedColor != CalRed) CalBlue2 else CalGreen2, + color = if (selectedColor != CalRed) CalBlue2 else CalGreen2, shape = RoundedCornerShape(14.dp) ) .noRippleClickable { diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index f2206b0d3..811df9d04 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -118,10 +118,9 @@ fun CalendarListScreen( onScrapButtonClicked = { scrapId -> viewModel.updateScrapCancelDialogVisible(scrapId) }, - onInternshipClicked = { internshipAnnouncementId -> - viewModel.updateInternDialogVisible( - internshipAnnouncementId - ) + onInternshipClicked = { scrapDetailModel -> + viewModel.updateIntershipModel(scrapDetailModel) + viewModel.updateInternDialogVisible(true) }, isFromList = true, noScrapScreen = {}) @@ -142,13 +141,13 @@ fun CalendarListScreen( } if (uiState.isInternshipClicked) { CalendarDetailDialog( - onDismissRequest = {viewModel.updateInternDialogVisible(null)}, + onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> Timber.tag("CalendarScreen") .d(": $newColor") }, onClickNavigateButton = { - viewModel.updateInternDialogVisible(null) + viewModel.updateInternDialogVisible(false) } ) } diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index d81029055..9b40dd02a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -22,6 +22,8 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController +import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.Grey400 @@ -35,6 +37,7 @@ import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.calendar.component.CalendarDetailDialog import com.terning.feature.calendar.calendar.component.CalendarCancelDialog import com.terning.feature.calendar.scrap.component.CalendarScrapList +import com.terning.feature.intern.navigation.navigateIntern import timber.log.Timber import java.time.LocalDate @@ -42,6 +45,7 @@ import java.time.LocalDate fun CalendarWeekScreen( modifier: Modifier = Modifier, uiState: CalendarUiState, + navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() ) { val lifecycleOwner = LocalLifecycleOwner.current @@ -92,7 +96,8 @@ fun CalendarWeekScreen( viewModel.updateScrapCancelDialogVisible(scrapId) }, onInternshipClicked = { scrapDetailModel -> - viewModel.updateInternDialogVisible(scrapDetailModel) + viewModel.updateIntershipModel(scrapDetailModel) + viewModel.updateInternDialogVisible(true) }) } } @@ -108,14 +113,16 @@ fun CalendarWeekScreen( } if (uiState.isInternshipClicked) { CalendarDetailDialog( - onDismissRequest = {viewModel.updateInternDialogVisible(null)}, - onClickColor = { newColor -> + onDismissRequest = {viewModel.updateInternDialogVisible(false)}, + onClickChangeColorButton = { newColor -> Timber.tag("CalendarScreen") .d(": $newColor") }, - onClickNavigate = { - viewModel.updateInternDialogVisible(null) - } + onClickNavigateButton = { announcementId -> + viewModel.updateInternDialogVisible(false) + navController.navigateIntern(announcementId = announcementId) + }, + ) } } From 647eceb179d8b22d9c9c860ae34ffe18db47c619 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Thu, 18 Jul 2024 23:05:53 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[FEAT/#129]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=EC=A0=95=EB=B3=B4=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=84=EB=8B=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/CalendarDetailDialog.kt | 87 ++++++++++--------- .../calendar/scrap/CalendarListScreen.kt | 7 +- .../calendar/week/CalendarWeekScreen.kt | 2 +- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt index 3c4859bcc..9c9ab4102 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDetailDialog.kt @@ -8,11 +8,14 @@ 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.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.shape.RoundedCornerShape import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -24,14 +27,18 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue 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.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource 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 @@ -40,6 +47,7 @@ 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 @@ -50,9 +58,11 @@ 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( + scrapDetailModel: CalendarScrapDetailModel?, onDismissRequest: () -> Unit, onClickChangeColorButton: (Color) -> Unit, onClickNavigateButton: (Long) -> Unit, @@ -67,20 +77,7 @@ fun CalendarDetailDialog( ) ) { InternDialogContent( - scrapDetailModel = CalendarScrapDetailModel( - scrapId = 1, - internshipAnnouncementId = 1, - title = "안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕안녕", - dDay = "D-8", - workingPeriod = "9개월", - color = "0xf3d1e3", - companyImage = "", - startYear = 2024, - startMonth = 8, - deadLine = "2024-07-13", - isScrapped = true - ), - state = InternViewState(), + scrapDetailModel = scrapDetailModel, onClickChangeColorButton = onClickChangeColorButton, onClickNavigateButton = onClickNavigateButton ) @@ -90,13 +87,12 @@ fun CalendarDetailDialog( @Composable private fun InternDialogContent( - scrapDetailModel: CalendarScrapDetailModel, - state: InternViewState, + scrapDetailModel: CalendarScrapDetailModel?, onClickChangeColorButton: (Color) -> Unit, onClickNavigateButton: (Long) -> Unit ) { var isPaletteOpen by remember { mutableStateOf(false) } - var selectedColor by remember {mutableStateOf(Color.Red)} + var selectedColor by remember {mutableStateOf(Color(android.graphics.Color.parseColor(scrapDetailModel?.color)))} Box( modifier = Modifier @@ -110,28 +106,25 @@ private fun InternDialogContent( .padding(horizontal = 11.dp), horizontalAlignment = Alignment.CenterHorizontally ) { - Image( - painter = painterResource( - id = R.drawable.ic_character1 - ), + AsyncImage( + model = ImageRequest.Builder(LocalContext.current) + .data(scrapDetailModel?.companyImage) + .build(), + contentDescription = scrapDetailModel?.title, + contentScale = ContentScale.Fit, modifier = Modifier - .size(80.dp) - .background( - Grey200, - shape = RoundedCornerShape(size = 15.dp) - ) + .width(80.dp) + .aspectRatio(1f) + .clip(RoundedCornerShape(5.dp)) + .background(color = Grey300) .border( width = 1.dp, color = TerningMain, - shape = RoundedCornerShape(size = 15.dp) - ), - contentDescription = null, - contentScale = ContentScale.Fit, - alignment = Alignment.Center + shape = RoundedCornerShape(size = 5.dp) + ) ) - Text( - text = scrapDetailModel.title, + text = scrapDetailModel?.title.orEmpty(), textAlign = TextAlign.Center, style = TerningTheme.typography.title4, color = Grey500, @@ -156,7 +149,7 @@ private fun InternDialogContent( Row( modifier = Modifier .background( - color = if (selectedColor != CalRed) CalBlue2 else CalGreen2, + color = selectedColor, shape = RoundedCornerShape(14.dp) ) .noRippleClickable { @@ -214,7 +207,7 @@ private fun InternDialogContent( } } else { Text( - text = scrapDetailModel.dDay, + text = scrapDetailModel?.dDay.orEmpty(), style = TerningTheme.typography.body5, color = TerningMain, modifier = Modifier.padding(bottom = 9.dp) @@ -229,15 +222,16 @@ private fun InternDialogContent( ) { InternInfoRow( title = stringResource(id = com.terning.feature.R.string.intern_info_d_day), - value = scrapDetailModel.title + value = scrapDetailModel?.title.orEmpty() ) InternInfoRow( title = stringResource(id = com.terning.feature.R.string.intern_info_working), - value = scrapDetailModel.workingPeriod + value = scrapDetailModel?.workingPeriod.orEmpty() ) InternInfoRow( title = stringResource(id = com.terning.feature.R.string.intern_info_start_date), - value = "${scrapDetailModel.startYear}년 ${scrapDetailModel.startMonth}월" + value = "${scrapDetailModel?.startYear?:LocalDate.now().year}년 " + + "${scrapDetailModel?.startMonth?:LocalDate.now().monthValue}월" ) } } @@ -257,7 +251,7 @@ private fun InternDialogContent( onClickChangeColorButton(selectedColor) isPaletteOpen = false } else { - onClickNavigateButton(scrapDetailModel.internshipAnnouncementId) + onClickNavigateButton(scrapDetailModel?.internshipAnnouncementId?:0) } }, modifier = Modifier.padding(bottom = 8.dp) @@ -274,7 +268,20 @@ fun InternDialogContentPreview() { CalendarDetailDialog( onDismissRequest = {}, onClickChangeColorButton = {}, - onClickNavigateButton = {} + onClickNavigateButton = {}, + scrapDetailModel = CalendarScrapDetailModel( + scrapId = 123, + internshipAnnouncementId = 123, + title = "테스트", + dDay = "asdas", + workingPeriod = "asdas", + startYear = 2023, + startMonth = 1, + isScrapped = true, + color = "0xFF4c3552", + companyImage = "", + deadLine = "sads" + ) ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 811df9d04..59d10e768 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -23,6 +23,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavController +import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme @@ -38,6 +39,7 @@ import com.terning.feature.calendar.calendar.component.CalendarCancelDialog import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage import com.terning.feature.calendar.scrap.component.CalendarScrapList +import com.terning.feature.intern.navigation.navigateIntern import kotlinx.coroutines.flow.distinctUntilChanged import timber.log.Timber import java.time.LocalDate @@ -48,6 +50,7 @@ fun CalendarListScreen( listState: LazyListState, uiState: CalendarUiState, modifier: Modifier = Modifier, + navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() ) { val lifecycleOwner = LocalLifecycleOwner.current @@ -141,13 +144,15 @@ fun CalendarListScreen( } if (uiState.isInternshipClicked) { CalendarDetailDialog( + scrapDetailModel = uiState.internshipModel, onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> Timber.tag("CalendarScreen") .d(": $newColor") }, - onClickNavigateButton = { + onClickNavigateButton = {announcementId -> viewModel.updateInternDialogVisible(false) + navController.navigateIntern(announcementId = announcementId) } ) } diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index 9b40dd02a..60c629b67 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -113,6 +113,7 @@ fun CalendarWeekScreen( } if (uiState.isInternshipClicked) { CalendarDetailDialog( + scrapDetailModel = uiState.internshipModel, onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> Timber.tag("CalendarScreen") @@ -122,7 +123,6 @@ fun CalendarWeekScreen( viewModel.updateInternDialogVisible(false) navController.navigateIntern(announcementId = announcementId) }, - ) } } From 24437d70930e5e2e10f146c00580a47f8fcfa51e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Thu, 18 Jul 2024 23:47:05 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[FEAT/#129]=20ScrapRepository=20patch=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt | 5 +++++ .../java/com/terning/domain/repository/ScrapRepository.kt | 1 + 2 files changed, 6 insertions(+) diff --git a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt index 57364e770..ccca0dc92 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -17,4 +17,9 @@ class ScrapRepositoryImpl @Inject constructor( : Result = runCatching { scrapDataSource.deleteScrap(scrapRequestModel) } + + override suspend fun patchScrap(scrapRequestModel: ScrapRequestModel) + : Result = runCatching { + scrapDataSource.patchScrap(scrapRequestModel) + } } \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt b/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt index 69647c6d4..ed66f6393 100644 --- a/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt @@ -5,4 +5,5 @@ import com.terning.domain.entity.request.ScrapRequestModel interface ScrapRepository { suspend fun postScrap(scrapRequestModel: ScrapRequestModel): Result suspend fun deleteScrap(scrapRequestModel: ScrapRequestModel): Result + suspend fun patchScrap(scrapRequestModel: ScrapRequestModel): Result } \ No newline at end of file From 6336ffd126b9ddc8d3b702c7f5c4182baf2161cf Mon Sep 17 00:00:00 2001 From: boiledegg Date: Thu, 18 Jul 2024 23:47:19 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[FEAT/#129]=20patch=20=ED=86=B5=EC=8B=A0?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 55 +++++++++++++++++-- .../calendar/scrap/CalendarListScreen.kt | 3 +- .../calendar/week/CalendarWeekScreen.kt | 5 +- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt index ddc017e77..cf3039901 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt @@ -1,9 +1,19 @@ package com.terning.feature.calendar.calendar import android.util.Log +import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.devtools.ksp.symbol.Visibility +import com.terning.core.designsystem.theme.CalBlue1 +import com.terning.core.designsystem.theme.CalBlue2 +import com.terning.core.designsystem.theme.CalGreen1 +import com.terning.core.designsystem.theme.CalGreen2 +import com.terning.core.designsystem.theme.CalOrange1 +import com.terning.core.designsystem.theme.CalOrange2 +import com.terning.core.designsystem.theme.CalPink +import com.terning.core.designsystem.theme.CalPurple +import com.terning.core.designsystem.theme.CalRed +import com.terning.core.designsystem.theme.CalYellow import com.terning.core.state.UiState import com.terning.domain.entity.request.ScrapRequestModel import com.terning.domain.entity.response.CalendarScrapDetailModel @@ -13,7 +23,6 @@ import com.terning.feature.R import com.terning.feature.calendar.month.CalendarMonthState import com.terning.feature.calendar.scrap.CalendarListState import com.terning.feature.calendar.week.CalendarWeekState -import com.terning.feature.intern.InternViewSideEffect import com.terning.feature.intern.model.InternScrapState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers @@ -24,7 +33,6 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import timber.log.Timber import java.time.LocalDate import javax.inject.Inject @@ -110,7 +118,7 @@ class CalendarViewModel @Inject constructor( } } - fun updateIntershipModel(scrapDetailModel: CalendarScrapDetailModel?) { + fun updateInternshipModel(scrapDetailModel: CalendarScrapDetailModel?) { _uiState.update { currentState -> currentState.copy( internshipModel = scrapDetailModel @@ -214,4 +222,43 @@ class CalendarViewModel @Inject constructor( } } } + + fun patchScrap(color: Color, isFromWeekScreen: Boolean = false) = viewModelScope.launch { + val scrap = _uiState.value + val colorIndex = getColorIndex(color) + + Log.d("CalendarScreen", "CalendarViewModel colorIndex:$colorIndex, scrapId:${scrap.scrapId}") + //여기서 보내줘야 할 데이터 정보는?? 인덱스 or 컬러 코드 + scrapRepository.patchScrap(ScrapRequestModel(scrap.scrapId, colorIndex)) + .onSuccess { + runCatching { + if (isFromWeekScreen) { + getScrapWeekList() + } else { + getScrapMonth( + _uiState.value.selectedDate.year, + _uiState.value.selectedDate.monthValue + ) + } + }.onSuccess { + updateScrapCancelDialogVisible() + } + }.onFailure { + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) + } + } + + private fun getColorIndex(color: Color): Int = listOf( + CalRed, + CalOrange2, + CalGreen1, + CalBlue1, + CalPurple, + CalOrange1, + CalYellow, + CalGreen2, + CalBlue2, + CalPink + ).indexOf(color) + } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 59d10e768..999585837 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -122,7 +122,7 @@ fun CalendarListScreen( viewModel.updateScrapCancelDialogVisible(scrapId) }, onInternshipClicked = { scrapDetailModel -> - viewModel.updateIntershipModel(scrapDetailModel) + viewModel.updateInternshipModel(scrapDetailModel) viewModel.updateInternDialogVisible(true) }, isFromList = true, @@ -147,6 +147,7 @@ fun CalendarListScreen( scrapDetailModel = uiState.internshipModel, onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> + viewModel.patchScrap(newColor) Timber.tag("CalendarScreen") .d(": $newColor") }, diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index 60c629b67..6ca2c390a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -1,7 +1,6 @@ package com.terning.feature.calendar.week 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.fillMaxSize @@ -25,7 +24,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavController import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.theme.Back -import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White @@ -96,7 +94,7 @@ fun CalendarWeekScreen( viewModel.updateScrapCancelDialogVisible(scrapId) }, onInternshipClicked = { scrapDetailModel -> - viewModel.updateIntershipModel(scrapDetailModel) + viewModel.updateInternshipModel(scrapDetailModel) viewModel.updateInternDialogVisible(true) }) } @@ -116,6 +114,7 @@ fun CalendarWeekScreen( scrapDetailModel = uiState.internshipModel, onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> + viewModel.patchScrap(newColor, true) Timber.tag("CalendarScreen") .d(": $newColor") }, From d33cc56aea9fae68e1e4e5a247506edbf768baa4 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:06:55 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[FEAT/#129]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EC=83=89=EC=83=81=20=EC=88=98=EC=A0=95=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 42 +++++++------------ .../calendar/scrap/CalendarListScreen.kt | 2 - .../calendar/week/CalendarWeekScreen.kt | 4 +- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt index cf3039901..9a3126149 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarViewModel.kt @@ -60,10 +60,6 @@ class CalendarViewModel @Inject constructor( private val _calendarWeekState = MutableStateFlow(CalendarWeekState()) val calendarWeekState = _calendarWeekState.asStateFlow() - private val _scrapState: MutableStateFlow = - MutableStateFlow(InternScrapState()) - val scrapState = _scrapState.asStateFlow() - private val _calendarSideEffect: MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() @@ -179,7 +175,6 @@ class CalendarViewModel @Inject constructor( _calendarWeekState.update { currentState -> currentState.copy( loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty - //loadState = UiState.Success(it) ) } }, @@ -195,11 +190,10 @@ class CalendarViewModel @Inject constructor( ) } - fun deleteScrap(isFromWeekScreen: Boolean = true) = viewModelScope.launch { + fun deleteScrap(isFromWeekScreen: Boolean = false) = viewModelScope.launch { _calendarWeekState.value.loadState .takeIf { it is UiState.Success } ?.let { ScrapRequestModel(_uiState.value.scrapId, null) }?.let { scrapRequestModel -> - Log.d("calendarViewModel", uiState.value.scrapId.toString()) scrapRepository.deleteScrap( scrapRequestModel ).onSuccess { @@ -207,7 +201,7 @@ class CalendarViewModel @Inject constructor( if (isFromWeekScreen) { getScrapWeekList() } else { - getScrapMonth( + getScrapMonthList( _uiState.value.selectedDate.year, _uiState.value.selectedDate.monthValue ) @@ -224,24 +218,20 @@ class CalendarViewModel @Inject constructor( } fun patchScrap(color: Color, isFromWeekScreen: Boolean = false) = viewModelScope.launch { - val scrap = _uiState.value + val scrapId = _uiState.value.internshipModel?.scrapId ?: 0 val colorIndex = getColorIndex(color) - Log.d("CalendarScreen", "CalendarViewModel colorIndex:$colorIndex, scrapId:${scrap.scrapId}") - //여기서 보내줘야 할 데이터 정보는?? 인덱스 or 컬러 코드 - scrapRepository.patchScrap(ScrapRequestModel(scrap.scrapId, colorIndex)) + scrapRepository.patchScrap(ScrapRequestModel(scrapId, colorIndex)) .onSuccess { runCatching { if (isFromWeekScreen) { getScrapWeekList() } else { - getScrapMonth( + getScrapMonthList( _uiState.value.selectedDate.year, _uiState.value.selectedDate.monthValue ) } - }.onSuccess { - updateScrapCancelDialogVisible() } }.onFailure { _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) @@ -249,16 +239,16 @@ class CalendarViewModel @Inject constructor( } private fun getColorIndex(color: Color): Int = listOf( - CalRed, - CalOrange2, - CalGreen1, - CalBlue1, - CalPurple, - CalOrange1, - CalYellow, - CalGreen2, - CalBlue2, - CalPink - ).indexOf(color) + CalRed, + CalOrange1, + CalOrange2, + CalYellow, + CalGreen1, + CalGreen2, + CalBlue1, + CalBlue2, + CalPurple, + CalPink + ).indexOf(color) } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 999585837..359b146f2 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -148,8 +148,6 @@ fun CalendarListScreen( onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> viewModel.patchScrap(newColor) - Timber.tag("CalendarScreen") - .d(": $newColor") }, onClickNavigateButton = {announcementId -> viewModel.updateInternDialogVisible(false) diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index 6ca2c390a..6a826a0a5 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -105,7 +105,7 @@ fun CalendarWeekScreen( CalendarCancelDialog( onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, onClickScrapCancel = { - viewModel.deleteScrap() + viewModel.deleteScrap(true) } ) } @@ -115,8 +115,6 @@ fun CalendarWeekScreen( onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> viewModel.patchScrap(newColor, true) - Timber.tag("CalendarScreen") - .d(": $newColor") }, onClickNavigateButton = { announcementId -> viewModel.updateInternDialogVisible(false) From 569d1312829895f079d36cdae9f475586c03bb18 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:26:03 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[MOVE/#129]=20=EB=8B=A4=EC=9D=B4=EC=96=BC?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EA=B3=B5=ED=86=B5=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarRoute.kt | 2 +- .../calendar/component/CalendarDialog.kt | 43 +++++++++++++++++++ .../calendar/scrap/CalendarListScreen.kt | 28 +++--------- .../calendar/week/CalendarWeekScreen.kt | 38 ++++------------ .../calendar/week/HorizontalCalendarWeek.kt | 6 +-- 5 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index bbd5e8bbc..296245368 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -163,7 +163,7 @@ private fun CalendarScreen( }, contentTwo = { CalendarWeekScreen( - uiState = calendarUiState, + calendarUiState = calendarUiState, viewModel = viewModel, navController = navController, modifier = Modifier diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt new file mode 100644 index 000000000..867ed44e0 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt @@ -0,0 +1,43 @@ +package com.terning.feature.calendar.calendar.component + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController +import androidx.navigation.compose.rememberNavController +import com.terning.feature.calendar.calendar.CalendarViewModel +import com.terning.feature.intern.navigation.navigateIntern + +@Composable +fun CalendarDialog( + navController: NavController = rememberNavController(), + viewModel: CalendarViewModel = hiltViewModel() +) { + val lifecycleOwner = LocalLifecycleOwner.current + val uiState by viewModel.uiState.collectAsStateWithLifecycle(lifecycleOwner) + + if (uiState.isScrapButtonClicked) { + CalendarCancelDialog( + onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, + onClickScrapCancel = { + viewModel.deleteScrap() + } + ) + } + + if (uiState.isInternshipClicked) { + CalendarDetailDialog( + scrapDetailModel = uiState.internshipModel, + onDismissRequest = {viewModel.updateInternDialogVisible(false)}, + onClickChangeColorButton = { newColor -> + viewModel.patchScrap(newColor) + }, + onClickNavigateButton = {announcementId -> + viewModel.updateInternDialogVisible(false) + navController.navigateIntern(announcementId = announcementId) + } + ) + } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 359b146f2..6ddba126c 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -36,6 +36,7 @@ import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.calendar.component.CalendarDetailDialog import com.terning.feature.calendar.calendar.component.CalendarCancelDialog +import com.terning.feature.calendar.calendar.component.CalendarDialog import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage import com.terning.feature.calendar.scrap.component.CalendarScrapList @@ -48,7 +49,6 @@ import java.time.LocalDate fun CalendarListScreen( pages: Int, listState: LazyListState, - uiState: CalendarUiState, modifier: Modifier = Modifier, navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() @@ -134,27 +134,11 @@ fun CalendarListScreen( } } } - if (uiState.isScrapButtonClicked) { - CalendarCancelDialog( - onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, - onClickScrapCancel = { - viewModel.deleteScrap() - } - ) - } - if (uiState.isInternshipClicked) { - CalendarDetailDialog( - scrapDetailModel = uiState.internshipModel, - onDismissRequest = {viewModel.updateInternDialogVisible(false)}, - onClickChangeColorButton = { newColor -> - viewModel.patchScrap(newColor) - }, - onClickNavigateButton = {announcementId -> - viewModel.updateInternDialogVisible(false) - navController.navigateIntern(announcementId = announcementId) - } - ) - } + + CalendarDialog( + viewModel = viewModel, + navController = navController + ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index 6a826a0a5..57a972d57 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -32,24 +32,21 @@ import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.calendar.CalendarViewModel -import com.terning.feature.calendar.calendar.component.CalendarDetailDialog -import com.terning.feature.calendar.calendar.component.CalendarCancelDialog +import com.terning.feature.calendar.calendar.component.CalendarDialog import com.terning.feature.calendar.scrap.component.CalendarScrapList -import com.terning.feature.intern.navigation.navigateIntern -import timber.log.Timber import java.time.LocalDate @Composable fun CalendarWeekScreen( modifier: Modifier = Modifier, - uiState: CalendarUiState, + calendarUiState: CalendarUiState, navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() ) { val lifecycleOwner = LocalLifecycleOwner.current val calendarWeekState by viewModel.calendarWeekState.collectAsStateWithLifecycle(lifecycleOwner) - LaunchedEffect(uiState.selectedDate) { + LaunchedEffect(calendarUiState.selectedDate) { viewModel.getScrapWeekList() } @@ -71,7 +68,7 @@ fun CalendarWeekScreen( modifier = Modifier .fillMaxWidth() .background(White), - selectedDate = uiState, + calendarUiState = calendarUiState, onDateSelected = { viewModel.updateSelectedDate(it) } @@ -89,7 +86,7 @@ fun CalendarWeekScreen( val scrapList = (calendarWeekState.loadState as UiState.Success).data CalendarWeekSuccess( scrapList = scrapList, - selectedDate = uiState.selectedDate, + selectedDate = calendarUiState.selectedDate, onScrapButtonClicked = { scrapId -> viewModel.updateScrapCancelDialogVisible(scrapId) }, @@ -101,27 +98,10 @@ fun CalendarWeekScreen( } } - if (uiState.isScrapButtonClicked) { - CalendarCancelDialog( - onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, - onClickScrapCancel = { - viewModel.deleteScrap(true) - } - ) - } - if (uiState.isInternshipClicked) { - CalendarDetailDialog( - scrapDetailModel = uiState.internshipModel, - onDismissRequest = {viewModel.updateInternDialogVisible(false)}, - onClickChangeColorButton = { newColor -> - viewModel.patchScrap(newColor, true) - }, - onClickNavigateButton = { announcementId -> - viewModel.updateInternDialogVisible(false) - navController.navigateIntern(announcementId = announcementId) - }, - ) - } + CalendarDialog( + viewModel = viewModel, + navController = navController + ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt b/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt index 9b16f9a9d..54c3c084a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt @@ -20,11 +20,11 @@ import java.time.YearMonth @Composable fun HorizontalCalendarWeek( - selectedDate: CalendarUiState, + calendarUiState: CalendarUiState, modifier: Modifier = Modifier, onDateSelected: (LocalDate) -> Unit = {} ) { - val date = selectedDate.selectedDate + val date = calendarUiState.selectedDate val monthData = MonthData(YearMonth.of(date.year, date.monthValue)) val currentWeek = date.getWeekIndexContainingSelectedDate(monthData.inDays) @@ -46,7 +46,7 @@ fun HorizontalCalendarWeek( items(items = monthData.calendarMonth.weekDays[page]) { day -> CalendarDay( dayData = day, - isSelected = selectedDate.selectedDate == day.date && selectedDate.isWeekEnabled, + isSelected = calendarUiState.selectedDate == day.date && calendarUiState.isWeekEnabled, isToday = day.date.isToday(), onDateSelected = onDateSelected ) From 59ca8709fc4a41aa7f26cb7b28ac22e5ff57ef47 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:26:19 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[FIX/#129]=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/calendar/calendar/CalendarRoute.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index 296245368..c29f55cca 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -178,7 +178,6 @@ private fun CalendarScreen( listState = listState, pages = state.getPageCount(), viewModel = viewModel, - uiState = calendarUiState, modifier = Modifier .fillMaxSize() .padding(top = paddingValues.calculateTopPadding()) From a8dc1ffe39864ee01988248de8dbc4741402ab58 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:34:30 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[FIX/#129]=20=EA=B8=B0=ED=83=80=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/component/topappbar/CalendarTopAppBar.kt | 4 ++-- .../com/terning/feature/calendar/calendar/CalendarRoute.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/CalendarTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/CalendarTopAppBar.kt index 2e95a0549..dc0089100 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/CalendarTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/CalendarTopAppBar.kt @@ -54,7 +54,7 @@ fun CalendarTopAppBar( Icon( painter = painterResource(id = R.drawable.ic_calendar_previous), contentDescription = stringResource(id = R.string.calendar_button_description_previous), - tint = Grey300, + tint = TerningMain, modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(-1) } ) } @@ -68,7 +68,7 @@ fun CalendarTopAppBar( Icon( painter = painterResource(id = R.drawable.ic_calendar_next), contentDescription = stringResource(id = R.string.calendar_button_description_next), - tint = Grey300, + tint = TerningMain, modifier = Modifier.noRippleClickable { onMonthNavigationButtonClicked(1) } ) } diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index c29f55cca..00aaf14bc 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -108,7 +108,7 @@ private fun CalendarScreen( CalendarTopAppBar( date = currentDate, isListExpanded = calendarUiState.isListEnabled, - isWeekExpanded = calendarUiState.isListEnabled, + isWeekExpanded = calendarUiState.isWeekEnabled, onListButtonClicked = { viewModel.changeListVisibility() if (calendarUiState.isWeekEnabled) { From 2ccfc2e2ae187406f8590fe1428ca95e89fa5acb Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:36:14 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[FIX/#129]=20=EC=BA=98=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/calendar/calendar/component/CalendarDialog.kt | 5 +++-- .../com/terning/feature/calendar/scrap/CalendarListScreen.kt | 1 + .../com/terning/feature/calendar/week/CalendarWeekScreen.kt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt index 867ed44e0..ec902815a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/CalendarDialog.kt @@ -12,6 +12,7 @@ import com.terning.feature.intern.navigation.navigateIntern @Composable fun CalendarDialog( + isWeekScreen: Boolean, navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() ) { @@ -22,7 +23,7 @@ fun CalendarDialog( CalendarCancelDialog( onDismissRequest = { viewModel.updateScrapCancelDialogVisible() }, onClickScrapCancel = { - viewModel.deleteScrap() + viewModel.deleteScrap(isWeekScreen) } ) } @@ -32,7 +33,7 @@ fun CalendarDialog( scrapDetailModel = uiState.internshipModel, onDismissRequest = {viewModel.updateInternDialogVisible(false)}, onClickChangeColorButton = { newColor -> - viewModel.patchScrap(newColor) + viewModel.patchScrap(newColor, isWeekScreen) }, onClickNavigateButton = {announcementId -> viewModel.updateInternDialogVisible(false) diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 6ddba126c..878c6b3ea 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -136,6 +136,7 @@ fun CalendarListScreen( } CalendarDialog( + isWeekScreen = false, viewModel = viewModel, navController = navController ) diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index 57a972d57..e2bf3d076 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -99,6 +99,7 @@ fun CalendarWeekScreen( } CalendarDialog( + isWeekScreen = true, viewModel = viewModel, navController = navController ) From 7770cf501d869ec41aa3114dd34821d4f2e20f6c Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 19 Jul 2024 00:46:41 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[FIX/#129]=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/calendar/calendar/CalendarRoute.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt index 00aaf14bc..a353dfb3e 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarRoute.kt @@ -178,6 +178,7 @@ private fun CalendarScreen( listState = listState, pages = state.getPageCount(), viewModel = viewModel, + navController = navController, modifier = Modifier .fillMaxSize() .padding(top = paddingValues.calculateTopPadding())