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..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.response.InternInfoModel 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(): InternInfoModel { - return InternInfoModel( - 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 new file mode 100644 index 000000000..7e3e8c1e0 --- /dev/null +++ b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt @@ -0,0 +1,23 @@ +package com.terning.data.mapper.intern + +import com.terning.data.dto.response.InternResponseDto +import com.terning.domain.entity.intern.InternInfo + +fun InternResponseDto.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 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..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,15 +1,15 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.InternDataSource -import com.terning.domain.entity.response.InternInfoModel +import com.terning.data.mapper.intern.toInternInfo +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 = - 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 diff --git a/domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt similarity index 84% rename from domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt rename to domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt index 3ad37dbde..77e70f12c 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/InternInfoModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt @@ -1,6 +1,6 @@ -package com.terning.domain.entity.response +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 7a7d85326..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.response.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 bcab1d50e..ef02c79ed 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -4,10 +4,10 @@ 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 -import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -22,16 +22,18 @@ 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 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.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,6 +45,7 @@ import java.text.DecimalFormat @Composable fun InternRoute( announcementId: Long = 0, + modifier: Modifier, viewModel: InternViewModel = hiltViewModel(), navController: NavHostController, ) { @@ -70,9 +73,24 @@ fun InternRoute( is UiState.Failure -> {} is UiState.Success -> { InternScreen( + announcementId = announcementId, internUiState = internState, - internInfoModel = (internState.loadState as UiState.Success).data, - navController = navController + modifier = modifier, + internInfo = (internState.loadState as UiState.Success).data, + navController = navController, + onDismissCancelDialog = { + viewModel.updateScrapCancelDialogVisibility(false) + }, + onDismissScrapDialog = { viewModel.updateInternDialogVisibility(false) }, + onClickCancelButton = { + viewModel.updateScrapCancelDialogVisibility(true) + }, + onClickScrapButton = { + with(viewModel) { + updateInternshipModel(it) + updateInternDialogVisibility(true) + } + } ) } } @@ -80,23 +98,27 @@ fun InternRoute( @Composable fun InternScreen( + announcementId: Long, modifier: Modifier = Modifier, navController: NavHostController, - viewModel: InternViewModel = hiltViewModel(), internUiState: InternUiState, - internInfoModel: InternInfoModel, + internInfo: InternInfo, + onDismissCancelDialog: (Boolean) -> Unit, + onDismissScrapDialog: () -> Unit, + onClickCancelButton: (InternInfo) -> Unit, + onClickScrapButton: (InternInfo) -> Unit, ) { 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,15 +129,18 @@ fun InternScreen( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, ) - loadUrl(internInfoModel.url) + loadUrl(internInfo.url) } }, ) } - Scaffold( - modifier = modifier, - topBar = { + Column( + modifier = modifier.fillMaxHeight(), + ) { + Column( + modifier = Modifier.weight(1f) + ) { BackButtonTopAppBar( title = stringResource(id = R.string.intern_top_app_bar_title), modifier = Modifier.customShadow( @@ -126,119 +151,135 @@ fun InternScreen( navController.popBackStack() }, ) - }, - bottomBar = { - InternBottomBar( - modifier = modifier, - scrapCount = decimal.format(internInfoModel.scrapCount), - scrapId = internInfoModel.scrapId, - onScrapClick = { - viewModel.updateScrapDialogVisible(true) - } - ) - } - ) { paddingValues -> - LazyColumn( - modifier = modifier - .padding(paddingValues) - ) { - 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 = internInfoModel.companyImage, - company = internInfoModel.company, - companyCategory = internInfoModel.companyCategory - ) - Spacer(modifier = modifier.padding(top = 20.dp)) + 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)) - InternTitle( - modifier = modifier, - dDay = internInfoModel.dDay, - title = internInfoModel.title, - viewCount = decimal.format(internInfoModel.viewCount) - ) + InternCompanyInfo( + modifier = Modifier, + companyImage = internInfo.companyImage, + company = internInfo.company, + companyCategory = internInfo.companyCategory + ) - Spacer(modifier = modifier.padding(top = 16.dp)) + Spacer(modifier = Modifier.padding(top = 20.dp)) - InternPageTitle( - modifier = modifier, - text = stringResource(id = R.string.intern_sub_title_intern_summary) - ) + InternTitle( + modifier = Modifier, + dDay = internInfo.dDay, + title = internInfo.title, + viewCount = decimal.format(internInfo.viewCount) + ) - Column( - modifier = modifier.padding( - top = 4.dp, - bottom = 4.dp, - start = 10.dp + Spacer(modifier = Modifier.padding(top = 16.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) - } - } - Spacer(modifier = modifier.padding(top = 16.dp)) + Column( + modifier = Modifier.padding( + top = 4.dp, + bottom = 4.dp, + start = 10.dp + ) + ) { + qualificationList.forEach { (title, value) -> + InternInfoRow(title, value) + } + } - InternPageTitle( - modifier = modifier, - text = stringResource(id = R.string.intern_sub_title_intern_detail) - ) + Spacer(modifier = Modifier.padding(top = 16.dp)) - 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 = internInfoModel.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 + ) + } } } } } } - if (internUiState.isScrapDialogVisible) { - TerningBasicDialog( - onDismissRequest = { - viewModel.updateScrapDialogVisible(false) - }, - content = {}, + InternBottomBar( + modifier = Modifier, + internInfo = internInfo, + onScrapClick = { + if (!internUiState.isScrappedState) + onClickScrapButton(internInfo) + else onClickCancelButton(internInfo) + }, + ) + + + 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/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 16f8afcc3..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,14 +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.response.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, - val isScrapDialogVisible: 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, ) \ No newline at end of file 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 0d30625fa..ce270cd8e 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -167,7 +167,10 @@ fun MainScreen( paddingValues = paddingValues, navHostController = navigator.navController ) - internNavGraph(navHostController = navigator.navController) + internNavGraph( + paddingValues = paddingValues, + navHostController = navigator.navController + ) myPageNavGraph( paddingValues = paddingValues, navHostController = navigator.navController 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..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.response.InternInfoModel import com.terning.domain.entity.search.SearchResult import com.terning.domain.repository.ScrapRepository import com.terning.domain.repository.SearchRepository