Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#239] 공고 상세 뷰 / QA 수정사항 반영 #249

Merged
merged 10 commits into from
Sep 16, 2024
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 아린언니 브렌치 들어가서 돌려봤는데 실기기 문제인 것 같아요..! 공기계로 돌려보니 안 뜨더라구요ㅜㅜ

130번째 줄에 아래와 같이 수정하면 웹 뷰 잘 뜨는 것 같습니당..!
확인부탁드려요!

val context = LocalContext.current

if (internUiState.showWeb) {
    CustomTabsIntent.Builder().build().launchUrl(context,internInfo.url.toUri())
}

Copy link
Member

@leeeyubin leeeyubin Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가로.. 제가 말한대로 작성 시 백버튼 눌렀을 때 다시 웹 뷰가 뜨는 이슈가 있는 것 같은데,, 저도 정확히 보지 않아서 뭐가 문제인지 확실하진 않지만,, 이 부분은 MyPageRoute 한번 참고해보면 좋을 것 같아요..!

Copy link
Contributor Author

@arinming arinming Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새삼스럽지만 사랑합니다 ㅜㅜ
수정했는데, 실기기에서 잘 동작하는지 확인해주심 감사 🥹

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니당 잘 동작하네요!! 수고했어요!!🙂 @arinming

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),
Comment on lines 137 to +142
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 넘 좋아요!!!

) {
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
Loading