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/#155] OurTodo, MyTodo / Empty 뷰 parent fragment로 이동 #161

Merged
merged 8 commits into from
Jan 17, 2024
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object Constants {
const val compileSdk = 34
const val minSdk = 28
const val targetSdk = 34
const val versionCode = 6
const val versionCode = 7
Copy link
Contributor

Choose a reason for hiding this comment

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

skrr 7!

Copy link
Member

Choose a reason for hiding this comment

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

벌써 버전 7~~~~~
가보자가보자

const val versionName = "1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.View
import android.view.ViewTreeObserver
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -57,6 +59,7 @@ class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_m
setViewPagerDebounce()
setTodoCountText()
setToolbarColor()
initEmptyViewHeight()
setEmptyViewHeight()
observeMyTripInfoState()
observeTotalUncompletedTodoCount()
Expand Down Expand Up @@ -171,17 +174,36 @@ class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_m
}
}

private fun initEmptyViewHeight() {
binding.appbarMyTodo.viewTreeObserver.addOnGlobalLayoutListener(object :
ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
binding.appbarMyTodo.viewTreeObserver.removeOnGlobalLayoutListener(this)
val displayHeight = activity?.getWindowHeight() ?: return
val toolbarHeight = binding.toolbarMyTodo.height
val appBarHeight = binding.appbarMyTodo.totalScrollRange
binding.layoutMyTodoEmpty.layoutParams = (binding.layoutMyTodoEmpty.layoutParams).also {
it.height = displayHeight - toolbarHeight - appBarHeight - 300
}
}
})
}

private fun setEmptyViewHeight() {
binding.appbarMyTodo.addOnOffsetChangedListener { appBarLayout, verticalOffset ->
val displayHeight = activity?.getWindowHeight() ?: return@addOnOffsetChangedListener
val toolbarHeight = binding.toolbarMyTodo.height
val appBarHeight = appBarLayout.totalScrollRange + verticalOffset
binding.vpMyTodo.layoutParams = (binding.vpMyTodo.layoutParams).also {
binding.layoutMyTodoEmpty.layoutParams = (binding.layoutMyTodoEmpty.layoutParams).also {
it.height = displayHeight - toolbarHeight - appBarHeight - 300
}
}
}

fun showEmptyView(show: Boolean) {
binding.layoutMyTodoEmpty.isVisible = show
}

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 @@ -104,7 +104,7 @@ class MyTodoCompleteFragment() :

private fun setLayoutEmpty(isEmpty: Boolean) {
binding.rvMyTodoComplete.isVisible = !isEmpty
binding.layoutMyTodoCompleteEmpty.isVisible = isEmpty
(requireParentFragment() as MyTodoFragment).showEmptyView(isEmpty)
}

private fun observeTodoRedoState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MyTodoUncompleteFragment() :

private fun setLayoutEmpty(isEmpty: Boolean) {
binding.rvMyTodoUncomplete.isVisible = !isEmpty
binding.layoutMyTodoUncompleteEmpty.isVisible = isEmpty
(requireParentFragment() as MyTodoFragment).showEmptyView(isEmpty)
}

private fun observeTodoFinishState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -213,12 +214,16 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
val displayHeight = activity?.getWindowHeight() ?: return@addOnOffsetChangedListener
val toolbarHeight = binding.toolbarOurTodo.height
val appBarHeight = appBarLayout.totalScrollRange + verticalOffset
binding.vpOurTodo.layoutParams = (binding.vpOurTodo.layoutParams).also {
binding.layoutOurTodoEmpty.layoutParams = (binding.layoutOurTodoEmpty.layoutParams).also {
it.height = displayHeight - toolbarHeight - appBarHeight - 300
}
}
}

fun showEmptyView(show: Boolean) {
binding.layoutOurTodoEmpty.isVisible = show
}

