From 24fee2569fad142caa5f869097fe27681dd19c47 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 6 Sep 2024 20:36:56 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[MOVE/#220]=20InternInfoModel=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/data/dto/response/InternResponseDto.kt | 2 +- .../com/terning/data/repositoryimpl/InternRepositoryImpl.kt | 2 +- .../domain/entity/{response => intern}/InternInfoModel.kt | 2 +- .../main/java/com/terning/domain/repository/InternRepository.kt | 2 +- feature/src/main/java/com/terning/feature/intern/InternRoute.kt | 2 +- .../main/java/com/terning/feature/intern/model/InternUiState.kt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename domain/src/main/java/com/terning/domain/entity/{response => intern}/InternInfoModel.kt (90%) diff --git a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt index 6b0957464..39ef0832e 100644 --- a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt @@ -1,6 +1,6 @@ package com.terning.data.dto.response -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfoModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt index a76a71a26..7db146206 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt @@ -1,7 +1,7 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.InternDataSource -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfoModel import com.terning.domain.repository.InternRepository import javax.inject.Inject diff --git a/domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt b/domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt similarity index 90% rename from domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt rename to domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt index 3ad37dbde..fc79cbcb4 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt @@ -1,4 +1,4 @@ -package com.terning.domain.entity.response +package com.terning.domain.entity.intern data class InternInfoModel( val dDay: String, diff --git a/domain/src/main/java/com/terning/domain/repository/InternRepository.kt b/domain/src/main/java/com/terning/domain/repository/InternRepository.kt index 7a7d85326..1221e9390 100644 --- a/domain/src/main/java/com/terning/domain/repository/InternRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/InternRepository.kt @@ -1,6 +1,6 @@ package com.terning.domain.repository -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfoModel interface InternRepository { suspend fun getInternInfo(id: Long): Result diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index bcab1d50e..8d398f417 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -30,7 +30,7 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.customShadow import com.terning.core.extension.toast import com.terning.core.state.UiState -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfoModel import com.terning.feature.R import com.terning.feature.intern.component.InternBottomBar import com.terning.feature.intern.component.InternCompanyInfo diff --git a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt index 16f8afcc3..cea7ed2a1 100644 --- a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt +++ b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt @@ -3,7 +3,7 @@ package com.terning.feature.intern.model import androidx.compose.ui.graphics.Color import com.terning.core.designsystem.theme.CalRed import com.terning.core.state.UiState -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfoModel data class InternUiState( val loadState: UiState = UiState.Loading, From 71fcac115d04a18986ef3d040250fcd471698dad Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 6 Sep 2024 20:39:59 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[RENAME/#220]=20InternInfoModel=20->=20In?= =?UTF-8?q?ternInfo=20=EB=A6=AC=EB=84=A4=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/response/InternResponseDto.kt | 6 ++-- .../data/mapper/intern/InternInfoMapper.kt | 4 +++ .../repositoryimpl/InternRepositoryImpl.kt | 4 +-- .../{InternInfoModel.kt => InternInfo.kt} | 2 +- .../domain/repository/InternRepository.kt | 4 +-- .../com/terning/feature/intern/InternRoute.kt | 36 +++++++++---------- .../feature/intern/model/InternUiState.kt | 4 +-- 7 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt rename domain/src/main/java/com/terning/domain/entity/intern/{InternInfoModel.kt => InternInfo.kt} (94%) diff --git a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt index 39ef0832e..c6d8faf77 100644 --- a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt @@ -1,6 +1,6 @@ package com.terning.data.dto.response -import com.terning.domain.entity.intern.InternInfoModel +import com.terning.domain.entity.intern.InternInfo import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -37,8 +37,8 @@ data class InternResponseDto( @SerialName("scrapId") val scrapId: Long? = null, ) { - fun toInternEntity(): InternInfoModel { - return InternInfoModel( + fun toInternEntity(): InternInfo { + return InternInfo( dDay = dDay, title = title, deadline = deadline, diff --git a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt new file mode 100644 index 000000000..dc7014ba0 --- /dev/null +++ b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt @@ -0,0 +1,4 @@ +package com.terning.data.mapper.intern + +class InternInfoMapper { +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt index 7db146206..aae0c9daa 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt @@ -1,14 +1,14 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.InternDataSource -import com.terning.domain.entity.intern.InternInfoModel +import com.terning.domain.entity.intern.InternInfo import com.terning.domain.repository.InternRepository import javax.inject.Inject class InternRepositoryImpl @Inject constructor( private val internDataSource: InternDataSource, ) : InternRepository { - override suspend fun getInternInfo(id: Long): Result = + override suspend fun getInternInfo(id: Long): Result = runCatching { internDataSource.getInternInfo(id).result.toInternEntity() } diff --git a/domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt similarity index 94% rename from domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt rename to domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt index fc79cbcb4..77e70f12c 100644 --- a/domain/src/main/java/com/terning/domain/entity/intern/InternInfoModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt @@ -1,6 +1,6 @@ package com.terning.domain.entity.intern -data class InternInfoModel( +data class InternInfo( val dDay: String, val title: String, val deadline: String, diff --git a/domain/src/main/java/com/terning/domain/repository/InternRepository.kt b/domain/src/main/java/com/terning/domain/repository/InternRepository.kt index 1221e9390..3bdd6d60a 100644 --- a/domain/src/main/java/com/terning/domain/repository/InternRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/InternRepository.kt @@ -1,7 +1,7 @@ package com.terning.domain.repository -import com.terning.domain.entity.intern.InternInfoModel +import com.terning.domain.entity.intern.InternInfo interface InternRepository { - suspend fun getInternInfo(id: Long): Result + suspend fun getInternInfo(id: Long): Result } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index 8d398f417..1a9994fa0 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -30,7 +30,7 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.customShadow import com.terning.core.extension.toast import com.terning.core.state.UiState -import com.terning.domain.entity.intern.InternInfoModel +import com.terning.domain.entity.intern.InternInfo import com.terning.feature.R import com.terning.feature.intern.component.InternBottomBar import com.terning.feature.intern.component.InternCompanyInfo @@ -71,7 +71,7 @@ fun InternRoute( is UiState.Success -> { InternScreen( internUiState = internState, - internInfoModel = (internState.loadState as UiState.Success).data, + internInfo = (internState.loadState as UiState.Success).data, navController = navController ) } @@ -84,19 +84,19 @@ fun InternScreen( navController: NavHostController, viewModel: InternViewModel = hiltViewModel(), internUiState: InternUiState, - internInfoModel: InternInfoModel, + internInfo: InternInfo, ) { val decimal = DecimalFormat("#,###") val internInfoList = listOf( - stringResource(id = R.string.intern_info_d_day) to internInfoModel.deadline, - stringResource(id = R.string.intern_info_working) to internInfoModel.workingPeriod, - stringResource(id = R.string.intern_info_start_date) to internInfoModel.startDate, + stringResource(id = R.string.intern_info_d_day) to internInfo.deadline, + stringResource(id = R.string.intern_info_working) to internInfo.workingPeriod, + stringResource(id = R.string.intern_info_start_date) to internInfo.startDate, ) val qualificationList = listOf( - stringResource(id = R.string.intern_recruitment_target) to internInfoModel.qualification, - stringResource(id = R.string.intern_info_work) to internInfoModel.jobType, + stringResource(id = R.string.intern_recruitment_target) to internInfo.qualification, + stringResource(id = R.string.intern_info_work) to internInfo.jobType, ) if (internUiState.showWeb) { @@ -107,7 +107,7 @@ fun InternScreen( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, ) - loadUrl(internInfoModel.url) + loadUrl(internInfo.url) } }, ) @@ -130,8 +130,8 @@ fun InternScreen( bottomBar = { InternBottomBar( modifier = modifier, - scrapCount = decimal.format(internInfoModel.scrapCount), - scrapId = internInfoModel.scrapId, + scrapCount = decimal.format(internInfo.scrapCount), + scrapId = internInfo.scrapId, onScrapClick = { viewModel.updateScrapDialogVisible(true) } @@ -154,18 +154,18 @@ fun InternScreen( InternCompanyInfo( modifier = modifier, - companyImage = internInfoModel.companyImage, - company = internInfoModel.company, - companyCategory = internInfoModel.companyCategory + companyImage = internInfo.companyImage, + company = internInfo.company, + companyCategory = internInfo.companyCategory ) Spacer(modifier = modifier.padding(top = 20.dp)) InternTitle( modifier = modifier, - dDay = internInfoModel.dDay, - title = internInfoModel.title, - viewCount = decimal.format(internInfoModel.viewCount) + dDay = internInfo.dDay, + title = internInfo.title, + viewCount = decimal.format(internInfo.viewCount) ) Spacer(modifier = modifier.padding(top = 16.dp)) @@ -222,7 +222,7 @@ fun InternScreen( ) { SelectionContainer { Text( - text = internInfoModel.detail.trimIndent(), + text = internInfo.detail.trimIndent(), style = TerningTheme.typography.body3, color = Grey400 ) diff --git a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt index cea7ed2a1..a9b094007 100644 --- a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt +++ b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt @@ -3,10 +3,10 @@ package com.terning.feature.intern.model import androidx.compose.ui.graphics.Color import com.terning.core.designsystem.theme.CalRed import com.terning.core.state.UiState -import com.terning.domain.entity.intern.InternInfoModel +import com.terning.domain.entity.intern.InternInfo data class InternUiState( - val loadState: UiState = UiState.Loading, + val loadState: UiState = UiState.Loading, val isColorChange: Boolean = false, val isPaletteOpen: Boolean = false, val selectedColor: Color = CalRed, From cc8b5d59bcdd9318830bc25f77c7fbff8b9bd462 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 6 Sep 2024 20:43:10 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[FEAT/#220]=20InternInfoMapper=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/mapper/intern/InternInfoMapper.kt | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt index dc7014ba0..cb1156625 100644 --- a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt +++ b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt @@ -1,4 +1,22 @@ package com.terning.data.mapper.intern -class InternInfoMapper { -} \ No newline at end of file +import com.terning.domain.entity.intern.InternInfo + +fun InternInfo.toInternInfo(): InternInfo = + InternInfo( + dDay = dDay, + title = title, + deadline = deadline, + workingPeriod = workingPeriod, + startDate = startDate, + scrapCount = scrapCount, + viewCount = viewCount, + company = company, + companyCategory = companyCategory, + companyImage = companyImage, + qualification = qualification, + jobType = jobType, + detail = detail, + url = url, + scrapId = scrapId + ) \ No newline at end of file From 2e3023e910bdfee929bf7a3713dbb9af3e493839 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 6 Sep 2024 21:15:36 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[FEAT/#220]=20InternInfoMapper=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/response/InternResponseDto.kt | 23 +------------------ .../data/mapper/intern/InternInfoMapper.kt | 3 ++- .../repositoryimpl/InternRepositoryImpl.kt | 8 +++---- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt index c6d8faf77..542c29130 100644 --- a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt @@ -1,6 +1,5 @@ package com.terning.data.dto.response -import com.terning.domain.entity.intern.InternInfo import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -36,24 +35,4 @@ data class InternResponseDto( val url: String, @SerialName("scrapId") val scrapId: Long? = null, -) { - fun toInternEntity(): InternInfo { - return InternInfo( - dDay = dDay, - title = title, - deadline = deadline, - workingPeriod = workingPeriod, - startDate = startDate, - scrapCount = scrapCount, - viewCount = viewCount, - company = company, - companyCategory = companyCategory, - companyImage = companyImage, - qualification = qualification, - jobType = jobType, - detail = detail, - url = url, - scrapId = scrapId - ) - } -} +) \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt index cb1156625..7e3e8c1e0 100644 --- a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt +++ b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt @@ -1,8 +1,9 @@ package com.terning.data.mapper.intern +import com.terning.data.dto.response.InternResponseDto import com.terning.domain.entity.intern.InternInfo -fun InternInfo.toInternInfo(): InternInfo = +fun InternResponseDto.toInternInfo(): InternInfo = InternInfo( dDay = dDay, title = title, diff --git a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt index aae0c9daa..27696e06b 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/InternRepositoryImpl.kt @@ -1,6 +1,7 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.InternDataSource +import com.terning.data.mapper.intern.toInternInfo import com.terning.domain.entity.intern.InternInfo import com.terning.domain.repository.InternRepository import javax.inject.Inject @@ -8,8 +9,7 @@ import javax.inject.Inject class InternRepositoryImpl @Inject constructor( private val internDataSource: InternDataSource, ) : InternRepository { - override suspend fun getInternInfo(id: Long): Result = - runCatching { - internDataSource.getInternInfo(id).result.toInternEntity() - } + override suspend fun getInternInfo(id: Long): Result = runCatching { + internDataSource.getInternInfo(id).result.toInternInfo() + } } \ No newline at end of file From 29ef0a5b4a36634eb39e06f4d0b5ba4bfeed717e Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 9 Sep 2024 17:39:58 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[FEAT/#220]=20Scaffold=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/intern/InternRoute.kt | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index 1a9994fa0..e84a43bdb 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.text.selection.SelectionContainer -import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -43,6 +42,7 @@ import java.text.DecimalFormat @Composable fun InternRoute( announcementId: Long = 0, + modifier: Modifier = Modifier, viewModel: InternViewModel = hiltViewModel(), navController: NavHostController, ) { @@ -71,6 +71,7 @@ fun InternRoute( is UiState.Success -> { InternScreen( internUiState = internState, + modifier = modifier, internInfo = (internState.loadState as UiState.Success).data, navController = navController ) @@ -113,35 +114,20 @@ fun InternScreen( ) } - Scaffold( + Column( modifier = modifier, - topBar = { - BackButtonTopAppBar( - title = stringResource(id = R.string.intern_top_app_bar_title), - modifier = Modifier.customShadow( - color = Grey200, - offsetY = 2.dp - ), - onBackButtonClick = { - navController.popBackStack() - }, - ) - }, - bottomBar = { - InternBottomBar( - modifier = modifier, - scrapCount = decimal.format(internInfo.scrapCount), - scrapId = internInfo.scrapId, - onScrapClick = { - viewModel.updateScrapDialogVisible(true) - } - ) - } - ) { paddingValues -> - LazyColumn( - modifier = modifier - .padding(paddingValues) - ) { + ) { + BackButtonTopAppBar( + title = stringResource(id = R.string.intern_top_app_bar_title), + modifier = Modifier.customShadow( + color = Grey200, + offsetY = 2.dp + ), + onBackButtonClick = { + navController.popBackStack() + }, + ) + LazyColumn { item { Column( modifier = modifier.padding( @@ -229,9 +215,19 @@ fun InternScreen( } } } + InternBottomBar( + modifier = modifier, + scrapCount = decimal.format(internInfo.scrapCount), + scrapId = internInfo.scrapId, + onScrapClick = { + viewModel.updateScrapDialogVisible(true) + } + ) } + } + if (internUiState.isScrapDialogVisible) { TerningBasicDialog( onDismissRequest = { From 6646fb6a45d2aa35d03ba7bba76d3bafff3bd26f Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 9 Sep 2024 17:45:19 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[FEAT/#220]=20paddingValues=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 --- .../terning/feature/intern/navigation/InternNavigation.kt | 5 +++++ feature/src/main/java/com/terning/feature/main/MainScreen.kt | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/intern/navigation/InternNavigation.kt b/feature/src/main/java/com/terning/feature/intern/navigation/InternNavigation.kt index 7bc5c14c3..7af39f4c0 100644 --- a/feature/src/main/java/com/terning/feature/intern/navigation/InternNavigation.kt +++ b/feature/src/main/java/com/terning/feature/intern/navigation/InternNavigation.kt @@ -2,6 +2,9 @@ package com.terning.feature.intern.navigation import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.padding +import androidx.compose.ui.Modifier import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController @@ -24,6 +27,7 @@ fun NavController.navigateIntern( fun NavGraphBuilder.internNavGraph( navHostController: NavHostController, + paddingValues: PaddingValues, ) { composable( exitTransition = { @@ -42,6 +46,7 @@ fun NavGraphBuilder.internNavGraph( val args = it.toRoute() InternRoute( announcementId = args.announcementId, + modifier = Modifier.padding(paddingValues), navController = navHostController ) } 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 516f63bf1..47ee3919c 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -160,7 +160,10 @@ fun MainScreen( ) searchProcessNavGraph(navHostController = navigator.navController) changeFilterNavGraph(navHostController = navigator.navController) - internNavGraph(navHostController = navigator.navController) + internNavGraph( + paddingValues = paddingValues, + navHostController = navigator.navController + ) myPageNavGraph( paddingValues = paddingValues, navHostController = navigator.navController From fdd3033f7a2b81d99d0fc52ec9a3ee27feacbddf Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 9 Sep 2024 18:05:45 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[FEAT/#220]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=8C=A8?= =?UTF-8?q?=EB=94=A9=20=EA=B0=92=20=EC=A1=B0=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/intern/InternRoute.kt | 187 +++++++++--------- 1 file changed, 97 insertions(+), 90 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index e84a43bdb..b5b1effc5 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -4,6 +4,7 @@ import android.view.ViewGroup import android.webkit.WebView import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.text.selection.SelectionContainer @@ -115,118 +116,124 @@ fun InternScreen( } Column( - modifier = modifier, + modifier = modifier.fillMaxHeight(), ) { - BackButtonTopAppBar( - title = stringResource(id = R.string.intern_top_app_bar_title), - modifier = Modifier.customShadow( - color = Grey200, - offsetY = 2.dp - ), - onBackButtonClick = { - navController.popBackStack() - }, - ) - LazyColumn { - item { - Column( - modifier = modifier.padding( - top = 24.dp, - start = 24.dp, - end = 24.dp - ) - ) { - Spacer(modifier = modifier.padding(top = 16.dp)) - - InternCompanyInfo( - modifier = modifier, - companyImage = internInfo.companyImage, - company = internInfo.company, - companyCategory = internInfo.companyCategory - ) + Column( + modifier = Modifier.weight(1f) + ) { + BackButtonTopAppBar( + title = stringResource(id = R.string.intern_top_app_bar_title), + modifier = Modifier.customShadow( + color = Grey200, + offsetY = 2.dp + ), + onBackButtonClick = { + navController.popBackStack() + }, + ) + + LazyColumn( + modifier = Modifier.weight(1f) + ) { + item { + Column( + modifier = Modifier.padding( + top = 24.dp, + start = 24.dp, + end = 24.dp + ) + ) { + Spacer(modifier = Modifier.padding(top = 16.dp)) - Spacer(modifier = modifier.padding(top = 20.dp)) + InternCompanyInfo( + modifier = Modifier, + companyImage = internInfo.companyImage, + company = internInfo.company, + companyCategory = internInfo.companyCategory + ) - InternTitle( - modifier = modifier, - dDay = internInfo.dDay, - title = internInfo.title, - viewCount = decimal.format(internInfo.viewCount) - ) + Spacer(modifier = Modifier.padding(top = 20.dp)) - Spacer(modifier = modifier.padding(top = 16.dp)) + InternTitle( + modifier = Modifier, + dDay = internInfo.dDay, + title = internInfo.title, + viewCount = decimal.format(internInfo.viewCount) + ) - InternPageTitle( - modifier = modifier, - text = stringResource(id = R.string.intern_sub_title_intern_summary) - ) + Spacer(modifier = Modifier.padding(top = 16.dp)) - Column( - modifier = modifier.padding( - top = 4.dp, - bottom = 4.dp, - start = 10.dp + InternPageTitle( + modifier = Modifier, + text = stringResource(id = R.string.intern_sub_title_intern_summary) ) - ) { - internInfoList.forEach { (title, value) -> - InternInfoRow(title, value) - } - } - Spacer(modifier = modifier.padding(top = 16.dp)) + Column( + modifier = Modifier.padding( + top = 4.dp, + bottom = 4.dp, + start = 10.dp + ) + ) { + internInfoList.forEach { (title, value) -> + InternInfoRow(title, value) + } + } - InternPageTitle( - modifier = modifier, - text = stringResource(id = R.string.intern_info_request) - ) + Spacer(modifier = Modifier.padding(top = 16.dp)) - Column( - modifier = modifier.padding( - top = 4.dp, - bottom = 4.dp, - start = 10.dp + InternPageTitle( + modifier = Modifier, + text = stringResource(id = R.string.intern_info_request) ) - ) { - qualificationList.forEach { (title, value) -> - InternInfoRow(title, value) + + Column( + modifier = Modifier.padding( + top = 4.dp, + bottom = 4.dp, + start = 10.dp + ) + ) { + qualificationList.forEach { (title, value) -> + InternInfoRow(title, value) + } } - } - Spacer(modifier = modifier.padding(top = 16.dp)) + Spacer(modifier = Modifier.padding(top = 16.dp)) - InternPageTitle( - modifier = modifier, - text = stringResource(id = R.string.intern_sub_title_intern_detail) - ) - - Column( - modifier = modifier.padding( - start = 10.dp, - top = 5.dp, - bottom = 20.dp + InternPageTitle( + modifier = Modifier, + text = stringResource(id = R.string.intern_sub_title_intern_detail) ) - ) { - SelectionContainer { - Text( - text = internInfo.detail.trimIndent(), - style = TerningTheme.typography.body3, - color = Grey400 + + Column( + modifier = Modifier.padding( + start = 10.dp, + top = 5.dp, + bottom = 20.dp ) + ) { + SelectionContainer { + Text( + text = internInfo.detail.trimIndent(), + style = TerningTheme.typography.body3, + color = Grey400 + ) + } } } } - InternBottomBar( - modifier = modifier, - scrapCount = decimal.format(internInfo.scrapCount), - scrapId = internInfo.scrapId, - onScrapClick = { - viewModel.updateScrapDialogVisible(true) - } - ) } - } + InternBottomBar( + modifier = Modifier, + scrapCount = decimal.format(internInfo.scrapCount), + scrapId = internInfo.scrapId, + onScrapClick = { + viewModel.updateScrapDialogVisible(true) + } + ) if (internUiState.isScrapDialogVisible) { TerningBasicDialog( From 2dfd5b78067de85c686156e2c6c30930edcc0234 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 9 Sep 2024 18:52:44 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[FEAT/#220]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=9E=A9=20=EB=8B=A4=EC=9D=B4=EC=96=B4=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=9D=84=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/dialog/detail/ScrapDialog.kt | 45 ++-- .../com/terning/feature/intern/InternRoute.kt | 50 +++- .../terning/feature/intern/InternViewModel.kt | 28 +- .../intern/component/ScrapDialogContent.kt | 250 ------------------ .../feature/intern/model/InternUiState.kt | 6 +- 5 files changed, 86 insertions(+), 293 deletions(-) delete mode 100644 feature/src/main/java/com/terning/feature/intern/component/ScrapDialogContent.kt diff --git a/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt b/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt index e160aea7a..6432d0d5a 100644 --- a/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt +++ b/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt @@ -59,17 +59,18 @@ fun ScrapDialog( title: String, scrapColor: Color, deadline: String, - startYear: Int, - startMonth: Int, + startYear: Int = 0, + startMonth: Int = 0, + startDate: String = "", workingPeriod: String, - scrapId: Long, - internshipAnnouncementId: Long, + scrapId: Long = -1, + internshipAnnouncementId: Long = -1, companyImage: String, isScrapped: Boolean, onDismissRequest: () -> Unit, - onClickChangeColor: () -> Unit, - onClickNavigateButton: (Long) -> Unit, - viewModel: ScrapDialogViewModel = hiltViewModel() + onClickChangeColor: () -> Unit = {}, + onClickNavigateButton: (Long) -> Unit = {}, + viewModel: ScrapDialogViewModel = hiltViewModel(), ) { val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current @@ -81,6 +82,7 @@ fun ScrapDialog( is ScrapDialogSideEffect.ShowToast -> { context.toast(sideEffect.message) } + is ScrapDialogSideEffect.DismissDialog -> { viewModel.initUiState() onDismissRequest() @@ -110,6 +112,7 @@ fun ScrapDialog( deadline = deadline, startYear = startYear, startMonth = startMonth, + startDate = startDate, workingPeriod = workingPeriod, isScrapped = isScrapped, companyImage = companyImage, @@ -118,8 +121,8 @@ fun ScrapDialog( isColorChangedOnce = uiState.isColorChangedOnce, onClickColorButton = viewModel::changeSelectedColor, onClickColorChangeButton = { - if(uiState.isColorChanged) - viewModel.patchScrap(scrapId = scrapId, color = uiState.selectedColorType) + if (uiState.isColorChanged) + viewModel.patchScrap(scrapId = scrapId, color = uiState.selectedColorType) }, onClickNavigateButton = viewModel::navigateToDetail, onClickScrapButton = { @@ -136,6 +139,7 @@ private fun ScrapDialogScreen( deadline: String, startYear: Int, startMonth: Int, + startDate: String, workingPeriod: String, isScrapped: Boolean, companyImage: String, @@ -145,7 +149,7 @@ private fun ScrapDialogScreen( onClickColorButton: (ColorType) -> Unit, onClickNavigateButton: () -> Unit, onClickColorChangeButton: () -> Unit, - onClickScrapButton: () -> Unit + onClickScrapButton: () -> Unit, ) { Box( modifier = Modifier @@ -176,6 +180,7 @@ private fun ScrapDialogScreen( ) Spacer(modifier = Modifier.height(15.dp)) + Box( modifier = Modifier .height(TerningTheme.typography.title4.getFixHeightByMaxLine(3)) @@ -250,10 +255,17 @@ private fun ScrapDialogScreen( title = stringResource(id = R.string.intern_info_working), value = workingPeriod ) - InternInfoRow( - title = stringResource(id = R.string.intern_info_start_date), - value = "${startYear}년 ${startMonth}월" - ) + if (startDate == "") { + InternInfoRow( + title = stringResource(id = R.string.intern_info_start_date), + value = "${startYear}년 ${startMonth}월" + ) + } else { + InternInfoRow( + title = stringResource(id = R.string.intern_info_start_date), + value = startDate + ) + } } } @@ -277,7 +289,7 @@ private fun ScrapDialogScreen( @Composable private fun NewScrapButton( onClickScrapButton: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { RoundButton( style = TerningTheme.typography.button3, @@ -295,7 +307,7 @@ private fun DetailScrapButton( isColorChangedOnce: Boolean, onClickNavigateButton: () -> Unit, onClickColorChangeButton: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Row( modifier = modifier @@ -329,6 +341,7 @@ private fun ScrapDialogPreview() { deadline = "2024/09/07", startYear = 2024, startMonth = 11, + startDate = "", workingPeriod = "2개월", companyImage = "", isScrapped = false, diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index b5b1effc5..669b5c0e6 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -22,8 +22,8 @@ import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import androidx.navigation.NavHostController -import com.terning.core.designsystem.component.dialog.TerningBasicDialog import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar +import com.terning.core.designsystem.theme.CalRed import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme @@ -32,6 +32,8 @@ import com.terning.core.extension.toast import com.terning.core.state.UiState import com.terning.domain.entity.intern.InternInfo import com.terning.feature.R +import com.terning.feature.dialog.cancel.ScrapCancelDialog +import com.terning.feature.dialog.detail.ScrapDialog import com.terning.feature.intern.component.InternBottomBar import com.terning.feature.intern.component.InternCompanyInfo import com.terning.feature.intern.component.InternInfoRow @@ -43,7 +45,7 @@ import java.text.DecimalFormat @Composable fun InternRoute( announcementId: Long = 0, - modifier: Modifier = Modifier, + modifier: Modifier, viewModel: InternViewModel = hiltViewModel(), navController: NavHostController, ) { @@ -74,7 +76,19 @@ fun InternRoute( internUiState = internState, modifier = modifier, internInfo = (internState.loadState as UiState.Success).data, - navController = navController + navController = navController, + onDismissCancelDialog = { + viewModel.updateScrapDialogVisibility(false) + }, + onDismissInternDialog = { + viewModel.updateScrapDialogVisibility(false) + }, + onClickScrapButton = { detail -> + with(viewModel) { + updateInternshipModel(detail) + updateScrapDialogVisibility(true) + } + } ) } } @@ -87,6 +101,9 @@ fun InternScreen( viewModel: InternViewModel = hiltViewModel(), internUiState: InternUiState, internInfo: InternInfo, + onDismissCancelDialog: (Boolean) -> Unit, + onDismissInternDialog: () -> Unit, + onClickScrapButton: (InternInfo) -> Unit, ) { val decimal = DecimalFormat("#,###") @@ -231,16 +248,29 @@ fun InternScreen( scrapCount = decimal.format(internInfo.scrapCount), scrapId = internInfo.scrapId, onScrapClick = { - viewModel.updateScrapDialogVisible(true) + viewModel.updateScrapDialogVisibility(true) } ) - if (internUiState.isScrapDialogVisible) { - TerningBasicDialog( - onDismissRequest = { - viewModel.updateScrapDialogVisible(false) - }, - content = {}, + if (internUiState.isCancelDialogVisibility) { + internUiState.scrapId?.run { + ScrapCancelDialog( + scrapId = this, + onDismissRequest = onDismissCancelDialog + ) + } + } + + if (internUiState.isScrapDialogVisibility) { + ScrapDialog( + title = internInfo.title, + scrapColor = CalRed, + deadline = internInfo.deadline, + startDate = internInfo.startDate, + workingPeriod = internInfo.workingPeriod, + companyImage = internInfo.companyImage, + isScrapped = internUiState.isScrappedState, + onDismissRequest = onDismissInternDialog, ) } } diff --git a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt index 7322223a9..ab7636caf 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt @@ -1,10 +1,10 @@ package com.terning.feature.intern -import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState import com.terning.domain.entity.CalendarScrapRequest +import com.terning.domain.entity.intern.InternInfo import com.terning.domain.repository.InternRepository import com.terning.domain.repository.ScrapRepository import com.terning.feature.R @@ -60,7 +60,7 @@ class InternViewModel @Inject constructor( it.copy(isScrap = UiState.Success(true)) } getInternInfo(id) - updateScrapDialogVisible(false) + updateScrapDialogVisibility(false) _sideEffect.emit( InternViewSideEffect.Toast(R.string.intern_scrap_add_toast_message) ) @@ -85,7 +85,7 @@ class InternViewModel @Inject constructor( it.copy(isScrap = UiState.Success(false)) } getInternInfo(announcementId) - updateScrapDialogVisible(false) + updateScrapDialogVisibility(false) _sideEffect.emit(InternViewSideEffect.Toast(R.string.intern_scrap_delete_toast_message)) }.onFailure { _sideEffect.emit( @@ -96,27 +96,23 @@ class InternViewModel @Inject constructor( } } - fun updateSelectColor(newColor: Color) { + fun updateCancelDialogVisibility(visible: Boolean) { _internUiState.update { - it.copy(selectedColor = newColor) + it.copy(isCancelDialogVisibility = visible) } } - fun updateScrapDialogVisible(visible: Boolean) { + fun updateScrapDialogVisibility(visible: Boolean) { _internUiState.update { - it.copy(isScrapDialogVisible = visible) + it.copy(isScrapDialogVisibility = visible) } } - fun updatePaletteOpen(open: Boolean) { - _internUiState.update { - it.copy(isPaletteOpen = open) - } - } - - fun updateColorChange(change: Boolean) { - _internUiState.update { - it.copy(isColorChange = change) + fun updateInternshipModel(scrapDetailModel: InternInfo?) { + _internUiState.update { currentState -> + currentState.copy( + internshipModel = scrapDetailModel + ) } } diff --git a/feature/src/main/java/com/terning/feature/intern/component/ScrapDialogContent.kt b/feature/src/main/java/com/terning/feature/intern/component/ScrapDialogContent.kt deleted file mode 100644 index 3746f5f13..000000000 --- a/feature/src/main/java/com/terning/feature/intern/component/ScrapDialogContent.kt +++ /dev/null @@ -1,250 +0,0 @@ -package com.terning.feature.intern.component - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp -import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import coil.compose.AsyncImage -import coil.request.ImageRequest -import com.terning.core.R -import com.terning.core.designsystem.component.button.RoundButton -import com.terning.core.designsystem.component.item.ColorPalette -import com.terning.core.designsystem.theme.CalBlue1 -import com.terning.core.designsystem.theme.CalBlue2 -import com.terning.core.designsystem.theme.CalGreen1 -import com.terning.core.designsystem.theme.CalGreen2 -import com.terning.core.designsystem.theme.CalOrange1 -import com.terning.core.designsystem.theme.CalOrange2 -import com.terning.core.designsystem.theme.CalPink -import com.terning.core.designsystem.theme.CalPurple -import com.terning.core.designsystem.theme.CalRed -import com.terning.core.designsystem.theme.CalYellow -import com.terning.core.designsystem.theme.Grey200 -import com.terning.core.designsystem.theme.Grey350 -import com.terning.core.designsystem.theme.Grey500 -import com.terning.core.designsystem.theme.TerningMain -import com.terning.core.designsystem.theme.TerningTheme -import com.terning.core.designsystem.theme.White -import com.terning.core.extension.noRippleClickable -import com.terning.feature.intern.InternViewModel - - -@Composable -fun ScrapDialogContent( - internInfoList: List>, - viewModel: InternViewModel = hiltViewModel(), - dDay: String, - companyImage: String, - title: String, - announcementId: Long, - type: Int, -) { - val state by viewModel.internUiState.collectAsStateWithLifecycle() - - val colorList = listOf( - CalRed, - CalOrange1, - CalOrange2, - CalYellow, - CalGreen1, - CalGreen2, - CalBlue1, - CalBlue2, - CalPurple, - CalPink - ) - - Column( - modifier = Modifier - .wrapContentSize() - .padding(horizontal = 11.dp) - .padding(top = 32.dp), - horizontalAlignment = Alignment.CenterHorizontally - ) { - AsyncImage( - model = ImageRequest.Builder(LocalContext.current) - .data(companyImage) - .build(), - contentDescription = stringResource(R.string.image_content_descriptin), - modifier = Modifier - .size(80.dp) - .border( - width = 1.dp, - color = TerningMain, - shape = RoundedCornerShape(size = 15.dp) - ) - .clip(RoundedCornerShape(size = 15.dp)), - contentScale = ContentScale.Fit, - alignment = Alignment.Center - ) - - Text( - text = title, - textAlign = TextAlign.Center, - style = TerningTheme.typography.title4, - color = Grey500, - modifier = Modifier.padding(top = 20.dp), - maxLines = 3, - overflow = TextOverflow.Ellipsis - ) - Text( - text = stringResource(id = R.string.dialog_content_scrap_sub_title), - style = TerningTheme.typography.body5, - color = Grey350, - modifier = Modifier.padding( - top = 4.dp - ) - ) - Spacer(modifier = Modifier.height(26.dp)) - Column( - horizontalAlignment = Alignment.Start, - verticalArrangement = Arrangement.Top, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 13.dp) - ) { - Row( - modifier = Modifier - .background( - color = state.selectedColor, - shape = RoundedCornerShape(14.dp) - ) - .noRippleClickable { - viewModel.updatePaletteOpen(!state.isPaletteOpen) - }, - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Start - ) { - Text( - text = stringResource(id = R.string.dialog_content_color_button), - style = TerningTheme.typography.body5, - color = White, - modifier = Modifier.padding( - start = 13.dp, - top = 5.dp, - bottom = 5.dp - ) - ) - Icon( - painter = painterResource( - id = if (state.isPaletteOpen) R.drawable.ic_up_22 - else R.drawable.ic_down_22 - ), - contentDescription = stringResource( - id = R.string.dialog_content_color_button - ), - tint = White, - modifier = Modifier.padding( - end = 7.dp - ) - ) - } - HorizontalDivider( - thickness = 1.dp, - color = Grey200, - modifier = Modifier.padding( - top = 11.dp, - bottom = 8.dp - ) - ) - if (state.isPaletteOpen) { - Box( - modifier = Modifier - .fillMaxWidth() - .padding( - top = 12.dp, - bottom = 23.dp, - ), - contentAlignment = Alignment.Center - ) { - ColorPalette( - initialColor = state.selectedColor, - onColorSelected = { newColor -> - viewModel.updateSelectColor(newColor) - } - ) - } - } else { - Text( - text = dDay, - style = TerningTheme.typography.body5, - color = TerningMain, - modifier = Modifier.padding(bottom = 9.dp) - ) - Column( - modifier = Modifier.padding(bottom = 29.dp), - verticalArrangement = Arrangement.spacedBy( - 5.dp, - Alignment.CenterVertically - ), - horizontalAlignment = Alignment.Start, - ) { - internInfoList.forEach { - InternInfoRow( - title = it.first, - value = it.second - ) - } - } - } - } - Box( - modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.BottomCenter - ) { - val selectedColorIndex = - colorList.indexOf(state.selectedColor).takeIf { it >= 0 } ?: 0 - - RoundButton( - style = TerningTheme.typography.button3, - paddingVertical = 12.dp, - cornerRadius = 8.dp, - text = R.string.dialog_scrap_button, - onButtonClick = { - if (state.isPaletteOpen) { - viewModel.updatePaletteOpen(false) - viewModel.postScrap(announcementId, selectedColorIndex) - viewModel.updateColorChange(false) - viewModel.updateScrapDialogVisible(false) - } else { - if (state.isColorChange) { - viewModel.postScrap(announcementId, selectedColorIndex) - viewModel.updateColorChange(false) - } else { - viewModel.postScrap(announcementId, selectedColorIndex) - } - viewModel.updateScrapDialogVisible(false) - } - }, - modifier = Modifier.padding(bottom = 8.dp) - ) - } - } - -} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt index a9b094007..cee2e5373 100644 --- a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt +++ b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt @@ -3,6 +3,7 @@ package com.terning.feature.intern.model import androidx.compose.ui.graphics.Color import com.terning.core.designsystem.theme.CalRed import com.terning.core.state.UiState +import com.terning.domain.entity.CalendarScrapDetail import com.terning.domain.entity.intern.InternInfo data class InternUiState( @@ -10,7 +11,10 @@ data class InternUiState( val isColorChange: Boolean = false, val isPaletteOpen: Boolean = false, val selectedColor: Color = CalRed, - val isScrapDialogVisible: Boolean = false, + val isCancelDialogVisibility: Boolean = false, + val isScrapDialogVisibility: Boolean = false, val isScrappedState: Boolean = false, val showWeb: Boolean = false, + val scrapId: Long? = null, + val internshipModel: InternInfo? = null ) \ No newline at end of file From 011571f0a2c8305e0f9b1eda3e780a6c6fbab592 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 9 Sep 2024 19:36:19 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[FEAT/#220]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=9E=A9=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/intern/InternRoute.kt | 68 +++++++------- .../terning/feature/intern/InternViewModel.kt | 90 ++++--------------- .../intern/component/InternBottomBar.kt | 14 +-- .../feature/intern/model/InternUiState.kt | 8 +- 4 files changed, 66 insertions(+), 114 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index 669b5c0e6..ef02c79ed 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -73,20 +73,22 @@ fun InternRoute( is UiState.Failure -> {} is UiState.Success -> { InternScreen( + announcementId = announcementId, internUiState = internState, modifier = modifier, internInfo = (internState.loadState as UiState.Success).data, navController = navController, onDismissCancelDialog = { - viewModel.updateScrapDialogVisibility(false) + viewModel.updateScrapCancelDialogVisibility(false) }, - onDismissInternDialog = { - viewModel.updateScrapDialogVisibility(false) + onDismissScrapDialog = { viewModel.updateInternDialogVisibility(false) }, + onClickCancelButton = { + viewModel.updateScrapCancelDialogVisibility(true) }, - onClickScrapButton = { detail -> + onClickScrapButton = { with(viewModel) { - updateInternshipModel(detail) - updateScrapDialogVisibility(true) + updateInternshipModel(it) + updateInternDialogVisibility(true) } } ) @@ -96,13 +98,14 @@ fun InternRoute( @Composable fun InternScreen( + announcementId: Long, modifier: Modifier = Modifier, navController: NavHostController, - viewModel: InternViewModel = hiltViewModel(), internUiState: InternUiState, internInfo: InternInfo, onDismissCancelDialog: (Boolean) -> Unit, - onDismissInternDialog: () -> Unit, + onDismissScrapDialog: () -> Unit, + onClickCancelButton: (InternInfo) -> Unit, onClickScrapButton: (InternInfo) -> Unit, ) { val decimal = DecimalFormat("#,###") @@ -245,33 +248,38 @@ fun InternScreen( InternBottomBar( modifier = Modifier, - scrapCount = decimal.format(internInfo.scrapCount), - scrapId = internInfo.scrapId, + internInfo = internInfo, onScrapClick = { - viewModel.updateScrapDialogVisibility(true) - } + if (!internUiState.isScrappedState) + onClickScrapButton(internInfo) + else onClickCancelButton(internInfo) + }, ) - if (internUiState.isCancelDialogVisibility) { - internUiState.scrapId?.run { - ScrapCancelDialog( - scrapId = this, - onDismissRequest = onDismissCancelDialog - ) - } - } - if (internUiState.isScrapDialogVisibility) { - ScrapDialog( - title = internInfo.title, - scrapColor = CalRed, - deadline = internInfo.deadline, - startDate = internInfo.startDate, - workingPeriod = internInfo.workingPeriod, - companyImage = internInfo.companyImage, - isScrapped = internUiState.isScrappedState, - onDismissRequest = onDismissInternDialog, + if (internUiState.scrapDialogVisibility) { + ScrapCancelDialog( + internshipAnnouncementId = announcementId, + onDismissRequest = onDismissCancelDialog ) } + + if (internUiState.internDialogVisibility) { + internUiState.internshipModel?.let { + ScrapDialog( + title = internUiState.internshipModel.title, + scrapColor = CalRed, + deadline = internUiState.internshipModel.deadline, + startYearMonth = internUiState.internshipModel.startDate, + workingPeriod = internUiState.internshipModel.workingPeriod, + internshipAnnouncementId = announcementId, + companyImage = internUiState.internshipModel.companyImage, + isScrapped = false, + onDismissRequest = onDismissScrapDialog, + onClickChangeColor = { }, + onClickNavigateButton = { } + ) + } + } } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt index 460e980b6..03c8b5b60 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt @@ -1,14 +1,12 @@ package com.terning.feature.intern -import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState -import com.terning.domain.entity.calendar.CalendarScrapRequest +import com.terning.domain.entity.calendar.CalendarScrapDetail +import com.terning.domain.entity.intern.InternInfo import com.terning.domain.repository.InternRepository -import com.terning.domain.repository.ScrapRepository import com.terning.feature.R -import com.terning.feature.intern.model.InternScrapState import com.terning.feature.intern.model.InternUiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow @@ -22,14 +20,11 @@ import javax.inject.Inject @HiltViewModel class InternViewModel @Inject constructor( private val internRepository: InternRepository, - private val scrapRepository: ScrapRepository, ) : ViewModel() { + private val _internUiState = MutableStateFlow(InternUiState()) val internUiState get() = _internUiState.asStateFlow() - private val _scrapState: MutableStateFlow = - MutableStateFlow(InternScrapState()) - private val _sideEffect: MutableSharedFlow = MutableSharedFlow() val sideEffect = _sideEffect.asSharedFlow() @@ -47,76 +42,27 @@ class InternViewModel @Inject constructor( } } - - fun postScrap( - id: Long, - color: Int, - ) { - viewModelScope.launch { - scrapRepository.postScrap( - CalendarScrapRequest(id, color) - ).onSuccess { - _scrapState.update { - it.copy(isScrap = UiState.Success(true)) - } - getInternInfo(id) - updateScrapDialogVisible(false) - _sideEffect.emit( - InternViewSideEffect.Toast(R.string.intern_scrap_add_toast_message) - ) - }.onFailure { - _sideEffect.emit( - InternViewSideEffect.Toast(R.string.server_failure) - ) - } + fun updateInternshipModel(scrapDetailModel: InternInfo?) { + _internUiState.update { currentState -> + currentState.copy( + internshipModel = scrapDetailModel + ) } } - fun deleteScrap( - scrapId: Long?, - announcementId: Long, - ) { - viewModelScope.launch { - scrapId?.let { CalendarScrapRequest(it, null) }?.let { scrapRequestModel -> - scrapRepository.deleteScrap( - scrapRequestModel - ).onSuccess { - _scrapState.update { - it.copy(isScrap = UiState.Success(false)) - } - getInternInfo(announcementId) - updateScrapDialogVisible(false) - _sideEffect.emit(InternViewSideEffect.Toast(R.string.intern_scrap_delete_toast_message)) - }.onFailure { - _sideEffect.emit( - InternViewSideEffect.Toast(R.string.server_failure) - ) - } - } + fun updateScrapCancelDialogVisibility(visibility: Boolean) { + _internUiState.update { currentState -> + currentState.copy( + scrapDialogVisibility = visibility + ) } } - fun updateSelectColor(newColor: Color) { - _internUiState.update { - it.copy(selectedColor = newColor) - } - } - - fun updateScrapDialogVisible(visible: Boolean) { - _internUiState.update { - it.copy(isScrapDialogVisible = visible) - } - } - - fun updatePaletteOpen(open: Boolean) { - _internUiState.update { - it.copy(isPaletteOpen = open) - } - } - - fun updateColorChange(change: Boolean) { - _internUiState.update { - it.copy(isColorChange = change) + fun updateInternDialogVisibility(visibility: Boolean) { + _internUiState.update { currentState -> + currentState.copy( + internDialogVisibility = visibility + ) } } diff --git a/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt b/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt index c1c9ff186..46e7dc7c0 100644 --- a/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt +++ b/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt @@ -24,15 +24,15 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.customShadow import com.terning.core.extension.noRippleClickable +import com.terning.domain.entity.intern.InternInfo import com.terning.feature.R import com.terning.feature.intern.InternViewModel @Composable fun InternBottomBar( modifier: Modifier, - scrapCount: String, - scrapId: Long? = null, - onScrapClick: () -> Unit, + internInfo: InternInfo, + onScrapClick: (InternInfo) -> Unit, viewModel: InternViewModel = hiltViewModel(), ) { @@ -64,7 +64,7 @@ fun InternBottomBar( Icon( painter = painterResource( id = - if (scrapId != null) R.drawable.ic_scrap_true_24 + if (internInfo.scrapId != null) R.drawable.ic_scrap_true_24 else R.drawable.ic_scrap_false_24, ), contentDescription = null, @@ -73,15 +73,15 @@ fun InternBottomBar( bottom = 6.dp ) .noRippleClickable { - onScrapClick() + onScrapClick(internInfo) }, - tint = if (scrapId != null) TerningMain + tint = if (internInfo.scrapId != null) TerningMain else Grey350 ) Text( text = stringResource( id = R.string.intern_view_count_detail, - scrapCount + internInfo.scrapCount ), style = TerningTheme.typography.detail3, color = Grey400 diff --git a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt index cee2e5373..adc01874f 100644 --- a/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt +++ b/feature/src/main/java/com/terning/feature/intern/model/InternUiState.kt @@ -3,18 +3,16 @@ package com.terning.feature.intern.model import androidx.compose.ui.graphics.Color import com.terning.core.designsystem.theme.CalRed import com.terning.core.state.UiState -import com.terning.domain.entity.CalendarScrapDetail import com.terning.domain.entity.intern.InternInfo data class InternUiState( val loadState: UiState = UiState.Loading, val isColorChange: Boolean = false, - val isPaletteOpen: Boolean = false, val selectedColor: Color = CalRed, - val isCancelDialogVisibility: Boolean = false, - val isScrapDialogVisibility: Boolean = false, + val scrapDialogVisibility: Boolean = false, + val internDialogVisibility: Boolean = false, val isScrappedState: Boolean = false, val showWeb: Boolean = false, val scrapId: Long? = null, - val internshipModel: InternInfo? = null + val internshipModel: InternInfo? = null, ) \ No newline at end of file From dc62afde43a27b44128b14ceb5d17ef2f78bf96d Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 10 Sep 2024 04:19:14 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[FIX/#220]=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/search/searchprocess/SearchProcessRoute.kt | 4 ++-- .../feature/search/searchprocess/SearchProcessViewModel.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt index a9db28632..50809694c 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt @@ -50,7 +50,7 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.core.extension.noRippleClickable import com.terning.core.extension.toast -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfo import com.terning.feature.R import com.terning.feature.dialog.cancel.ScrapCancelDialog import com.terning.feature.dialog.detail.ScrapDialog @@ -111,7 +111,7 @@ fun SearchProcessScreen( onDismissCancelDialog: (Boolean) -> Unit, onDismissScrapDialog: () -> Unit, onClickCancelButton: (Long) -> Unit, - onClickScrapButton: (InternInfoModel) -> Unit, + onClickScrapButton: (InternInfo) -> Unit, ) { val state by viewModel.state.collectAsStateWithLifecycle() var sheetState by remember { mutableStateOf(false) } diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt index bb8b7eae3..1ad9daaf8 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt @@ -4,7 +4,7 @@ import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.domain.entity.calendar.CalendarScrapRequest -import com.terning.domain.entity.response.InternInfoModel +import com.terning.domain.entity.intern.InternInfo import com.terning.domain.entity.search.SearchResult import com.terning.domain.repository.ScrapRepository import com.terning.domain.repository.SearchRepository From 435cac66e83384d35dd650267cd91635cb8a3f79 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 10 Sep 2024 04:20:29 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[DEL/#220]=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/search/searchprocess/SearchProcessViewModel.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt index 1ad9daaf8..b8391af88 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt @@ -1,10 +1,7 @@ package com.terning.feature.search.searchprocess -import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.terning.domain.entity.calendar.CalendarScrapRequest -import com.terning.domain.entity.intern.InternInfo import com.terning.domain.entity.search.SearchResult import com.terning.domain.repository.ScrapRepository import com.terning.domain.repository.SearchRepository