Skip to content

Commit

Permalink
[MERGE] #239 -> develop
Browse files Browse the repository at this point in the history
[FIX/#239] ๊ณต๊ณ  ์ƒ์„ธ ๋ทฐ / QA ์ˆ˜์ •์‚ฌํ•ญ ๋ฐ˜์˜
  • Loading branch information
arinming authored Sep 16, 2024
2 parents 2635fb5 + 180f9f3 commit 5c6c360
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ data class InternResponseDto(
val deadline: String,
@SerialName("workingPeriod")
val workingPeriod: String,
@SerialName("startDate")
val startDate: String,
@SerialName("startYearMonth")
val startYearMonth: String,
@SerialName("scrapCount")
val scrapCount: Int,
@SerialName("viewCount")
Expand All @@ -33,6 +33,8 @@ data class InternResponseDto(
val detail: String,
@SerialName("url")
val url: String,
@SerialName("scrapId")
val scrapId: Long? = null,
@SerialName("isScrapped")
val isScrapped: Boolean,
@SerialName("color")
val color: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fun InternResponseDto.toInternInfo(): InternInfo =
title = title,
deadline = deadline,
workingPeriod = workingPeriod,
startDate = startDate,
startYearMonth = startYearMonth,
scrapCount = scrapCount,
viewCount = viewCount,
company = company,
Expand All @@ -19,5 +19,6 @@ fun InternResponseDto.toInternInfo(): InternInfo =
jobType = jobType,
detail = detail,
url = url,
scrapId = scrapId
isScrapped = isScrapped,
color = color,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data class InternInfo(
val title: String,
val deadline: String,
val workingPeriod: String,
val startDate: String,
val startYearMonth: String,
val scrapCount: Int,
val viewCount: Int,
val company: String,
Expand All @@ -15,5 +15,6 @@ data class InternInfo(
val jobType: String,
val detail: String,
val url: String,
val scrapId: Long? = null,
val isScrapped: Boolean,
val color: String? = null,
)
98 changes: 50 additions & 48 deletions feature/src/main/java/com/terning/feature/intern/InternRoute.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.terning.feature.intern

import android.view.ViewGroup
import android.webkit.WebView
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.Text
Expand All @@ -16,7 +18,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.net.toUri
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -27,6 +29,7 @@ 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.designsystem.theme.White
import com.terning.core.extension.customShadow
import com.terning.core.extension.toast
import com.terning.core.state.UiState
Expand All @@ -45,14 +48,12 @@ import java.text.DecimalFormat
@Composable
fun InternRoute(
announcementId: Long = 0,
modifier: Modifier,
viewModel: InternViewModel = hiltViewModel(),
navController: NavHostController,
) {
val internState by viewModel.internUiState.collectAsStateWithLifecycle()

val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val internState by viewModel.internUiState.collectAsStateWithLifecycle(lifecycleOwner)

LaunchedEffect(key1 = true) {
viewModel.getInternInfo(announcementId)
Expand All @@ -75,21 +76,25 @@ fun InternRoute(
InternScreen(
announcementId = announcementId,
internUiState = internState,
modifier = modifier,
internInfo = (internState.loadState as UiState.Success).data,
navController = navController,
onDismissCancelDialog = {
viewModel.updateScrapCancelDialogVisibility(false)
with(viewModel) {
updateScrapCancelDialogVisibility(false)
getInternInfo(announcementId)
}
},
onDismissScrapDialog = {
with(viewModel) {
updateInternDialogVisibility(false)
getInternInfo(announcementId)
}
},
onDismissScrapDialog = { viewModel.updateInternDialogVisibility(false) },
onClickCancelButton = {
viewModel.updateScrapCancelDialogVisibility(true)
},
onClickScrapButton = {
with(viewModel) {
updateInternshipModel(it)
updateInternDialogVisibility(true)
}
viewModel.updateInternDialogVisibility(true)
}
)
}
Expand All @@ -108,35 +113,33 @@ fun InternScreen(
onClickCancelButton: (InternInfo) -> Unit,
onClickScrapButton: (InternInfo) -> Unit,
) {
val context = LocalContext.current

val decimal = DecimalFormat("#,###")

val internInfoList = listOf(
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,
stringResource(id = R.string.intern_info_start_date) to internInfo.startYearMonth,
)

val qualificationList = listOf(
stringResource(id = R.string.intern_recruitment_target) to internInfo.qualification,
stringResource(id = R.string.intern_info_work) to internInfo.jobType,
)

if (internUiState.showWeb) {
AndroidView(
factory = {
WebView(it).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
loadUrl(internInfo.url)
}
},
)
LaunchedEffect(internUiState.showWeb) {
if (internUiState.showWeb) {
CustomTabsIntent.Builder().build().launchUrl(context, internInfo.url.toUri())
}
}

Column(
modifier = modifier.fillMaxHeight(),
modifier = modifier
.statusBarsPadding()
.navigationBarsPadding()
.fillMaxHeight()
.background(White),
) {
Column(
modifier = Modifier.weight(1f)
Expand Down Expand Up @@ -200,7 +203,7 @@ fun InternScreen(
}
}

Spacer(modifier = Modifier.padding(top = 16.dp))
Spacer(modifier = Modifier.padding(top = 13.dp))

InternPageTitle(
modifier = Modifier,
Expand All @@ -219,7 +222,7 @@ fun InternScreen(
}
}

Spacer(modifier = Modifier.padding(top = 16.dp))
Spacer(modifier = Modifier.padding(top = 13.dp))

InternPageTitle(
modifier = Modifier,
Expand Down Expand Up @@ -250,36 +253,35 @@ fun InternScreen(
modifier = Modifier,
internInfo = internInfo,
onScrapClick = {
if (!internUiState.isScrappedState)
if (internInfo.isScrapped) {
onClickCancelButton(internInfo)
} else {
onClickScrapButton(internInfo)
else onClickCancelButton(internInfo)
}
},
)


if (internUiState.scrapDialogVisibility) {
if (internUiState.scrapCancelDialogVisibility) {
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 = { }
)
}
ScrapDialog(
title = internInfo.title,
scrapColor = CalRed,
deadline = internInfo.deadline,
startYearMonth = internInfo.startYearMonth,
workingPeriod = internInfo.workingPeriod,
internshipAnnouncementId = announcementId,
companyImage = internInfo.companyImage,
isScrapped = internInfo.isScrapped,
onDismissRequest = onDismissScrapDialog,
onClickChangeColor = { },
onClickNavigateButton = { }
)
}
}
}
26 changes: 14 additions & 12 deletions feature/src/main/java/com/terning/feature/intern/InternViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.terning.feature.intern
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.terning.core.state.UiState
import com.terning.domain.entity.calendar.CalendarScrapDetail
import com.terning.domain.entity.intern.InternInfo
import com.terning.domain.repository.InternRepository
import com.terning.feature.R
Expand Down Expand Up @@ -32,36 +31,39 @@ class InternViewModel @Inject constructor(
viewModelScope.launch {
internRepository.getInternInfo(id)
.onSuccess { internInfoModel ->
_internUiState.update { currentState ->
currentState.copy(loadState = UiState.Success(internInfoModel))
}
_internUiState.value = _internUiState.value.copy(
loadState = UiState.Success(internInfoModel)
)
}
.onFailure {
.onFailure { exception: Throwable ->
_internUiState.value = _internUiState.value.copy(
loadState = UiState.Failure(exception.toString())
)
_sideEffect.emit(InternViewSideEffect.Toast(R.string.server_failure))
}
}
}

fun updateInternshipModel(scrapDetailModel: InternInfo?) {
fun updateScrapCancelDialogVisibility(visibility: Boolean) {
_internUiState.update { currentState ->
currentState.copy(
internshipModel = scrapDetailModel
scrapCancelDialogVisibility = visibility,
)
}
}

fun updateScrapCancelDialogVisibility(visibility: Boolean) {
fun updateInternDialogVisibility(visibility: Boolean) {
_internUiState.update { currentState ->
currentState.copy(
scrapDialogVisibility = visibility
internDialogVisibility = visibility
)
}
}

fun updateInternDialogVisibility(visibility: Boolean) {
fun updateInternshipModel(scrapDetailModel: InternInfo?) {
_internUiState.update { currentState ->
currentState.copy(
internDialogVisibility = visibility
internshipModel = scrapDetailModel
)
}
}
Expand All @@ -71,4 +73,4 @@ class InternViewModel @Inject constructor(
it.copy(showWeb = show)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.terning.core.extension.noRippleClickable
import com.terning.domain.entity.intern.InternInfo
import com.terning.feature.R
import com.terning.feature.intern.InternViewModel
import com.terning.feature.intern.model.InternUiState

@Composable
fun InternBottomBar(
Expand All @@ -35,7 +36,6 @@ fun InternBottomBar(
onScrapClick: (InternInfo) -> Unit,
viewModel: InternViewModel = hiltViewModel(),
) {

Row(
modifier = modifier
.fillMaxWidth()
Expand Down Expand Up @@ -63,20 +63,19 @@ fun InternBottomBar(
) {
Icon(
painter = painterResource(
id =
if (internInfo.scrapId != null) R.drawable.ic_scrap_true_24
else R.drawable.ic_scrap_false_24,
id = if (internInfo.isScrapped) {
R.drawable.ic_scrap_true_24
} else {
R.drawable.ic_scrap_false_24
}
),
contentDescription = null,
modifier = modifier
.padding(
bottom = 6.dp
)
.padding(bottom = 6.dp)
.noRippleClickable {
onScrapClick(internInfo)
},
tint = if (internInfo.scrapId != null) TerningMain
else Grey350
tint = if (internInfo.isScrapped) TerningMain else Grey350
)
Text(
text = stringResource(
Expand All @@ -99,4 +98,4 @@ fun InternBottomBar(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package com.terning.feature.intern.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.Grey500
Expand All @@ -13,6 +15,7 @@ import com.terning.core.designsystem.theme.TerningTheme
@Composable
fun InternInfoRow(title: String, value: String) {
Row(
modifier = Modifier.padding(bottom = 3.dp),
horizontalArrangement = Arrangement.spacedBy(23.dp, Alignment.Start),
verticalAlignment = Alignment.Top,
) {
Expand Down
Loading

0 comments on commit 5c6c360

Please sign in to comment.