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/#140] OurTodo, MyTodo / 투두 스티키 헤더 상태에 따른 탭바 색상 전환 #147

Merged
merged 8 commits into from
Jan 16, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.going.domain.entity

enum class CodeState {
Empty, Success, Blank, Invalid
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ data class PreferenceData(
val question : String,
val rightPrefer: String,
val leftPrefer : String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data class EnterPreferenceRequestModel(
val styleC: Int,
val styleD: Int,
val styleE: Int
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ data class TodoCreateRequestModel(
val allocators: List<Long>,
val memo: String?,
val secret: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ data class CheckFriendsModel(
val rate: Int,
val isLeft: Boolean
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ data class DashBoardModel(
val endDate: String,
val day: Int
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ data class MockFollowerModel(
val name: String,
val email: String,
val image: String
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ data class MyTripInfoModel(
val participantId: Long,
val title: String,
val count: Int
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data class OurTripInfoModel(
val code: String,
val isComplete: Boolean,
val participants: List<TripParticipantModel>
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.going.domain.entity.response
data class TodoAllocatorModel(
val name: String,
val isOwner: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ data class TodoDetailModel(
val allocators: List<TodoAllocatorModel>,
val memo: String,
val secret: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ data class TodoModel(
val endDate: String,
val allocators: List<TodoAllocatorModel>,
val secret: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ data class TripParticipantModel(
val name: String,
val result: Int,
var isSelected: Boolean = false
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ data class TripParticipantsListModel(
val styleC: Int,
val styleD: Int,
val styleE: Int,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.going.domain.entity.CodeState
import com.going.presentation.R
import com.going.presentation.databinding.ActivityEnterTripBinding
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripViewModel.Companion.ERROR_NO_EXIST
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripViewModel.Companion.ERROR_OVER_SIX
import com.going.ui.base.BaseActivity
import com.going.ui.extension.UiState
import com.going.ui.extension.setOnSingleClickListener
Expand Down Expand Up @@ -95,10 +97,12 @@ class EnterTripActivity : BaseActivity<ActivityEnterTripBinding>(R.layout.activi
}

is UiState.Failure -> {
if (state.msg == getString(R.string.profile_tv_no_trip)) {
toast(getString(R.string.enter_trip_invite_code_error))
} else {
toast(getString(R.string.server_error))
when (state.msg) {
ERROR_NO_EXIST -> toast(getString(R.string.enter_trip_invite_code_exist_error))

ERROR_OVER_SIX -> toast(getString(R.string.enter_trip_invite_code_over_error))

else -> toast(getString(R.string.server_error))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ class EnterTripViewModel @Inject constructor(
}.onFailure { throwable ->
if (throwable is HttpException) {
val errorResponse = throwable.response()?.errorBody()?.string()
val jsonObject = JSONObject(errorResponse)
val jsonObject = JSONObject(errorResponse.orEmpty())
val errorCode = jsonObject.getString("code")
val errorMessage = jsonObject.getString("message")

if (errorCode == ERROR_CODE) {
_tripState.value = UiState.Failure(errorMessage)
} else {
_tripState.value = UiState.Failure(throwable.message.orEmpty())
}
_tripState.value = UiState.Failure(errorCode)
}
}
}
Expand All @@ -77,6 +71,7 @@ class EnterTripViewModel @Inject constructor(
private const val ENG_NUM_PATTERN = "^[a-z0-9]*$"
val ENG_NUM_REGEX: Pattern = Pattern.compile(ENG_NUM_PATTERN)
const val MAX_INVITE_LEN = 6
const val ERROR_CODE = "e4043"
const val ERROR_NO_EXIST = "e4043"
const val ERROR_OVER_SIX = "e4006"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import com.going.presentation.profile.ProfileActivity
import com.going.presentation.todo.TodoActivity.Companion.EXTRA_TRIP_ID
import com.going.presentation.todo.mytodo.create.MyTodoCreateActivity
import com.going.presentation.todo.mytodo.todolist.MyTodoViewPagerAdapter
import com.going.presentation.todo.ourtodo.OurTodoFragment
import com.going.presentation.todo.ourtodo.OurTodoFragment.Companion.debounceTime
import com.going.presentation.todo.ourtodo.create.OurTodoCreateActivity.Companion.EXTRA_PARTICIPANT_ID
import com.going.ui.base.BaseFragment
import com.going.ui.extension.UiState
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.setStatusBarColor
import com.going.ui.extension.toast
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlin.math.abs

@AndroidEntryPoint
class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_my_todo) {
Expand All @@ -53,6 +54,7 @@ class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_m
setViewPagerChangeListener()
setViewPagerDebounce()
setTodoCountText()
setToolbarColor()
observeMyTripInfoState()
observeTotalUncompletedTodoCount()

Expand Down Expand Up @@ -146,6 +148,26 @@ class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_m
setTodoCount(viewModel.totalUncompletedTodoCount.value)
}

private fun setToolbarColor() {
binding.appbarMyTodo.addOnOffsetChangedListener { appBarLayout, verticalOffset ->
if (abs(verticalOffset) == appBarLayout.totalScrollRange) {
setStatusBarColor(R.color.white_000)
binding.toolbarMyTodo.setBackgroundColor(
ContextCompat.getColor(
requireContext(), R.color.white_000
)
)
} else {
setStatusBarColor(R.color.gray_50)
binding.toolbarMyTodo.setBackgroundColor(
ContextCompat.getColor(
requireContext(), R.color.gray_50
)
)
}
}
}

private fun observeMyTripInfoState() {
viewModel.myTripInfoState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class MyTodoViewModel @Inject constructor(
fun resetListState() {
_todoCompleteListState.value = UiState.Empty
_todoUncompleteListState.value = UiState.Empty
_todoFinishState.value = EnumUiState.EMPTY
_todoRedoState.value = EnumUiState.EMPTY
}

fun getToFinishTodoFromServer(todoId: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ import com.going.presentation.todo.ourtodo.todolist.OurTodoViewPagerAdapter
import com.going.ui.base.BaseFragment
import com.going.ui.extension.UiState
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.setStatusBarColor
import com.going.ui.extension.toast
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlin.math.abs

@AndroidEntryPoint
class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment_our_todo) {
Expand All @@ -52,8 +54,6 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment

private var participantList = listOf<TripParticipantModel>()

private var lastClickTime = 0L

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand All @@ -68,6 +68,7 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
setViewPager()
setViewPagerChangeListener()
setViewPagerDebounce()
setToolbarColor()
observeOurTripInfoState()
}

Expand Down Expand Up @@ -178,6 +179,26 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
}, debounceTime)
}

private fun setToolbarColor() {
binding.appbarOurTodo.addOnOffsetChangedListener { appBarLayout, verticalOffset ->
if (abs(verticalOffset) == appBarLayout.totalScrollRange) {
setStatusBarColor(R.color.white_000)
binding.toolbarOurTodo.setBackgroundColor(
ContextCompat.getColor(
requireContext(), R.color.white_000
)
)
} else {
setStatusBarColor(R.color.gray_50)
binding.toolbarOurTodo.setBackgroundColor(
ContextCompat.getColor(
requireContext(), R.color.gray_50
)
)
}
}
}

private fun observeOurTripInfoState() {
viewModel.ourTripInfoState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
Expand All @@ -188,8 +209,7 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
setTitleTextWithDay(state.data.day)
tvOurTodoTitleUp.text = state.data.title
tvOurTodoTitleDate.text = getString(R.string.our_todo_date_form).format(
convertDate(state.data.startDate),
convertDate(state.data.endDate)
convertDate(state.data.startDate), convertDate(state.data.endDate)
)
progressBarOurTodo.progress = state.data.progress
tvOurTripInfoPercent.text = state.data.progress.toString() + "%"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center"
android:fontFamily="@font/font_pretendard_bold"
android:paddingVertical="3dp"
android:text="@string/todo_invite_tv_subtitle"
Expand Down
7 changes: 4 additions & 3 deletions presentation/src/main/res/layout/fragment_our_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@

<ImageView
android:id="@+id/iv_our_todo_title_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1"
android:paddingVertical="8dp"
android:src="@drawable/ic_calendar"
app:layout_constraintBottom_toBottomOf="@id/tv_our_todo_title_date"
app:layout_constraintStart_toStartOf="@id/tv_our_todo_title_up"
Expand All @@ -109,7 +111,6 @@
style="@style/TextAppearance.Doorip.Body1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="24dp"
android:textColor="@color/gray_300"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:id="@+id/iv_our_todo_complete_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_mytodo_empty"
android:src="@drawable/img_ourtodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_our_todo_complete_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:id="@+id/iv_our_todo_uncomplete_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_mytodo_empty"
android:src="@drawable/img_ourtodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_our_todo_uncomplete_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
7 changes: 4 additions & 3 deletions presentation/src/main/res/layout/item_my_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
<TextView
android:id="@+id/tv_my_todo_item_title"
style="@style/TextAppearance.Doorip.Body3.Medi"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginTop="16dp"
android:textColor="@color/gray_700"
app:layout_constraintEnd_toStartOf="@id/tv_my_todo_item_date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="숙소 예약금 걸기" />
Expand All @@ -48,11 +49,11 @@
style="@style/TextAppearance.Doorip.Detail3.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:textColor="@color/gray_300"
app:layout_constraintBottom_toBottomOf="@id/tv_my_todo_item_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_my_todo_item_title"
tools:text="2023.09.23까지" />

<androidx.recyclerview.widget.RecyclerView
Expand Down
7 changes: 4 additions & 3 deletions presentation/src/main/res/layout/item_our_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
<TextView
android:id="@+id/tv_our_todo_item_title"
style="@style/TextAppearance.Doorip.Body3.Medi"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toStartOf="@id/tv_our_todo_item_date"
android:textColor="@color/gray_700"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -25,11 +26,11 @@
style="@style/TextAppearance.Doorip.Detail3.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:textColor="@color/gray_300"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_our_todo_item_title"
app:layout_constraintBottom_toBottomOf="@id/tv_our_todo_item_title"
tools:text="2023.09.23까지" />

<androidx.recyclerview.widget.RecyclerView
Expand Down
Loading