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

[UI/#191] 공고 상세 뷰 / 2차 UI로 전면 수정 #215

Merged
merged 17 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ val Grey150 = Color(0xFFE9E9E9)
val Grey200 = Color(0xFFDDDDDD)
val Grey300 = Color(0xFFBCBCBC)
val Grey350 = Color(0xFFADADAD)
val Grey375 = Color(0xFF898989)
val Grey400 = Color(0xFF666666)
val Grey500 = Color(0xFF373737)
val Black = Color(0xFF171717)
Expand Down
301 changes: 72 additions & 229 deletions feature/src/main/java/com/terning/feature/intern/InternRoute.kt

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions feature/src/main/java/com/terning/feature/intern/InternViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ 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.InternViewState
import com.terning.feature.intern.model.InternUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
Expand All @@ -25,9 +24,8 @@ class InternViewModel @Inject constructor(
private val internRepository: InternRepository,
private val scrapRepository: ScrapRepository,
) : ViewModel() {
private val _internState: MutableStateFlow<InternViewState> =
MutableStateFlow(InternViewState())
val internState: StateFlow<InternViewState> = _internState.asStateFlow()
private val _internUiState = MutableStateFlow(InternUiState())
val internUiState get() = _internUiState.asStateFlow()

private val _scrapState: MutableStateFlow<InternScrapState> =
MutableStateFlow(InternScrapState())
Expand All @@ -37,20 +35,19 @@ class InternViewModel @Inject constructor(

fun getInternInfo(id: Long) {
viewModelScope.launch {
internRepository.getInternInfo(
id
).onSuccess { internInfo ->
_internState.update {
it.copy(internInfo = UiState.Success(internInfo))
internRepository.getInternInfo(id)
.onSuccess { internInfoModel ->
_internUiState.update { currentState ->
currentState.copy(loadState = UiState.Success(internInfoModel))
}
}
.onFailure {
_sideEffect.emit(InternViewSideEffect.Toast(R.string.server_failure))
}
}.onFailure {
_sideEffect.emit(
InternViewSideEffect.Toast(R.string.server_failure)
)
}
}
}


fun postScrap(
id: Long,
color: Int,
Expand Down Expand Up @@ -100,31 +97,31 @@ class InternViewModel @Inject constructor(
}

fun updateSelectColor(newColor: Color) {
_internState.update {
_internUiState.update {
it.copy(selectedColor = newColor)
}
}

fun updateScrapDialogVisible(visible: Boolean) {
_internState.update {
_internUiState.update {
it.copy(isScrapDialogVisible = visible)
}
}

fun updatePaletteOpen(open: Boolean) {
_internState.update {
_internUiState.update {
it.copy(isPaletteOpen = open)
}
}

fun updateColorChange(change: Boolean) {
_internState.update {
_internUiState.update {
it.copy(isColorChange = change)
}
}

fun updateShowWeb(show: Boolean) {
_internState.update {
_internUiState.update {
it.copy(showWeb = show)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.Grey350
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.feature.R

Expand All @@ -36,70 +36,58 @@ fun InternCompanyInfo(
company: String,
companyCategory: String,
) {
Row(
modifier = modifier.padding(
start = 20.dp,
)
Column(
modifier = Modifier
.fillMaxWidth(),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Column(
verticalArrangement = Arrangement.spacedBy(
2.dp,
Alignment.CenterVertically
),
horizontalAlignment = Alignment.Start,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.size(60.dp)
.border(
width = 1.dp,
color = TerningMain,
shape = RoundedCornerShape(size = 30.dp)
)
) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data(companyImage)
.crossfade(true)
.build(),
contentDescription = stringResource(id = R.string.search_image),
contentScale = ContentScale.Fit,
modifier = modifier
.fillMaxWidth()
.clip(CircleShape),
)
}
}
Column(
verticalArrangement = Arrangement.spacedBy(
3.dp,
Alignment.Bottom
),
horizontalAlignment = Alignment.Start,
modifier = modifier
.padding(
horizontal = 12.dp
)
) {
Text(
text = company,
style = TerningTheme.typography.title4,
color = Black,
modifier = modifier.padding(top = 11.dp),
maxLines = MAX_LINES,
overflow = TextOverflow.Ellipsis
modifier = Modifier
.size(128.dp)
.border(
width = 1.dp,
color = Grey150,
shape = RoundedCornerShape(size = 20.dp)
)
Text(
text = companyCategory,
style = TerningTheme.typography.body4,
color = Grey300,
modifier = modifier.padding(bottom = 6.dp)
) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.crossfade(true)
.data(companyImage)
.build(),
contentDescription = stringResource(id = R.string.search_image),
contentScale = ContentScale.Crop,
modifier = Modifier
.fillMaxWidth()
.clip(CircleShape),
)
}
Column(
verticalArrangement = Arrangement.spacedBy(
4.dp,
Alignment.Bottom
),
horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier
.padding(
Copy link
Member

Choose a reason for hiding this comment

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

이 부분은 불필요한 것 같네요!!
그리고 왜 여기에 인자로 받은 modifier를 사용하신건가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

삭제했습니당!!!1감사해요

)
}
) {
Text(
text = company,
style = TerningTheme.typography.title4,
color = Black,
modifier = modifier.padding(top = 20.dp),
maxLines = MAX_LINES,
overflow = TextOverflow.Ellipsis
)
Text(
text = companyCategory,
style = TerningTheme.typography.body4,
color = Grey350,
modifier = modifier.padding(bottom = 8.dp)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.Grey500
import com.terning.core.designsystem.theme.TerningTheme

@Composable
fun InternInfoRow(title: String, value: String) {
Row(
horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start),
horizontalArrangement = Arrangement.spacedBy(23.dp, Alignment.Start),
verticalAlignment = Alignment.Top,
) {
Text(
text = title,
style = TerningTheme.typography.body2,
color = Black,
color = Grey500,
)
Text(
text = value,
style = TerningTheme.typography.body3,
color = Grey500,
color = Grey400,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
package com.terning.feature.intern.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningSub4
import com.terning.core.designsystem.theme.TerningTheme

@Composable
fun InternPageTitle(
modifier: Modifier,
text: String
text: String,
) {
Row(
modifier = modifier
.height(IntrinsicSize.Min)
.fillMaxWidth()
.padding(
top = 16.dp,
bottom = 16.dp
top = 7.dp,
bottom = 6.dp,
)
.background(TerningSub4)
) {
VerticalDivider(
color = TerningMain,
thickness = 2.dp,
)
Text(
text = text,
style = TerningTheme.typography.title4,
color = TerningMain,
color = Black,
modifier = modifier.padding(
top = 7.dp,
bottom = 6.dp,
start = 20.dp
start = 8.dp
)
)
}
Expand Down
Loading
Loading