private fun observeOurTripInfoState() {
viewModel.ourTripInfoState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package com.going.presentation.todo.ourtodo

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.TripParticipantModel
import com.going.presentation.databinding.ItemTodoFriendsBinding
import com.going.ui.extension.ItemDiffCallback

class OurTodoFriendAdapter : ListAdapter<TripParticipantModel, OurTodoFriendViewHolder>(diffUtil) {
class OurTodoFriendAdapter : RecyclerView.Adapter<OurTodoFriendViewHolder>() {

private var itemList = mutableListOf<TripParticipantModel>()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoFriendViewHolder {
val binding: ItemTodoFriendsBinding =
Expand All @@ -16,13 +17,14 @@ class OurTodoFriendAdapter : ListAdapter<TripParticipantModel, OurTodoFriendView
}

override fun onBindViewHolder(holder: OurTodoFriendViewHolder, position: Int) {
holder.onBind(getItem(position))
holder.onBind(itemList[position])
}

companion object {
private val diffUtil = ItemDiffCallback<TripParticipantModel>(
onItemsTheSame = { old, new -> old.participantId == new.participantId },
onContentsTheSame = { old, new -> old == new },
)
override fun getItemCount(): Int = itemList.size

fun submitList(newItems: List<TripParticipantModel>) {
this.itemList.clear()
this.itemList.addAll(newItems)
notifyDataSetChanged()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.going.presentation.todo.ourtodo.OurTodoViewModel.Companion.COMPLETE
import com.going.presentation.todo.ourtodo.OurTodoViewModel.Companion.OUR_TODO
import com.going.presentation.todo.detail.PublicDetailActivity
import com.going.presentation.todo.detail.PublicDetailActivity.Companion.EXTRA_TODO_ID
import com.going.presentation.todo.mytodo.MyTodoFragment
import com.going.presentation.todo.ourtodo.OurTodoFragment
import com.going.ui.base.BaseFragment
import com.going.ui.extension.UiState
Expand Down Expand Up @@ -90,7 +91,7 @@ class OurTodoCompleteFragment() :

private fun setLayoutEmpty(isEmpty: Boolean) {
binding.rvOurTodoComplete.isVisible = !isEmpty
binding.layoutOurTodoCompleteEmpty.isVisible = isEmpty
(requireParentFragment() as OurTodoFragment).showEmptyView(isEmpty)
}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class OurTodoUncompleteFragment() :

private fun setLayoutEmpty(isEmpty: Boolean) {
binding.rvOurTodoUncomplete.isVisible = !isEmpty
binding.layoutOurTodoUncompleteEmpty.isVisible = isEmpty
(requireParentFragment() as OurTodoFragment).showEmptyView(isEmpty)
}

override fun onDestroyView() {
Expand Down
33 changes: 33 additions & 0 deletions presentation/src/main/res/layout/fragment_my_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,39 @@
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_my_todo_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<ImageView
android:id="@+id/iv_my_todo_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_mytodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_my_todo_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/tv_my_todo_empty"
style="@style/TextAppearance.Doorip.Detail1.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_my_todo_empty"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
37 changes: 0 additions & 37 deletions presentation/src/main/res/layout/fragment_my_todo_complete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="23dp"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
Expand All @@ -27,42 +26,6 @@
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_our_todo" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_my_todo_complete_empty"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/iv_my_todo_complete_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_mytodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_my_todo_complete_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/tv_my_todo_complete_empty"
style="@style/TextAppearance.Doorip.Detail1.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_my_todo_complete_empty"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
36 changes: 0 additions & 36 deletions presentation/src/main/res/layout/fragment_my_todo_uncomplete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="23dp"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
Expand All @@ -27,41 +26,6 @@
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_my_todo" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_my_todo_uncomplete_empty"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/iv_my_todo_uncomplete_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_mytodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_my_todo_uncomplete_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/tv_my_todo_uncomplete_empty"
style="@style/TextAppearance.Doorip.Detail1.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_my_todo_uncomplete_empty"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
33 changes: 33 additions & 0 deletions presentation/src/main/res/layout/fragment_our_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,39 @@
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_our_todo_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<ImageView
android:id="@+id/iv_our_todo_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_ourtodo_empty"
app:layout_constraintBottom_toTopOf="@id/tv_our_todo_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/tv_our_todo_empty"
style="@style/TextAppearance.Doorip.Detail1.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_our_todo_empty"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
36 changes: 0 additions & 36 deletions presentation/src/main/res/layout/fragment_our_todo_complete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,6 @@
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_our_todo" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_our_todo_complete_empty"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/iv_our_todo_complete_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />

<TextView
android:id="@+id/tv_our_todo_complete_empty"
style="@style/TextAppearance.Doorip.Detail1.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_our_todo_complete_empty"
app:layout_constraintVertical_chainStyle="packed" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
Loading