From acc7547695844bd0b94e9399d9a708dde801a91c Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 14 Jul 2024 04:30:04 +0900 Subject: [PATCH 01/37] =?UTF-8?q?[FEAT/#59]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EC=97=94=ED=8B=B0=ED=8B=B0,=20Dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/request/ScrapRequestDto.kt | 12 ++ .../data/dto/response/ScrapResponseDto.kt | 142 ++++++++++++++++++ .../domain/entity/response/ScrapModel.kt | 9 ++ 3 files changed, 163 insertions(+) create mode 100644 data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt create mode 100644 data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt create mode 100644 domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt diff --git a/data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt b/data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt new file mode 100644 index 000000000..f93df1059 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt @@ -0,0 +1,12 @@ +package com.terning.data.dto.request + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ScrapRequestDto( + @SerialName("year") + val year: Int, + @SerialName("month") + val month: Int +) diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt new file mode 100644 index 000000000..139b9b77e --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt @@ -0,0 +1,142 @@ +package com.terning.data.dto.response + +import com.terning.data.dto.response.ScrapResponseDto.ScrapByDeadline +import com.terning.domain.entity.response.ScrapModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ScrapResponseDto( + @SerialName("scrapsByDeadline") + val scrapsByDeadline: List, +) { + @Serializable + data class ScrapByDeadline( + @SerialName("deadline") + val deadline: String, + @SerialName("scraps") + val scraps: List + ) { + @Serializable + data class Scrap( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("title") + val title: String, + @SerialName("deadline") + val deadline: String, + @SerialName("color") + val color: String + ) + } +} + +fun ScrapResponseDto.toScrapsByDeadLineList() = scrapsByDeadline.map { it.toScrapModelList() } + +private fun ScrapByDeadline.toScrapModelList() = scraps.map { it.toScrapModel() } + +private fun ScrapByDeadline.Scrap.toScrapModel() = ScrapModel( + scrapId = scrapId, + title = title, + deadLine = deadline, + color = color, + isScrapped = true +) + + + +fun ScrapResponseDto.toScrapModelList(): List { + return with(mutableListOf()) { + apply { + for (items in this@toScrapModelList.scrapsByDeadline) { + for(item in items.scraps) { + add( + ScrapModel( + scrapId = item.scrapId, + title = item.title, + deadLine = item.deadline, + color = item.color, + isScrapped = true + ) + ) + } + } + } + } +} + +fun getMockScrapList(month: Int): ScrapResponseDto { + val deadline = month.toString().padStart(2, '0') + return ScrapResponseDto( + scrapsByDeadline = listOf( + ScrapByDeadline( + deadline = "2024-${deadline}-13", + scraps = listOf( + ScrapByDeadline.Scrap( + scrapId = 1, + title = "제목1", + deadline = "2024-${deadline}-13", + color = "0xFFED4E54" + ), + ScrapByDeadline.Scrap( + scrapId = 2, + title = "제목2", + deadline = "2024-${deadline}-13", + color = "0xFFC4E953" + ), + ScrapByDeadline.Scrap( + scrapId = 3, + title = "제목3", + deadline = "2024-${deadline}-13", + color = "0xFF9B64E2" + ), + ScrapByDeadline.Scrap( + scrapId = 4, + title = "제목4", + deadline = "2024-${deadline}-13", + color = "0xFFF260AC" + ) + ) + ), + ScrapByDeadline( + deadline = "2024-${deadline}-17", + scraps = listOf( + ScrapByDeadline.Scrap( + scrapId = 1, + title = "제목1", + deadline = "2024-${deadline}-17", + color = "0xFFC4E953" + ), + ScrapByDeadline.Scrap( + scrapId = 2, + title = "제목2", + deadline = "2024-${deadline}-17", + color = "0xFF45D0CC" + ), + ) + ), + ScrapByDeadline( + deadline = "2024-${deadline}-23", + scraps = listOf( + ScrapByDeadline.Scrap( + scrapId = 1, + title = "제목1", + deadline = "2024-${deadline}-23", + color = "0xFF5397F3" + ) + ) + ), + ScrapByDeadline( + deadline = "2024-${deadline}-30", + scraps = listOf( + ScrapByDeadline.Scrap( + scrapId = 1, + title = "제목1", + deadline = "2024-${deadline}-30", + color = "0xFF45D0CC" + ) + ) + ) + ) + ) +} \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt b/domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt new file mode 100644 index 000000000..8b68bbe35 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt @@ -0,0 +1,9 @@ +package com.terning.domain.entity.response + +data class ScrapModel( + val scrapId: Long, + val title: String, + val deadLine: String, + val color: String, + val isScrapped: Boolean +) \ No newline at end of file From ef23c12d117fbba92a827d104bb30c9fdb3046d6 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 14 Jul 2024 04:30:20 +0900 Subject: [PATCH 02/37] =?UTF-8?q?[FEAT/#59]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EC=86=8C=EC=8A=A4=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/ScrapDataSource.kt | 9 +++++++++ .../datasourceimpl/ScrapDataSourceImpl.kt | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt create mode 100644 data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt diff --git a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt new file mode 100644 index 000000000..586b5e518 --- /dev/null +++ b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt @@ -0,0 +1,9 @@ +package com.terning.data.datasource + +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.ScrapRequestDto +import com.terning.data.dto.response.ScrapResponseDto + +interface ScrapDataSource { + suspend fun getMonthScrapList(request: ScrapRequestDto): BaseResponse +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt new file mode 100644 index 000000000..9b3c2815a --- /dev/null +++ b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt @@ -0,0 +1,19 @@ +package com.terning.data.datasourceimpl + +import com.terning.data.datasource.ScrapDataSource +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.ScrapRequestDto +import com.terning.data.dto.response.ScrapResponseDto +import com.terning.data.dto.response.getMockScrapList +import javax.inject.Inject + +class ScrapDataSourceImpl @Inject constructor( + +) : ScrapDataSource { + override suspend fun getMonthScrapList(request: ScrapRequestDto): BaseResponse = + BaseResponse( + status = 200, + message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", + result = getMockScrapList(request.month) + ) +} \ No newline at end of file From 2e52a96f1f27b789f13a69de7cc951d07e2f2631 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 14 Jul 2024 04:31:17 +0900 Subject: [PATCH 03/37] =?UTF-8?q?[FEAT/#59]=20=EC=8A=A4=ED=81=AC=EB=9E=A9?= =?UTF-8?q?=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositoryimpl/ScrapRepositoryImpl.kt | 23 +++++++++++++++++++ .../domain/repository/ScrapRepository.kt | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt create mode 100644 domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt diff --git a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt new file mode 100644 index 000000000..3c75fb944 --- /dev/null +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -0,0 +1,23 @@ +package com.terning.data.repositoryimpl + +import com.terning.data.datasource.ScrapDataSource +import com.terning.data.dto.request.ScrapRequestDto +import com.terning.data.dto.response.toScrapsByDeadLineList +import com.terning.domain.entity.response.ScrapModel +import com.terning.domain.repository.ScrapRepository +import javax.inject.Inject + +class ScrapRepositoryImpl @Inject constructor( + private val scrapDataSource: ScrapDataSource +): ScrapRepository { + override suspend fun getMonthScrapList(year: Int, month: Int): Result>> = + runCatching { + val response = scrapDataSource.getMonthScrapList( + request = ScrapRequestDto( + year = year, + month = month + ) + ) + response.result.toScrapsByDeadLineList() + } +} \ 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 new file mode 100644 index 000000000..403e02765 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt @@ -0,0 +1,7 @@ +package com.terning.domain.repository + +import com.terning.domain.entity.response.ScrapModel + +interface ScrapRepository{ + suspend fun getMonthScrapList(year: Int, month: Int): Result>> +} \ No newline at end of file From b6b97b4bc19a3ed28dd97d842a805fd412bf9c64 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 14 Jul 2024 04:31:45 +0900 Subject: [PATCH 04/37] =?UTF-8?q?[ADD/#59]=20=ED=9E=90=ED=8A=B8=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/terning/point/di/DataSourceModule.kt | 8 ++++++++ .../main/java/com/terning/point/di/RepositoryModule.kt | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/com/terning/point/di/DataSourceModule.kt b/app/src/main/java/com/terning/point/di/DataSourceModule.kt index c1541df6a..1c395b630 100644 --- a/app/src/main/java/com/terning/point/di/DataSourceModule.kt +++ b/app/src/main/java/com/terning/point/di/DataSourceModule.kt @@ -1,7 +1,11 @@ package com.terning.point.di import com.terning.data.datasource.MockDataSource +import com.terning.data.datasource.ScrapDataSource import com.terning.data.datasourceimpl.MockDataSourceImpl +import com.terning.data.datasourceimpl.ScrapDataSourceImpl +import com.terning.data.repositoryimpl.ScrapRepositoryImpl +import com.terning.domain.repository.ScrapRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -12,6 +16,10 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) abstract class DataSourceModule { + @Binds + @Singleton + abstract fun bindScrapRepository(scrapDataSourceImpl: ScrapDataSourceImpl): ScrapDataSource + @Binds @Singleton abstract fun bindMockDataSource(mockDataSourceImpl: MockDataSourceImpl): MockDataSource diff --git a/app/src/main/java/com/terning/point/di/RepositoryModule.kt b/app/src/main/java/com/terning/point/di/RepositoryModule.kt index 9de02a07a..9aa69d3a6 100644 --- a/app/src/main/java/com/terning/point/di/RepositoryModule.kt +++ b/app/src/main/java/com/terning/point/di/RepositoryModule.kt @@ -1,7 +1,9 @@ package com.terning.point.di import com.terning.data.repositoryimpl.MockRepositoryImpl +import com.terning.data.repositoryimpl.ScrapRepositoryImpl import com.terning.domain.repository.MockRepository +import com.terning.domain.repository.ScrapRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -12,6 +14,10 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) abstract class RepositoryModule { + @Binds + @Singleton + abstract fun scrapRepository(scrapRepositoryImpl: ScrapRepositoryImpl): ScrapRepository + @Binds @Singleton abstract fun bindMockRepository(mockRepositoryImpl: MockRepositoryImpl): MockRepository From 8facc3da608ea3e5e28fbda3415439ced6ab2260 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 14 Jul 2024 05:00:02 +0900 Subject: [PATCH 05/37] =?UTF-8?q?[MOVE/#59]=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{models => calendar}/CalendarDefault.kt | 2 +- .../calendar/calendar/CalendarRoute.kt | 7 ++---- .../{models => calendar}/CalendarState.kt | 2 +- .../calendar/calendar/CalendarViewModel.kt | 24 +++++++++++++++++-- .../{models => calendar}/SelectedDateState.kt | 2 +- .../navigation/CalendarNavigation.kt | 2 +- .../calendar/{calendar => day}/CalendarDay.kt | 12 +++++----- .../DayModel.kt => day/model/DayClass.kt} | 4 ++-- .../{calendar => month}/CalendarMonth.kt | 13 ++++------ .../{calendar => month}/CalendarMonths.kt | 12 +++++----- .../{models => month/model}/MonthData.kt | 9 +++---- .../{models => month/model}/MonthModel.kt | 5 ++-- .../feature/calendar/scrap/CalendarScrap.kt | 2 +- .../calendar/scrap/CalendarScrapList.kt | 2 +- .../calendar/scrap/CalendarScrapListScreen.kt | 6 ++--- .../calendar/scrap/CalendarScrapStrip.kt | 2 +- .../calendar/{models => scrap/model}/Scrap.kt | 2 +- .../{calendar => week}/CalendarWeek.kt | 9 ++++--- .../CalendarWeekWithScrap.kt | 6 ++--- .../com/terning/feature/main/MainNavigator.kt | 3 ++- .../com/terning/feature/main/MainScreen.kt | 2 +- .../java/com/terning/feature/main/MainTab.kt | 2 +- 22 files changed, 73 insertions(+), 57 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/{models => calendar}/CalendarDefault.kt (96%) rename feature/src/main/java/com/terning/feature/calendar/{models => calendar}/CalendarState.kt (97%) rename feature/src/main/java/com/terning/feature/calendar/{models => calendar}/SelectedDateState.kt (72%) rename feature/src/main/java/com/terning/feature/calendar/{ => calendar}/navigation/CalendarNavigation.kt (91%) rename feature/src/main/java/com/terning/feature/calendar/{calendar => day}/CalendarDay.kt (90%) rename feature/src/main/java/com/terning/feature/calendar/{models/DayModel.kt => day/model/DayClass.kt} (67%) rename feature/src/main/java/com/terning/feature/calendar/{calendar => month}/CalendarMonth.kt (86%) rename feature/src/main/java/com/terning/feature/calendar/{calendar => month}/CalendarMonths.kt (76%) rename feature/src/main/java/com/terning/feature/calendar/{models => month/model}/MonthData.kt (86%) rename feature/src/main/java/com/terning/feature/calendar/{models => month/model}/MonthModel.kt (87%) rename feature/src/main/java/com/terning/feature/calendar/{models => scrap/model}/Scrap.kt (85%) rename feature/src/main/java/com/terning/feature/calendar/{calendar => week}/CalendarWeek.kt (88%) rename feature/src/main/java/com/terning/feature/calendar/{calendar => week}/CalendarWeekWithScrap.kt (94%) diff --git a/feature/src/main/java/com/terning/feature/calendar/models/CalendarDefault.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/calendar/models/CalendarDefault.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt index 59a554d7d..29b1393b5 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/CalendarDefault.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.calendar import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.gestures.FlingBehavior 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 7d8372b70..9a5b701bb 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 @@ -8,12 +8,8 @@ import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutHorizontally import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith -import androidx.compose.foundation.background 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 import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.HorizontalDivider @@ -36,8 +32,9 @@ import com.terning.core.designsystem.component.topappbar.CalendarTopAppBar import com.terning.core.designsystem.theme.Grey200 import com.terning.feature.R import com.terning.feature.calendar.calendar.component.WeekDaysHeader -import com.terning.feature.calendar.models.CalendarState +import com.terning.feature.calendar.month.CalendarMonths import com.terning.feature.calendar.scrap.CalendarScrapListScreen +import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch import java.time.LocalDate diff --git a/feature/src/main/java/com/terning/feature/calendar/models/CalendarState.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/calendar/models/CalendarState.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt index 98e3cfd94..54775c159 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/CalendarState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.calendar import androidx.compose.runtime.Stable import androidx.compose.runtime.getValue 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 49f263050..537f75b6c 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,5 +1,6 @@ package com.terning.feature.calendar.calendar +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.designsystem.theme.CalBlue1 @@ -9,8 +10,9 @@ 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.feature.calendar.models.Scrap -import com.terning.feature.calendar.models.SelectedDateState +import com.terning.domain.repository.ScrapRepository +import com.terning.feature.R +import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow @@ -21,7 +23,12 @@ import javax.inject.Inject @HiltViewModel class CalendarViewModel @Inject constructor( + private val scrapRepository: ScrapRepository ) : ViewModel() { + init { + getScrapModelList() + } + private val _selectedDate = MutableStateFlow( SelectedDateState( selectedDate = LocalDate.now(), @@ -49,12 +56,25 @@ class CalendarViewModel @Inject constructor( fun disableWeekCalendar() { _selectedDate.update { currentState -> + + val sad = R.string.calendar_animation_label currentState.copy( isEnabled = false ) } } + fun getScrapModelList() = viewModelScope.launch { + scrapRepository.getMonthScrapList(2024, 7).fold( + onSuccess = { + Log.d("CalendarScreen", it.toString()) + }, + onFailure = { + Log.d("CalendarScreen", it.message.toString()) + } + ) + } + //To be erased in future diff --git a/feature/src/main/java/com/terning/feature/calendar/models/SelectedDateState.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt similarity index 72% rename from feature/src/main/java/com/terning/feature/calendar/models/SelectedDateState.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt index 04864c848..d39fa154b 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/SelectedDateState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.calendar import java.time.LocalDate diff --git a/feature/src/main/java/com/terning/feature/calendar/navigation/CalendarNavigation.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt similarity index 91% rename from feature/src/main/java/com/terning/feature/calendar/navigation/CalendarNavigation.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt index 1725d9eb7..0d3b099d1 100644 --- a/feature/src/main/java/com/terning/feature/calendar/navigation/CalendarNavigation.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.navigation +package com.terning.feature.calendar.calendar.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDay.kt b/feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt similarity index 90% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDay.kt rename to feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt index 14a3b8656..34fcf7bc2 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDay.kt +++ b/feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.day import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -22,13 +22,13 @@ 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.feature.calendar.models.DayModel +import com.terning.feature.calendar.day.model.DayClass import java.time.LocalDate @Composable fun CalendarDay( modifier: Modifier = Modifier, - dayData: DayModel, + dayData: DayClass, isSelected: Boolean, isToday: Boolean, onDateSelected: (LocalDate) -> Unit @@ -82,19 +82,19 @@ fun CalendarDayPreview() { TerningPointTheme { Row { CalendarDay( - dayData = DayModel(LocalDate.now(), false), + dayData = DayClass(LocalDate.now(), false), isSelected = true, isToday = true, onDateSelected = {} ) CalendarDay( - dayData = DayModel(LocalDate.now(), false), + dayData = DayClass(LocalDate.now(), false), isSelected = false, isToday = true, onDateSelected = {} ) CalendarDay( - dayData = DayModel(LocalDate.now(), false), + dayData = DayClass(LocalDate.now(), false), isSelected = false, isToday = false, onDateSelected = {} diff --git a/feature/src/main/java/com/terning/feature/calendar/models/DayModel.kt b/feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt similarity index 67% rename from feature/src/main/java/com/terning/feature/calendar/models/DayModel.kt rename to feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt index 891a9f470..ac74e48d3 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/DayModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt @@ -1,10 +1,10 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.day.model import androidx.compose.runtime.Immutable import java.time.LocalDate @Immutable -data class DayModel( +data class DayClass( val date: LocalDate, val isOutDate: Boolean = false ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt similarity index 86% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonth.kt rename to feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index 3d1822b5c..00a36766c 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -1,12 +1,8 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.month -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable @@ -17,9 +13,10 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.extension.isToday -import com.terning.feature.calendar.models.MonthData -import com.terning.feature.calendar.models.Scrap -import com.terning.feature.calendar.models.SelectedDateState +import com.terning.feature.calendar.day.CalendarDay +import com.terning.feature.calendar.month.model.MonthData +import com.terning.feature.calendar.scrap.model.Scrap +import com.terning.feature.calendar.calendar.SelectedDateState import com.terning.feature.calendar.scrap.CalendarScrapStrip import java.time.LocalDate import java.time.YearMonth diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonths.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt similarity index 76% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonths.kt rename to feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt index 5d6e9d6c3..fb078a1cc 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarMonths.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.month import androidx.compose.foundation.background import androidx.compose.foundation.lazy.LazyListState @@ -6,11 +6,11 @@ import androidx.compose.foundation.lazy.LazyRow import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.terning.core.designsystem.theme.White -import com.terning.feature.calendar.models.CalendarDefaults.flingBehavior -import com.terning.feature.calendar.models.CalendarState.Companion.getDateByPage -import com.terning.feature.calendar.models.MonthData -import com.terning.feature.calendar.models.Scrap -import com.terning.feature.calendar.models.SelectedDateState +import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior +import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage +import com.terning.feature.calendar.month.model.MonthData +import com.terning.feature.calendar.scrap.model.Scrap +import com.terning.feature.calendar.calendar.SelectedDateState import java.time.LocalDate import java.time.YearMonth diff --git a/feature/src/main/java/com/terning/feature/calendar/models/MonthData.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt similarity index 86% rename from feature/src/main/java/com/terning/feature/calendar/models/MonthData.kt rename to feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt index 425f7beb6..a13ef0f82 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/MonthData.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt @@ -1,6 +1,7 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.month.model import androidx.compose.runtime.Immutable +import com.terning.feature.calendar.day.model.DayClass import java.time.YearMonth /** @@ -10,7 +11,7 @@ import java.time.YearMonth * [inDays] represents the number of days in the previous month that should be shown before the first day of the month. * [outDays] represents the number of days in the next month that should be shown after the last day of the month.] * [totalDays] represents the total number of days shown on calendar - * [calendarMonth] represents the list of days of the month, a list of [DayModel] + * [calendarMonth] represents the list of days of the month, a list of [DayClass] */ @@ -31,11 +32,11 @@ data class MonthData( val calendarMonth = MonthModel(month, rows.map { week -> week.map {dayOffset -> getDay(dayOffset)}}) - private fun getDay(dayOffset: Int): DayModel { + private fun getDay(dayOffset: Int): DayClass { val firstDayOnCalendar = month.atDay(1).minusDays(inDays.toLong()) val date = firstDayOnCalendar.plusDays(dayOffset.toLong()) val isOutDate = YearMonth.of(date.year, date.monthValue) != month - return DayModel(date, isOutDate) + return DayClass(date, isOutDate) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/models/MonthModel.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt similarity index 87% rename from feature/src/main/java/com/terning/feature/calendar/models/MonthModel.kt rename to feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt index 01a10041d..f1d665437 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/MonthModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt @@ -1,12 +1,13 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.month.model import androidx.compose.runtime.Immutable +import com.terning.feature.calendar.day.model.DayClass import java.time.YearMonth @Immutable data class MonthModel( val yearMonth: YearMonth, - val weekDays: List> + val weekDays: List> ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt index d89c1e9b2..68be03fad 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt @@ -10,7 +10,7 @@ import com.terning.core.designsystem.component.item.InternItem import com.terning.core.designsystem.component.item.ScrapBox import com.terning.core.designsystem.theme.CalBlue1 import com.terning.core.designsystem.theme.TerningPointTheme -import com.terning.feature.calendar.models.Scrap +import com.terning.feature.calendar.scrap.model.Scrap @Composable fun CalendarScrap( diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt index d1a9dc1ff..51c80e4a0 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.getDateStringInKorean -import com.terning.feature.calendar.models.Scrap +import com.terning.feature.calendar.scrap.model.Scrap import java.time.LocalDate @Composable diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt index 1731b789b..8cbe5dc47 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt @@ -14,9 +14,9 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.White -import com.terning.feature.calendar.models.CalendarDefaults.flingBehavior -import com.terning.feature.calendar.models.CalendarState.Companion.getDateByPage -import com.terning.feature.calendar.models.Scrap +import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior +import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage +import com.terning.feature.calendar.scrap.model.Scrap import java.time.LocalDate @Composable diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt index 34e8bdcf3..044ce38a9 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White -import com.terning.feature.calendar.models.Scrap +import com.terning.feature.calendar.scrap.model.Scrap @Composable fun CalendarScrapStrip( diff --git a/feature/src/main/java/com/terning/feature/calendar/models/Scrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/model/Scrap.kt similarity index 85% rename from feature/src/main/java/com/terning/feature/calendar/models/Scrap.kt rename to feature/src/main/java/com/terning/feature/calendar/scrap/model/Scrap.kt index 86d00350e..f7cc07035 100644 --- a/feature/src/main/java/com/terning/feature/calendar/models/Scrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/model/Scrap.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.models +package com.terning.feature.calendar.scrap.model import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.Color diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeek.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt similarity index 88% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeek.kt rename to feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt index ea6bb76b6..5e347e86a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeek.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.week import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.fillMaxWidth @@ -12,10 +12,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.terning.core.extension.getWeekIndexContainingSelectedDate import com.terning.core.extension.isToday -import com.terning.feature.calendar.models.MonthData -import com.terning.feature.calendar.models.Scrap -import com.terning.feature.calendar.models.SelectedDateState -import timber.log.Timber +import com.terning.feature.calendar.calendar.SelectedDateState +import com.terning.feature.calendar.day.CalendarDay +import com.terning.feature.calendar.month.model.MonthData import java.time.LocalDate import java.time.YearMonth diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeekWithScrap.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt similarity index 94% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeekWithScrap.kt rename to feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt index 54ab943b3..afa17e888 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarWeekWithScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.week import androidx.compose.foundation.background import androidx.compose.foundation.border @@ -20,8 +20,8 @@ import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.feature.R -import com.terning.feature.calendar.models.Scrap -import com.terning.feature.calendar.models.SelectedDateState +import com.terning.feature.calendar.calendar.SelectedDateState +import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.scrap.CalendarScrapList import java.time.LocalDate diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index b538c3e58..0ba71896a 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -9,7 +9,8 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions -import com.terning.feature.calendar.navigation.navigateCalendar +import com.terning.feature.calendar.calendar.navigation.navigateCalendar +import com.terning.feature.home.home.navigation.Home import com.terning.feature.home.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage import com.terning.feature.onboarding.signin.navigation.SignIn diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index be9252004..d49b4a96d 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -20,7 +20,7 @@ import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White import com.terning.core.util.NoRippleInteractionSource -import com.terning.feature.calendar.navigation.calendarNavGraph +import com.terning.feature.calendar.calendar.navigation.calendarNavGraph import com.terning.feature.home.home.navigation.homeNavGraph import com.terning.feature.mypage.navigation.myPageNavGraph import com.terning.feature.onboarding.filtering.navigation.filteringNavGraph diff --git a/feature/src/main/java/com/terning/feature/main/MainTab.kt b/feature/src/main/java/com/terning/feature/main/MainTab.kt index b7b826e31..54c65b52c 100644 --- a/feature/src/main/java/com/terning/feature/main/MainTab.kt +++ b/feature/src/main/java/com/terning/feature/main/MainTab.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable import com.terning.core.navigation.MainTabRoute import com.terning.core.navigation.Route import com.terning.feature.R -import com.terning.feature.calendar.navigation.Calendar +import com.terning.feature.calendar.calendar.navigation.Calendar import com.terning.feature.home.home.navigation.Home import com.terning.feature.mypage.navigation.MyPage import com.terning.feature.search.search.navigation.Search From a41c1c5c2e329682589e386433fd9e9fceb5ecfa Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 04:13:22 +0900 Subject: [PATCH 06/37] =?UTF-8?q?[MOD/#59]=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=ED=86=B5=EC=8B=A0=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/ScrapDataSource.kt | 2 + .../datasourceimpl/ScrapDataSourceImpl.kt | 9 ++ .../data/dto/response/ScrapResponsesDto.kt | 109 ++++++++++++++++++ .../repositoryimpl/ScrapRepositoryImpl.kt | 12 ++ .../domain/repository/ScrapRepository.kt | 2 + .../calendar/calendar/CalendarViewModel.kt | 20 +++- .../feature/calendar/month/CalendarMonths.kt | 3 + 7 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt diff --git a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt index 586b5e518..9e6293e04 100644 --- a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt @@ -3,7 +3,9 @@ package com.terning.data.datasource import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.ScrapRequestDto import com.terning.data.dto.response.ScrapResponseDto +import com.terning.data.dto.response.ScrapResponsesDto interface ScrapDataSource { suspend fun getMonthScrapList(request: ScrapRequestDto): BaseResponse + suspend fun getMonthScrapMap(request: ScrapRequestDto): BaseResponse> } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt index 9b3c2815a..6716bfeaf 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt @@ -4,6 +4,7 @@ import com.terning.data.datasource.ScrapDataSource import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.ScrapRequestDto import com.terning.data.dto.response.ScrapResponseDto +import com.terning.data.dto.response.ScrapResponsesDto import com.terning.data.dto.response.getMockScrapList import javax.inject.Inject @@ -16,4 +17,12 @@ class ScrapDataSourceImpl @Inject constructor( message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", result = getMockScrapList(request.month) ) + + override suspend fun getMonthScrapMap(request: ScrapRequestDto): BaseResponse> = + BaseResponse( + status = 200, + message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", + result = getMockScrapList(request.year, request.month) + ) + } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt new file mode 100644 index 000000000..08c730154 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt @@ -0,0 +1,109 @@ +package com.terning.data.dto.response + +import com.terning.domain.entity.response.ScrapModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ScrapResponsesDto( + @SerialName("deadline") + val deadline: String, + @SerialName("scraps") + val scraps: List +) { + @Serializable + data class Scrap( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("title") + val title: String, + @SerialName("color") + val color: String + ) +} + + +fun List.toScrapsByDeadlineMap(): Map> { + return this.flatMap { dto -> + dto.scraps.map { scrap -> + dto.deadline to scrap.toScrapModel(dto.deadline) + } + }.groupBy( + { it.first }, // 키: deadline + { it.second } // 값: Scrap 객체 + ) +} + +private fun ScrapResponsesDto.Scrap.toScrapModel(deadline: String) = ScrapModel( + scrapId = scrapId, + title = title, + color = color, + deadLine = deadline, + isScrapped = true +) + +fun getMockScrapList(year: Int, month: Int): List { + val deadline = month.toString().padStart(2, '0') + return listOf( + ScrapResponsesDto( + deadline = "${year}-${deadline}-13", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-17", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-23", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-30", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) + ) +} \ No newline at end of file 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 3c75fb944..3edf397b3 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.ScrapDataSource import com.terning.data.dto.request.ScrapRequestDto import com.terning.data.dto.response.toScrapsByDeadLineList +import com.terning.data.dto.response.toScrapsByDeadlineMap import com.terning.domain.entity.response.ScrapModel import com.terning.domain.repository.ScrapRepository import javax.inject.Inject @@ -20,4 +21,15 @@ class ScrapRepositoryImpl @Inject constructor( ) response.result.toScrapsByDeadLineList() } + + override suspend fun getMonthScrapLists(year: Int, month: Int): Result>> = + runCatching { + val response = scrapDataSource.getMonthScrapMap( + request = ScrapRequestDto( + year = year, + month = month + ) + ) + response.result.toScrapsByDeadlineMap() + } } \ 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 403e02765..b66a1b8f6 100644 --- a/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt @@ -4,4 +4,6 @@ import com.terning.domain.entity.response.ScrapModel interface ScrapRepository{ suspend fun getMonthScrapList(year: Int, month: Int): Result>> + + suspend fun getMonthScrapLists(year: Int, month: Int): Result>> } \ No newline at end of file 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 537f75b6c..a3b20a0cd 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 @@ -14,10 +14,13 @@ import com.terning.domain.repository.ScrapRepository import com.terning.feature.R import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow 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 @@ -26,7 +29,7 @@ class CalendarViewModel @Inject constructor( private val scrapRepository: ScrapRepository ) : ViewModel() { init { - getScrapModelList() + getScrapModelMap(2024, 7) } private val _selectedDate = MutableStateFlow( @@ -75,6 +78,21 @@ class CalendarViewModel @Inject constructor( ) } + fun getScrapModelMap( + year: Int, month: Int + ) = viewModelScope.launch { + withContext(Dispatchers.IO) { + scrapRepository.getMonthScrapLists(year, month) + }.fold( + onSuccess = { + Timber.tag("CalendarScreen").d(" ${it.toString()}") + }, + onFailure = { + Timber.tag("CalendarScreen").d(" ${it.message.toString()}") + } + ) + } + //To be erased in future diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt index fb078a1cc..46bd55cb0 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt @@ -1,5 +1,6 @@ package com.terning.feature.calendar.month +import android.util.Log import androidx.compose.foundation.background import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.LazyRow @@ -36,6 +37,8 @@ fun CalendarMonths( val date = getDateByPage(page) val monthData = MonthData(YearMonth.of(date.year, date.month)) + Log.d("CalendarScreen", "current date : $date") + CalendarMonth( modifier = Modifier.fillParentMaxSize(), selectedDate = selectedDate, From 7c0ba194ad5475e7e4021c845a8a945dd55e4fb7 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 05:37:31 +0900 Subject: [PATCH 07/37] =?UTF-8?q?[FEAT/#59]=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EC=A0=84=ED=99=98=20=EC=8B=9C=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/topappbar/CalendarTopAppBar.kt | 7 +- .../data/dto/response/ScrapResponsesDto.kt | 301 +++++++++++++++--- .../calendar/calendar/CalendarRoute.kt | 7 +- .../calendar/calendar/CalendarViewModel.kt | 15 +- .../feature/calendar/month/CalendarMonth.kt | 10 +- .../feature/calendar/month/CalendarMonths.kt | 183 ++++++++++- .../calendar/scrap/CalendarScrapStrip.kt | 14 +- 7 files changed, 461 insertions(+), 76 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 a18a80fa6..2e95a0549 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 @@ -24,11 +24,12 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.getStringAsTitle import com.terning.core.extension.noRippleClickable import java.time.LocalDate +import java.time.YearMonth @Composable fun CalendarTopAppBar( modifier: Modifier = Modifier, - date: LocalDate, + date: YearMonth, isWeekExpanded: Boolean, isListExpanded: Boolean, onListButtonClicked: () -> Unit, @@ -58,7 +59,7 @@ fun CalendarTopAppBar( ) } Text( - text = date.getStringAsTitle(), + text = LocalDate.of(date.year, date.month, 1).getStringAsTitle(), style = TerningTheme.typography.title2, color = Black, modifier = Modifier.padding(horizontal = 8.dp) @@ -97,7 +98,7 @@ fun CalendarTopAppBar( fun CalendarTopBarPreview() { TerningPointTheme { CalendarTopAppBar( - date = LocalDate.now(), + date = YearMonth.now(), isListExpanded = false, isWeekExpanded = false , diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt index 08c730154..ea8f08e76 100644 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt @@ -44,66 +44,267 @@ private fun ScrapResponsesDto.Scrap.toScrapModel(deadline: String) = ScrapModel( fun getMockScrapList(year: Int, month: Int): List { val deadline = month.toString().padStart(2, '0') - return listOf( - ScrapResponsesDto( - deadline = "${year}-${deadline}-13", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" + + return when (month % 4) { + 0 -> { + listOf( + ScrapResponsesDto( + deadline = "${year}-${deadline}-13", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" + ScrapResponsesDto( + deadline = "${year}-${deadline}-17", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) ), - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" + ScrapResponsesDto( + deadline = "${year}-${deadline}-23", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" + ScrapResponsesDto( + deadline = "${year}-${deadline}-30", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) ) ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-17", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" + } + 1 -> { + listOf( + ScrapResponsesDto( + deadline = "${year}-${deadline}-1", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" + ScrapResponsesDto( + deadline = "${year}-${deadline}-12", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-27", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-23", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" + } + 2 -> { + listOf( + ScrapResponsesDto( + deadline = "${year}-${deadline}-2", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-18", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-20", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) ) ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-30", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" + } + 3 -> { + listOf( + ScrapResponsesDto( + deadline = "${year}-${deadline}-5", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + )/*, + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + )*/ + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-11", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-19", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-28", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) ) ) - ) - ) + } + + else -> { + listOf() + } + } } \ No newline at end of file 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 9a5b701bb..b8beff95f 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 @@ -38,6 +38,7 @@ import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch import java.time.LocalDate +import java.time.YearMonth @Composable fun CalendarRoute() { @@ -56,7 +57,7 @@ fun CalendarScreen( initialFirstVisibleItemIndex = state.getInitialPage() ) - var currentDate by remember { mutableStateOf(LocalDate.now()) } + var currentDate by remember { mutableStateOf(YearMonth.now()) } var currentPage by remember { mutableIntStateOf(listState.firstVisibleItemIndex) } var isListExpanded by remember { mutableStateOf(false) } @@ -161,7 +162,7 @@ fun CalendarScreen( }, listState = listState, pages = state.getPageCount(), - scrapLists = viewModel.mockScrapList, + viewModel = viewModel ) } else { CalendarWeekWithScrap( @@ -178,8 +179,6 @@ fun CalendarScreen( } } } - } } - 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 a3b20a0cd..babf80c4e 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,6 +1,10 @@ package com.terning.feature.calendar.calendar import android.util.Log +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.designsystem.theme.CalBlue1 @@ -10,6 +14,7 @@ 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.domain.entity.response.ScrapModel import com.terning.domain.repository.ScrapRepository import com.terning.feature.R import com.terning.feature.calendar.scrap.model.Scrap @@ -32,7 +37,7 @@ class CalendarViewModel @Inject constructor( getScrapModelMap(2024, 7) } - private val _selectedDate = MutableStateFlow( + private var _selectedDate = MutableStateFlow( SelectedDateState( selectedDate = LocalDate.now(), isEnabled = false @@ -40,6 +45,10 @@ class CalendarViewModel @Inject constructor( ) val selectedDate get() = _selectedDate.asStateFlow() + private var _scrapList: MutableStateFlow>> = + MutableStateFlow( mapOf()) + val scrapList get() = _scrapList.asStateFlow() + fun updateSelectedDate(date: LocalDate) = viewModelScope.launch { if (_selectedDate.value.selectedDate != date) { _selectedDate.update { currentState -> @@ -59,8 +68,6 @@ class CalendarViewModel @Inject constructor( fun disableWeekCalendar() { _selectedDate.update { currentState -> - - val sad = R.string.calendar_animation_label currentState.copy( isEnabled = false ) @@ -85,7 +92,7 @@ class CalendarViewModel @Inject constructor( scrapRepository.getMonthScrapLists(year, month) }.fold( onSuccess = { - Timber.tag("CalendarScreen").d(" ${it.toString()}") + _scrapList.value = it }, onFailure = { Timber.tag("CalendarScreen").d(" ${it.message.toString()}") diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index 00a36766c..0b3cbf9e7 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.extension.isToday +import com.terning.domain.entity.response.ScrapModel import com.terning.feature.calendar.day.CalendarDay import com.terning.feature.calendar.month.model.MonthData import com.terning.feature.calendar.scrap.model.Scrap @@ -27,7 +28,8 @@ fun CalendarMonth( monthData: MonthData, onDateSelected: (LocalDate) -> Unit, selectedDate: SelectedDateState, - scrapLists: List> = listOf() + scrapLists: List> = listOf(), + scrapMap: Map> = mapOf() ) { Column( modifier = modifier @@ -53,9 +55,11 @@ fun CalendarMonth( onDateSelected = onDateSelected ) if(!day.isOutDate) { - val index = day.date.dayOfMonth - 1 + val index = day.date.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")) + //val index = day.date.dayOfMonth - 1 + CalendarScrapStrip( - scrapList = scrapLists[index] + scrapLists = scrapMap[index].orEmpty() ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt index 46bd55cb0..be499ef87 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt @@ -2,28 +2,73 @@ package com.terning.feature.calendar.month import android.util.Log import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.stopScroll import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.LazyRow import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier +import com.terning.core.designsystem.theme.CalBlue1 +import com.terning.core.designsystem.theme.CalGreen1 +import com.terning.core.designsystem.theme.CalGreen2 +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.designsystem.theme.White +import com.terning.domain.entity.response.ScrapModel import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage +import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.month.model.MonthData import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.calendar.SelectedDateState +import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate import java.time.YearMonth @Composable fun CalendarMonths( - listState: LazyListState, - onDateSelected: (LocalDate) -> Unit, pages: Int, + listState: LazyListState, selectedDate: SelectedDateState, - scrapLists: List>, + onDateSelected: (LocalDate) -> Unit, + viewModel: CalendarViewModel, modifier: Modifier = Modifier, ) { + /* var scrapList by remember { mutableStateOf(mockScrapList01) } + LaunchedEffect(key1 = listState) { + snapshotFlow { listState.firstVisibleItemIndex } + .distinctUntilChanged() + .collect { + val page = listState.firstVisibleItemIndex + + if(page %2 == 1) { + scrapList = mockScrapList01 + } else { + scrapList = mockScrapList02 + } + } + }*/ + + val scrapState by viewModel.scrapList.collectAsState() + + LaunchedEffect(key1 = listState) { + snapshotFlow { listState.firstVisibleItemIndex } + .distinctUntilChanged() + .collect { + val page = listState.firstVisibleItemIndex + val date = getDateByPage(page) + viewModel.getScrapModelMap(date.year, date.monthValue) + } + } + LazyRow( modifier = modifier .background(White), @@ -37,15 +82,141 @@ fun CalendarMonths( val date = getDateByPage(page) val monthData = MonthData(YearMonth.of(date.year, date.month)) - Log.d("CalendarScreen", "current date : $date") CalendarMonth( modifier = Modifier.fillParentMaxSize(), selectedDate = selectedDate, onDateSelected = onDateSelected, monthData = monthData, - scrapLists = scrapLists + scrapMap = scrapState ) } } -} \ No newline at end of file +} + +//To be erased in future +val mockScrapList01: List> + get() { + val list: MutableList> = mutableListOf() + for (i in 0..30) { + when (i % 6) { + 0 -> { + list.add( + i, + listOf() + ) + } + + 5 -> { + list.add( + i, + listOf( + Scrap("Task1_1", CalBlue1, dDay = "1", period = "3", isScraped = true), + ) + ) + } + + 2 -> { + list.add( + i, + listOf( + Scrap("Task2_1", CalPink, dDay = "2", period = "3", isScraped = true), + Scrap("Task2_2", CalGreen1, dDay = "2", period = "3", isScraped = true) + ) + ) + } + + 3 -> { + list.add( + i, + listOf() + ) + } + + 4 -> { + list.add( + i, + listOf() + ) + } + + 1 -> { + list.add( + i, + listOf( + Scrap("Task3_1", CalPink, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_2", CalPurple, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_3", CalRed, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_4", CalBlue1, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_5", CalGreen2, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_6", CalYellow, dDay = "5", period = "3", isScraped = true) + ) + ) + } + } + } + return list.toList() + } + +val mockScrapList02: List> + get() { + val list: MutableList> = mutableListOf() + for (i in 0..30) { + when (i % 6) { + 0 -> { + list.add( + i, + listOf() + ) + } + + 1 -> { + list.add( + i, + listOf( + Scrap("Task1_1", CalBlue1, dDay = "1", period = "3", isScraped = true), + ) + ) + } + + 2 -> { + list.add( + i, + listOf( + Scrap("Task2_1", CalPink, dDay = "2", period = "3", isScraped = true), + Scrap("Task2_2", CalGreen1, dDay = "2", period = "3", isScraped = true) + ) + ) + } + + 5 -> { + list.add( + i, + listOf() + ) + } + + 3 -> { + list.add( + i, + listOf() + ) + } + + 4 -> { + list.add( + i, + listOf( + Scrap("Task3_1", CalPink, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_2", CalPurple, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_3", CalRed, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_4", CalBlue1, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_5", CalGreen2, dDay = "5", period = "3", isScraped = true), + Scrap("Task3_6", CalYellow, dDay = "5", period = "3", isScraped = true) + ) + ) + } + } + } + return list.toList() + } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt index 044ce38a9..8ccaf7698 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt @@ -8,24 +8,26 @@ import androidx.compose.foundation.lazy.items import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White +import com.terning.domain.entity.response.ScrapModel import com.terning.feature.calendar.scrap.model.Scrap @Composable fun CalendarScrapStrip( modifier: Modifier = Modifier, - scrapList: List + scrapLists: List ) { LazyColumn( modifier = modifier.fillMaxWidth().padding(top = 3.dp) ) { - items(scrapList.subList(0, MAX_SCRAP_COUNT.coerceAtMost(scrapList.size))) { scrap -> + items(scrapLists.subList(0, MAX_SCRAP_COUNT.coerceAtMost(scrapLists.size))) { scrap -> Text( - text = scrap.text, + text = scrap.title, style = TerningTheme.typography.body5, textAlign = TextAlign.Center, color = White, @@ -33,14 +35,14 @@ fun CalendarScrapStrip( overflow = TextOverflow.Ellipsis, modifier = Modifier .fillMaxWidth() - .background(color = scrap.backgroundColor) + .background(color = Color(android.graphics.Color.parseColor(scrap.color))) ) } item{ - if(scrapList.size > MAX_SCRAP_COUNT) { + if(scrapLists.size > MAX_SCRAP_COUNT) { Text( - text = "+${(scrapList.size - MAX_SCRAP_COUNT)}", + text = "+${(scrapLists.size - MAX_SCRAP_COUNT)}", style = TerningTheme.typography.detail4, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() From a56ee6b441720d4b6878aec9d4f9b0de9ba57719 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 06:49:49 +0900 Subject: [PATCH 08/37] =?UTF-8?q?[REFACTOR/#59]=20=EC=9B=94=EA=B0=84=20?= =?UTF-8?q?=EC=BA=98=EB=A6=B0=EB=8D=94=20=ED=98=B8=EC=B6=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/ScrapDataSource.kt | 3 +- .../datasourceimpl/ScrapDataSourceImpl.kt | 9 +- .../data/dto/response/ScrapResponsesDto.kt | 31 ++- .../repositoryimpl/ScrapRepositoryImpl.kt | 13 +- .../domain/repository/ScrapRepository.kt | 4 +- .../calendar/calendar/CalendarRoute.kt | 5 +- .../calendar/calendar/CalendarViewModel.kt | 37 +-- .../calendar/month/CalendarMonthScreen.kt | 94 ++++++++ .../feature/calendar/month/CalendarMonths.kt | 222 ------------------ .../calendar/month/ScrapCalendarState.kt | 8 + .../calendar/scrap/CalendarScrapStrip.kt | 10 +- 11 files changed, 156 insertions(+), 280 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt delete mode 100644 feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt create mode 100644 feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt diff --git a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt index 9e6293e04..29371bad4 100644 --- a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt @@ -6,6 +6,5 @@ import com.terning.data.dto.response.ScrapResponseDto import com.terning.data.dto.response.ScrapResponsesDto interface ScrapDataSource { - suspend fun getMonthScrapList(request: ScrapRequestDto): BaseResponse - suspend fun getMonthScrapMap(request: ScrapRequestDto): BaseResponse> + suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt index 6716bfeaf..9cbd26d5a 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt @@ -11,14 +11,7 @@ import javax.inject.Inject class ScrapDataSourceImpl @Inject constructor( ) : ScrapDataSource { - override suspend fun getMonthScrapList(request: ScrapRequestDto): BaseResponse = - BaseResponse( - status = 200, - message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", - result = getMockScrapList(request.month) - ) - - override suspend fun getMonthScrapMap(request: ScrapRequestDto): BaseResponse> = + override suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> = BaseResponse( status = 200, message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt index ea8f08e76..daa9715f3 100644 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt @@ -113,7 +113,7 @@ fun getMockScrapList(year: Int, month: Int): List { 1 -> { listOf( ScrapResponsesDto( - deadline = "${year}-${deadline}-1", + deadline = "${year}-${deadline}-01", scraps = listOf( ScrapResponsesDto.Scrap( scrapId = 1, @@ -137,6 +137,31 @@ fun getMockScrapList(year: Int, month: Int): List { ) ) ), + ScrapResponsesDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + ScrapResponsesDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponsesDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FFED4E54" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), ScrapResponsesDto( deadline = "${year}-${deadline}-12", scraps = listOf( @@ -177,7 +202,7 @@ fun getMockScrapList(year: Int, month: Int): List { 2 -> { listOf( ScrapResponsesDto( - deadline = "${year}-${deadline}-2", + deadline = "${year}-${deadline}-02", scraps = listOf( ScrapResponsesDto.Scrap( scrapId = 1, @@ -241,7 +266,7 @@ fun getMockScrapList(year: Int, month: Int): List { 3 -> { listOf( ScrapResponsesDto( - deadline = "${year}-${deadline}-5", + deadline = "${year}-${deadline}-05", scraps = listOf( ScrapResponsesDto.Scrap( scrapId = 1, 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 3edf397b3..ecc6f27a3 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -11,18 +11,7 @@ import javax.inject.Inject class ScrapRepositoryImpl @Inject constructor( private val scrapDataSource: ScrapDataSource ): ScrapRepository { - override suspend fun getMonthScrapList(year: Int, month: Int): Result>> = - runCatching { - val response = scrapDataSource.getMonthScrapList( - request = ScrapRequestDto( - year = year, - month = month - ) - ) - response.result.toScrapsByDeadLineList() - } - - override suspend fun getMonthScrapLists(year: Int, month: Int): Result>> = + override suspend fun getScrapMonth(year: Int, month: Int): Result>> = runCatching { val response = scrapDataSource.getMonthScrapMap( request = ScrapRequestDto( 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 b66a1b8f6..bc13c9639 100644 --- a/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt @@ -3,7 +3,5 @@ package com.terning.domain.repository import com.terning.domain.entity.response.ScrapModel interface ScrapRepository{ - suspend fun getMonthScrapList(year: Int, month: Int): Result>> - - suspend fun getMonthScrapLists(year: Int, month: Int): Result>> + suspend fun getScrapMonth(year: Int, month: Int): Result>> } \ No newline at end of file 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 b8beff95f..4485c2273 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 @@ -32,12 +32,11 @@ import com.terning.core.designsystem.component.topappbar.CalendarTopAppBar import com.terning.core.designsystem.theme.Grey200 import com.terning.feature.R import com.terning.feature.calendar.calendar.component.WeekDaysHeader -import com.terning.feature.calendar.month.CalendarMonths +import com.terning.feature.calendar.month.CalendarMonthScreen import com.terning.feature.calendar.scrap.CalendarScrapListScreen import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch -import java.time.LocalDate import java.time.YearMonth @Composable @@ -154,7 +153,7 @@ fun CalendarScreen( label = stringResource(id = R.string.calendar_animation_label) ) { targetState -> if (!targetState) { - CalendarMonths( + CalendarMonthScreen( modifier = Modifier.fillMaxSize(), selectedDate = selectedDate, onDateSelected = { 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 babf80c4e..4dc09c13f 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,10 +1,5 @@ package com.terning.feature.calendar.calendar -import android.util.Log -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.designsystem.theme.CalBlue1 @@ -14,9 +9,9 @@ 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.domain.entity.response.ScrapModel +import com.terning.core.state.UiState import com.terning.domain.repository.ScrapRepository -import com.terning.feature.R +import com.terning.feature.calendar.month.ScrapCalendarState import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers @@ -34,7 +29,7 @@ class CalendarViewModel @Inject constructor( private val scrapRepository: ScrapRepository ) : ViewModel() { init { - getScrapModelMap(2024, 7) + getScrapMonth(2024, 7) } private var _selectedDate = MutableStateFlow( @@ -45,9 +40,8 @@ class CalendarViewModel @Inject constructor( ) val selectedDate get() = _selectedDate.asStateFlow() - private var _scrapList: MutableStateFlow>> = - MutableStateFlow( mapOf()) - val scrapList get() = _scrapList.asStateFlow() + private val _scrapCalendarState = MutableStateFlow(ScrapCalendarState()) + val scrapCalendarState = _scrapCalendarState.asStateFlow() fun updateSelectedDate(date: LocalDate) = viewModelScope.launch { if (_selectedDate.value.selectedDate != date) { @@ -74,25 +68,18 @@ class CalendarViewModel @Inject constructor( } } - fun getScrapModelList() = viewModelScope.launch { - scrapRepository.getMonthScrapList(2024, 7).fold( - onSuccess = { - Log.d("CalendarScreen", it.toString()) - }, - onFailure = { - Log.d("CalendarScreen", it.message.toString()) - } - ) - } - - fun getScrapModelMap( + fun getScrapMonth( year: Int, month: Int ) = viewModelScope.launch { withContext(Dispatchers.IO) { - scrapRepository.getMonthScrapLists(year, month) + scrapRepository.getScrapMonth(year, month) }.fold( onSuccess = { - _scrapList.value = it + _scrapCalendarState.update { currentState -> + currentState.copy ( + loadState = UiState.Success(it) + ) + } }, onFailure = { Timber.tag("CalendarScreen").d(" ${it.message.toString()}") diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt new file mode 100644 index 000000000..a858b11f6 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -0,0 +1,94 @@ +package com.terning.feature.calendar.month + +import androidx.compose.foundation.background +import androidx.compose.foundation.lazy.LazyListState +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Modifier +import com.terning.core.designsystem.theme.White +import com.terning.core.state.UiState +import com.terning.domain.entity.response.ScrapModel +import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior +import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage +import com.terning.feature.calendar.calendar.CalendarViewModel +import com.terning.feature.calendar.month.model.MonthData +import com.terning.feature.calendar.calendar.SelectedDateState +import kotlinx.coroutines.flow.distinctUntilChanged +import java.time.LocalDate +import java.time.YearMonth + +@Composable +fun CalendarMonthScreen( + pages: Int, + listState: LazyListState, + selectedDate: SelectedDateState, + onDateSelected: (LocalDate) -> Unit, + viewModel: CalendarViewModel, + modifier: Modifier = Modifier, +) { + val scrapState by viewModel.scrapCalendarState.collectAsState() + + LaunchedEffect(key1 = listState) { + snapshotFlow { listState.firstVisibleItemIndex } + .distinctUntilChanged() + .collect { + val page = listState.firstVisibleItemIndex + val date = getDateByPage(page) + viewModel.getScrapMonth(date.year, date.monthValue) + } + } + + when (scrapState.loadState) { + UiState.Loading -> {} + UiState.Empty -> {} + is UiState.Failure -> {} + is UiState.Success -> { + CalendarMonthList( + pages = pages, + modifier = modifier, + selectedDate = selectedDate, + onDateSelected = onDateSelected, + listState = listState, + scrapMap = (scrapState.loadState as UiState.Success).data + ) + } + } +} + + +@Composable +fun CalendarMonthList( + pages: Int, + listState: LazyListState, + modifier: Modifier = Modifier, + selectedDate: SelectedDateState, + onDateSelected: (LocalDate) -> Unit, + scrapMap: Map> +) { + LazyRow( + modifier = modifier + .background(White), + state = listState, + userScrollEnabled = true, + flingBehavior = flingBehavior( + state = listState + ) + ) { + items(pages) { page -> + val date = getDateByPage(page) + val monthData = MonthData(YearMonth.of(date.year, date.month)) + + CalendarMonth( + modifier = Modifier.fillParentMaxSize(), + selectedDate = selectedDate, + onDateSelected = onDateSelected, + monthData = monthData, + scrapMap = scrapMap + ) + } + } +} diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt deleted file mode 100644 index be499ef87..000000000 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonths.kt +++ /dev/null @@ -1,222 +0,0 @@ -package com.terning.feature.calendar.month - -import android.util.Log -import androidx.compose.foundation.background -import androidx.compose.foundation.gestures.stopScroll -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.runtime.snapshotFlow -import androidx.compose.ui.Modifier -import com.terning.core.designsystem.theme.CalBlue1 -import com.terning.core.designsystem.theme.CalGreen1 -import com.terning.core.designsystem.theme.CalGreen2 -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.designsystem.theme.White -import com.terning.domain.entity.response.ScrapModel -import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior -import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage -import com.terning.feature.calendar.calendar.CalendarViewModel -import com.terning.feature.calendar.month.model.MonthData -import com.terning.feature.calendar.scrap.model.Scrap -import com.terning.feature.calendar.calendar.SelectedDateState -import kotlinx.coroutines.flow.distinctUntilChanged -import java.time.LocalDate -import java.time.YearMonth - -@Composable -fun CalendarMonths( - pages: Int, - listState: LazyListState, - selectedDate: SelectedDateState, - onDateSelected: (LocalDate) -> Unit, - viewModel: CalendarViewModel, - modifier: Modifier = Modifier, -) { - /* var scrapList by remember { mutableStateOf(mockScrapList01) } - LaunchedEffect(key1 = listState) { - snapshotFlow { listState.firstVisibleItemIndex } - .distinctUntilChanged() - .collect { - val page = listState.firstVisibleItemIndex - - if(page %2 == 1) { - scrapList = mockScrapList01 - } else { - scrapList = mockScrapList02 - } - } - }*/ - - val scrapState by viewModel.scrapList.collectAsState() - - LaunchedEffect(key1 = listState) { - snapshotFlow { listState.firstVisibleItemIndex } - .distinctUntilChanged() - .collect { - val page = listState.firstVisibleItemIndex - val date = getDateByPage(page) - viewModel.getScrapModelMap(date.year, date.monthValue) - } - } - - LazyRow( - modifier = modifier - .background(White), - state = listState, - userScrollEnabled = true, - flingBehavior = flingBehavior( - state = listState - ) - ) { - items(pages) { page -> - val date = getDateByPage(page) - val monthData = MonthData(YearMonth.of(date.year, date.month)) - - - CalendarMonth( - modifier = Modifier.fillParentMaxSize(), - selectedDate = selectedDate, - onDateSelected = onDateSelected, - monthData = monthData, - scrapMap = scrapState - ) - } - } -} - -//To be erased in future -val mockScrapList01: List> - get() { - val list: MutableList> = mutableListOf() - for (i in 0..30) { - when (i % 6) { - 0 -> { - list.add( - i, - listOf() - ) - } - - 5 -> { - list.add( - i, - listOf( - Scrap("Task1_1", CalBlue1, dDay = "1", period = "3", isScraped = true), - ) - ) - } - - 2 -> { - list.add( - i, - listOf( - Scrap("Task2_1", CalPink, dDay = "2", period = "3", isScraped = true), - Scrap("Task2_2", CalGreen1, dDay = "2", period = "3", isScraped = true) - ) - ) - } - - 3 -> { - list.add( - i, - listOf() - ) - } - - 4 -> { - list.add( - i, - listOf() - ) - } - - 1 -> { - list.add( - i, - listOf( - Scrap("Task3_1", CalPink, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_2", CalPurple, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_3", CalRed, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_4", CalBlue1, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_5", CalGreen2, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_6", CalYellow, dDay = "5", period = "3", isScraped = true) - ) - ) - } - } - } - return list.toList() - } - -val mockScrapList02: List> - get() { - val list: MutableList> = mutableListOf() - for (i in 0..30) { - when (i % 6) { - 0 -> { - list.add( - i, - listOf() - ) - } - - 1 -> { - list.add( - i, - listOf( - Scrap("Task1_1", CalBlue1, dDay = "1", period = "3", isScraped = true), - ) - ) - } - - 2 -> { - list.add( - i, - listOf( - Scrap("Task2_1", CalPink, dDay = "2", period = "3", isScraped = true), - Scrap("Task2_2", CalGreen1, dDay = "2", period = "3", isScraped = true) - ) - ) - } - - 5 -> { - list.add( - i, - listOf() - ) - } - - 3 -> { - list.add( - i, - listOf() - ) - } - - 4 -> { - list.add( - i, - listOf( - Scrap("Task3_1", CalPink, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_2", CalPurple, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_3", CalRed, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_4", CalBlue1, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_5", CalGreen2, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_6", CalYellow, dDay = "5", period = "3", isScraped = true) - ) - ) - } - } - } - return list.toList() - } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt b/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt new file mode 100644 index 000000000..c332a75a9 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.calendar.month + +import com.terning.core.state.UiState +import com.terning.domain.entity.response.ScrapModel + +data class ScrapCalendarState ( + val loadState: UiState>> = UiState.Loading +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt index 8ccaf7698..4b4b411e2 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -23,7 +24,7 @@ fun CalendarScrapStrip( scrapLists: List ) { LazyColumn( - modifier = modifier.fillMaxWidth().padding(top = 3.dp) + modifier = modifier.fillMaxWidth() ) { items(scrapLists.subList(0, MAX_SCRAP_COUNT.coerceAtMost(scrapLists.size))) { scrap -> Text( @@ -34,8 +35,13 @@ fun CalendarScrapStrip( maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier + .padding(top = 2.dp) + .padding(horizontal = 2.dp) .fillMaxWidth() - .background(color = Color(android.graphics.Color.parseColor(scrap.color))) + .background( + color = Color(android.graphics.Color.parseColor(scrap.color)), + shape = RoundedCornerShape(size = 1.dp) + ) ) } From c71d01f05fecb8dd95933f4c97c2a4532c5a97d2 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 07:21:40 +0900 Subject: [PATCH 09/37] =?UTF-8?q?[MOD/#59]=20=EA=B8=B0=ED=83=80=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/ScrapDataSource.kt | 3 +- .../datasourceimpl/ScrapDataSourceImpl.kt | 3 +- .../data/dto/response/ScrapResponseDto.kt | 413 +++++++++++++----- .../data/dto/response/ScrapResponsesDto.kt | 335 -------------- .../repositoryimpl/ScrapRepositoryImpl.kt | 3 +- .../calendar/calendar/CalendarViewModel.kt | 78 +++- 6 files changed, 372 insertions(+), 463 deletions(-) delete mode 100644 data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt diff --git a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt index 29371bad4..97e893cda 100644 --- a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt @@ -3,8 +3,7 @@ package com.terning.data.datasource import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.ScrapRequestDto import com.terning.data.dto.response.ScrapResponseDto -import com.terning.data.dto.response.ScrapResponsesDto interface ScrapDataSource { - suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> + suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt index 9cbd26d5a..5b4afdf5e 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt @@ -4,14 +4,13 @@ import com.terning.data.datasource.ScrapDataSource import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.ScrapRequestDto import com.terning.data.dto.response.ScrapResponseDto -import com.terning.data.dto.response.ScrapResponsesDto import com.terning.data.dto.response.getMockScrapList import javax.inject.Inject class ScrapDataSourceImpl @Inject constructor( ) : ScrapDataSource { - override suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> = + override suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> = BaseResponse( status = 200, message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt index 139b9b77e..02412b76d 100644 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt @@ -1,142 +1,335 @@ package com.terning.data.dto.response -import com.terning.data.dto.response.ScrapResponseDto.ScrapByDeadline import com.terning.domain.entity.response.ScrapModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable data class ScrapResponseDto( - @SerialName("scrapsByDeadline") - val scrapsByDeadline: List, + @SerialName("deadline") + val deadline: String, + @SerialName("scraps") + val scraps: List ) { @Serializable - data class ScrapByDeadline( - @SerialName("deadline") - val deadline: String, - @SerialName("scraps") - val scraps: List - ) { - @Serializable - data class Scrap( - @SerialName("scrapId") - val scrapId: Long, - @SerialName("title") - val title: String, - @SerialName("deadline") - val deadline: String, - @SerialName("color") - val color: String - ) - } + data class Scrap( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("title") + val title: String, + @SerialName("color") + val color: String + ) } -fun ScrapResponseDto.toScrapsByDeadLineList() = scrapsByDeadline.map { it.toScrapModelList() } -private fun ScrapByDeadline.toScrapModelList() = scraps.map { it.toScrapModel() } +fun List.toScrapsByDeadlineMap(): Map> { + return this.flatMap { dto -> + dto.scraps.map { scrap -> + dto.deadline to scrap.toScrapModel(dto.deadline) + } + }.groupBy( + { it.first }, + { it.second } + ) +} -private fun ScrapByDeadline.Scrap.toScrapModel() = ScrapModel( +private fun ScrapResponseDto.Scrap.toScrapModel(deadline: String) = ScrapModel( scrapId = scrapId, title = title, - deadLine = deadline, color = color, + deadLine = deadline, isScrapped = true ) +fun getMockScrapList(year: Int, month: Int): List { + val deadline = month.toString().padStart(2, '0') - -fun ScrapResponseDto.toScrapModelList(): List { - return with(mutableListOf()) { - apply { - for (items in this@toScrapModelList.scrapsByDeadline) { - for(item in items.scraps) { - add( - ScrapModel( - scrapId = item.scrapId, - title = item.title, - deadLine = item.deadline, - color = item.color, - isScrapped = true + return when (month % 4) { + 0 -> { + listOf( + ScrapResponseDto( + deadline = "${year}-${deadline}-13", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" ) ) - } - } - } - } -} - -fun getMockScrapList(month: Int): ScrapResponseDto { - val deadline = month.toString().padStart(2, '0') - return ScrapResponseDto( - scrapsByDeadline = listOf( - ScrapByDeadline( - deadline = "2024-${deadline}-13", - scraps = listOf( - ScrapByDeadline.Scrap( - scrapId = 1, - title = "제목1", - deadline = "2024-${deadline}-13", - color = "0xFFED4E54" - ), - ScrapByDeadline.Scrap( - scrapId = 2, - title = "제목2", - deadline = "2024-${deadline}-13", - color = "0xFFC4E953" - ), - ScrapByDeadline.Scrap( - scrapId = 3, - title = "제목3", - deadline = "2024-${deadline}-13", - color = "0xFF9B64E2" - ), - ScrapByDeadline.Scrap( - scrapId = 4, - title = "제목4", - deadline = "2024-${deadline}-13", - color = "0xFFF260AC" + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-17", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-23", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-30", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) ) ) - ), - ScrapByDeadline( - deadline = "2024-${deadline}-17", - scraps = listOf( - ScrapByDeadline.Scrap( - scrapId = 1, - title = "제목1", - deadline = "2024-${deadline}-17", - color = "0xFFC4E953" - ), - ScrapByDeadline.Scrap( - scrapId = 2, - title = "제목2", - deadline = "2024-${deadline}-17", - color = "0xFF45D0CC" - ), + ) + } + 1 -> { + listOf( + ScrapResponseDto( + deadline = "${year}-${deadline}-01", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF9B64E2" + ), + ScrapResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FFED4E54" + ), + ScrapResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-12", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-27", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) ) - ), - ScrapByDeadline( - deadline = "2024-${deadline}-23", - scraps = listOf( - ScrapByDeadline.Scrap( - scrapId = 1, - title = "제목1", - deadline = "2024-${deadline}-23", - color = "0xFF5397F3" + ) + } + 2 -> { + listOf( + ScrapResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-18", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-20", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) ) ) - ), - ScrapByDeadline( - deadline = "2024-${deadline}-30", - scraps = listOf( - ScrapByDeadline.Scrap( - scrapId = 1, - title = "제목1", - deadline = "2024-${deadline}-30", - color = "0xFF45D0CC" + ) + } + 3 -> { + listOf( + ScrapResponseDto( + deadline = "${year}-${deadline}-05", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + )/*, + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + )*/ + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-11", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + ScrapResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-19", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + ScrapResponseDto( + deadline = "${year}-${deadline}-28", + scraps = listOf( + ScrapResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) ) ) ) - ) - ) + } + + else -> { + listOf() + } + } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt deleted file mode 100644 index daa9715f3..000000000 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponsesDto.kt +++ /dev/null @@ -1,335 +0,0 @@ -package com.terning.data.dto.response - -import com.terning.domain.entity.response.ScrapModel -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ScrapResponsesDto( - @SerialName("deadline") - val deadline: String, - @SerialName("scraps") - val scraps: List -) { - @Serializable - data class Scrap( - @SerialName("scrapId") - val scrapId: Long, - @SerialName("title") - val title: String, - @SerialName("color") - val color: String - ) -} - - -fun List.toScrapsByDeadlineMap(): Map> { - return this.flatMap { dto -> - dto.scraps.map { scrap -> - dto.deadline to scrap.toScrapModel(dto.deadline) - } - }.groupBy( - { it.first }, // 키: deadline - { it.second } // 값: Scrap 객체 - ) -} - -private fun ScrapResponsesDto.Scrap.toScrapModel(deadline: String) = ScrapModel( - scrapId = scrapId, - title = title, - color = color, - deadLine = deadline, - isScrapped = true -) - -fun getMockScrapList(year: Int, month: Int): List { - val deadline = month.toString().padStart(2, '0') - - return when (month % 4) { - 0 -> { - listOf( - ScrapResponsesDto( - deadline = "${year}-${deadline}-13", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-17", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-23", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-30", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - 1 -> { - listOf( - ScrapResponsesDto( - deadline = "${year}-${deadline}-01", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FFED4E54" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-12", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-27", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - 2 -> { - listOf( - ScrapResponsesDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-18", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-20", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - 3 -> { - listOf( - ScrapResponsesDto( - deadline = "${year}-${deadline}-05", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - )/*, - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - )*/ - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-11", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponsesDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-19", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponsesDto( - deadline = "${year}-${deadline}-28", - scraps = listOf( - ScrapResponsesDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - else -> { - listOf() - } - } -} \ No newline at end of file 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 ecc6f27a3..a4f299fc5 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -2,7 +2,6 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.ScrapDataSource import com.terning.data.dto.request.ScrapRequestDto -import com.terning.data.dto.response.toScrapsByDeadLineList import com.terning.data.dto.response.toScrapsByDeadlineMap import com.terning.domain.entity.response.ScrapModel import com.terning.domain.repository.ScrapRepository @@ -13,7 +12,7 @@ class ScrapRepositoryImpl @Inject constructor( ): ScrapRepository { override suspend fun getScrapMonth(year: Int, month: Int): Result>> = runCatching { - val response = scrapDataSource.getMonthScrapMap( + val response = scrapDataSource.getScrapMonth( request = ScrapRequestDto( year = year, month = month 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 4dc09c13f..d9201943c 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 @@ -32,12 +32,13 @@ class CalendarViewModel @Inject constructor( getScrapMonth(2024, 7) } - private var _selectedDate = MutableStateFlow( + private var _selectedDate:MutableStateFlow = MutableStateFlow( SelectedDateState( selectedDate = LocalDate.now(), isEnabled = false ) ) + val selectedDate get() = _selectedDate.asStateFlow() private val _scrapCalendarState = MutableStateFlow(ScrapCalendarState()) @@ -76,7 +77,7 @@ class CalendarViewModel @Inject constructor( }.fold( onSuccess = { _scrapCalendarState.update { currentState -> - currentState.copy ( + currentState.copy( loadState = UiState.Success(it) ) } @@ -88,7 +89,6 @@ class CalendarViewModel @Inject constructor( } - //To be erased in future val mockScrapList: List> get() { @@ -106,7 +106,13 @@ class CalendarViewModel @Inject constructor( list.add( i, listOf( - Scrap("Task1_1", CalBlue1, dDay = "1", period = "3", isScraped = true), + Scrap( + "Task1_1", + CalBlue1, + dDay = "1", + period = "3", + isScraped = true + ), ) ) } @@ -115,8 +121,20 @@ class CalendarViewModel @Inject constructor( list.add( i, listOf( - Scrap("Task2_1", CalPink, dDay = "2", period = "3", isScraped = true), - Scrap("Task2_2", CalGreen1, dDay = "2", period = "3", isScraped = true) + Scrap( + "Task2_1", + CalPink, + dDay = "2", + period = "3", + isScraped = true + ), + Scrap( + "Task2_2", + CalGreen1, + dDay = "2", + period = "3", + isScraped = true + ) ) ) } @@ -139,12 +157,48 @@ class CalendarViewModel @Inject constructor( list.add( i, listOf( - Scrap("Task3_1", CalPink, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_2", CalPurple, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_3", CalRed, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_4", CalBlue1, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_5", CalGreen2, dDay = "5", period = "3", isScraped = true), - Scrap("Task3_6", CalYellow, dDay = "5", period = "3", isScraped = true) + Scrap( + "Task3_1", + CalPink, + dDay = "5", + period = "3", + isScraped = true + ), + Scrap( + "Task3_2", + CalPurple, + dDay = "5", + period = "3", + isScraped = true + ), + Scrap( + "Task3_3", + CalRed, + dDay = "5", + period = "3", + isScraped = true + ), + Scrap( + "Task3_4", + CalBlue1, + dDay = "5", + period = "3", + isScraped = true + ), + Scrap( + "Task3_5", + CalGreen2, + dDay = "5", + period = "3", + isScraped = true + ), + Scrap( + "Task3_6", + CalYellow, + dDay = "5", + period = "3", + isScraped = true + ) ) ) } From 86827497f80294199dcd764748d0111388bcb87e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 07:52:39 +0900 Subject: [PATCH 10/37] =?UTF-8?q?[FEAT/#59]=20SideEffect=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/calendar/calendar/CalendarRoute.kt | 18 +++++++++++++++++- .../calendar/calendar/CalendarSideEffect.kt | 7 +++++++ .../calendar/calendar/CalendarViewModel.kt | 14 ++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/calendar/CalendarSideEffect.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 4485c2273..343af63a6 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 @@ -24,12 +24,16 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.flowWithLifecycle import com.terning.core.designsystem.component.topappbar.CalendarTopAppBar import com.terning.core.designsystem.theme.Grey200 +import com.terning.core.extension.toast import com.terning.feature.R import com.terning.feature.calendar.calendar.component.WeekDaysHeader import com.terning.feature.calendar.month.CalendarMonthScreen @@ -49,7 +53,19 @@ fun CalendarScreen( modifier: Modifier = Modifier, viewModel: CalendarViewModel = hiltViewModel() ) { - val selectedDate by viewModel.selectedDate.collectAsStateWithLifecycle() + val context = LocalContext.current + val lifecycleOwner = LocalLifecycleOwner.current + + val selectedDate by viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner) + LaunchedEffect(viewModel.calendarSideEffect, lifecycleOwner) { + viewModel.calendarSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) + .collect { sideEffect -> + when (sideEffect) { + is CalendarSideEffect.ShowToast -> context.toast(sideEffect.message) + } + } + } + val state by remember { mutableStateOf(CalendarState()) } val listState = rememberLazyListState( diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarSideEffect.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarSideEffect.kt new file mode 100644 index 000000000..c9026f467 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarSideEffect.kt @@ -0,0 +1,7 @@ +package com.terning.feature.calendar.calendar + +import androidx.annotation.StringRes + +sealed class CalendarSideEffect { + class ShowToast(@StringRes val message: Int) : CalendarSideEffect() +} \ No newline at end of file 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 d9201943c..d2b33c9d0 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 @@ -11,11 +11,14 @@ import com.terning.core.designsystem.theme.CalRed import com.terning.core.designsystem.theme.CalYellow import com.terning.core.state.UiState import com.terning.domain.repository.ScrapRepository +import com.terning.feature.R import com.terning.feature.calendar.month.ScrapCalendarState import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch @@ -28,9 +31,8 @@ import javax.inject.Inject class CalendarViewModel @Inject constructor( private val scrapRepository: ScrapRepository ) : ViewModel() { - init { - getScrapMonth(2024, 7) - } + private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() + val calendarSideEffect = _calendarSideEffect.asSharedFlow() private var _selectedDate:MutableStateFlow = MutableStateFlow( SelectedDateState( @@ -44,6 +46,9 @@ class CalendarViewModel @Inject constructor( private val _scrapCalendarState = MutableStateFlow(ScrapCalendarState()) val scrapCalendarState = _scrapCalendarState.asStateFlow() + + + fun updateSelectedDate(date: LocalDate) = viewModelScope.launch { if (_selectedDate.value.selectedDate != date) { _selectedDate.update { currentState -> @@ -81,9 +86,10 @@ class CalendarViewModel @Inject constructor( loadState = UiState.Success(it) ) } + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_success)) }, onFailure = { - Timber.tag("CalendarScreen").d(" ${it.message.toString()}") + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) } ) } From f8173572439023ba283c822d342ed04a7af63fcb Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 16:58:10 +0900 Subject: [PATCH 11/37] =?UTF-8?q?[REFACTOR/#59]=20UI=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EB=A6=AC=ED=8C=A9=20=EB=B0=8F=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarRoute.kt | 122 +++++++++--------- ...electedDateState.kt => CalendarUiState.kt} | 5 +- .../calendar/calendar/CalendarViewModel.kt | 27 ++-- .../calendar/component/ScreenTransition.kt | 37 ++++++ .../calendar/{ => model}/CalendarDefault.kt | 2 +- .../calendar/{ => model}/CalendarState.kt | 2 +- .../calendar/navigation/CalendarNavigation.kt | 8 +- .../feature/calendar/month/CalendarMonth.kt | 15 +-- .../calendar/month/CalendarMonthScreen.kt | 25 ++-- .../{day => month/component}/CalendarDay.kt | 4 +- .../calendar/{day => month}/model/DayClass.kt | 2 +- .../feature/calendar/month/model/MonthData.kt | 1 - .../calendar/month/model/MonthModel.kt | 1 - ...darScrapStrip.kt => CalendarMonthScrap.kt} | 1 - .../calendar/scrap/CalendarScrapList.kt | 64 ++++++++- .../calendar/scrap/CalendarScrapListScreen.kt | 73 ----------- .../scrap/{ => component}/CalendarScrap.kt | 2 +- .../feature/calendar/week/CalendarWeek.kt | 8 +- .../calendar/week/CalendarWeekWithScrap.kt | 4 +- .../com/terning/feature/main/MainNavigator.kt | 3 +- 20 files changed, 217 insertions(+), 189 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/calendar/{SelectedDateState.kt => CalendarUiState.kt} (50%) create mode 100644 feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt rename feature/src/main/java/com/terning/feature/calendar/calendar/{ => model}/CalendarDefault.kt (96%) rename feature/src/main/java/com/terning/feature/calendar/calendar/{ => model}/CalendarState.kt (96%) rename feature/src/main/java/com/terning/feature/calendar/{day => month/component}/CalendarDay.kt (96%) rename feature/src/main/java/com/terning/feature/calendar/{day => month}/model/DayClass.kt (76%) rename feature/src/main/java/com/terning/feature/calendar/scrap/{CalendarScrapStrip.kt => CalendarMonthScrap.kt} (97%) delete mode 100644 feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt rename feature/src/main/java/com/terning/feature/calendar/scrap/{ => component}/CalendarScrap.kt (93%) 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 343af63a6..d6b1135c5 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 @@ -11,6 +11,7 @@ import androidx.compose.animation.togetherWith import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Scaffold @@ -31,32 +32,42 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle +import androidx.navigation.NavController +import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.component.topappbar.CalendarTopAppBar import com.terning.core.designsystem.theme.Grey200 import com.terning.core.extension.toast import com.terning.feature.R +import com.terning.feature.calendar.calendar.component.ScreenTransition import com.terning.feature.calendar.calendar.component.WeekDaysHeader +import com.terning.feature.calendar.calendar.model.CalendarState import com.terning.feature.calendar.month.CalendarMonthScreen -import com.terning.feature.calendar.scrap.CalendarScrapListScreen +import com.terning.feature.calendar.scrap.CalendarScrapList import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch +import java.time.LocalDate import java.time.YearMonth @Composable -fun CalendarRoute() { - CalendarScreen() +fun CalendarRoute( + navController: NavController +) { + CalendarScreen( + navController = navController + ) } @Composable fun CalendarScreen( modifier: Modifier = Modifier, + navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() ) { val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current - val selectedDate by viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner) + val calendarUiState by viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner) LaunchedEffect(viewModel.calendarSideEffect, lifecycleOwner) { viewModel.calendarSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> @@ -75,8 +86,6 @@ fun CalendarScreen( var currentDate by remember { mutableStateOf(YearMonth.now()) } var currentPage by remember { mutableIntStateOf(listState.firstVisibleItemIndex) } - var isListExpanded by remember { mutableStateOf(false) } - LaunchedEffect(key1 = listState) { snapshotFlow { listState.firstVisibleItemIndex } .distinctUntilChanged() @@ -89,8 +98,12 @@ fun CalendarScreen( } BackHandler { - if (selectedDate.isEnabled) { - viewModel.updateSelectedDate(selectedDate.selectedDate) + if (calendarUiState.isWeekEnabled) { + viewModel.updateSelectedDate(calendarUiState.selectedDate) + } else if (calendarUiState.isListEnabled) { + viewModel.changeListVisibility() + } else { + navController.navigateUp() } } @@ -100,13 +113,14 @@ fun CalendarScreen( val coroutineScope = rememberCoroutineScope() CalendarTopAppBar( date = currentDate, - isListExpanded = isListExpanded, - isWeekExpanded = selectedDate.isEnabled, + isListExpanded = calendarUiState.isListEnabled, + isWeekExpanded = calendarUiState.isListEnabled, onListButtonClicked = { - isListExpanded = !isListExpanded - if(selectedDate.isEnabled){ + viewModel.changeListVisibility() + if (calendarUiState.isWeekEnabled) { viewModel.disableWeekCalendar() - } }, + } + }, onMonthNavigationButtonClicked = { direction -> coroutineScope.launch { listState.animateScrollToItem( @@ -117,30 +131,13 @@ fun CalendarScreen( ) } ) { paddingValues -> - AnimatedContent( - targetState = isListExpanded, - transitionSpec = { - if (!targetState) { - slideInHorizontally { fullWidth -> -fullWidth } togetherWith - slideOutHorizontally { fullWidth -> fullWidth } - } else { - slideInHorizontally { fullWidth -> fullWidth } togetherWith - slideOutHorizontally { fullWidth -> -fullWidth } - }.using( - sizeTransform = SizeTransform(clip = true) - ) - }, - label = stringResource(id = R.string.calendar_animation_label) - ) { isListExpanded -> - if (isListExpanded) { - CalendarScrapListScreen( - modifier = Modifier - .padding(top = paddingValues.calculateTopPadding()), - scrapList = viewModel.mockScrapList, - listState = listState, - pages = state.getPageCount(), - ) - } else { + ScreenTransition( + targetState = !calendarUiState.isListEnabled, + transitionOne = slideInHorizontally { fullWidth -> -fullWidth } togetherWith + slideOutHorizontally { fullWidth -> fullWidth }, + transitionTwo = slideInHorizontally { fullWidth -> fullWidth } togetherWith + slideOutHorizontally { fullWidth -> -fullWidth }, + contentOne = { Column( modifier = Modifier .fillMaxSize() @@ -153,47 +150,48 @@ fun CalendarScreen( color = Grey200 ) - AnimatedContent( - targetState = selectedDate.isEnabled, - transitionSpec = { - if (!targetState) { - slideInVertically { fullHeight -> -fullHeight } togetherWith - slideOutVertically { fullHeight -> fullHeight } - } else { - slideInVertically { fullHeight -> fullHeight } togetherWith - slideOutVertically { fullHeight -> -fullHeight } - }.using( - sizeTransform = SizeTransform(clip = true) - ) - }, - label = stringResource(id = R.string.calendar_animation_label) - ) { targetState -> - if (!targetState) { + ScreenTransition( + targetState = !calendarUiState.isWeekEnabled, + transitionOne = slideInVertically { fullHeight -> -fullHeight } togetherWith + slideOutVertically { fullHeight -> fullHeight }, + transitionTwo = slideInVertically { fullHeight -> fullHeight } togetherWith + slideOutVertically { fullHeight -> -fullHeight }, + contentOne = { CalendarMonthScreen( modifier = Modifier.fillMaxSize(), - selectedDate = selectedDate, + calendarUiState = calendarUiState, onDateSelected = { viewModel.updateSelectedDate(it) }, listState = listState, pages = state.getPageCount(), - viewModel = viewModel ) - } else { + }, + contentTwo = { CalendarWeekWithScrap( modifier = Modifier .fillMaxSize(), - selectedDate = selectedDate, + selectedDate = calendarUiState, scrapLists = viewModel.mockScrapList, - onDateSelected = {newDate-> - viewModel.updateSelectedDate(newDate) + onDateSelected = { + viewModel.updateSelectedDate(it) } ) } - } + ) } - } - } + }, + contentTwo = { + CalendarScrapList( + scrapList = viewModel.mockScrapList, + listState = listState, + pages = state.getPageCount(), + modifier = Modifier + .fillMaxSize() + .padding(top = paddingValues.calculateTopPadding()) + ) + }, + ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarUiState.kt similarity index 50% rename from feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/CalendarUiState.kt index d39fa154b..93432ef49 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/SelectedDateState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarUiState.kt @@ -2,7 +2,8 @@ package com.terning.feature.calendar.calendar import java.time.LocalDate -data class SelectedDateState( +data class CalendarUiState( val selectedDate: LocalDate, - val isEnabled: Boolean + val isListEnabled: Boolean = false, + val isWeekEnabled: Boolean = false ) 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 d2b33c9d0..2f6d7ad04 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 @@ -23,7 +23,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 @@ -31,13 +30,11 @@ import javax.inject.Inject class CalendarViewModel @Inject constructor( private val scrapRepository: ScrapRepository ) : ViewModel() { - private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() - val calendarSideEffect = _calendarSideEffect.asSharedFlow() - private var _selectedDate:MutableStateFlow = MutableStateFlow( - SelectedDateState( + private var _selectedDate:MutableStateFlow = MutableStateFlow( + CalendarUiState( selectedDate = LocalDate.now(), - isEnabled = false + isListEnabled = false ) ) @@ -46,30 +43,38 @@ class CalendarViewModel @Inject constructor( private val _scrapCalendarState = MutableStateFlow(ScrapCalendarState()) val scrapCalendarState = _scrapCalendarState.asStateFlow() - - + private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() + val calendarSideEffect = _calendarSideEffect.asSharedFlow() fun updateSelectedDate(date: LocalDate) = viewModelScope.launch { if (_selectedDate.value.selectedDate != date) { _selectedDate.update { currentState -> currentState.copy( selectedDate = date, - isEnabled = true + isWeekEnabled = true ) } } else { _selectedDate.update { currentState -> currentState.copy( - isEnabled = !currentState.isEnabled + isWeekEnabled = !currentState.isWeekEnabled ) } } } + fun changeListVisibility() { + _selectedDate.update { currentState -> + currentState.copy( + isListEnabled = !currentState.isListEnabled + ) + } + } + fun disableWeekCalendar() { _selectedDate.update { currentState -> currentState.copy( - isEnabled = false + isWeekEnabled = false ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt new file mode 100644 index 000000000..52a54da73 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt @@ -0,0 +1,37 @@ +package com.terning.feature.calendar.calendar.component + +import androidx.compose.animation.AnimatedContent +import androidx.compose.animation.ContentTransform +import androidx.compose.animation.SizeTransform +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import com.terning.feature.R + +@Composable +fun ScreenTransition( + targetState: Boolean, + transitionOne: ContentTransform, + transitionTwo: ContentTransform, + contentOne: @Composable () -> Unit, + contentTwo: @Composable () -> Unit + ) { + AnimatedContent( + targetState = targetState, + transitionSpec = { + if (targetState) { + transitionOne + } else { + transitionTwo + }.using( + sizeTransform = SizeTransform(clip = true) + ) + }, + label = stringResource(id = R.string.calendar_animation_label) + ) { state -> + if(state) { + contentOne.invoke() + } else { + contentTwo.invoke() + } + } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarDefault.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarDefault.kt index 29b1393b5..1d2cf981a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarDefault.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarDefault.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.calendar.model import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.gestures.FlingBehavior diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarState.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt rename to feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarState.kt index 54775c159..90c00f759 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/CalendarState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/model/CalendarState.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.calendar +package com.terning.feature.calendar.calendar.model import androidx.compose.runtime.Stable import androidx.compose.runtime.getValue diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt index 0d3b099d1..83037a00c 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/navigation/CalendarNavigation.kt @@ -16,9 +16,13 @@ fun NavController.navigateCalendar(navOptions: NavOptions? = null) { ) } -fun NavGraphBuilder.calendarNavGraph() { +fun NavGraphBuilder.calendarNavGraph( + navHostController: NavController +) { composable { - CalendarRoute() + CalendarRoute( + navController = navHostController + ) } } diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index 0b3cbf9e7..dad61a86e 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -14,10 +14,9 @@ import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.extension.isToday import com.terning.domain.entity.response.ScrapModel -import com.terning.feature.calendar.day.CalendarDay +import com.terning.feature.calendar.calendar.CalendarUiState +import com.terning.feature.calendar.month.component.CalendarDay import com.terning.feature.calendar.month.model.MonthData -import com.terning.feature.calendar.scrap.model.Scrap -import com.terning.feature.calendar.calendar.SelectedDateState import com.terning.feature.calendar.scrap.CalendarScrapStrip import java.time.LocalDate import java.time.YearMonth @@ -27,8 +26,7 @@ fun CalendarMonth( modifier: Modifier = Modifier, monthData: MonthData, onDateSelected: (LocalDate) -> Unit, - selectedDate: SelectedDateState, - scrapLists: List> = listOf(), + calendarUiState: CalendarUiState, scrapMap: Map> = mapOf() ) { Column( @@ -50,14 +48,12 @@ fun CalendarMonth( ) { CalendarDay( dayData = day, - isSelected = selectedDate.selectedDate == day.date && selectedDate.isEnabled, + isSelected = calendarUiState.selectedDate == day.date && calendarUiState.isWeekEnabled, isToday = day.date.isToday(), onDateSelected = onDateSelected ) if(!day.isOutDate) { val index = day.date.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")) - //val index = day.date.dayOfMonth - 1 - CalendarScrapStrip( scrapLists = scrapMap[index].orEmpty() ) @@ -81,9 +77,8 @@ fun CalendarMonthPreview() { TerningPointTheme { CalendarMonth( monthData = MonthData(YearMonth.now()), - selectedDate = SelectedDateState(LocalDate.now(), true), + calendarUiState = CalendarUiState(LocalDate.now(), true), onDateSelected = {}, - scrapLists = listOf() ) } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index a858b11f6..4e36aefca 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -9,14 +9,15 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier +import androidx.hilt.navigation.compose.hiltViewModel import com.terning.core.designsystem.theme.White import com.terning.core.state.UiState import com.terning.domain.entity.response.ScrapModel -import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior -import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage +import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior +import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.month.model.MonthData -import com.terning.feature.calendar.calendar.SelectedDateState +import com.terning.feature.calendar.calendar.CalendarUiState import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate import java.time.YearMonth @@ -25,10 +26,10 @@ import java.time.YearMonth fun CalendarMonthScreen( pages: Int, listState: LazyListState, - selectedDate: SelectedDateState, + calendarUiState: CalendarUiState, onDateSelected: (LocalDate) -> Unit, - viewModel: CalendarViewModel, modifier: Modifier = Modifier, + viewModel: CalendarViewModel = hiltViewModel() ) { val scrapState by viewModel.scrapCalendarState.collectAsState() @@ -47,10 +48,10 @@ fun CalendarMonthScreen( UiState.Empty -> {} is UiState.Failure -> {} is UiState.Success -> { - CalendarMonthList( + HorizontalCalendar( pages = pages, modifier = modifier, - selectedDate = selectedDate, + calendarUiState = calendarUiState, onDateSelected = onDateSelected, listState = listState, scrapMap = (scrapState.loadState as UiState.Success).data @@ -61,13 +62,13 @@ fun CalendarMonthScreen( @Composable -fun CalendarMonthList( +fun HorizontalCalendar( pages: Int, listState: LazyListState, - modifier: Modifier = Modifier, - selectedDate: SelectedDateState, + calendarUiState: CalendarUiState, + scrapMap: Map>, onDateSelected: (LocalDate) -> Unit, - scrapMap: Map> + modifier: Modifier = Modifier, ) { LazyRow( modifier = modifier @@ -84,7 +85,7 @@ fun CalendarMonthList( CalendarMonth( modifier = Modifier.fillParentMaxSize(), - selectedDate = selectedDate, + calendarUiState = calendarUiState, onDateSelected = onDateSelected, monthData = monthData, scrapMap = scrapMap diff --git a/feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt b/feature/src/main/java/com/terning/feature/calendar/month/component/CalendarDay.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt rename to feature/src/main/java/com/terning/feature/calendar/month/component/CalendarDay.kt index 34fcf7bc2..bb7788ea6 100644 --- a/feature/src/main/java/com/terning/feature/calendar/day/CalendarDay.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/component/CalendarDay.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.day +package com.terning.feature.calendar.month.component import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -22,7 +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.feature.calendar.day.model.DayClass +import com.terning.feature.calendar.month.model.DayClass import java.time.LocalDate @Composable diff --git a/feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/DayClass.kt similarity index 76% rename from feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt rename to feature/src/main/java/com/terning/feature/calendar/month/model/DayClass.kt index ac74e48d3..814175be4 100644 --- a/feature/src/main/java/com/terning/feature/calendar/day/model/DayClass.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/DayClass.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.day.model +package com.terning.feature.calendar.month.model import androidx.compose.runtime.Immutable import java.time.LocalDate diff --git a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt index a13ef0f82..f24bdd2f0 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt @@ -1,7 +1,6 @@ package com.terning.feature.calendar.month.model import androidx.compose.runtime.Immutable -import com.terning.feature.calendar.day.model.DayClass import java.time.YearMonth /** diff --git a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt index f1d665437..389df4894 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthModel.kt @@ -1,7 +1,6 @@ package com.terning.feature.calendar.month.model import androidx.compose.runtime.Immutable -import com.terning.feature.calendar.day.model.DayClass import java.time.YearMonth @Immutable diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt rename to feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt index 4b4b411e2..c07a9ea52 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapStrip.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.domain.entity.response.ScrapModel -import com.terning.feature.calendar.scrap.model.Scrap @Composable fun CalendarScrapStrip( diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt index 51c80e4a0..099df3971 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt @@ -1,22 +1,84 @@ package com.terning.feature.calendar.scrap +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyListState +import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Black +import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.TerningTheme +import com.terning.core.designsystem.theme.White import com.terning.core.extension.getDateStringInKorean +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.CalendarScrap import com.terning.feature.calendar.scrap.model.Scrap import java.time.LocalDate +@Composable +fun CalendarScrapList( + scrapList: List>, + pages: Int, + listState: LazyListState, + modifier: Modifier = Modifier +) { + LazyRow( + modifier = modifier + .background(White), + state = listState, + userScrollEnabled = true, + flingBehavior = flingBehavior( + state = listState + ) + ) { + items(pages) { page -> + val getDate = getDateByPage(page) + + LazyColumn( + modifier = Modifier + .fillParentMaxWidth() + .fillMaxHeight() + .background(Back) + ) { + items(scrapList.size) { day -> + runCatching { + LocalDate.of(getDate.year, getDate.monthValue, day + 1) + }.onSuccess { + CalendarScrapList( + selectedDate = it, + scrapLists = scrapList, + isFromList = true, + noScrapScreen = {}) + + + if (scrapList[day].isNotEmpty()) { + Spacer( + modifier = Modifier + .height(4.dp) + .fillMaxWidth() + .background(Grey200) + ) + } + } + } + } + } + } +} + @Composable fun CalendarScrapList( selectedDate: LocalDate, @@ -60,4 +122,4 @@ fun CalendarScrapList( } } } -} \ No newline at end of file +} diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt deleted file mode 100644 index 5cd3e310f..000000000 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.terning.feature.calendar.scrap - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.terning.core.designsystem.theme.Back -import com.terning.core.designsystem.theme.Grey200 -import com.terning.core.designsystem.theme.White -import com.terning.feature.calendar.calendar.CalendarDefaults.flingBehavior -import com.terning.feature.calendar.calendar.CalendarState.Companion.getDateByPage -import com.terning.feature.calendar.scrap.model.Scrap -import java.time.LocalDate - -@Composable -fun CalendarScrapListScreen( - scrapList: List>, - pages: Int, - listState: LazyListState, - modifier: Modifier = Modifier -) { - LazyRow( - modifier = modifier - .background(White), - state = listState, - userScrollEnabled = true, - flingBehavior = flingBehavior( - state = listState - ) - ) { - items(pages) { page -> - val getDate = getDateByPage(page) - - LazyColumn( - modifier = Modifier - .fillParentMaxWidth() - .fillMaxHeight() - .background(Back) - ) { - items(scrapList.size) { day -> - runCatching { - LocalDate.of(getDate.year, getDate.monthValue, day + 1) - }.onSuccess { - CalendarScrapList( - selectedDate = it, - scrapLists = scrapList, - isFromList = true, - noScrapScreen = {}) - - - if (scrapList[day].isNotEmpty()) { - Spacer( - modifier = Modifier - .height(4.dp) - .fillMaxWidth() - .background(Grey200) - ) - } - } - } - } - } - } - -} - diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt similarity index 93% rename from feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt rename to feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt index 857ae0fdc..2989c59f7 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrap.kt @@ -1,4 +1,4 @@ -package com.terning.feature.calendar.scrap +package com.terning.feature.calendar.scrap.component import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt index 5e347e86a..7ed5bf177 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt @@ -12,15 +12,15 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.terning.core.extension.getWeekIndexContainingSelectedDate import com.terning.core.extension.isToday -import com.terning.feature.calendar.calendar.SelectedDateState -import com.terning.feature.calendar.day.CalendarDay +import com.terning.feature.calendar.calendar.CalendarUiState +import com.terning.feature.calendar.month.component.CalendarDay import com.terning.feature.calendar.month.model.MonthData import java.time.LocalDate import java.time.YearMonth @Composable fun CalendarWeek( - selectedDate: SelectedDateState, + selectedDate: CalendarUiState, modifier: Modifier = Modifier, onDateSelected: (LocalDate) -> Unit = {} ) { @@ -45,7 +45,7 @@ fun CalendarWeek( items(items = monthData.calendarMonth.weekDays[page]) { day -> CalendarDay( dayData = day, - isSelected = selectedDate.selectedDate == day.date && selectedDate.isEnabled, + isSelected = selectedDate.selectedDate == day.date && selectedDate.isWeekEnabled, isToday = day.date.isToday(), onDateSelected = onDateSelected ) diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt index afa17e888..6745379f9 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt @@ -20,7 +20,7 @@ import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.feature.R -import com.terning.feature.calendar.calendar.SelectedDateState +import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.scrap.CalendarScrapList import java.time.LocalDate @@ -28,7 +28,7 @@ import java.time.LocalDate @Composable fun CalendarWeekWithScrap( modifier: Modifier = Modifier, - selectedDate: SelectedDateState, + selectedDate: CalendarUiState, scrapLists: List> = listOf(), onDateSelected: (LocalDate) -> Unit ) { diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 6efdd17c6..523daedfe 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -9,6 +9,7 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions +import com.terning.feature.calendar.calendar.navigation.Calendar import com.terning.feature.calendar.calendar.navigation.navigateCalendar import com.terning.feature.home.home.navigation.Home import com.terning.feature.home.home.navigation.navigateHome @@ -25,7 +26,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SignIn + val startDestination = Home val currentTab: MainTab? @Composable get() = MainTab.find { tab -> From 3129dff0e25153c2a9051249676a3f7e9a8d19ce Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 16:59:20 +0900 Subject: [PATCH 12/37] =?UTF-8?q?[FIX/#59]=20MainNavigator=20=EC=9E=AC?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/terning/feature/main/MainNavigator.kt | 6 +----- .../src/main/java/com/terning/feature/main/MainScreen.kt | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 523daedfe..736728c99 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -9,14 +9,10 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions -import com.terning.feature.calendar.calendar.navigation.Calendar import com.terning.feature.calendar.calendar.navigation.navigateCalendar -import com.terning.feature.home.home.navigation.Home import com.terning.feature.home.home.navigation.navigateHome -import com.terning.feature.intern.navigation.Intern import com.terning.feature.mypage.navigation.navigateMyPage import com.terning.feature.onboarding.signin.navigation.SignIn -import com.terning.feature.search.search.navigation.Search import com.terning.feature.search.search.navigation.navigateSearch class MainNavigator( @@ -26,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = Home + val startDestination = SignIn val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index a52f14783..22d92ea17 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -58,7 +58,7 @@ fun MainScreen( startDestination = navigator.startDestination ) { homeNavGraph() - calendarNavGraph() + calendarNavGraph(navHostController = navigator.navController) searchNavGraph(navHostController = navigator.navController) myPageNavGraph() signInNavGraph(navHostController = navigator.navController) From 9c9a462d371d1f54bb54aafa09e8fddfcc3aad6f Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 17:22:32 +0900 Subject: [PATCH 13/37] =?UTF-8?q?[FIX/#59]=20MainNavigator=202=EC=B0=A8=20?= =?UTF-8?q?=EC=9E=AC=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/terning/feature/main/MainNavigator.kt | 2 +- feature/src/main/java/com/terning/feature/main/MainScreen.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 2f4550eee..736728c99 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -22,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = Search + val startDestination = SignIn val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 77ea4e6b4..b5f8e5d1c 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -21,7 +21,6 @@ import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White import com.terning.core.util.NoRippleInteractionSource import com.terning.feature.calendar.calendar.navigation.calendarNavGraph -import com.terning.feature.calendar.navigation.calendarNavGraph import com.terning.feature.home.changefilter.navigation.changeFilterNavGraph import com.terning.feature.home.home.navigation.homeNavGraph import com.terning.feature.intern.navigation.internNavGraph @@ -59,7 +58,7 @@ fun MainScreen( navController = navigator.navController, startDestination = navigator.startDestination ) { - homeNavGraph() + homeNavGraph(navHostController = navigator.navController) calendarNavGraph(navHostController = navigator.navController) searchNavGraph(navHostController = navigator.navController) myPageNavGraph() From 12641e9af044ee0c14785034462aaa300026ce29 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 16 Jul 2024 17:59:49 +0900 Subject: [PATCH 14/37] =?UTF-8?q?[MOD/#59]=20Dto=20=EB=A7=A4=ED=8D=BC=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 --- .../data/dto/response/ScrapResponseDto.kt | 31 +++++++------------ .../repositoryimpl/ScrapRepositoryImpl.kt | 12 ++++--- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt index 02412b76d..1a44012a9 100644 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt @@ -20,28 +20,18 @@ data class ScrapResponseDto( @SerialName("color") val color: String ) -} - -fun List.toScrapsByDeadlineMap(): Map> { - return this.flatMap { dto -> - dto.scraps.map { scrap -> - dto.deadline to scrap.toScrapModel(dto.deadline) - } - }.groupBy( - { it.first }, - { it.second } - ) + fun toScrapModelList(): List = scraps.map { scrap -> + ScrapModel( + scrapId = scrap.scrapId, + title = scrap.title, + color = scrap.color, + deadLine = deadline, + isScrapped = true + ) + } } -private fun ScrapResponseDto.Scrap.toScrapModel(deadline: String) = ScrapModel( - scrapId = scrapId, - title = title, - color = color, - deadLine = deadline, - isScrapped = true -) - fun getMockScrapList(year: Int, month: Int): List { val deadline = month.toString().padStart(2, '0') @@ -110,6 +100,7 @@ fun getMockScrapList(year: Int, month: Int): List { ) ) } + 1 -> { listOf( ScrapResponseDto( @@ -199,6 +190,7 @@ fun getMockScrapList(year: Int, month: Int): List { ) ) } + 2 -> { listOf( ScrapResponseDto( @@ -263,6 +255,7 @@ fun getMockScrapList(year: Int, month: Int): List { ) ) } + 3 -> { listOf( ScrapResponseDto( 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 a4f299fc5..686cdf29a 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt @@ -2,7 +2,6 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.ScrapDataSource import com.terning.data.dto.request.ScrapRequestDto -import com.terning.data.dto.response.toScrapsByDeadlineMap import com.terning.domain.entity.response.ScrapModel import com.terning.domain.repository.ScrapRepository import javax.inject.Inject @@ -12,12 +11,17 @@ class ScrapRepositoryImpl @Inject constructor( ): ScrapRepository { override suspend fun getScrapMonth(year: Int, month: Int): Result>> = runCatching { - val response = scrapDataSource.getScrapMonth( + val result = scrapDataSource.getScrapMonth( request = ScrapRequestDto( year = year, month = month ) - ) - response.result.toScrapsByDeadlineMap() + ).result + + val scrapModelMapByDeadLine = result.flatMap{ dto -> + dto.toScrapModelList() + }.groupBy { it.deadLine } + + scrapModelMapByDeadLine } } \ No newline at end of file From 8988ae864d067bbc0f5817f78f40a3ee0f03e14f Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 00:37:41 +0900 Subject: [PATCH 15/37] =?UTF-8?q?[FEAT/#91]=20Dto=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/CalendarDayListRequestDto.kt | 5 + .../request/CalendarMonthListRequestDto.kt | 13 + ...questDto.kt => CalendarMonthRequestDto.kt} | 2 +- .../dto/response/CalendarListResponseDto.kt | 49 +++ .../dto/response/CalendarMonthResponseDto.kt | 33 ++ .../data/dto/response/ScrapResponseDto.kt | 328 ------------------ 6 files changed, 101 insertions(+), 329 deletions(-) create mode 100644 data/src/main/java/com/terning/data/dto/request/CalendarDayListRequestDto.kt create mode 100644 data/src/main/java/com/terning/data/dto/request/CalendarMonthListRequestDto.kt rename data/src/main/java/com/terning/data/dto/request/{ScrapRequestDto.kt => CalendarMonthRequestDto.kt} (86%) create mode 100644 data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt create mode 100644 data/src/main/java/com/terning/data/dto/response/CalendarMonthResponseDto.kt delete mode 100644 data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt diff --git a/data/src/main/java/com/terning/data/dto/request/CalendarDayListRequestDto.kt b/data/src/main/java/com/terning/data/dto/request/CalendarDayListRequestDto.kt new file mode 100644 index 000000000..857b75029 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/request/CalendarDayListRequestDto.kt @@ -0,0 +1,5 @@ +package com.terning.data.dto.request + +data class CalendarDayListRequestDto( + val date: String +) \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/request/CalendarMonthListRequestDto.kt b/data/src/main/java/com/terning/data/dto/request/CalendarMonthListRequestDto.kt new file mode 100644 index 000000000..6a951d73d --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/request/CalendarMonthListRequestDto.kt @@ -0,0 +1,13 @@ +package com.terning.data.dto.request + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class CalendarMonthListRequestDto( + @SerialName("deadline") + val year: Int, + @SerialName("scraps") + val month: Int +) + diff --git a/data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt b/data/src/main/java/com/terning/data/dto/request/CalendarMonthRequestDto.kt similarity index 86% rename from data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt rename to data/src/main/java/com/terning/data/dto/request/CalendarMonthRequestDto.kt index f93df1059..00eaf4696 100644 --- a/data/src/main/java/com/terning/data/dto/request/ScrapRequestDto.kt +++ b/data/src/main/java/com/terning/data/dto/request/CalendarMonthRequestDto.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ScrapRequestDto( +data class CalendarMonthRequestDto( @SerialName("year") val year: Int, @SerialName("month") diff --git a/data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt new file mode 100644 index 000000000..16e426a60 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt @@ -0,0 +1,49 @@ +package com.terning.data.dto.response + +import com.terning.domain.entity.response.CalendarScrapDetailModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class CalendarListResponseDto( + @SerialName("deadline") + val deadline: String, + @SerialName("scraps") + val scraps: List +) { + @Serializable + data class Scrap( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("internshipAnnouncementId") + val internshipAnnouncementId: Long, + @SerialName("title") + val title: String, + @SerialName("dDay") + val dDay: String, + @SerialName("workingPeriod") + val workingPeriod: String, + @SerialName("color") + val color: String, + @SerialName("companyImage") + val companyImage: String, + @SerialName("startYear") + val startYear: Int, + @SerialName("startMonth") + val startMonth: Int + ) + + fun toScrapDetailModelList(): List = scraps.map { scrap -> + CalendarScrapDetailModel( + scrapId = scrap.scrapId, + internshipAnnouncementId = scrap.internshipAnnouncementId, + title = scrap.title, + dDay = scrap.dDay, + workingPeriod = scrap.workingPeriod, + color = scrap.color, + companyImage = scrap.companyImage, + startYear = scrap.startYear, + startMonth = scrap.startMonth + ) + } +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/CalendarMonthResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/CalendarMonthResponseDto.kt new file mode 100644 index 000000000..2af310d95 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/CalendarMonthResponseDto.kt @@ -0,0 +1,33 @@ +package com.terning.data.dto.response + +import com.terning.domain.entity.response.CalendarScrapModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class CalendarMonthResponseDto( + @SerialName("deadline") + val deadline: String, + @SerialName("scraps") + val scraps: List +) { + @Serializable + data class Scrap( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("title") + val title: String, + @SerialName("color") + val color: String + ) + + fun toScrapModelList(): List = scraps.map { scrap -> + CalendarScrapModel( + scrapId = scrap.scrapId, + title = scrap.title, + color = scrap.color, + deadLine = deadline, + isScrapped = true + ) + } +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt deleted file mode 100644 index 1a44012a9..000000000 --- a/data/src/main/java/com/terning/data/dto/response/ScrapResponseDto.kt +++ /dev/null @@ -1,328 +0,0 @@ -package com.terning.data.dto.response - -import com.terning.domain.entity.response.ScrapModel -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ScrapResponseDto( - @SerialName("deadline") - val deadline: String, - @SerialName("scraps") - val scraps: List -) { - @Serializable - data class Scrap( - @SerialName("scrapId") - val scrapId: Long, - @SerialName("title") - val title: String, - @SerialName("color") - val color: String - ) - - fun toScrapModelList(): List = scraps.map { scrap -> - ScrapModel( - scrapId = scrap.scrapId, - title = scrap.title, - color = scrap.color, - deadLine = deadline, - isScrapped = true - ) - } -} - -fun getMockScrapList(year: Int, month: Int): List { - val deadline = month.toString().padStart(2, '0') - - return when (month % 4) { - 0 -> { - listOf( - ScrapResponseDto( - deadline = "${year}-${deadline}-13", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-17", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-23", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-30", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 1 -> { - listOf( - ScrapResponseDto( - deadline = "${year}-${deadline}-01", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF9B64E2" - ), - ScrapResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FFED4E54" - ), - ScrapResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-12", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-27", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 2 -> { - listOf( - ScrapResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-18", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-20", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 3 -> { - listOf( - ScrapResponseDto( - deadline = "${year}-${deadline}-05", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - )/*, - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - )*/ - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-11", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - ScrapResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-19", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - ScrapResponseDto( - deadline = "${year}-${deadline}-28", - scraps = listOf( - ScrapResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - else -> { - listOf() - } - } -} \ No newline at end of file From 59ca4f5ef68cfcfcc340c16b1eee62f27e491f51 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 00:40:17 +0900 Subject: [PATCH 16/37] =?UTF-8?q?[RENAME/#91]=20=ED=86=B5=EC=8B=A0=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=84=A4=EC=9D=B4=EB=B0=8D=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 --- .../data/datasource/CalendarDataSource.kt | 12 + .../data/datasource/ScrapDataSource.kt | 9 - .../datasourceimpl/CalendarDataSourceImpl.kt | 31 + .../data/datasourceimpl/CalendarList.kt | 792 ++++++++++++++++++ .../datasourceimpl/ScrapDataSourceImpl.kt | 20 - .../repositoryimpl/CalendarRepositoryImpl.kt | 27 + .../repositoryimpl/ScrapRepositoryImpl.kt | 27 - .../terning/data/service/CalendarService.kt | 28 + .../response/CalendarScrapDetailModel.kt | 13 + .../{ScrapModel.kt => CalendarScrapModel.kt} | 2 +- .../domain/repository/CalendarRepository.kt | 7 + .../domain/repository/ScrapRepository.kt | 7 - .../calendar/calendar/CalendarViewModel.kt | 6 +- .../feature/calendar/month/CalendarMonth.kt | 4 +- .../calendar/month/CalendarMonthScreen.kt | 4 +- .../calendar/month/ScrapCalendarState.kt | 4 +- .../calendar/scrap/CalendarMonthScrap.kt | 4 +- 17 files changed, 922 insertions(+), 75 deletions(-) create mode 100644 data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt delete mode 100644 data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt create mode 100644 data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt create mode 100644 data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt delete mode 100644 data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt create mode 100644 data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt delete mode 100644 data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt create mode 100644 data/src/main/java/com/terning/data/service/CalendarService.kt create mode 100644 domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt rename domain/src/main/java/com/terning/domain/entity/response/{ScrapModel.kt => CalendarScrapModel.kt} (84%) create mode 100644 domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt delete mode 100644 domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt diff --git a/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt new file mode 100644 index 000000000..be62daa3a --- /dev/null +++ b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt @@ -0,0 +1,12 @@ +package com.terning.data.datasource + +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.CalendarMonthListRequestDto +import com.terning.data.dto.request.CalendarMonthRequestDto +import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarMonthResponseDto + +interface CalendarDataSource { + suspend fun getScrapMonth(request: CalendarMonthRequestDto): BaseResponse> + suspend fun getScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt b/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt deleted file mode 100644 index 97e893cda..000000000 --- a/data/src/main/java/com/terning/data/datasource/ScrapDataSource.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.terning.data.datasource - -import com.terning.data.dto.BaseResponse -import com.terning.data.dto.request.ScrapRequestDto -import com.terning.data.dto.response.ScrapResponseDto - -interface ScrapDataSource { - suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> -} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt new file mode 100644 index 000000000..4a219bd54 --- /dev/null +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt @@ -0,0 +1,31 @@ +package com.terning.data.datasourceimpl + +import com.terning.data.datasource.CalendarDataSource +import com.terning.data.datasourceimpl.CalendarList.getMockScrapList +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.CalendarMonthListRequestDto +import com.terning.data.dto.request.CalendarMonthRequestDto +import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarMonthResponseDto +import javax.inject.Inject + +class CalendarDataSourceImpl @Inject constructor( + +) : CalendarDataSource { + override suspend fun getScrapMonth(request: CalendarMonthRequestDto): BaseResponse> = + BaseResponse( + status = 200, + message = "캘린더 > (월간) 스크랩 된 공고 정보 (리스트) 불러오기를 성공했습니다", + result = getMockScrapList(request.year, request.month) + ) + + override suspend fun getScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> { + return BaseResponse( + status = 200, + message = "캘린더 > (월간) 스크랩 된 공고 정보 (리스트) 불러오기를 성공했습니다", + result = getMockScrapDetailList(request.year, request.month) + ) + } + + +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt new file mode 100644 index 000000000..be7d920b9 --- /dev/null +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -0,0 +1,792 @@ +package com.terning.data.datasourceimpl + +import com.terning.data.dto.request.CalendarMonthListRequestDto +import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarMonthResponseDto + +object CalendarList { + fun getMockScrapList(year: Int, month: Int): List { + val deadline = month.toString().padStart(2, '0') + return when (month % 4) { + 0 -> { + listOf( + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-13", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-17", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-23", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-30", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) + ) + } + + 1 -> { + listOf( + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-01", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF9B64E2" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FFED4E54" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-12", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-27", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) + ) + } + + 2 -> { + listOf( + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-18", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-20", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) + ) + } + + 3 -> { + listOf( + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-05", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953" + )/*, + ScrapResponsesDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2" + ), + ScrapResponsesDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC" + )*/ + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-11", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFC4E953" + ), + CalendarMonthResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FF45D0CC" + ), + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-19", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF5397F3" + ) + ) + ), + CalendarMonthResponseDto( + deadline = "${year}-${deadline}-28", + scraps = listOf( + CalendarMonthResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FF45D0CC" + ) + ) + ) + ) + } + + else -> { + listOf() + } + } + } +} + + +/*************************MockDataType***************************/ + +fun getMockScrapDetailList(year: Int, month: Int): List { + val deadline = month.toString().padStart(2, '0') + return when (month % 4) { + 0 -> { + listOf( + CalendarListResponseDto( + deadline = "${year}-${deadline}-13", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 1, + title = "제목1", + color = "#FFED4E54", + internshipAnnouncementId = 1, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 2, + title = "제목2", + color = "#FFC4E953", + internshipAnnouncementId = 2, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 3, + title = "제목3", + color = "#FF9B64E2", + internshipAnnouncementId = 3, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 4, + title = "제목4", + color = "#FFF260AC", + internshipAnnouncementId = 3, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-17", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 5, + title = "제목5", + color = "#FFC4E953", + internshipAnnouncementId = 5, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 6, + title = "제목6", + color = "#FF45D0CC", + internshipAnnouncementId = 6, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-23", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 7, + title = "제목7", + color = "#FF5397F3", + internshipAnnouncementId = 7, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-30", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 8, + title = "제목8", + color = "#FF45D0CC", + internshipAnnouncementId = 8, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ) + ) + } + + 1 -> { + listOf( + CalendarListResponseDto( + deadline = "${year}-${deadline}-01", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 9, + title = "제목9", + color = "#FFED4E54", + internshipAnnouncementId = 9, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 10, + title = "제목10", + color = "#FFC4E953", + internshipAnnouncementId = 10, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 11, + title = "제목11", + color = "#FF9B64E2", + internshipAnnouncementId = 11, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 12, + title = "제목12", + color = "#FFF260AC", + internshipAnnouncementId = 12, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 13, + title = "제목13", + color = "#FFC4E953", + internshipAnnouncementId = 13, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 14, + title = "제목14", + color = "#FF9B64E2", + internshipAnnouncementId = 14, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 15, + title = "제목15", + color = "#FFED4E54", + internshipAnnouncementId = 15, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 16, + title = "제목16", + color = "#FFF260AC", + internshipAnnouncementId = 16, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-12", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 17, + title = "제목17", + color = "#FFC4E953", + internshipAnnouncementId = 17, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 18, + title = "제목18", + color = "#FF45D0CC", + internshipAnnouncementId = 18, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-27", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 19, + title = "제목19", + color = "#FF5397F3", + internshipAnnouncementId = 19, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 20, + title = "제목20", + color = "#FF45D0CC", + internshipAnnouncementId = 20, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ) + ) + } + + 2 -> { + listOf( + CalendarListResponseDto( + deadline = "${year}-${deadline}-02", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 21, + title = "제목1", + color = "#FFED4E54", + internshipAnnouncementId = 21, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 22, + title = "제목22", + color = "#FFC4E953", + internshipAnnouncementId = 22, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 23, + title = "제목23", + color = "#FF9B64E2", + internshipAnnouncementId = 23, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 24, + title = "제목24", + color = "#FFF260AC", + internshipAnnouncementId = 24, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-18", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 25, + title = "제목25", + color = "#FFC4E953", + internshipAnnouncementId =25, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 26, + title = "제목26", + color = "#FF45D0CC", + internshipAnnouncementId = 26, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-20", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 27, + title = "제목27", + color = "#FF5397F3", + internshipAnnouncementId = 27, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-29", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 28, + title = "제목28", + color = "#FF45D0CC", + internshipAnnouncementId = 28, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ) + ) + } + + 3 -> { + listOf( + CalendarListResponseDto( + deadline = "${year}-${deadline}-05", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 29, + title = "제목29", + color = "#FFED4E54", + internshipAnnouncementId = 29, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 30, + title = "제목30", + color = "#FFC4E953", + internshipAnnouncementId = 30, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-11", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 31, + title = "제목31", + color = "#FFC4E953", + internshipAnnouncementId = 31, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarListResponseDto.Scrap( + scrapId = 32, + title = "제목32", + color = "#FF45D0CC", + internshipAnnouncementId = 32, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-19", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 33, + title = "제목33", + color = "#FF5397F3", + internshipAnnouncementId = 33, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ), + CalendarListResponseDto( + deadline = "${year}-${deadline}-28", + scraps = listOf( + CalendarListResponseDto.Scrap( + scrapId = 34, + title = "제목34", + color = "#FF45D0CC", + internshipAnnouncementId = 34, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ) + ) + ) + ) + } + + else -> { + listOf() + } + } +} diff --git a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt deleted file mode 100644 index 5b4afdf5e..000000000 --- a/data/src/main/java/com/terning/data/datasourceimpl/ScrapDataSourceImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.terning.data.datasourceimpl - -import com.terning.data.datasource.ScrapDataSource -import com.terning.data.dto.BaseResponse -import com.terning.data.dto.request.ScrapRequestDto -import com.terning.data.dto.response.ScrapResponseDto -import com.terning.data.dto.response.getMockScrapList -import javax.inject.Inject - -class ScrapDataSourceImpl @Inject constructor( - -) : ScrapDataSource { - override suspend fun getScrapMonth(request: ScrapRequestDto): BaseResponse> = - BaseResponse( - status = 200, - message = "(월간) 스크랩된 공고 정보가 성공적으로 로드되었습니다.", - result = getMockScrapList(request.year, request.month) - ) - -} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt new file mode 100644 index 000000000..1264b2d7d --- /dev/null +++ b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt @@ -0,0 +1,27 @@ +package com.terning.data.repositoryimpl + +import com.terning.data.datasource.CalendarDataSource +import com.terning.data.dto.request.CalendarMonthRequestDto +import com.terning.domain.entity.response.CalendarScrapModel +import com.terning.domain.repository.CalendarRepository +import javax.inject.Inject + +class CalendarRepositoryImpl @Inject constructor( + private val calendarDataSource: CalendarDataSource +): CalendarRepository { + override suspend fun getScrapMonth(year: Int, month: Int): Result>> = + runCatching { + val result = calendarDataSource.getScrapMonth( + request = CalendarMonthRequestDto( + year = year, + month = month + ) + ).result + + val scrapModelMapByDeadLine = result.flatMap{ dto -> + dto.toScrapModelList() + }.groupBy { it.deadLine } + + scrapModelMapByDeadLine + } +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt deleted file mode 100644 index 686cdf29a..000000000 --- a/data/src/main/java/com/terning/data/repositoryimpl/ScrapRepositoryImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.terning.data.repositoryimpl - -import com.terning.data.datasource.ScrapDataSource -import com.terning.data.dto.request.ScrapRequestDto -import com.terning.domain.entity.response.ScrapModel -import com.terning.domain.repository.ScrapRepository -import javax.inject.Inject - -class ScrapRepositoryImpl @Inject constructor( - private val scrapDataSource: ScrapDataSource -): ScrapRepository { - override suspend fun getScrapMonth(year: Int, month: Int): Result>> = - runCatching { - val result = scrapDataSource.getScrapMonth( - request = ScrapRequestDto( - year = year, - month = month - ) - ).result - - val scrapModelMapByDeadLine = result.flatMap{ dto -> - dto.toScrapModelList() - }.groupBy { it.deadLine } - - scrapModelMapByDeadLine - } -} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/CalendarService.kt b/data/src/main/java/com/terning/data/service/CalendarService.kt new file mode 100644 index 000000000..a28e7a443 --- /dev/null +++ b/data/src/main/java/com/terning/data/service/CalendarService.kt @@ -0,0 +1,28 @@ +package com.terning.data.service + +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarMonthResponseDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface CalendarService{ + @GET("/api/v1/calendar/monthly-default") + suspend fun getCalendarScrapMonth( + @Query("year") year: Int, + @Query("month") month: Int + ): BaseResponse> + + @GET("/api/v1/calendar/monthly-list") + suspend fun getCalendarScrapMonthList( + @Query("year") year: Int, + @Query("month") month: Int + ): BaseResponse> + + @GET("/api/v1/calendar/daily") + suspend fun getCalendarScrapDayList( + @Query("year") year: Int, + @Query("month") month: Int, + @Query("day") day: Int + ): BaseResponse> +} \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt new file mode 100644 index 000000000..ed48cf0e7 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt @@ -0,0 +1,13 @@ +package com.terning.domain.entity.response + +data class CalendarScrapDetailModel( + val scrapId: Long, + val internshipAnnouncementId: Long, + val title: String, + val dDay: String, + val workingPeriod: String, + val color: String, + val companyImage: String, + val startYear: Int, + val startMonth: Int +) diff --git a/domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapModel.kt similarity index 84% rename from domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt rename to domain/src/main/java/com/terning/domain/entity/response/CalendarScrapModel.kt index 8b68bbe35..162b4544d 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/ScrapModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapModel.kt @@ -1,6 +1,6 @@ package com.terning.domain.entity.response -data class ScrapModel( +data class CalendarScrapModel( val scrapId: Long, val title: String, val deadLine: String, diff --git a/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt new file mode 100644 index 000000000..f69338cb5 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt @@ -0,0 +1,7 @@ +package com.terning.domain.repository + +import com.terning.domain.entity.response.CalendarScrapModel + +interface CalendarRepository{ + suspend fun getScrapMonth(year: Int, month: Int): Result>> +} \ 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 deleted file mode 100644 index bc13c9639..000000000 --- a/domain/src/main/java/com/terning/domain/repository/ScrapRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.terning.domain.repository - -import com.terning.domain.entity.response.ScrapModel - -interface ScrapRepository{ - suspend fun getScrapMonth(year: Int, month: Int): Result>> -} \ No newline at end of file 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 2f6d7ad04..854707f6a 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 @@ -10,7 +10,7 @@ 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.repository.ScrapRepository +import com.terning.domain.repository.CalendarRepository import com.terning.feature.R import com.terning.feature.calendar.month.ScrapCalendarState import com.terning.feature.calendar.scrap.model.Scrap @@ -28,7 +28,7 @@ import javax.inject.Inject @HiltViewModel class CalendarViewModel @Inject constructor( - private val scrapRepository: ScrapRepository + private val calendarRepository: CalendarRepository ) : ViewModel() { private var _selectedDate:MutableStateFlow = MutableStateFlow( @@ -83,7 +83,7 @@ class CalendarViewModel @Inject constructor( year: Int, month: Int ) = viewModelScope.launch { withContext(Dispatchers.IO) { - scrapRepository.getScrapMonth(year, month) + calendarRepository.getScrapMonth(year, month) }.fold( onSuccess = { _scrapCalendarState.update { currentState -> diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index dad61a86e..59eaabcb4 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.extension.isToday -import com.terning.domain.entity.response.ScrapModel +import com.terning.domain.entity.response.CalendarScrapModel import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.month.component.CalendarDay import com.terning.feature.calendar.month.model.MonthData @@ -27,7 +27,7 @@ fun CalendarMonth( monthData: MonthData, onDateSelected: (LocalDate) -> Unit, calendarUiState: CalendarUiState, - scrapMap: Map> = mapOf() + scrapMap: Map> = mapOf() ) { Column( modifier = modifier diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index 4e36aefca..d6ff63ad9 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel import com.terning.core.designsystem.theme.White import com.terning.core.state.UiState -import com.terning.domain.entity.response.ScrapModel +import com.terning.domain.entity.response.CalendarScrapModel import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage import com.terning.feature.calendar.calendar.CalendarViewModel @@ -66,7 +66,7 @@ fun HorizontalCalendar( pages: Int, listState: LazyListState, calendarUiState: CalendarUiState, - scrapMap: Map>, + scrapMap: Map>, onDateSelected: (LocalDate) -> Unit, modifier: Modifier = Modifier, ) { diff --git a/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt b/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt index c332a75a9..49e1058a4 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt @@ -1,8 +1,8 @@ package com.terning.feature.calendar.month import com.terning.core.state.UiState -import com.terning.domain.entity.response.ScrapModel +import com.terning.domain.entity.response.CalendarScrapModel data class ScrapCalendarState ( - val loadState: UiState>> = UiState.Loading + val loadState: UiState>> = UiState.Loading ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt index c07a9ea52..900bf6d5a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt @@ -15,12 +15,12 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White -import com.terning.domain.entity.response.ScrapModel +import com.terning.domain.entity.response.CalendarScrapModel @Composable fun CalendarScrapStrip( modifier: Modifier = Modifier, - scrapLists: List + scrapLists: List ) { LazyColumn( modifier = modifier.fillMaxWidth() From 5302933e02d049876bc734b7b580bc47f0d79b92 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 00:41:35 +0900 Subject: [PATCH 17/37] =?UTF-8?q?[FEAT/#91]=20=EB=AA=A8=EB=93=88=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 --- .../main/java/com/terning/point/di/DataSourceModule.kt | 8 +++----- .../main/java/com/terning/point/di/RepositoryModule.kt | 6 +++--- app/src/main/java/com/terning/point/di/ServiceModule.kt | 6 ++++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/terning/point/di/DataSourceModule.kt b/app/src/main/java/com/terning/point/di/DataSourceModule.kt index 1c395b630..46a21ec83 100644 --- a/app/src/main/java/com/terning/point/di/DataSourceModule.kt +++ b/app/src/main/java/com/terning/point/di/DataSourceModule.kt @@ -1,11 +1,9 @@ package com.terning.point.di import com.terning.data.datasource.MockDataSource -import com.terning.data.datasource.ScrapDataSource +import com.terning.data.datasource.CalendarDataSource import com.terning.data.datasourceimpl.MockDataSourceImpl -import com.terning.data.datasourceimpl.ScrapDataSourceImpl -import com.terning.data.repositoryimpl.ScrapRepositoryImpl -import com.terning.domain.repository.ScrapRepository +import com.terning.data.datasourceimpl.CalendarDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -18,7 +16,7 @@ abstract class DataSourceModule { @Binds @Singleton - abstract fun bindScrapRepository(scrapDataSourceImpl: ScrapDataSourceImpl): ScrapDataSource + abstract fun bindCalendarRepository(calendarDataSourceImpl: CalendarDataSourceImpl): CalendarDataSource @Binds @Singleton diff --git a/app/src/main/java/com/terning/point/di/RepositoryModule.kt b/app/src/main/java/com/terning/point/di/RepositoryModule.kt index 9aa69d3a6..54c54b317 100644 --- a/app/src/main/java/com/terning/point/di/RepositoryModule.kt +++ b/app/src/main/java/com/terning/point/di/RepositoryModule.kt @@ -1,9 +1,9 @@ package com.terning.point.di import com.terning.data.repositoryimpl.MockRepositoryImpl -import com.terning.data.repositoryimpl.ScrapRepositoryImpl +import com.terning.data.repositoryimpl.CalendarRepositoryImpl import com.terning.domain.repository.MockRepository -import com.terning.domain.repository.ScrapRepository +import com.terning.domain.repository.CalendarRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -16,7 +16,7 @@ abstract class RepositoryModule { @Binds @Singleton - abstract fun scrapRepository(scrapRepositoryImpl: ScrapRepositoryImpl): ScrapRepository + abstract fun calendarRepository(calendarRepositoryImpl: CalendarRepositoryImpl): CalendarRepository @Binds @Singleton diff --git a/app/src/main/java/com/terning/point/di/ServiceModule.kt b/app/src/main/java/com/terning/point/di/ServiceModule.kt index 317c02f92..1c5c7297d 100644 --- a/app/src/main/java/com/terning/point/di/ServiceModule.kt +++ b/app/src/main/java/com/terning/point/di/ServiceModule.kt @@ -1,5 +1,6 @@ package com.terning.point.di +import com.terning.data.service.CalendarService import com.terning.data.service.MockService import com.terning.point.di.qualifier.OPEN import dagger.Module @@ -18,4 +19,9 @@ object ServiceModule { fun provideMockService(@OPEN retrofit: Retrofit): MockService = retrofit.create(MockService::class.java) + @Provides + @Singleton + fun provideCalendarService(@OPEN retrofit: Retrofit): CalendarService = + retrofit.create(CalendarService::class.java) + } \ No newline at end of file From 3565d93f674df452592b2103b5eecf84902f882b Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 00:58:01 +0900 Subject: [PATCH 18/37] =?UTF-8?q?[FEAT/#91]=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/CalendarDataSource.kt | 6 ++-- .../datasourceimpl/CalendarDataSourceImpl.kt | 25 ++++++---------- .../data/datasourceimpl/CalendarList.kt | 30 +++++++++++++++++++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt index be62daa3a..209f50efe 100644 --- a/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt @@ -1,12 +1,14 @@ package com.terning.data.datasource import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto import com.terning.data.dto.response.CalendarListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto interface CalendarDataSource { - suspend fun getScrapMonth(request: CalendarMonthRequestDto): BaseResponse> - suspend fun getScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> + suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> + suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> + suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt index 4a219bd54..6fe5bcfd4 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt @@ -1,31 +1,24 @@ package com.terning.data.datasourceimpl import com.terning.data.datasource.CalendarDataSource -import com.terning.data.datasourceimpl.CalendarList.getMockScrapList import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto import com.terning.data.dto.response.CalendarListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto +import com.terning.data.service.CalendarService import javax.inject.Inject class CalendarDataSourceImpl @Inject constructor( - + private val calendarService: CalendarService ) : CalendarDataSource { - override suspend fun getScrapMonth(request: CalendarMonthRequestDto): BaseResponse> = - BaseResponse( - status = 200, - message = "캘린더 > (월간) 스크랩 된 공고 정보 (리스트) 불러오기를 성공했습니다", - result = getMockScrapList(request.year, request.month) - ) - - override suspend fun getScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> { - return BaseResponse( - status = 200, - message = "캘린더 > (월간) 스크랩 된 공고 정보 (리스트) 불러오기를 성공했습니다", - result = getMockScrapDetailList(request.year, request.month) - ) - } + override suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> = + CalendarList.getCalendarScrapMonth(request) + override suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> = + CalendarList.getCalendarScrapMonthList(request) + override suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> = + CalendarList.getCalendarScrapDayList(request) } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt index be7d920b9..19aec20db 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -1,10 +1,36 @@ package com.terning.data.datasourceimpl +import com.terning.data.dto.BaseResponse +import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto +import com.terning.data.dto.request.CalendarMonthRequestDto import com.terning.data.dto.response.CalendarListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto object CalendarList { + fun getCalendarScrapMonth(request: CalendarMonthRequestDto): BaseResponse> = + BaseResponse( + status = 200, + message = "캘린더 > (월간) 스크랩 된 공고 정보 불러오기를 성공했습니다", + result = getMockScrapList(request.year, request.month) + ) + + fun getCalendarScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> = + BaseResponse( + status = 200, + message = "캘린더 > (월간) 스크랩 된 공고 정보 불러오기를 성공했습니다", + result = getMockScrapDetailList(request.year, request.month) + ) + + fun getCalendarScrapDayList(requestDto: CalendarDayListRequestDto): BaseResponse> = + BaseResponse( + status = 200, + message = "캘린더 > (일간) 스크랩 된 공고 정보 불러오기를 성공했습니다", + result = getMockDayList(requestDto.date) + ) + + + fun getMockScrapList(year: Int, month: Int): List { val deadline = month.toString().padStart(2, '0') return when (month % 4) { @@ -790,3 +816,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List } } } + +/******************DayList******************/ + +fun getMockDayList(request: String): List = listOf() From 2db05f0ba101060a72e515fdfb81fe35bb84e223 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 01:23:37 +0900 Subject: [PATCH 19/37] =?UTF-8?q?[FEAT/#91]=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/CalendarDataSource.kt | 7 +- .../datasourceimpl/CalendarDataSourceImpl.kt | 7 +- .../data/datasourceimpl/CalendarList.kt | 113 +++++++++--------- .../response/CalendarDayListResponseDto.kt | 42 +++++++ ...Dto.kt => CalendarMonthListResponseDto.kt} | 5 +- .../repositoryimpl/CalendarRepositoryImpl.kt | 60 ++++++++-- .../terning/data/service/CalendarService.kt | 6 +- .../response/CalendarScrapDetailModel.kt | 3 +- .../domain/repository/CalendarRepository.kt | 3 + 9 files changed, 169 insertions(+), 77 deletions(-) create mode 100644 data/src/main/java/com/terning/data/dto/response/CalendarDayListResponseDto.kt rename data/src/main/java/com/terning/data/dto/response/{CalendarListResponseDto.kt => CalendarMonthListResponseDto.kt} (92%) diff --git a/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt index 209f50efe..609019fa8 100644 --- a/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt @@ -4,11 +4,12 @@ import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto -import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarDayListResponseDto +import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto interface CalendarDataSource { suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> - suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> - suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> + suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> + suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt index 6fe5bcfd4..eddcecef0 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt @@ -5,7 +5,8 @@ import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto -import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarDayListResponseDto +import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto import com.terning.data.service.CalendarService import javax.inject.Inject @@ -16,9 +17,9 @@ class CalendarDataSourceImpl @Inject constructor( override suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> = CalendarList.getCalendarScrapMonth(request) - override suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> = + override suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> = CalendarList.getCalendarScrapMonthList(request) - override suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> = + override suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> = CalendarList.getCalendarScrapDayList(request) } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt index 19aec20db..a61cc128e 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -4,7 +4,8 @@ import com.terning.data.dto.BaseResponse import com.terning.data.dto.request.CalendarDayListRequestDto import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto -import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarDayListResponseDto +import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto object CalendarList { @@ -15,14 +16,14 @@ object CalendarList { result = getMockScrapList(request.year, request.month) ) - fun getCalendarScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> = + fun getCalendarScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> = BaseResponse( status = 200, message = "캘린더 > (월간) 스크랩 된 공고 정보 불러오기를 성공했습니다", result = getMockScrapDetailList(request.year, request.month) ) - fun getCalendarScrapDayList(requestDto: CalendarDayListRequestDto): BaseResponse> = + fun getCalendarScrapDayList(requestDto: CalendarDayListRequestDto): BaseResponse> = BaseResponse( status = 200, message = "캘린더 > (일간) 스크랩 된 공고 정보 불러오기를 성공했습니다", @@ -329,15 +330,15 @@ object CalendarList { /*************************MockDataType***************************/ -fun getMockScrapDetailList(year: Int, month: Int): List { +fun getMockScrapDetailList(year: Int, month: Int): List { val deadline = month.toString().padStart(2, '0') return when (month % 4) { 0 -> { listOf( - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-13", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 1, title = "제목1", color = "#FFED4E54", @@ -348,7 +349,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 2, title = "제목2", color = "#FFC4E953", @@ -359,7 +360,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 3, title = "제목3", color = "#FF9B64E2", @@ -370,7 +371,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 4, title = "제목4", color = "#FFF260AC", @@ -383,10 +384,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-17", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 5, title = "제목5", color = "#FFC4E953", @@ -397,7 +398,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 6, title = "제목6", color = "#FF45D0CC", @@ -410,10 +411,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ), ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-23", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 7, title = "제목7", color = "#FF5397F3", @@ -426,10 +427,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-30", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 8, title = "제목8", color = "#FF45D0CC", @@ -447,10 +448,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List 1 -> { listOf( - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-01", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 9, title = "제목9", color = "#FFED4E54", @@ -461,7 +462,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 10, title = "제목10", color = "#FFC4E953", @@ -472,7 +473,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 11, title = "제목11", color = "#FF9B64E2", @@ -483,7 +484,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 12, title = "제목12", color = "#FFF260AC", @@ -496,10 +497,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-02", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 13, title = "제목13", color = "#FFC4E953", @@ -510,7 +511,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 14, title = "제목14", color = "#FF9B64E2", @@ -521,7 +522,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 15, title = "제목15", color = "#FFED4E54", @@ -532,7 +533,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 16, title = "제목16", color = "#FFF260AC", @@ -545,10 +546,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-12", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 17, title = "제목17", color = "#FFC4E953", @@ -559,7 +560,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 18, title = "제목18", color = "#FF45D0CC", @@ -572,10 +573,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ), ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-27", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 19, title = "제목19", color = "#FF5397F3", @@ -588,10 +589,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-29", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 20, title = "제목20", color = "#FF45D0CC", @@ -609,10 +610,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List 2 -> { listOf( - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-02", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 21, title = "제목1", color = "#FFED4E54", @@ -623,7 +624,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 22, title = "제목22", color = "#FFC4E953", @@ -634,7 +635,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 23, title = "제목23", color = "#FF9B64E2", @@ -645,7 +646,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 24, title = "제목24", color = "#FFF260AC", @@ -658,10 +659,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-18", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 25, title = "제목25", color = "#FFC4E953", @@ -672,7 +673,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 26, title = "제목26", color = "#FF45D0CC", @@ -685,10 +686,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ), ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-20", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 27, title = "제목27", color = "#FF5397F3", @@ -701,10 +702,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-29", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 28, title = "제목28", color = "#FF45D0CC", @@ -722,10 +723,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List 3 -> { listOf( - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-05", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 29, title = "제목29", color = "#FFED4E54", @@ -736,7 +737,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 30, title = "제목30", color = "#FFC4E953", @@ -749,10 +750,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-11", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 31, title = "제목31", color = "#FFC4E953", @@ -763,7 +764,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List startYear = 2024, startMonth = 8 ), - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 32, title = "제목32", color = "#FF45D0CC", @@ -776,10 +777,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ), ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-19", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 33, title = "제목33", color = "#FF5397F3", @@ -792,10 +793,10 @@ fun getMockScrapDetailList(year: Int, month: Int): List ) ) ), - CalendarListResponseDto( + CalendarMonthListResponseDto( deadline = "${year}-${deadline}-28", scraps = listOf( - CalendarListResponseDto.Scrap( + CalendarMonthListResponseDto.Scrap( scrapId = 34, title = "제목34", color = "#FF45D0CC", @@ -819,4 +820,4 @@ fun getMockScrapDetailList(year: Int, month: Int): List /******************DayList******************/ -fun getMockDayList(request: String): List = listOf() +fun getMockDayList(request: String): List = listOf() diff --git a/data/src/main/java/com/terning/data/dto/response/CalendarDayListResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/CalendarDayListResponseDto.kt new file mode 100644 index 000000000..e2d23afb1 --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/CalendarDayListResponseDto.kt @@ -0,0 +1,42 @@ +package com.terning.data.dto.response + +import com.terning.domain.entity.response.CalendarScrapDetailModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class CalendarDayListResponseDto( + @SerialName("scrapId") + val scrapId: Long, + @SerialName("internshipAnnouncementId") + val internshipAnnouncementId: Long, + @SerialName("title") + val title: String, + @SerialName("dDay") + val dDay: String, + @SerialName("workingPeriod") + val workingPeriod: String, + @SerialName("color") + val color: String, + @SerialName("companyImage") + val companyImage: String, + @SerialName("startYear") + val startYear: Int, + @SerialName("startMonth") + val startMonth: Int +){ + fun toScrapDetailModelList(): CalendarScrapDetailModel = + CalendarScrapDetailModel( + scrapId = scrapId, + internshipAnnouncementId = internshipAnnouncementId, + title = title, + dDay = dDay, + workingPeriod = workingPeriod, + color = color, + companyImage = companyImage, + startYear = startYear, + startMonth = startMonth, + deadLine = "" + ) + +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/CalendarMonthListResponseDto.kt similarity index 92% rename from data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt rename to data/src/main/java/com/terning/data/dto/response/CalendarMonthListResponseDto.kt index 16e426a60..1aa7ac882 100644 --- a/data/src/main/java/com/terning/data/dto/response/CalendarListResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/CalendarMonthListResponseDto.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class CalendarListResponseDto( +data class CalendarMonthListResponseDto( @SerialName("deadline") val deadline: String, @SerialName("scraps") @@ -43,7 +43,8 @@ data class CalendarListResponseDto( color = scrap.color, companyImage = scrap.companyImage, startYear = scrap.startYear, - startMonth = scrap.startMonth + startMonth = scrap.startMonth, + deadLine = deadline ) } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt index 1264b2d7d..6968766e7 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt @@ -1,27 +1,69 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.CalendarDataSource +import com.terning.data.dto.request.CalendarDayListRequestDto +import com.terning.data.dto.request.CalendarMonthListRequestDto import com.terning.data.dto.request.CalendarMonthRequestDto +import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.domain.entity.response.CalendarScrapModel import com.terning.domain.repository.CalendarRepository import javax.inject.Inject class CalendarRepositoryImpl @Inject constructor( private val calendarDataSource: CalendarDataSource -): CalendarRepository { - override suspend fun getScrapMonth(year: Int, month: Int): Result>> = +) : CalendarRepository { + override suspend fun getScrapMonth( + year: Int, + month: Int + ): Result>> = runCatching { - val result = calendarDataSource.getScrapMonth( - request = CalendarMonthRequestDto( - year = year, - month = month - ) + val result = calendarDataSource.getCalendarMonth( + request = CalendarMonthRequestDto( + year = year, + month = month + ) ).result - val scrapModelMapByDeadLine = result.flatMap{ dto -> + val scrapModelMapByDeadLine = result.flatMap { dto -> dto.toScrapModelList() }.groupBy { it.deadLine } scrapModelMapByDeadLine } -} \ No newline at end of file + + override suspend fun getScrapMonthList( + year: Int, + month: Int + ): Result>> = + runCatching { + val result = calendarDataSource.getCalendarMonthList( + request = CalendarMonthListRequestDto( + year = year, + month = month + ) + ).result + + val scrapModelMapByDeadLine = result.flatMap { dto -> + dto.toScrapDetailModelList() + }.groupBy { it.deadLine } + + scrapModelMapByDeadLine + } + + override suspend fun getScrapDayList( + year: Int, + month: Int, + day: Int + ): Result> = + runCatching { + val monthString = month.toString().padStart(2, '0') + val request = CalendarDayListRequestDto("$year-$monthString-$day") + val response = calendarDataSource.getCalendarDayList(request) + val scrapModelList = response.result.map { scrap -> + scrap.toScrapDetailModelList() + } + scrapModelList + } + + +} diff --git a/data/src/main/java/com/terning/data/service/CalendarService.kt b/data/src/main/java/com/terning/data/service/CalendarService.kt index a28e7a443..57a21408e 100644 --- a/data/src/main/java/com/terning/data/service/CalendarService.kt +++ b/data/src/main/java/com/terning/data/service/CalendarService.kt @@ -1,7 +1,7 @@ package com.terning.data.service import com.terning.data.dto.BaseResponse -import com.terning.data.dto.response.CalendarListResponseDto +import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto import retrofit2.http.GET import retrofit2.http.Query @@ -17,12 +17,12 @@ interface CalendarService{ suspend fun getCalendarScrapMonthList( @Query("year") year: Int, @Query("month") month: Int - ): BaseResponse> + ): BaseResponse> @GET("/api/v1/calendar/daily") suspend fun getCalendarScrapDayList( @Query("year") year: Int, @Query("month") month: Int, @Query("day") day: Int - ): BaseResponse> + ): BaseResponse> } \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt index ed48cf0e7..23fe46357 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt @@ -9,5 +9,6 @@ data class CalendarScrapDetailModel( val color: String, val companyImage: String, val startYear: Int, - val startMonth: Int + val startMonth: Int, + val deadLine: String ) diff --git a/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt index f69338cb5..d6adeb490 100644 --- a/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt @@ -1,7 +1,10 @@ package com.terning.domain.repository +import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.domain.entity.response.CalendarScrapModel interface CalendarRepository{ suspend fun getScrapMonth(year: Int, month: Int): Result>> + suspend fun getScrapMonthList(year: Int, month: Int): Result>> + suspend fun getScrapDayList(year: Int, month: Int, day: Int): Result> } \ No newline at end of file From 79a3ed2323fddbe39306b9aae9e066a0c2bedd58 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 01:25:16 +0900 Subject: [PATCH 20/37] =?UTF-8?q?[RENAME/#91]=20State=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/calendar/calendar/CalendarViewModel.kt | 8 ++++---- .../{ScrapCalendarState.kt => CalendarMonthState.kt} | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/month/{ScrapCalendarState.kt => CalendarMonthState.kt} (87%) 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 854707f6a..5af16f9df 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 @@ -12,7 +12,7 @@ import com.terning.core.designsystem.theme.CalYellow import com.terning.core.state.UiState import com.terning.domain.repository.CalendarRepository import com.terning.feature.R -import com.terning.feature.calendar.month.ScrapCalendarState +import com.terning.feature.calendar.month.CalendarMonthState import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers @@ -40,8 +40,8 @@ class CalendarViewModel @Inject constructor( val selectedDate get() = _selectedDate.asStateFlow() - private val _scrapCalendarState = MutableStateFlow(ScrapCalendarState()) - val scrapCalendarState = _scrapCalendarState.asStateFlow() + private val _CalendarMonthState = MutableStateFlow(CalendarMonthState()) + val scrapCalendarState = _CalendarMonthState.asStateFlow() private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() @@ -86,7 +86,7 @@ class CalendarViewModel @Inject constructor( calendarRepository.getScrapMonth(year, month) }.fold( onSuccess = { - _scrapCalendarState.update { currentState -> + _CalendarMonthState.update { currentState -> currentState.copy( loadState = UiState.Success(it) ) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt similarity index 87% rename from feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt rename to feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt index 49e1058a4..acd6b1bde 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/ScrapCalendarState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt @@ -3,6 +3,6 @@ package com.terning.feature.calendar.month import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapModel -data class ScrapCalendarState ( +data class CalendarMonthState ( val loadState: UiState>> = UiState.Loading ) \ No newline at end of file From 88684e75fc6febf4cd20740485ead852c62ec1f3 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 01:34:03 +0900 Subject: [PATCH 21/37] =?UTF-8?q?[FEAT/#91]=20=EB=B7=B0=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 36 +++++++++++++++++-- .../calendar/month/CalendarMonthScreen.kt | 2 +- .../calendar/scrap/CalendarListState.kt | 8 +++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt 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 5af16f9df..7d89f652b 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 @@ -10,9 +10,11 @@ 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.response.CalendarScrapDetailModel import com.terning.domain.repository.CalendarRepository import com.terning.feature.R import com.terning.feature.calendar.month.CalendarMonthState +import com.terning.feature.calendar.scrap.CalendarListState import com.terning.feature.calendar.scrap.model.Scrap import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers @@ -40,8 +42,11 @@ class CalendarViewModel @Inject constructor( val selectedDate get() = _selectedDate.asStateFlow() - private val _CalendarMonthState = MutableStateFlow(CalendarMonthState()) - val scrapCalendarState = _CalendarMonthState.asStateFlow() + private val _calendarMonthState = MutableStateFlow(CalendarMonthState()) + val calendarMonthState = _calendarMonthState.asStateFlow() + + private val _calendarListState = MutableStateFlow(CalendarListState()) + val calendarListState = _calendarListState.asStateFlow() private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() @@ -86,7 +91,7 @@ class CalendarViewModel @Inject constructor( calendarRepository.getScrapMonth(year, month) }.fold( onSuccess = { - _CalendarMonthState.update { currentState -> + _calendarMonthState.update { currentState -> currentState.copy( loadState = UiState.Success(it) ) @@ -99,6 +104,31 @@ class CalendarViewModel @Inject constructor( ) } + fun getScrapMonthList( + year: Int, month: Int + ) = viewModelScope.launch { + withContext(Dispatchers.IO) { + calendarRepository.getScrapMonthList(year, month) + }.fold( + onSuccess = { + _calendarListState.update { currentState -> + currentState.copy( + loadState = UiState.Success(it) + ) + } + }, + onFailure = { + _calendarListState.update { currentState -> + currentState.copy( + loadState = UiState.Failure(it.message.toString()) + ) + + } + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) + } + ) + } + //To be erased in future val mockScrapList: List> diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index d6ff63ad9..b9a931ce1 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -31,7 +31,7 @@ fun CalendarMonthScreen( modifier: Modifier = Modifier, viewModel: CalendarViewModel = hiltViewModel() ) { - val scrapState by viewModel.scrapCalendarState.collectAsState() + val scrapState by viewModel.calendarMonthState.collectAsState() LaunchedEffect(key1 = listState) { snapshotFlow { listState.firstVisibleItemIndex } diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt new file mode 100644 index 000000000..958a020e8 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.calendar.scrap + +import com.terning.core.state.UiState +import com.terning.domain.entity.response.CalendarScrapDetailModel + +data class CalendarListState ( + val loadState: UiState>> = UiState.Loading +) \ No newline at end of file From 55be60d7cc1a5f048a9cc3a20b1376a3c5c0cec7 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 02:29:33 +0900 Subject: [PATCH 22/37] =?UTF-8?q?[FEAT/#91]=20=EC=9B=94=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/core/extension/Map.kt | 3 + .../response/CalendarScrapDetailModel.kt | 3 +- .../calendar/calendar/CalendarRoute.kt | 1 + .../calendar/month/CalendarMonthScreen.kt | 31 +++- .../calendar/scrap/CalendarScrapList.kt | 150 ++++++++++++++---- .../calendar/scrap/component/CalendarScrap.kt | 24 +++ 6 files changed, 170 insertions(+), 42 deletions(-) create mode 100644 core/src/main/java/com/terning/core/extension/Map.kt diff --git a/core/src/main/java/com/terning/core/extension/Map.kt b/core/src/main/java/com/terning/core/extension/Map.kt new file mode 100644 index 000000000..fab779e23 --- /dev/null +++ b/core/src/main/java/com/terning/core/extension/Map.kt @@ -0,0 +1,3 @@ +package com.terning.core.extension + +fun List?.isListNotEmpty():Boolean = this.orEmpty().isNotEmpty() diff --git a/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt index 23fe46357..881c4623b 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/CalendarScrapDetailModel.kt @@ -10,5 +10,6 @@ data class CalendarScrapDetailModel( val companyImage: String, val startYear: Int, val startMonth: Int, - val deadLine: String + val deadLine: String, + val isScrapped: Boolean = true ) 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 d6b1135c5..5730d7d85 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 @@ -186,6 +186,7 @@ fun CalendarScreen( scrapList = viewModel.mockScrapList, listState = listState, pages = state.getPageCount(), + viewModel = viewModel, modifier = Modifier .fillMaxSize() .padding(top = paddingValues.calculateTopPadding()) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index b9a931ce1..aa7511daf 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -48,14 +48,29 @@ fun CalendarMonthScreen( UiState.Empty -> {} is UiState.Failure -> {} is UiState.Success -> { - HorizontalCalendar( - pages = pages, - modifier = modifier, - calendarUiState = calendarUiState, - onDateSelected = onDateSelected, - listState = listState, - scrapMap = (scrapState.loadState as UiState.Success).data - ) + val scrapMap = (scrapState.loadState as UiState.Success).data + LazyRow( + modifier = modifier + .background(White), + state = listState, + userScrollEnabled = true, + flingBehavior = flingBehavior( + state = listState + ) + ) { + items(pages) { page -> + val date = getDateByPage(page) + val monthData = MonthData(YearMonth.of(date.year, date.month)) + + CalendarMonth( + modifier = Modifier.fillParentMaxSize(), + calendarUiState = calendarUiState, + onDateSelected = onDateSelected, + monthData = monthData, + scrapMap = scrapMap + ) + } + } } } } diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt index 099df3971..2b732d1df 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt @@ -14,63 +14,99 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.getDateStringInKorean +import com.terning.core.extension.isListNotEmpty +import com.terning.core.state.UiState +import com.terning.domain.entity.response.CalendarScrapDetailModel +import com.terning.feature.calendar.calendar.CalendarViewModel 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.CalendarScrap import com.terning.feature.calendar.scrap.model.Scrap +import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate +import java.time.format.DateTimeFormatter @Composable fun CalendarScrapList( scrapList: List>, pages: Int, listState: LazyListState, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + viewModel: CalendarViewModel = hiltViewModel() ) { - LazyRow( - modifier = modifier - .background(White), - state = listState, - userScrollEnabled = true, - flingBehavior = flingBehavior( - state = listState - ) - ) { - items(pages) { page -> - val getDate = getDateByPage(page) + val lifecycleOwner = LocalLifecycleOwner.current + val scrapState by viewModel.calendarListState.collectAsStateWithLifecycle(lifecycleOwner) + + LaunchedEffect(key1 = listState) { + snapshotFlow { listState.firstVisibleItemIndex } + .distinctUntilChanged() + .collect { + val page = listState.firstVisibleItemIndex + val date = getDateByPage(page) + viewModel.getScrapMonthList(date.year, date.monthValue) + } + } - LazyColumn( - modifier = Modifier - .fillParentMaxWidth() - .fillMaxHeight() - .background(Back) + when (scrapState.loadState) { + UiState.Loading -> {} + UiState.Empty -> {} + is UiState.Failure -> {} + is UiState.Success -> { + val scrapMap = (scrapState.loadState as UiState.Success).data + + LazyRow( + modifier = modifier + .background(White), + state = listState, + userScrollEnabled = true, + flingBehavior = flingBehavior( + state = listState + ) ) { - items(scrapList.size) { day -> - runCatching { - LocalDate.of(getDate.year, getDate.monthValue, day + 1) - }.onSuccess { - CalendarScrapList( - selectedDate = it, - scrapLists = scrapList, - isFromList = true, - noScrapScreen = {}) + items(pages) { page -> + val getDate = getDateByPage(page) + + LazyColumn( + modifier = Modifier + .fillParentMaxWidth() + .fillMaxHeight() + .background(Back) + ) { + items(scrapList.size) { day -> + runCatching { + LocalDate.of(getDate.year, getDate.monthValue, day + 1) + }.onSuccess { + CalendarScrapList( + selectedDate = it, + //scrapLists = scrapList, + scrapMap = scrapMap, + isFromList = true, + noScrapScreen = {}) - if (scrapList[day].isNotEmpty()) { - Spacer( - modifier = Modifier - .height(4.dp) - .fillMaxWidth() - .background(Grey200) - ) + if (scrapList[day].isNotEmpty()) { + Spacer( + modifier = Modifier + .height(4.dp) + .fillMaxWidth() + .background(Grey200) + ) + } + } } } } @@ -123,3 +159,51 @@ fun CalendarScrapList( } } } + +@Composable +fun CalendarScrapList( + selectedDate: LocalDate, + scrapMap: Map>, + isFromList: Boolean = false, + noScrapScreen: @Composable () -> Unit +) { + val scrollState = rememberScrollState() + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") + val scrapList = scrapMap[selectedDate.format(formatter)] + + if (scrapList.isListNotEmpty()) { + Text( + text = selectedDate.getDateStringInKorean(), + style = TerningTheme.typography.title5, + color = Black, + modifier = Modifier.padding(start = 24.dp, top = 16.dp, bottom = 15.dp) + ) + } + val topModifier = if (!isFromList) { + Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp) + .verticalScroll(scrollState) + } else { + Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp) + } + + if (!scrapList.isListNotEmpty()) { + noScrapScreen() + } else { + Column( + modifier = topModifier + ) { + for (scrap in scrapMap[selectedDate.format(formatter)].orEmpty()) { + CalendarScrap( + scrap = scrap + ) + Spacer( + modifier = Modifier.height(12.dp) + ) + } + } + } +} 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 2989c59f7..538c2737f 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 @@ -2,9 +2,12 @@ package com.terning.feature.calendar.scrap.component import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.colorResource import androidx.compose.ui.unit.dp import com.terning.core.designsystem.component.item.InternItem import com.terning.core.designsystem.component.item.ScrapBox +import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.feature.calendar.scrap.model.Scrap @Composable @@ -26,4 +29,25 @@ fun CalendarScrap( isScraped = scrap.isScraped ) } +} + +@Composable +fun CalendarScrap( + scrap: CalendarScrapDetailModel, + modifier: Modifier = Modifier, +) { + ScrapBox( + modifier = modifier, + cornerRadius = 10.dp, + scrapColor = Color(android.graphics.Color.parseColor(scrap.color)), + elevation = 1.dp, + ) { + InternItem( + imageUrl = scrap.companyImage.orEmpty(), + title = scrap.title, + dateDeadline = scrap.dDay, + workingPeriod = scrap.workingPeriod, + isScraped = scrap.isScrapped + ) + } } \ No newline at end of file From b64665bf2fcd39b7586296ef562f46424816bb62 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 03:20:15 +0900 Subject: [PATCH 23/37] =?UTF-8?q?[CHORE/#91]=20=EC=9B=94=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EC=98=A4?= =?UTF-8?q?=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 --- .../terning/core/extension/LocalDateExt.kt | 6 ++++ .../calendar/scrap/CalendarScrapList.kt | 34 ++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/terning/core/extension/LocalDateExt.kt b/core/src/main/java/com/terning/core/extension/LocalDateExt.kt index 702ea1182..1f8d4355f 100644 --- a/core/src/main/java/com/terning/core/extension/LocalDateExt.kt +++ b/core/src/main/java/com/terning/core/extension/LocalDateExt.kt @@ -1,6 +1,7 @@ package com.terning.core.extension import java.time.LocalDate +import java.time.format.DateTimeFormatter import java.time.format.TextStyle import java.util.Locale @@ -10,6 +11,11 @@ fun LocalDate.getStringAsTitle(): String = fun LocalDate.getDateStringInKorean(): String = "${monthValue}월 ${dayOfMonth}일 ${dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN)}" +fun LocalDate.getDateAsMapString(): String { + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") + return format(formatter) +} + fun LocalDate.getWeekIndexContainingSelectedDate(inDays: Int): Int = (inDays + dayOfMonth - 1) / 7 fun LocalDate.isToday(): Boolean = this == LocalDate.now() \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt index 2b732d1df..c25159f84 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt @@ -1,9 +1,11 @@ package com.terning.feature.calendar.scrap import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer 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 @@ -27,6 +29,7 @@ import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White +import com.terning.core.extension.getDateAsMapString import com.terning.core.extension.getDateStringInKorean import com.terning.core.extension.isListNotEmpty import com.terning.core.state.UiState @@ -37,6 +40,7 @@ import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDa import com.terning.feature.calendar.scrap.component.CalendarScrap import com.terning.feature.calendar.scrap.model.Scrap import kotlinx.coroutines.flow.distinctUntilChanged +import timber.log.Timber import java.time.LocalDate import java.time.format.DateTimeFormatter @@ -62,7 +66,9 @@ fun CalendarScrapList( } when (scrapState.loadState) { - UiState.Loading -> {} + UiState.Loading -> { + Box(modifier = Modifier.background(color = White).fillMaxSize()) + } UiState.Empty -> {} is UiState.Failure -> {} is UiState.Success -> { @@ -86,26 +92,18 @@ fun CalendarScrapList( .fillMaxHeight() .background(Back) ) { - items(scrapList.size) { day -> - runCatching { - LocalDate.of(getDate.year, getDate.monthValue, day + 1) - }.onSuccess { + items(getDate.lengthOfMonth()) { day -> + val currentDate = LocalDate.of(getDate.year, getDate.monthValue, day+1) + val dateIndex = currentDate.getDateAsMapString() + Timber.tag("CalendarScreen").d(dateIndex) + + if(scrapMap[dateIndex].isListNotEmpty()){ CalendarScrapList( - selectedDate = it, + selectedDate = currentDate, //scrapLists = scrapList, scrapMap = scrapMap, isFromList = true, noScrapScreen = {}) - - - if (scrapList[day].isNotEmpty()) { - Spacer( - modifier = Modifier - .height(4.dp) - .fillMaxWidth() - .background(Grey200) - ) - } } } } @@ -197,6 +195,10 @@ fun CalendarScrapList( modifier = topModifier ) { for (scrap in scrapMap[selectedDate.format(formatter)].orEmpty()) { + Timber.tag("CalendarScreen").d( + " ${scrap}, amount = ${scrapMap[selectedDate.format(formatter)].orEmpty().size}" + ) + CalendarScrap( scrap = scrap ) From 35e5ac28fa562d5897c6fddad1738e6c27ff4342 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 03:32:02 +0900 Subject: [PATCH 24/37] =?UTF-8?q?[CHORE/#91]=20=EC=9B=94=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarRoute.kt | 11 ++-------- ...crapList.kt => CalendarScrapListScreen.kt} | 22 +++++-------------- .../calendar/week/CalendarWeekWithScrap.kt | 4 ++-- 3 files changed, 9 insertions(+), 28 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/scrap/{CalendarScrapList.kt => CalendarScrapListScreen.kt} (88%) 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 5730d7d85..f430fb4f1 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 @@ -1,8 +1,6 @@ package com.terning.feature.calendar.calendar import androidx.activity.compose.BackHandler -import androidx.compose.animation.AnimatedContent -import androidx.compose.animation.SizeTransform import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutHorizontally @@ -11,7 +9,6 @@ import androidx.compose.animation.togetherWith import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Scaffold @@ -26,7 +23,6 @@ import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner @@ -37,16 +33,14 @@ import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.component.topappbar.CalendarTopAppBar import com.terning.core.designsystem.theme.Grey200 import com.terning.core.extension.toast -import com.terning.feature.R import com.terning.feature.calendar.calendar.component.ScreenTransition import com.terning.feature.calendar.calendar.component.WeekDaysHeader import com.terning.feature.calendar.calendar.model.CalendarState import com.terning.feature.calendar.month.CalendarMonthScreen -import com.terning.feature.calendar.scrap.CalendarScrapList +import com.terning.feature.calendar.scrap.CalendarScrapListScreen import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch -import java.time.LocalDate import java.time.YearMonth @Composable @@ -182,8 +176,7 @@ fun CalendarScreen( } }, contentTwo = { - CalendarScrapList( - scrapList = viewModel.mockScrapList, + CalendarScrapListScreen( listState = listState, pages = state.getPageCount(), viewModel = viewModel, diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt similarity index 88% rename from feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt rename to feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt index c25159f84..d531823a0 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapList.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt @@ -26,7 +26,6 @@ import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Black -import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.getDateAsMapString @@ -40,13 +39,10 @@ import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDa import com.terning.feature.calendar.scrap.component.CalendarScrap import com.terning.feature.calendar.scrap.model.Scrap import kotlinx.coroutines.flow.distinctUntilChanged -import timber.log.Timber import java.time.LocalDate -import java.time.format.DateTimeFormatter @Composable -fun CalendarScrapList( - scrapList: List>, +fun CalendarScrapListScreen( pages: Int, listState: LazyListState, modifier: Modifier = Modifier, @@ -95,13 +91,11 @@ fun CalendarScrapList( items(getDate.lengthOfMonth()) { day -> val currentDate = LocalDate.of(getDate.year, getDate.monthValue, day+1) val dateIndex = currentDate.getDateAsMapString() - Timber.tag("CalendarScreen").d(dateIndex) if(scrapMap[dateIndex].isListNotEmpty()){ CalendarScrapList( selectedDate = currentDate, - //scrapLists = scrapList, - scrapMap = scrapMap, + scrapList = scrapMap[dateIndex].orEmpty(), isFromList = true, noScrapScreen = {}) } @@ -114,7 +108,7 @@ fun CalendarScrapList( } @Composable -fun CalendarScrapList( +fun CalendarScrapListss( selectedDate: LocalDate, scrapLists: List>, isFromList: Boolean = false, @@ -161,13 +155,11 @@ fun CalendarScrapList( @Composable fun CalendarScrapList( selectedDate: LocalDate, - scrapMap: Map>, + scrapList: List, isFromList: Boolean = false, noScrapScreen: @Composable () -> Unit ) { val scrollState = rememberScrollState() - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") - val scrapList = scrapMap[selectedDate.format(formatter)] if (scrapList.isListNotEmpty()) { Text( @@ -194,11 +186,7 @@ fun CalendarScrapList( Column( modifier = topModifier ) { - for (scrap in scrapMap[selectedDate.format(formatter)].orEmpty()) { - Timber.tag("CalendarScreen").d( - " ${scrap}, amount = ${scrapMap[selectedDate.format(formatter)].orEmpty().size}" - ) - + for (scrap in scrapList) { CalendarScrap( scrap = scrap ) diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt index 6745379f9..d3e27d412 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt @@ -22,7 +22,7 @@ import com.terning.core.designsystem.theme.White import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.scrap.model.Scrap -import com.terning.feature.calendar.scrap.CalendarScrapList +import com.terning.feature.calendar.scrap.CalendarScrapListss import java.time.LocalDate @Composable @@ -58,7 +58,7 @@ fun CalendarWeekWithScrap( onDateSelected = onDateSelected ) } - CalendarScrapList( + CalendarScrapListss( selectedDate = selectedDate.selectedDate, scrapLists = scrapLists, noScrapScreen = { From 9cf9e7f97d56f5917ccd7715c6d9810a65e0cc05 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 03:42:12 +0900 Subject: [PATCH 25/37] =?UTF-8?q?[FEAT/#91]=20=EC=9D=BC=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositoryimpl/CalendarRepositoryImpl.kt | 12 ++++----- .../domain/repository/CalendarRepository.kt | 3 ++- .../calendar/calendar/CalendarViewModel.kt | 27 +++++++++++++++++++ .../calendar/week/CalendarWeekState.kt | 8 ++++++ .../calendar/week/CalendarWeekWithScrap.kt | 14 ++++++++++ 5 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt diff --git a/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt index 6968766e7..b9e0c308f 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt @@ -7,6 +7,8 @@ import com.terning.data.dto.request.CalendarMonthRequestDto import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.domain.entity.response.CalendarScrapModel import com.terning.domain.repository.CalendarRepository +import java.time.LocalDate +import java.time.format.DateTimeFormatter import javax.inject.Inject class CalendarRepositoryImpl @Inject constructor( @@ -51,19 +53,15 @@ class CalendarRepositoryImpl @Inject constructor( } override suspend fun getScrapDayList( - year: Int, - month: Int, - day: Int + currentDate: LocalDate ): Result> = runCatching { - val monthString = month.toString().padStart(2, '0') - val request = CalendarDayListRequestDto("$year-$monthString-$day") + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") + val request = CalendarDayListRequestDto(currentDate.format(formatter)) val response = calendarDataSource.getCalendarDayList(request) val scrapModelList = response.result.map { scrap -> scrap.toScrapDetailModelList() } scrapModelList } - - } diff --git a/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt index d6adeb490..2150e6864 100644 --- a/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/CalendarRepository.kt @@ -2,9 +2,10 @@ package com.terning.domain.repository import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.domain.entity.response.CalendarScrapModel +import java.time.LocalDate interface CalendarRepository{ suspend fun getScrapMonth(year: Int, month: Int): Result>> suspend fun getScrapMonthList(year: Int, month: Int): Result>> - suspend fun getScrapDayList(year: Int, month: Int, day: Int): Result> + suspend fun getScrapDayList(currentDate: LocalDate): Result> } \ No newline at end of file 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 7d89f652b..6ef0edf5d 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 @@ -16,6 +16,7 @@ import com.terning.feature.R import com.terning.feature.calendar.month.CalendarMonthState import com.terning.feature.calendar.scrap.CalendarListState import com.terning.feature.calendar.scrap.model.Scrap +import com.terning.feature.calendar.week.CalendarWeekState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow @@ -48,6 +49,9 @@ class CalendarViewModel @Inject constructor( private val _calendarListState = MutableStateFlow(CalendarListState()) val calendarListState = _calendarListState.asStateFlow() + private val _calendarWeekState = MutableStateFlow(CalendarWeekState()) + val calendarWeekState = _calendarWeekState.asStateFlow() + private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() @@ -129,6 +133,29 @@ class CalendarViewModel @Inject constructor( ) } + fun getScrapWeekList() = viewModelScope.launch { + withContext(Dispatchers.IO) { + calendarRepository.getScrapDayList(_selectedDate.value.selectedDate) + }.fold( + onSuccess = { + _calendarWeekState.update { currentState -> + currentState.copy( + loadState = UiState.Success(it) + ) + } + }, + onFailure = { + _calendarListState.update { currentState -> + currentState.copy( + loadState = UiState.Failure(it.message.toString()) + ) + + } + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) + } + ) + } + //To be erased in future val mockScrapList: List> diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt new file mode 100644 index 000000000..8c661ee2e --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.calendar.week + +import com.terning.core.state.UiState +import com.terning.domain.entity.response.CalendarScrapDetailModel + +data class CalendarWeekState ( + val loadState: UiState> = UiState.Loading +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt index d3e27d412..fe1ba8b27 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt @@ -14,6 +14,9 @@ import androidx.compose.ui.draw.shadow import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.Grey400 @@ -21,10 +24,21 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarUiState +import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.scrap.CalendarScrapListss import java.time.LocalDate +@Composable +fun CalendarWeekScreen( + modifier: Modifier = Modifier, + viewModel: CalendarViewModel = hiltViewModel() +) { + val lifecycleOwner = LocalLifecycleOwner.current + val uiState = viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner) + +} + @Composable fun CalendarWeekWithScrap( modifier: Modifier = Modifier, From c22a402f1355aca4275b01c5e2bf042998a15932 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 04:16:46 +0900 Subject: [PATCH 26/37] =?UTF-8?q?[CHORE/#91]=20=EC=9D=BC=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=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 --- .../data/datasourceimpl/CalendarList.kt | 26 +++- .../calendar/calendar/CalendarRoute.kt | 9 +- .../calendar/calendar/CalendarViewModel.kt | 131 ++---------------- ...WeekWithScrap.kt => CalendarWeekScreen.kt} | 58 +++++--- 4 files changed, 78 insertions(+), 146 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/week/{CalendarWeekWithScrap.kt => CalendarWeekScreen.kt} (62%) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt index a61cc128e..d7f66e76b 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -820,4 +820,28 @@ fun getMockScrapDetailList(year: Int, month: Int): List = listOf() +fun getMockDayList(request: String): List = listOf( + /*CalendarDayListResponseDto( + scrapId = 34, + title = "제목34", + color = "#FF45D0CC", + internshipAnnouncementId = 34, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ), + CalendarDayListResponseDto( + scrapId = 34, + title = "제목34", + color = "#FF45D0CC", + internshipAnnouncementId = 34, + dDay = "10", + workingPeriod = "10", + companyImage = "", + startYear = 2024, + startMonth = 8 + ),*/ + +) 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 f430fb4f1..a1ce3c968 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 @@ -38,6 +38,7 @@ import com.terning.feature.calendar.calendar.component.WeekDaysHeader import com.terning.feature.calendar.calendar.model.CalendarState import com.terning.feature.calendar.month.CalendarMonthScreen import com.terning.feature.calendar.scrap.CalendarScrapListScreen +import com.terning.feature.calendar.week.CalendarWeekScreen import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch @@ -162,14 +163,10 @@ fun CalendarScreen( ) }, contentTwo = { - CalendarWeekWithScrap( + CalendarWeekScreen( modifier = Modifier .fillMaxSize(), - selectedDate = calendarUiState, - scrapLists = viewModel.mockScrapList, - onDateSelected = { - viewModel.updateSelectedDate(it) - } + viewModel = viewModel ) } ) 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 6ef0edf5d..8388ca0f4 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 @@ -26,6 +26,7 @@ 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 @@ -34,7 +35,7 @@ class CalendarViewModel @Inject constructor( private val calendarRepository: CalendarRepository ) : ViewModel() { - private var _selectedDate:MutableStateFlow = MutableStateFlow( + private var _selectedDate: MutableStateFlow = MutableStateFlow( CalendarUiState( selectedDate = LocalDate.now(), isListEnabled = false @@ -52,7 +53,7 @@ class CalendarViewModel @Inject constructor( private val _calendarWeekState = MutableStateFlow(CalendarWeekState()) val calendarWeekState = _calendarWeekState.asStateFlow() - private val _calendarSideEffect:MutableSharedFlow = MutableSharedFlow() + private val _calendarSideEffect: MutableSharedFlow = MutableSharedFlow() val calendarSideEffect = _calendarSideEffect.asSharedFlow() fun updateSelectedDate(date: LocalDate) = viewModelScope.launch { @@ -63,6 +64,7 @@ class CalendarViewModel @Inject constructor( isWeekEnabled = true ) } + getScrapWeekList() } else { _selectedDate.update { currentState -> currentState.copy( @@ -100,7 +102,6 @@ class CalendarViewModel @Inject constructor( loadState = UiState.Success(it) ) } - _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_success)) }, onFailure = { _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_failure)) @@ -139,13 +140,16 @@ class CalendarViewModel @Inject constructor( }.fold( onSuccess = { _calendarWeekState.update { currentState -> + Timber.tag("CalendarScreen").d(" $it") currentState.copy( + /*loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty*/ loadState = UiState.Success(it) ) } + _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_success)) }, onFailure = { - _calendarListState.update { currentState -> + _calendarWeekState.update { currentState -> currentState.copy( loadState = UiState.Failure(it.message.toString()) ) @@ -155,123 +159,4 @@ class CalendarViewModel @Inject constructor( } ) } - - - //To be erased in future - val mockScrapList: List> - get() { - val list: MutableList> = mutableListOf() - for (i in 0..30) { - when (i % 6) { - 0 -> { - list.add( - i, - listOf() - ) - } - - 1 -> { - list.add( - i, - listOf( - Scrap( - "Task1_1", - CalBlue1, - dDay = "1", - period = "3", - isScraped = true - ), - ) - ) - } - - 2 -> { - list.add( - i, - listOf( - Scrap( - "Task2_1", - CalPink, - dDay = "2", - period = "3", - isScraped = true - ), - Scrap( - "Task2_2", - CalGreen1, - dDay = "2", - period = "3", - isScraped = true - ) - ) - ) - } - - 3 -> { - list.add( - i, - listOf() - ) - } - - 4 -> { - list.add( - i, - listOf() - ) - } - - 5 -> { - list.add( - i, - listOf( - Scrap( - "Task3_1", - CalPink, - dDay = "5", - period = "3", - isScraped = true - ), - Scrap( - "Task3_2", - CalPurple, - dDay = "5", - period = "3", - isScraped = true - ), - Scrap( - "Task3_3", - CalRed, - dDay = "5", - period = "3", - isScraped = true - ), - Scrap( - "Task3_4", - CalBlue1, - dDay = "5", - period = "3", - isScraped = true - ), - Scrap( - "Task3_5", - CalGreen2, - dDay = "5", - period = "3", - isScraped = true - ), - Scrap( - "Task3_6", - CalYellow, - dDay = "5", - period = "3", - isScraped = true - ) - ) - ) - } - } - } - return list.toList() - } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt similarity index 62% rename from feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt rename to feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index fe1ba8b27..babb3bf12 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekWithScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -9,6 +9,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.res.stringResource @@ -22,11 +24,15 @@ 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 +import com.terning.core.state.UiState +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.scrap.CalendarScrapList import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.scrap.CalendarScrapListss +import timber.log.Timber import java.time.LocalDate @Composable @@ -36,6 +42,29 @@ fun CalendarWeekScreen( ) { val lifecycleOwner = LocalLifecycleOwner.current val uiState = viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner) + val calendarWeekState by viewModel.calendarWeekState.collectAsStateWithLifecycle(lifecycleOwner) + + LaunchedEffect(uiState.value.selectedDate) { + viewModel.getScrapWeekList() + } + + when(calendarWeekState.loadState) { + is UiState.Loading -> {} + is UiState.Empty -> {} + is UiState.Failure -> {} + is UiState.Success -> { + val scrapList = (calendarWeekState.loadState as UiState.Success).data + + CalendarWeekWithScrap( + modifier = modifier, + selectedDate = uiState.value, + scrapList = scrapList, + onDateSelected = { + viewModel.updateSelectedDate(it) + } + ) + } + } } @@ -43,7 +72,7 @@ fun CalendarWeekScreen( fun CalendarWeekWithScrap( modifier: Modifier = Modifier, selectedDate: CalendarUiState, - scrapLists: List> = listOf(), + scrapList: List, onDateSelected: (LocalDate) -> Unit ) { Column( @@ -72,21 +101,18 @@ fun CalendarWeekWithScrap( onDateSelected = onDateSelected ) } - CalendarScrapListss( - selectedDate = selectedDate.selectedDate, - scrapLists = scrapLists, - noScrapScreen = { - Text( - modifier = Modifier - .padding(top = 42.dp) - .fillMaxWidth(), - text = stringResource(id = R.string.calendar_empty_scrap), - textAlign = TextAlign.Center, - style = TerningTheme.typography.body5, - color = Grey400 - ) - } - ) + CalendarScrapList(selectedDate = selectedDate.selectedDate, scrapList = scrapList) { + //Timber.tag("CalendarScreen").d(" ${selectedDate.selectedDate}") + Text( + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } } } From 02009461732025e5516ac475621f937eed838fd6 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 04:35:31 +0900 Subject: [PATCH 27/37] =?UTF-8?q?[FEAT/#91]=20=EC=9D=BC=EA=B0=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9=EB=A1=9D=20=EB=B9=88?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasourceimpl/CalendarList.kt | 7 +- .../calendar/calendar/CalendarRoute.kt | 1 - .../calendar/calendar/CalendarViewModel.kt | 3 +- .../calendar/scrap/CalendarScrapListScreen.kt | 49 ++----------- .../calendar/week/CalendarWeekScreen.kt | 68 ++++++++----------- 5 files changed, 39 insertions(+), 89 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt index d7f66e76b..74b1ff8e0 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -332,7 +332,7 @@ object CalendarList { fun getMockScrapDetailList(year: Int, month: Int): List { val deadline = month.toString().padStart(2, '0') - return when (month % 4) { + return when (month % 5) { 0 -> { listOf( CalendarMonthListResponseDto( @@ -821,7 +821,7 @@ fun getMockScrapDetailList(year: Int, month: Int): List = listOf( - /*CalendarDayListResponseDto( + CalendarDayListResponseDto( scrapId = 34, title = "제목34", color = "#FF45D0CC", @@ -842,6 +842,5 @@ fun getMockDayList(request: String): List = listOf( companyImage = "", startYear = 2024, startMonth = 8 - ),*/ - + ) ) 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 a1ce3c968..7dc8e9c8e 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 @@ -39,7 +39,6 @@ import com.terning.feature.calendar.calendar.model.CalendarState import com.terning.feature.calendar.month.CalendarMonthScreen import com.terning.feature.calendar.scrap.CalendarScrapListScreen import com.terning.feature.calendar.week.CalendarWeekScreen -import com.terning.feature.calendar.week.CalendarWeekWithScrap import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch import java.time.YearMonth 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 8388ca0f4..4abca00cd 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 @@ -118,7 +118,8 @@ class CalendarViewModel @Inject constructor( onSuccess = { _calendarListState.update { currentState -> currentState.copy( - loadState = UiState.Success(it) + loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty + //loadState = UiState.Success(it) ) } }, diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt index d531823a0..7783ea75a 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt @@ -20,12 +20,15 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.Back import com.terning.core.designsystem.theme.Black +import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.getDateAsMapString @@ -33,6 +36,7 @@ import com.terning.core.extension.getDateStringInKorean import com.terning.core.extension.isListNotEmpty import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapDetailModel +import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage @@ -107,51 +111,6 @@ fun CalendarScrapListScreen( } } -@Composable -fun CalendarScrapListss( - selectedDate: LocalDate, - scrapLists: List>, - isFromList: Boolean = false, - noScrapScreen: @Composable () -> Unit -) { - val scrollState = rememberScrollState() - if (scrapLists[selectedDate.dayOfMonth - 1].isNotEmpty()) { - Text( - text = selectedDate.getDateStringInKorean(), - style = TerningTheme.typography.title5, - color = Black, - modifier = Modifier.padding(start = 24.dp, top = 16.dp, bottom = 15.dp) - ) - } - val topModifier = if (!isFromList) { - Modifier - .fillMaxWidth() - .padding(horizontal = 24.dp) - .verticalScroll(scrollState) - } else { - Modifier - .fillMaxWidth() - .padding(horizontal = 24.dp) - } - - if (scrapLists[selectedDate.dayOfMonth - 1].isEmpty()) { - noScrapScreen() - } else { - Column( - modifier = topModifier - ) { - for (scrap in scrapLists[selectedDate.dayOfMonth - 1]) { - CalendarScrap( - scrap = scrap - ) - Spacer( - modifier = Modifier.height(12.dp) - ) - } - } - } -} - @Composable fun CalendarScrapList( selectedDate: LocalDate, 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 babb3bf12..5945c201a 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 @@ -30,9 +30,6 @@ import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.scrap.CalendarScrapList -import com.terning.feature.calendar.scrap.model.Scrap -import com.terning.feature.calendar.scrap.CalendarScrapListss -import timber.log.Timber import java.time.LocalDate @Composable @@ -41,40 +38,13 @@ fun CalendarWeekScreen( viewModel: CalendarViewModel = hiltViewModel() ) { val lifecycleOwner = LocalLifecycleOwner.current - val uiState = viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner) + val uiState by viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner) val calendarWeekState by viewModel.calendarWeekState.collectAsStateWithLifecycle(lifecycleOwner) - LaunchedEffect(uiState.value.selectedDate) { + LaunchedEffect(uiState.selectedDate) { viewModel.getScrapWeekList() } - when(calendarWeekState.loadState) { - is UiState.Loading -> {} - is UiState.Empty -> {} - is UiState.Failure -> {} - is UiState.Success -> { - val scrapList = (calendarWeekState.loadState as UiState.Success).data - - CalendarWeekWithScrap( - modifier = modifier, - selectedDate = uiState.value, - scrapList = scrapList, - onDateSelected = { - viewModel.updateSelectedDate(it) - } - ) - } - } - -} - -@Composable -fun CalendarWeekWithScrap( - modifier: Modifier = Modifier, - selectedDate: CalendarUiState, - scrapList: List, - onDateSelected: (LocalDate) -> Unit -) { Column( modifier = modifier .background(Back) @@ -97,13 +67,17 @@ fun CalendarWeekWithScrap( modifier = Modifier .fillMaxWidth() .background(White), - selectedDate = selectedDate, - onDateSelected = onDateSelected + selectedDate = uiState, + onDateSelected = { + viewModel.updateSelectedDate(it) + } ) } - CalendarScrapList(selectedDate = selectedDate.selectedDate, scrapList = scrapList) { - //Timber.tag("CalendarScreen").d(" ${selectedDate.selectedDate}") - Text( + + when (calendarWeekState.loadState) { + is UiState.Loading -> {} + is UiState.Empty -> { + Text( modifier = Modifier .padding(top = 42.dp) .fillMaxWidth(), @@ -111,10 +85,28 @@ fun CalendarWeekWithScrap( textAlign = TextAlign.Center, style = TerningTheme.typography.body5, color = Grey400 - ) + )} + is UiState.Failure -> {} + is UiState.Success -> { + val scrapList = (calendarWeekState.loadState as UiState.Success).data + + CalendarScrapList(selectedDate = uiState.selectedDate, scrapList = scrapList) { + //Timber.tag("CalendarScreen").d(" ${selectedDate.selectedDate}") + Text( + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } + } } } } + From e0db6a1f2e19f3ffeeb0310e0834f3189a7def4b Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 05:00:18 +0900 Subject: [PATCH 28/37] =?UTF-8?q?[REFACTOR/#91]=20=EC=BA=98=EB=A6=B0?= =?UTF-8?q?=EB=8D=94=20=EC=A0=84=EB=A9=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarRoute.kt | 6 +- .../calendar/calendar/CalendarViewModel.kt | 1 - .../feature/calendar/month/CalendarMonth.kt | 3 +- .../calendar/month/CalendarMonthScreen.kt | 29 ++------ ...rapListScreen.kt => CalendarListScreen.kt} | 68 +++++++++++-------- .../calendar/week/CalendarWeekScreen.kt | 19 +++--- 6 files changed, 62 insertions(+), 64 deletions(-) rename feature/src/main/java/com/terning/feature/calendar/scrap/{CalendarScrapListScreen.kt => CalendarListScreen.kt} (74%) 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 7dc8e9c8e..a64244d21 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 @@ -37,7 +37,7 @@ import com.terning.feature.calendar.calendar.component.ScreenTransition import com.terning.feature.calendar.calendar.component.WeekDaysHeader import com.terning.feature.calendar.calendar.model.CalendarState import com.terning.feature.calendar.month.CalendarMonthScreen -import com.terning.feature.calendar.scrap.CalendarScrapListScreen +import com.terning.feature.calendar.scrap.CalendarListScreen import com.terning.feature.calendar.week.CalendarWeekScreen import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch @@ -53,7 +53,7 @@ fun CalendarRoute( } @Composable -fun CalendarScreen( +private fun CalendarScreen( modifier: Modifier = Modifier, navController: NavController = rememberNavController(), viewModel: CalendarViewModel = hiltViewModel() @@ -172,7 +172,7 @@ fun CalendarScreen( } }, contentTwo = { - CalendarScrapListScreen( + CalendarListScreen( listState = listState, pages = state.getPageCount(), viewModel = viewModel, 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 4abca00cd..acda2aa4c 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 @@ -141,7 +141,6 @@ class CalendarViewModel @Inject constructor( }.fold( onSuccess = { _calendarWeekState.update { currentState -> - Timber.tag("CalendarScreen").d(" $it") currentState.copy( /*loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty*/ loadState = UiState.Success(it) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index 59eaabcb4..4fa0f6f50 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp 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.domain.entity.response.CalendarScrapModel import com.terning.feature.calendar.calendar.CalendarUiState @@ -53,7 +54,7 @@ fun CalendarMonth( onDateSelected = onDateSelected ) if(!day.isOutDate) { - val index = day.date.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")) + val index = day.date.getDateAsMapString() CalendarScrapStrip( scrapLists = scrapMap[index].orEmpty() ) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index aa7511daf..c1b62c67d 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -49,33 +49,18 @@ fun CalendarMonthScreen( is UiState.Failure -> {} is UiState.Success -> { val scrapMap = (scrapState.loadState as UiState.Success).data - LazyRow( + HorizontalCalendar( + pages = pages, + listState = listState, + calendarUiState = calendarUiState, + scrapMap = scrapMap, + onDateSelected = onDateSelected, modifier = modifier - .background(White), - state = listState, - userScrollEnabled = true, - flingBehavior = flingBehavior( - state = listState - ) - ) { - items(pages) { page -> - val date = getDateByPage(page) - val monthData = MonthData(YearMonth.of(date.year, date.month)) - - CalendarMonth( - modifier = Modifier.fillParentMaxSize(), - calendarUiState = calendarUiState, - onDateSelected = onDateSelected, - monthData = monthData, - scrapMap = scrapMap - ) - } - } + ) } } } - @Composable fun HorizontalCalendar( pages: Int, diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt similarity index 74% rename from feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt rename to feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt index 7783ea75a..49d99e93b 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarScrapListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListScreen.kt @@ -41,12 +41,11 @@ import com.terning.feature.calendar.calendar.CalendarViewModel 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.CalendarScrap -import com.terning.feature.calendar.scrap.model.Scrap import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate @Composable -fun CalendarScrapListScreen( +fun CalendarListScreen( pages: Int, listState: LazyListState, modifier: Modifier = Modifier, @@ -65,42 +64,55 @@ fun CalendarScrapListScreen( } } - when (scrapState.loadState) { - UiState.Loading -> { - Box(modifier = Modifier.background(color = White).fillMaxSize()) - } - UiState.Empty -> {} - is UiState.Failure -> {} - is UiState.Success -> { - val scrapMap = (scrapState.loadState as UiState.Success).data - LazyRow( - modifier = modifier - .background(White), - state = listState, - userScrollEnabled = true, - flingBehavior = flingBehavior( - state = listState - ) + LazyRow( + modifier = modifier + .background(White), + state = listState, + userScrollEnabled = true, + flingBehavior = flingBehavior( + state = listState + ) + ) { + items(pages) { page -> + val getDate = getDateByPage(page) + + LazyColumn( + modifier = Modifier + .fillParentMaxWidth() + .fillMaxHeight() + .background(Back) ) { - items(pages) { page -> - val getDate = getDateByPage(page) + when (scrapState.loadState) { + UiState.Loading -> {} + UiState.Empty -> { + item { + Text( + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } + } - LazyColumn( - modifier = Modifier - .fillParentMaxWidth() - .fillMaxHeight() - .background(Back) - ) { + is UiState.Failure -> {} + is UiState.Success -> { items(getDate.lengthOfMonth()) { day -> - val currentDate = LocalDate.of(getDate.year, getDate.monthValue, day+1) + val scrapMap = (scrapState.loadState as UiState.Success).data + val currentDate = + LocalDate.of(getDate.year, getDate.monthValue, day + 1) val dateIndex = currentDate.getDateAsMapString() - if(scrapMap[dateIndex].isListNotEmpty()){ + if (scrapMap[dateIndex].isListNotEmpty()) { CalendarScrapList( selectedDate = currentDate, scrapList = scrapMap[dateIndex].orEmpty(), isFromList = true, + noScrapScreen = {}) } } 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 5945c201a..56b882ff9 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 @@ -78,20 +78,21 @@ fun CalendarWeekScreen( is UiState.Loading -> {} is UiState.Empty -> { Text( - modifier = Modifier - .padding(top = 42.dp) - .fillMaxWidth(), - text = stringResource(id = R.string.calendar_empty_scrap), - textAlign = TextAlign.Center, - style = TerningTheme.typography.body5, - color = Grey400 - )} + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } + is UiState.Failure -> {} is UiState.Success -> { val scrapList = (calendarWeekState.loadState as UiState.Success).data CalendarScrapList(selectedDate = uiState.selectedDate, scrapList = scrapList) { - //Timber.tag("CalendarScreen").d(" ${selectedDate.selectedDate}") Text( modifier = Modifier .padding(top = 42.dp) From 5717f6ee752caf291f9f9d13a0ad2dba15a406a0 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 05:15:05 +0900 Subject: [PATCH 29/37] =?UTF-8?q?[CHORE/#91]=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/terning/point/di/RepositoryModule.kt | 6 ++---- app/src/main/java/com/terning/point/di/ServiceModule.kt | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/terning/point/di/RepositoryModule.kt b/app/src/main/java/com/terning/point/di/RepositoryModule.kt index c9771426c..bf31bd876 100644 --- a/app/src/main/java/com/terning/point/di/RepositoryModule.kt +++ b/app/src/main/java/com/terning/point/di/RepositoryModule.kt @@ -1,13 +1,11 @@ package com.terning.point.di -import com.terning.data.repositoryimpl.MockRepositoryImpl -import com.terning.data.repositoryimpl.CalendarRepositoryImpl -import com.terning.domain.repository.MockRepository -import com.terning.domain.repository.CalendarRepository import com.terning.data.repositoryimpl.AuthRepositoryImpl +import com.terning.data.repositoryimpl.CalendarRepositoryImpl import com.terning.data.repositoryimpl.SearchViewsRepositoryImpl import com.terning.data.repositoryimpl.TokenRepositoryImpl import com.terning.domain.repository.AuthRepository +import com.terning.domain.repository.CalendarRepository import com.terning.domain.repository.SearchRepository import com.terning.domain.repository.TokenRepository import dagger.Binds diff --git a/app/src/main/java/com/terning/point/di/ServiceModule.kt b/app/src/main/java/com/terning/point/di/ServiceModule.kt index ee344feef..fcb0ced95 100644 --- a/app/src/main/java/com/terning/point/di/ServiceModule.kt +++ b/app/src/main/java/com/terning/point/di/ServiceModule.kt @@ -1,10 +1,9 @@ package com.terning.point.di import com.terning.data.service.AuthService +import com.terning.data.service.CalendarService import com.terning.data.service.SearchService import com.terning.point.di.qualifier.JWT -import com.terning.data.service.CalendarService -import com.terning.point.di.qualifier.OPEN import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -28,7 +27,7 @@ object ServiceModule { @Provides @Singleton - fun provideCalendarService(@OPEN retrofit: Retrofit): CalendarService = + fun provideCalendarService(@JWT retrofit: Retrofit): CalendarService = retrofit.create(CalendarService::class.java) } \ No newline at end of file From 76093d181c5511f540224ac966a9119924948484 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 14:21:01 +0900 Subject: [PATCH 30/37] =?UTF-8?q?[REFACTOR/#91]=20=EC=9E=84=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 14 +--- .../calendar/month/CalendarMonthScreen.kt | 4 +- .../calendar/scrap/CalendarListScreen.kt | 78 ++++--------------- .../calendar/scrap/component/CalendarScrap.kt | 23 ------ .../scrap/component/CalendarScrapList.kt | 65 ++++++++++++++++ .../calendar/week/CalendarWeekScreen.kt | 61 +++++++++------ ...endarWeek.kt => HorizontalCalendarWeek.kt} | 2 +- 7 files changed, 122 insertions(+), 125 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrapList.kt rename feature/src/main/java/com/terning/feature/calendar/week/{CalendarWeek.kt => HorizontalCalendarWeek.kt} (98%) 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 acda2aa4c..0c11f4792 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 @@ -2,20 +2,11 @@ package com.terning.feature.calendar.calendar import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.terning.core.designsystem.theme.CalBlue1 -import com.terning.core.designsystem.theme.CalGreen1 -import com.terning.core.designsystem.theme.CalGreen2 -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.response.CalendarScrapDetailModel import com.terning.domain.repository.CalendarRepository import com.terning.feature.R import com.terning.feature.calendar.month.CalendarMonthState import com.terning.feature.calendar.scrap.CalendarListState -import com.terning.feature.calendar.scrap.model.Scrap import com.terning.feature.calendar.week.CalendarWeekState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers @@ -26,7 +17,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 @@ -142,8 +132,8 @@ class CalendarViewModel @Inject constructor( onSuccess = { _calendarWeekState.update { currentState -> currentState.copy( - /*loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty*/ - loadState = UiState.Success(it) + loadState = if (it.isNotEmpty()) UiState.Success(it) else UiState.Empty + //loadState = UiState.Success(it) ) } _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_success)) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index c1b62c67d..06fb41092 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -13,11 +13,11 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.terning.core.designsystem.theme.White import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapModel +import com.terning.feature.calendar.calendar.CalendarUiState +import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.calendar.model.CalendarDefaults.flingBehavior import com.terning.feature.calendar.calendar.model.CalendarState.Companion.getDateByPage -import com.terning.feature.calendar.calendar.CalendarViewModel import com.terning.feature.calendar.month.model.MonthData -import com.terning.feature.calendar.calendar.CalendarUiState import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate import java.time.YearMonth 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 49d99e93b..04bdf8532 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 @@ -2,23 +2,19 @@ package com.terning.feature.calendar.scrap import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer 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.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -27,20 +23,17 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.Back -import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.getDateAsMapString -import com.terning.core.extension.getDateStringInKorean import com.terning.core.extension.isListNotEmpty import com.terning.core.state.UiState -import com.terning.domain.entity.response.CalendarScrapDetailModel import com.terning.feature.R import com.terning.feature.calendar.calendar.CalendarViewModel 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.CalendarScrap +import com.terning.feature.calendar.scrap.component.CalendarScrapList import kotlinx.coroutines.flow.distinctUntilChanged import java.time.LocalDate @@ -87,15 +80,20 @@ fun CalendarListScreen( UiState.Loading -> {} UiState.Empty -> { item { - Text( - modifier = Modifier - .padding(top = 42.dp) - .fillMaxWidth(), - text = stringResource(id = R.string.calendar_empty_scrap), - textAlign = TextAlign.Center, - style = TerningTheme.typography.body5, - color = Grey400 - ) + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center + ) { + Text( + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } } } @@ -123,48 +121,4 @@ fun CalendarListScreen( } } -@Composable -fun CalendarScrapList( - selectedDate: LocalDate, - scrapList: List, - isFromList: Boolean = false, - noScrapScreen: @Composable () -> Unit -) { - val scrollState = rememberScrollState() - if (scrapList.isListNotEmpty()) { - Text( - text = selectedDate.getDateStringInKorean(), - style = TerningTheme.typography.title5, - color = Black, - modifier = Modifier.padding(start = 24.dp, top = 16.dp, bottom = 15.dp) - ) - } - val topModifier = if (!isFromList) { - Modifier - .fillMaxWidth() - .padding(horizontal = 24.dp) - .verticalScroll(scrollState) - } else { - Modifier - .fillMaxWidth() - .padding(horizontal = 24.dp) - } - - if (!scrapList.isListNotEmpty()) { - noScrapScreen() - } else { - Column( - modifier = topModifier - ) { - for (scrap in scrapList) { - CalendarScrap( - scrap = scrap - ) - Spacer( - modifier = Modifier.height(12.dp) - ) - } - } - } -} 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 538c2737f..239618a87 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 @@ -3,33 +3,10 @@ package com.terning.feature.calendar.scrap.component import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.colorResource import androidx.compose.ui.unit.dp import com.terning.core.designsystem.component.item.InternItem import com.terning.core.designsystem.component.item.ScrapBox import com.terning.domain.entity.response.CalendarScrapDetailModel -import com.terning.feature.calendar.scrap.model.Scrap - -@Composable -fun CalendarScrap( - scrap: Scrap, - modifier: Modifier = Modifier, -) { - ScrapBox( - modifier = modifier, - cornerRadius = 10.dp, - scrapColor = scrap.backgroundColor, - elevation = 1.dp, - ) { - InternItem( - imageUrl = scrap.image.orEmpty(), - title = scrap.text, - dateDeadline = scrap.dDay, - workingPeriod = scrap.period, - isScraped = scrap.isScraped - ) - } -} @Composable fun CalendarScrap( diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrapList.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrapList.kt new file mode 100644 index 000000000..844e4e523 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/component/CalendarScrapList.kt @@ -0,0 +1,65 @@ +package com.terning.feature.calendar.scrap.component + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.theme.Black +import com.terning.core.designsystem.theme.TerningTheme +import com.terning.core.extension.getDateStringInKorean +import com.terning.core.extension.isListNotEmpty +import com.terning.domain.entity.response.CalendarScrapDetailModel +import java.time.LocalDate + +@Composable +fun CalendarScrapList( + selectedDate: LocalDate, + scrapList: List, + isFromList: Boolean = false, + noScrapScreen: @Composable () -> Unit +) { + val scrollState = rememberScrollState() + + if (scrapList.isListNotEmpty()) { + Text( + text = selectedDate.getDateStringInKorean(), + style = TerningTheme.typography.title5, + color = Black, + modifier = Modifier.padding(start = 24.dp, top = 16.dp, bottom = 15.dp) + ) + } + val topModifier = if (!isFromList) { + Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp) + .verticalScroll(scrollState) + } else { + Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp) + } + + if (!scrapList.isListNotEmpty()) { + noScrapScreen() + } else { + Column( + modifier = topModifier + ) { + for (scrap in scrapList) { + CalendarScrap( + scrap = scrap + ) + Spacer( + modifier = Modifier.height(12.dp) + ) + } + } + } +} \ No newline at end of file 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 56b882ff9..b22a15f9a 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 @@ -2,6 +2,7 @@ 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.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -11,6 +12,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.res.stringResource @@ -27,9 +29,8 @@ import com.terning.core.designsystem.theme.White import com.terning.core.state.UiState 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.scrap.CalendarScrapList +import com.terning.feature.calendar.scrap.component.CalendarScrapList import java.time.LocalDate @Composable @@ -63,7 +64,7 @@ fun CalendarWeekScreen( shape = RoundedCornerShape(bottomStart = 20.dp, bottomEnd = 20.dp), ) { - CalendarWeek( + HorizontalCalendarWeek( modifier = Modifier .fillMaxWidth() .background(White), @@ -77,37 +78,47 @@ fun CalendarWeekScreen( when (calendarWeekState.loadState) { is UiState.Loading -> {} is UiState.Empty -> { - Text( - modifier = Modifier - .padding(top = 42.dp) - .fillMaxWidth(), - text = stringResource(id = R.string.calendar_empty_scrap), - textAlign = TextAlign.Center, - style = TerningTheme.typography.body5, - color = Grey400 - ) + CalendarWeekEmpty() } - is UiState.Failure -> {} is UiState.Success -> { val scrapList = (calendarWeekState.loadState as UiState.Success).data - - CalendarScrapList(selectedDate = uiState.selectedDate, scrapList = scrapList) { - Text( - modifier = Modifier - .padding(top = 42.dp) - .fillMaxWidth(), - text = stringResource(id = R.string.calendar_empty_scrap), - textAlign = TextAlign.Center, - style = TerningTheme.typography.body5, - color = Grey400 - ) - } + CalendarWeekSuccess(scrapList = scrapList, selectedDate = uiState.selectedDate) } } } } +@Composable +fun CalendarWeekEmpty( + modifier: Modifier = Modifier +) { + Box( + contentAlignment = Alignment.Center + ) { + + + Text( + modifier = Modifier + .padding(top = 42.dp) + .fillMaxWidth(), + text = stringResource(id = R.string.calendar_empty_scrap), + textAlign = TextAlign.Center, + style = TerningTheme.typography.body5, + color = Grey400 + ) + } +} + +@Composable +fun CalendarWeekSuccess( + scrapList: List, + selectedDate: LocalDate, +) { + + CalendarScrapList(selectedDate = selectedDate, scrapList = scrapList) {} +} + diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt b/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt similarity index 98% rename from feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt rename to feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt index 7ed5bf177..4bfe69ba4 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeek.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/HorizontalCalendarWeek.kt @@ -19,7 +19,7 @@ import java.time.LocalDate import java.time.YearMonth @Composable -fun CalendarWeek( +fun HorizontalCalendarWeek( selectedDate: CalendarUiState, modifier: Modifier = Modifier, onDateSelected: (LocalDate) -> Unit = {} From 4f589973be5851e3231a760c3db410fa1065aac9 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 16:49:27 +0900 Subject: [PATCH 31/37] =?UTF-8?q?[CHORE/#59]=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasourceimpl/CalendarDataSourceImpl.kt | 10 ++++---- .../data/datasourceimpl/CalendarList.kt | 24 +++++++++++++++++++ .../terning/data/service/CalendarService.kt | 7 +++--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt index eddcecef0..4a927b980 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt @@ -12,14 +12,16 @@ import com.terning.data.service.CalendarService import javax.inject.Inject class CalendarDataSourceImpl @Inject constructor( - private val calendarService: CalendarService + //private val calendarService: CalendarService ) : CalendarDataSource { + private val calendarService = TempCalendarService() + override suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> = - CalendarList.getCalendarScrapMonth(request) + calendarService.getCalendarScrapMonth(request.year, request.month) override suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse> = - CalendarList.getCalendarScrapMonthList(request) + calendarService.getCalendarScrapMonthList(request.year, request.month) override suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse> = - CalendarList.getCalendarScrapDayList(request) + calendarService.getCalendarScrapDayList(request.date) } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt index 74b1ff8e0..b00673970 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt @@ -7,6 +7,30 @@ import com.terning.data.dto.request.CalendarMonthRequestDto import com.terning.data.dto.response.CalendarDayListResponseDto import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto +import com.terning.data.service.CalendarService + +class TempCalendarService: CalendarService { + override suspend fun getCalendarScrapMonth( + year: Int, + month: Int + ): BaseResponse> = CalendarList.getCalendarScrapMonth( + CalendarMonthRequestDto(year, month) + ) + + override suspend fun getCalendarScrapMonthList( + year: Int, + month: Int + ): BaseResponse> = CalendarList.getCalendarScrapMonthList( + CalendarMonthListRequestDto(year, month) + ) + + override suspend fun getCalendarScrapDayList( + date: String + ): BaseResponse> = CalendarList.getCalendarScrapDayList( + CalendarDayListRequestDto(date) + ) + +} object CalendarList { fun getCalendarScrapMonth(request: CalendarMonthRequestDto): BaseResponse> = diff --git a/data/src/main/java/com/terning/data/service/CalendarService.kt b/data/src/main/java/com/terning/data/service/CalendarService.kt index 57a21408e..8ca05f7e9 100644 --- a/data/src/main/java/com/terning/data/service/CalendarService.kt +++ b/data/src/main/java/com/terning/data/service/CalendarService.kt @@ -1,6 +1,7 @@ package com.terning.data.service import com.terning.data.dto.BaseResponse +import com.terning.data.dto.response.CalendarDayListResponseDto import com.terning.data.dto.response.CalendarMonthListResponseDto import com.terning.data.dto.response.CalendarMonthResponseDto import retrofit2.http.GET @@ -21,8 +22,6 @@ interface CalendarService{ @GET("/api/v1/calendar/daily") suspend fun getCalendarScrapDayList( - @Query("year") year: Int, - @Query("month") month: Int, - @Query("day") day: Int - ): BaseResponse> + @Query("date") date: String + ): BaseResponse> } \ No newline at end of file From c256acd67dec20c0483764771d313ea72e1e4ff1 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 16:50:01 +0900 Subject: [PATCH 32/37] =?UTF-8?q?[RENAME/#59]=20=EC=9B=94=EA=B0=84=20?= =?UTF-8?q?=EC=BA=98=EB=A6=B0=EB=8D=94=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/calendar/month/CalendarMonth.kt | 4 ++-- .../com/terning/feature/calendar/scrap/CalendarMonthScrap.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index 4fa0f6f50..fd1995e23 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -18,7 +18,7 @@ import com.terning.domain.entity.response.CalendarScrapModel import com.terning.feature.calendar.calendar.CalendarUiState import com.terning.feature.calendar.month.component.CalendarDay import com.terning.feature.calendar.month.model.MonthData -import com.terning.feature.calendar.scrap.CalendarScrapStrip +import com.terning.feature.calendar.scrap.CalendarMonthScrap import java.time.LocalDate import java.time.YearMonth @@ -55,7 +55,7 @@ fun CalendarMonth( ) if(!day.isOutDate) { val index = day.date.getDateAsMapString() - CalendarScrapStrip( + CalendarMonthScrap( scrapLists = scrapMap[index].orEmpty() ) } diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt index 900bf6d5a..03bae35a8 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt @@ -18,7 +18,7 @@ import com.terning.core.designsystem.theme.White import com.terning.domain.entity.response.CalendarScrapModel @Composable -fun CalendarScrapStrip( +fun CalendarMonthScrap( modifier: Modifier = Modifier, scrapLists: List ) { From e212c0486bd3ecb7bb96a532da8dfb11fd40f4ed Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 19:23:59 +0900 Subject: [PATCH 33/37] =?UTF-8?q?[RENAME/#59]=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt index 4a927b980..15f60843e 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt @@ -12,10 +12,8 @@ import com.terning.data.service.CalendarService import javax.inject.Inject class CalendarDataSourceImpl @Inject constructor( - //private val calendarService: CalendarService + private val calendarService: CalendarService ) : CalendarDataSource { - private val calendarService = TempCalendarService() - override suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse> = calendarService.getCalendarScrapMonth(request.year, request.month) From 88029821091afb43e9c59616e8cac07d1cc964b0 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 19:26:22 +0900 Subject: [PATCH 34/37] =?UTF-8?q?[REFACTOR/#59]=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/calendar/CalendarViewModel.kt | 1 - .../calendar/component/ScreenTransition.kt | 4 +- .../calendar/component/WeekDaysHeader.kt | 55 ++++++++++--------- .../feature/calendar/month/CalendarMonth.kt | 4 +- .../calendar/month/CalendarMonthState.kt | 2 +- .../feature/calendar/month/model/MonthData.kt | 3 +- .../calendar/scrap/CalendarListState.kt | 2 +- .../calendar/scrap/CalendarMonthScrap.kt | 4 +- .../calendar/week/CalendarWeekScreen.kt | 1 + .../calendar/week/CalendarWeekState.kt | 2 +- .../calendar/week/HorizontalCalendarWeek.kt | 7 ++- 11 files changed, 44 insertions(+), 41 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 0c11f4792..b593082b3 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 @@ -136,7 +136,6 @@ class CalendarViewModel @Inject constructor( //loadState = UiState.Success(it) ) } - _calendarSideEffect.emit(CalendarSideEffect.ShowToast(R.string.server_success)) }, onFailure = { _calendarWeekState.update { currentState -> diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt index 52a54da73..52339d6af 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/ScreenTransition.kt @@ -14,7 +14,7 @@ fun ScreenTransition( transitionTwo: ContentTransform, contentOne: @Composable () -> Unit, contentTwo: @Composable () -> Unit - ) { +) { AnimatedContent( targetState = targetState, transitionSpec = { @@ -28,7 +28,7 @@ fun ScreenTransition( }, label = stringResource(id = R.string.calendar_animation_label) ) { state -> - if(state) { + if (state) { contentOne.invoke() } else { contentTwo.invoke() diff --git a/feature/src/main/java/com/terning/feature/calendar/calendar/component/WeekDaysHeader.kt b/feature/src/main/java/com/terning/feature/calendar/calendar/component/WeekDaysHeader.kt index e02bde2ce..554a3cd1d 100644 --- a/feature/src/main/java/com/terning/feature/calendar/calendar/component/WeekDaysHeader.kt +++ b/feature/src/main/java/com/terning/feature/calendar/calendar/component/WeekDaysHeader.kt @@ -22,39 +22,40 @@ import com.terning.feature.R fun WeekDaysHeader( modifier: Modifier = Modifier, ) { - Row( - modifier = modifier - .fillMaxWidth() - .background(Color.White) - .padding( - horizontal = 20.dp, - vertical = 18.dp - ), - ){ - val dayOfWeek = listOf( - R.string.calendar_text_sunday, - R.string.calendar_text_monday, - R.string.calendar_text_tuesday, - R.string.calendar_text_wednesday, - R.string.calendar_text_thursday, - R.string.calendar_text_friday, - R.string.calendar_text_saturday,) - dayOfWeek.forEach { day -> - Text( - modifier = Modifier.weight(1f), - text = stringResource(id = day), - style = TerningTheme.typography.body7, - color = if(day == R.string.calendar_text_sunday) SundayRed else Black, - textAlign = TextAlign.Center - ) - } + Row( + modifier = modifier + .fillMaxWidth() + .background(Color.White) + .padding( + horizontal = 20.dp, + vertical = 18.dp + ), + ) { + val dayOfWeek = listOf( + R.string.calendar_text_sunday, + R.string.calendar_text_monday, + R.string.calendar_text_tuesday, + R.string.calendar_text_wednesday, + R.string.calendar_text_thursday, + R.string.calendar_text_friday, + R.string.calendar_text_saturday, + ) + dayOfWeek.forEach { day -> + Text( + modifier = Modifier.weight(1f), + text = stringResource(id = day), + style = TerningTheme.typography.body7, + color = if (day == R.string.calendar_text_sunday) SundayRed else Black, + textAlign = TextAlign.Center + ) } + } } @Preview(showBackground = true) @Composable fun WeekDaysHeaderPreview() { - TerningPointTheme{ + TerningPointTheme { WeekDaysHeader() } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt index fd1995e23..e69cecce0 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonth.kt @@ -53,7 +53,7 @@ fun CalendarMonth( isToday = day.date.isToday(), onDateSelected = onDateSelected ) - if(!day.isOutDate) { + if (!day.isOutDate) { val index = day.date.getDateAsMapString() CalendarMonthScrap( scrapLists = scrapMap[index].orEmpty() @@ -62,7 +62,7 @@ fun CalendarMonth( } } } - if(month.indexOf(week) != month.lastIndex) { + if (month.indexOf(week) != month.lastIndex) { HorizontalDivider( thickness = 1.dp, color = Grey150 diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt index acd6b1bde..4e37e7b1f 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthState.kt @@ -3,6 +3,6 @@ package com.terning.feature.calendar.month import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapModel -data class CalendarMonthState ( +data class CalendarMonthState( val loadState: UiState>> = UiState.Loading ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt index f24bdd2f0..365720da5 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/model/MonthData.kt @@ -29,7 +29,8 @@ data class MonthData( private val rows = (0 until totalDays).chunked(7) - val calendarMonth = MonthModel(month, rows.map { week -> week.map {dayOffset -> getDay(dayOffset)}}) + val calendarMonth = + MonthModel(month, rows.map { week -> week.map { dayOffset -> getDay(dayOffset) } }) private fun getDay(dayOffset: Int): DayClass { val firstDayOnCalendar = month.atDay(1).minusDays(inDays.toLong()) diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt index 958a020e8..10fa93cdb 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarListState.kt @@ -3,6 +3,6 @@ package com.terning.feature.calendar.scrap import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapDetailModel -data class CalendarListState ( +data class CalendarListState( val loadState: UiState>> = UiState.Loading ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt index 03bae35a8..089a9f654 100644 --- a/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt +++ b/feature/src/main/java/com/terning/feature/calendar/scrap/CalendarMonthScrap.kt @@ -44,8 +44,8 @@ fun CalendarMonthScrap( ) } - item{ - if(scrapLists.size > MAX_SCRAP_COUNT) { + item { + if (scrapLists.size > MAX_SCRAP_COUNT) { Text( text = "+${(scrapLists.size - MAX_SCRAP_COUNT)}", style = TerningTheme.typography.detail4, 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 b22a15f9a..817bcdd17 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 @@ -80,6 +80,7 @@ fun CalendarWeekScreen( is UiState.Empty -> { CalendarWeekEmpty() } + is UiState.Failure -> {} is UiState.Success -> { val scrapList = (calendarWeekState.loadState as UiState.Success).data diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt index 8c661ee2e..b94f2a54f 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekState.kt @@ -3,6 +3,6 @@ package com.terning.feature.calendar.week import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapDetailModel -data class CalendarWeekState ( +data class CalendarWeekState( val loadState: UiState> = UiState.Loading ) \ No newline at end of file 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 4bfe69ba4..9b16f9a9d 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 @@ -28,14 +28,15 @@ fun HorizontalCalendarWeek( val monthData = MonthData(YearMonth.of(date.year, date.monthValue)) val currentWeek = date.getWeekIndexContainingSelectedDate(monthData.inDays) - val pagerState = rememberPagerState ( + val pagerState = rememberPagerState( initialPage = currentWeek, - pageCount = {monthData.totalDays / 7} + pageCount = { monthData.totalDays / 7 } ) HorizontalPager( modifier = modifier, - state = pagerState) { page -> + state = pagerState + ) { page -> LazyRow( modifier = Modifier .fillMaxWidth() From e6b1236dc367c10148b633bb8853234a71cd90d9 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 19:30:51 +0900 Subject: [PATCH 35/37] =?UTF-8?q?[ADD/#59]=20LifecycleOwner=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/calendar/calendar/CalendarRoute.kt | 2 +- .../terning/feature/calendar/month/CalendarMonthScreen.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 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 a64244d21..f0016d96d 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 @@ -60,8 +60,8 @@ private fun CalendarScreen( ) { val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current - val calendarUiState by viewModel.selectedDate.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner) + LaunchedEffect(viewModel.calendarSideEffect, lifecycleOwner) { viewModel.calendarSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> diff --git a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt index 06fb41092..402910a1e 100644 --- a/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/month/CalendarMonthScreen.kt @@ -10,6 +10,8 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.theme.White import com.terning.core.state.UiState import com.terning.domain.entity.response.CalendarScrapModel @@ -31,7 +33,8 @@ fun CalendarMonthScreen( modifier: Modifier = Modifier, viewModel: CalendarViewModel = hiltViewModel() ) { - val scrapState by viewModel.calendarMonthState.collectAsState() + val lifecycleOwner = LocalLifecycleOwner.current + val scrapState by viewModel.calendarMonthState.collectAsStateWithLifecycle(lifecycleOwner) LaunchedEffect(key1 = listState) { snapshotFlow { listState.firstVisibleItemIndex } From 212ed2717720aa4013f79866fab875047ace7a77 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 19:59:47 +0900 Subject: [PATCH 36/37] =?UTF-8?q?[DEL/#59]=20=EB=8D=94=EB=AF=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasourceimpl/CalendarList.kt | 870 ------------------ 1 file changed, 870 deletions(-) delete mode 100644 data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt diff --git a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt b/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt deleted file mode 100644 index b00673970..000000000 --- a/data/src/main/java/com/terning/data/datasourceimpl/CalendarList.kt +++ /dev/null @@ -1,870 +0,0 @@ -package com.terning.data.datasourceimpl - -import com.terning.data.dto.BaseResponse -import com.terning.data.dto.request.CalendarDayListRequestDto -import com.terning.data.dto.request.CalendarMonthListRequestDto -import com.terning.data.dto.request.CalendarMonthRequestDto -import com.terning.data.dto.response.CalendarDayListResponseDto -import com.terning.data.dto.response.CalendarMonthListResponseDto -import com.terning.data.dto.response.CalendarMonthResponseDto -import com.terning.data.service.CalendarService - -class TempCalendarService: CalendarService { - override suspend fun getCalendarScrapMonth( - year: Int, - month: Int - ): BaseResponse> = CalendarList.getCalendarScrapMonth( - CalendarMonthRequestDto(year, month) - ) - - override suspend fun getCalendarScrapMonthList( - year: Int, - month: Int - ): BaseResponse> = CalendarList.getCalendarScrapMonthList( - CalendarMonthListRequestDto(year, month) - ) - - override suspend fun getCalendarScrapDayList( - date: String - ): BaseResponse> = CalendarList.getCalendarScrapDayList( - CalendarDayListRequestDto(date) - ) - -} - -object CalendarList { - fun getCalendarScrapMonth(request: CalendarMonthRequestDto): BaseResponse> = - BaseResponse( - status = 200, - message = "캘린더 > (월간) 스크랩 된 공고 정보 불러오기를 성공했습니다", - result = getMockScrapList(request.year, request.month) - ) - - fun getCalendarScrapMonthList(request: CalendarMonthListRequestDto): BaseResponse> = - BaseResponse( - status = 200, - message = "캘린더 > (월간) 스크랩 된 공고 정보 불러오기를 성공했습니다", - result = getMockScrapDetailList(request.year, request.month) - ) - - fun getCalendarScrapDayList(requestDto: CalendarDayListRequestDto): BaseResponse> = - BaseResponse( - status = 200, - message = "캘린더 > (일간) 스크랩 된 공고 정보 불러오기를 성공했습니다", - result = getMockDayList(requestDto.date) - ) - - - - fun getMockScrapList(year: Int, month: Int): List { - val deadline = month.toString().padStart(2, '0') - return when (month % 4) { - 0 -> { - listOf( - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-13", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-17", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-23", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-30", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 1 -> { - listOf( - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-01", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF9B64E2" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FFED4E54" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-12", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-27", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 2 -> { - listOf( - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-18", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-20", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - 3 -> { - listOf( - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-05", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953" - )/*, - ScrapResponsesDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2" - ), - ScrapResponsesDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC" - )*/ - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-11", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFC4E953" - ), - CalendarMonthResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FF45D0CC" - ), - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-19", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF5397F3" - ) - ) - ), - CalendarMonthResponseDto( - deadline = "${year}-${deadline}-28", - scraps = listOf( - CalendarMonthResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FF45D0CC" - ) - ) - ) - ) - } - - else -> { - listOf() - } - } - } -} - - -/*************************MockDataType***************************/ - -fun getMockScrapDetailList(year: Int, month: Int): List { - val deadline = month.toString().padStart(2, '0') - return when (month % 5) { - 0 -> { - listOf( - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-13", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 1, - title = "제목1", - color = "#FFED4E54", - internshipAnnouncementId = 1, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 2, - title = "제목2", - color = "#FFC4E953", - internshipAnnouncementId = 2, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 3, - title = "제목3", - color = "#FF9B64E2", - internshipAnnouncementId = 3, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 4, - title = "제목4", - color = "#FFF260AC", - internshipAnnouncementId = 3, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-17", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 5, - title = "제목5", - color = "#FFC4E953", - internshipAnnouncementId = 5, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 6, - title = "제목6", - color = "#FF45D0CC", - internshipAnnouncementId = 6, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-23", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 7, - title = "제목7", - color = "#FF5397F3", - internshipAnnouncementId = 7, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-30", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 8, - title = "제목8", - color = "#FF45D0CC", - internshipAnnouncementId = 8, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ) - ) - } - - 1 -> { - listOf( - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-01", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 9, - title = "제목9", - color = "#FFED4E54", - internshipAnnouncementId = 9, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 10, - title = "제목10", - color = "#FFC4E953", - internshipAnnouncementId = 10, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 11, - title = "제목11", - color = "#FF9B64E2", - internshipAnnouncementId = 11, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 12, - title = "제목12", - color = "#FFF260AC", - internshipAnnouncementId = 12, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 13, - title = "제목13", - color = "#FFC4E953", - internshipAnnouncementId = 13, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 14, - title = "제목14", - color = "#FF9B64E2", - internshipAnnouncementId = 14, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 15, - title = "제목15", - color = "#FFED4E54", - internshipAnnouncementId = 15, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 16, - title = "제목16", - color = "#FFF260AC", - internshipAnnouncementId = 16, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-12", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 17, - title = "제목17", - color = "#FFC4E953", - internshipAnnouncementId = 17, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 18, - title = "제목18", - color = "#FF45D0CC", - internshipAnnouncementId = 18, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-27", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 19, - title = "제목19", - color = "#FF5397F3", - internshipAnnouncementId = 19, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 20, - title = "제목20", - color = "#FF45D0CC", - internshipAnnouncementId = 20, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ) - ) - } - - 2 -> { - listOf( - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-02", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 21, - title = "제목1", - color = "#FFED4E54", - internshipAnnouncementId = 21, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 22, - title = "제목22", - color = "#FFC4E953", - internshipAnnouncementId = 22, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 23, - title = "제목23", - color = "#FF9B64E2", - internshipAnnouncementId = 23, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 24, - title = "제목24", - color = "#FFF260AC", - internshipAnnouncementId = 24, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-18", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 25, - title = "제목25", - color = "#FFC4E953", - internshipAnnouncementId =25, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 26, - title = "제목26", - color = "#FF45D0CC", - internshipAnnouncementId = 26, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-20", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 27, - title = "제목27", - color = "#FF5397F3", - internshipAnnouncementId = 27, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-29", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 28, - title = "제목28", - color = "#FF45D0CC", - internshipAnnouncementId = 28, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ) - ) - } - - 3 -> { - listOf( - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-05", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 29, - title = "제목29", - color = "#FFED4E54", - internshipAnnouncementId = 29, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 30, - title = "제목30", - color = "#FFC4E953", - internshipAnnouncementId = 30, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-11", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 31, - title = "제목31", - color = "#FFC4E953", - internshipAnnouncementId = 31, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarMonthListResponseDto.Scrap( - scrapId = 32, - title = "제목32", - color = "#FF45D0CC", - internshipAnnouncementId = 32, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-19", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 33, - title = "제목33", - color = "#FF5397F3", - internshipAnnouncementId = 33, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ), - CalendarMonthListResponseDto( - deadline = "${year}-${deadline}-28", - scraps = listOf( - CalendarMonthListResponseDto.Scrap( - scrapId = 34, - title = "제목34", - color = "#FF45D0CC", - internshipAnnouncementId = 34, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) - ) - ) - ) - } - - else -> { - listOf() - } - } -} - -/******************DayList******************/ - -fun getMockDayList(request: String): List = listOf( - CalendarDayListResponseDto( - scrapId = 34, - title = "제목34", - color = "#FF45D0CC", - internshipAnnouncementId = 34, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ), - CalendarDayListResponseDto( - scrapId = 34, - title = "제목34", - color = "#FF45D0CC", - internshipAnnouncementId = 34, - dDay = "10", - workingPeriod = "10", - companyImage = "", - startYear = 2024, - startMonth = 8 - ) -) From 7d4ec19bcc82e0a9ddbe39cb2a75eefb95a00620 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 17 Jul 2024 20:05:33 +0900 Subject: [PATCH 37/37] =?UTF-8?q?[RENAME/#59]=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=EC=86=8C=EC=8A=A4=20=EB=84=A4=EC=9D=B4=EB=B0=8D=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 --- app/src/main/java/com/terning/point/di/DataSourceModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/terning/point/di/DataSourceModule.kt b/app/src/main/java/com/terning/point/di/DataSourceModule.kt index e090887e4..f3b8cc071 100644 --- a/app/src/main/java/com/terning/point/di/DataSourceModule.kt +++ b/app/src/main/java/com/terning/point/di/DataSourceModule.kt @@ -20,7 +20,7 @@ abstract class DataSourceModule { @Binds @Singleton - abstract fun bindCalendarRepository(calendarDataSourceImpl: CalendarDataSourceImpl): CalendarDataSource + abstract fun bindCalendarDataSource(calendarDataSourceImpl: CalendarDataSourceImpl): CalendarDataSource @Binds @Singleton