Skip to content

Commit

Permalink
[FEAT/#85] 날짜 별 제목 분기처리
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Jan 12, 2024
1 parent d24b7cb commit a43c7b7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.going.data.datasource
import com.going.data.dto.NonDataBaseResponse

interface SettingDataSource {
suspend fun patchSignOut(): NonDataBaseResponse<Any?>
suspend fun patchSignOut(): NonDataBaseResponse

suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
suspend fun deleteWithDraw(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TendencyTestRequestDto

interface TendencyDataSource {
suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse<Any?>
suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import javax.inject.Inject
class SettingDataSourceImpl @Inject constructor(
private val settingService: SettingService,
) : SettingDataSource {
override suspend fun patchSignOut(): NonDataBaseResponse<Any?> = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse<Any?> = settingService.deleteWithDraw()
override suspend fun patchSignOut(): NonDataBaseResponse = settingService.patchSignOut()
override suspend fun deleteWithDraw(): NonDataBaseResponse = settingService.deleteWithDraw()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import javax.inject.Inject
class TendencyDataSourceImpl @Inject constructor(
private val tendencyService: TendencyService,
) : TendencyDataSource {
override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse<Any?> =
override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse =
tendencyService.patchTendencyTest(result)
}
4 changes: 2 additions & 2 deletions data/src/main/java/com/going/data/service/SettingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import retrofit2.http.PATCH

interface SettingService {
@PATCH("api/users/signout")
suspend fun patchSignOut(): NonDataBaseResponse<Any?>
suspend fun patchSignOut(): NonDataBaseResponse

@DELETE("api/users/withdraw")
suspend fun deleteWithDraw(): NonDataBaseResponse<Any?>
suspend fun deleteWithDraw(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface TendencyService {
@PATCH("api/users/test")
suspend fun patchTendencyTest(
@Body result: TendencyTestRequestDto,
): NonDataBaseResponse<Any?>
): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,10 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment

private fun setMyTripInfo() {
// TODO: tripId
val tripId : Long = 1
val tripId: Long = 1
viewModel.getOurTripInfoFromServer(tripId)
}

private fun setDateTextColor() {
binding.tvOurTodoTitleDown.apply {
text = SpannableStringBuilder(text).apply {
setSpan(
ForegroundColorSpan(
ContextCompat.getColor(
requireContext(), R.color.red_500
)
), 6, length - 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
}
}

private fun setTabLayout() {
binding.tabOurTodo.apply {
for (tabName in tabTextList) {
Expand All @@ -109,11 +95,12 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment

is UiState.Success -> {
binding.run {
setTitleTextWithDay(state.data.day)
tvOurTodoTitleUp.text = state.data.title
// TODO: 날짜 분기처리
tvOurTodoTitleDown.text = getString(R.string.our_todo_title_down).format(state.data.day)
setDateTextColor()
tvOurTodoTitleDate.text = getString(R.string.our_todo_date_form).format(convertDate(state.data.startDate), convertDate(state.data.endDate))
tvOurTodoTitleDate.text = getString(R.string.our_todo_date_form).format(
convertDate(state.data.startDate),
convertDate(state.data.endDate)
)
progressBarOurTodo.progress = state.data.progress
tvOurTripInfoPercent.text = state.data.progress.toString() + "%"
adapter.submitList(state.data.participants)
Expand All @@ -132,6 +119,39 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
return getString(R.string.our_todo_day_form).format(splitDate[1], splitDate[2])
}

private fun setTitleTextWithDay(day: Int) {
when {
day > 0 -> {
binding.tvOurTodoTitleDown.text = getString(R.string.our_todo_title_down_before).format(day)
setDateTextColor(6, 6)
}

day == 0 -> {
binding.tvOurTodoTitleDown.text = getString(R.string.our_todo_title_down_during)
setDateTextColor(0, 4)
}

else -> {
binding.tvOurTodoTitleDown.text = getString(R.string.our_todo_title_down_end)
setDateTextColor(4, 5)
}
}
}

private fun setDateTextColor(start: Int, end: Int) {
binding.tvOurTodoTitleDown.apply {
text = SpannableStringBuilder(text).apply {
setSpan(
ForegroundColorSpan(
ContextCompat.getColor(
requireContext(), R.color.red_500
)
), start, length - end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
}
}

override fun onDestroyView() {
super.onDestroyView()
_adapter = null
Expand Down
4 changes: 3 additions & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
<string name="our_todo_tv_trip_friend_title">여행 친구들</string>
<string name="our_todo_btn_invite_friend">초대</string>
<string name="our_todo_btn_add_todo">같이 할일</string>
<string name="our_todo_title_down">여행일까지 %s일 남았어요!</string>
<string name="our_todo_title_down_before">여행일까지 %s일 남았어요!</string>
<string name="our_todo_title_down_during">여행 중이에요!</string>
<string name="our_todo_title_down_end">여행이 완료되었어요!</string>
<string name="our_todo_date_form">%s - %s</string>
<string name="our_todo_day_form">%s월 %s일</string>

Expand Down

0 comments on commit a43c7b7

Please sign in to comment.