Skip to content

Commit

Permalink
[FEAT/#73] UiState가 Empty일 때의 상태 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 12, 2024
1 parent b2c86da commit 48e7291
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.presentation.dashboard.triplist

import android.os.Bundle
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -54,17 +55,25 @@ class CompletedTripFragment :
private fun observeDashBoardListState() {
viewModel.dashBoardCompletedListState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
is UiState.Success -> adapter.submitList(state.data.trips)
is UiState.Success -> {
setEmptyView(false)
adapter.submitList(state.data.trips)
}

is UiState.Failure -> toast(getString(R.string.server_error))

is UiState.Loading -> return@onEach

is UiState.Empty -> return@onEach
is UiState.Empty -> setEmptyView(true)
}
}.launchIn(lifecycleScope)
}

private fun setEmptyView(isEmpty: Boolean) {
binding.rvDashboardCompletedTrip.isVisible = !isEmpty
binding.layoutDashboardEmpty.isVisible = isEmpty
}


override fun onDestroyView() {
super.onDestroyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.presentation.dashboard.triplist

import android.os.Bundle
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -55,25 +56,32 @@ class OngoingTripFragment :
private fun observeDashBoardListState() {
viewModel.dashBoardOngoingListState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
is UiState.Success -> adapter.submitList(state.data.trips)
is UiState.Success -> {
setEmptyView(false)
adapter.submitList(state.data.trips)
}

is UiState.Failure -> toast(getString(R.string.server_error))

is UiState.Loading -> return@onEach

is UiState.Empty -> return@onEach
is UiState.Empty -> setEmptyView(true)
}
}.launchIn(lifecycleScope)
}

private fun setEmptyView(isEmpty: Boolean) {
binding.rvDashboardOngoingTrip.isVisible = !isEmpty
binding.layoutDashboardEmpty.isVisible = isEmpty
}

override fun onDestroyView() {
super.onDestroyView()
_adapter = null
}

override fun onDashBoardSelectedListener(tripCreate: DashBoardModel.DashBoardTripModel) {
TODO("Not yet implemented")
}

}

}
82 changes: 82 additions & 0 deletions presentation/src/main/res/drawable/ic_empty_dashboard_doorip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="210dp"
android:height="324dp"
android:viewportWidth="210"
android:viewportHeight="324">
<group>
<clip-path
android:pathData="M0,0h210v324h-210z"/>
<path
android:pathData="M61.83,100.46C62.29,98.51 62.53,96.48 62.53,94.39C62.53,79.75 50.66,67.88 36.02,67.88C21.38,67.88 9.52,79.75 9.52,94.39C9.52,108.73 20.91,120.41 35.14,120.88C50.12,138.6 82.96,165.97 115.95,157.27L81.25,110.2C76.57,109.17 67.4,105.97 61.83,100.46Z"
android:fillColor="#F3F3F6"
android:fillType="evenOdd"/>
<group>
<clip-path
android:pathData="M61.83,100.46C62.29,98.51 62.53,96.48 62.53,94.39C62.53,79.75 50.66,67.88 36.02,67.88C21.38,67.88 9.52,79.75 9.52,94.39C9.52,108.73 20.91,120.41 35.14,120.88C50.12,138.6 82.96,165.97 115.95,157.27L81.25,110.2C76.57,109.17 67.4,105.97 61.83,100.46Z"
android:fillType="evenOdd"/>
<path
android:pathData="M61.83,100.46L57.05,99.34L56.42,102.02L58.37,103.96L61.83,100.46ZM35.14,120.88L38.89,117.71L37.48,116.04L35.3,115.97L35.14,120.88ZM115.95,157.27L117.2,162.02L124.2,160.18L119.9,154.36L115.95,157.27ZM81.25,110.2L85.21,107.29L84.11,105.8L82.31,105.4L81.25,110.2ZM57.62,94.39C57.62,96.1 57.42,97.75 57.05,99.34L66.62,101.59C67.16,99.27 67.45,96.86 67.45,94.39H57.62ZM36.02,72.79C47.95,72.79 57.62,82.46 57.62,94.39H67.45C67.45,77.03 53.38,62.96 36.02,62.96V72.79ZM14.43,94.39C14.43,82.46 24.1,72.79 36.02,72.79V62.96C18.67,62.96 4.6,77.03 4.6,94.39H14.43ZM35.3,115.97C23.71,115.59 14.43,106.07 14.43,94.39H4.6C4.6,111.39 18.11,125.24 34.98,125.79L35.3,115.97ZM114.69,152.52C99.9,156.42 84.79,152.32 71.2,144.7C57.62,137.08 46.1,126.24 38.89,117.71L31.38,124.05C39.15,133.24 51.55,144.94 66.39,153.27C81.21,161.59 99.01,166.82 117.2,162.02L114.69,152.52ZM77.3,113.12L111.99,160.19L119.9,154.36L85.21,107.29L77.3,113.12ZM58.37,103.96C64.91,110.43 75.15,113.89 80.2,115L82.31,105.4C77.98,104.45 69.88,101.51 65.29,96.97L58.37,103.96Z"
android:fillColor="#C3C4CE"/>
</group>
<path
android:pathData="M51.41,58.09L3.18,7.28L73.23,6.59L51.41,58.09Z"
android:strokeLineJoin="round"
android:strokeWidth="4.91558"
android:fillColor="#ffffff"
android:strokeColor="#C3C4CE"/>
<path
android:pathData="M74.22,3.74L10.04,154.71"
android:strokeWidth="5.6178"
android:fillColor="#00000000"
android:strokeColor="#C3C4CE"
android:strokeLineCap="round"/>
<path
android:pathData="M45.68,88.45C36.29,92.5 30.57,84.88 28.88,80.56C25.71,83.73 19.9,93.43 22,106.87C24.11,120.3 37.58,114.62 44.06,110.1C48.51,101.2 55.07,84.4 45.68,88.45Z"
android:fillColor="#F3F3F6"/>
<path
android:pathData="M239.59,268.81C196.06,261 165.53,233 154.96,218.63L209.59,197.01C218.73,214.07 262.64,228.55 276.14,232.12C289.65,235.69 285.68,246.21 285.08,248.39C284.58,250.23 279.92,265.38 278.13,272.99C273.28,293.62 271.58,309.16 255.48,308.7C233.39,308.06 235.68,281.84 239.59,268.81Z"
android:fillColor="#F3F3F6"/>
<path
android:pathData="M239.59,268.81C196.06,261 165.53,233 154.96,218.63L209.59,197.01C218.73,214.07 262.64,228.55 276.14,232.12C289.65,235.69 285.68,246.21 285.08,248.39C284.58,250.23 279.92,265.38 278.13,272.99C273.28,293.62 271.58,309.16 255.48,308.7C233.39,308.06 235.68,281.84 239.59,268.81ZM239.59,268.81C244.34,269.67 249.24,270.28 254.29,270.61L239.59,268.81Z"
android:strokeLineJoin="round"
android:strokeWidth="4.91558"
android:fillColor="#00000000"
android:strokeColor="#C3C4CE"/>
<path
android:pathData="M180.54,266.2C180.54,244.6 190.67,220.94 195.73,211.81L249.26,193.36C235.59,220.29 225.84,270.51 220.78,292.06C222.3,319.64 207.68,322.3 201.42,319.64L160.04,301.38C151.11,297.58 140.94,284.11 151.11,270.57C159.52,259.38 177.98,265.52 189.31,272.28L180.54,266.2Z"
android:strokeLineJoin="round"
android:strokeWidth="4.91558"
android:fillColor="#F3F3F6"
android:strokeColor="#C3C4CE"/>
<path
android:pathData="M77.74,114.5C80.17,58.44 127.58,14.97 183.64,17.4C239.7,19.83 283.17,67.24 280.74,123.3C278.31,179.36 230.9,222.83 174.84,220.4C118.78,217.97 75.31,170.55 77.74,114.5Z"
android:strokeWidth="4.91558"
android:fillColor="#F3F3F6"
android:strokeColor="#C3C4CE"/>
<path
android:pathData="M146.85,79.95C149.71,81.24 150.59,85.47 148.82,89.41C147.05,93.34 143.3,95.49 140.44,94.2C137.58,92.91 136.69,88.68 138.46,84.75C140.23,80.81 143.99,78.67 146.85,79.95Z"
android:fillColor="#C3C4CE"/>
<path
android:pathData="M123.24,78.73C126.1,80.02 126.99,84.25 125.21,88.19C123.44,92.12 119.69,94.27 116.83,92.98C113.97,91.69 113.08,87.46 114.85,83.53C116.62,79.59 120.38,77.45 123.24,78.73Z"
android:fillColor="#C3C4CE"/>
<path
android:pathData="M146.15,124.62C137.51,127.08 128.52,122.28 125.69,113.85L157.89,104.69C159.91,113.35 154.79,122.16 146.15,124.62Z"
android:strokeWidth="4.91558"
android:fillColor="#C3C4CE"
android:strokeColor="#C3C4CE"/>
<group>
<clip-path
android:pathData="M146.14,124.62C137.5,127.08 128.51,122.28 125.68,113.85L157.88,104.7C159.91,113.35 154.79,122.16 146.14,124.62Z"/>
<path
android:pathData="M144.78,112.17C156,109.4 166.39,114.81 168.99,123.43L128.58,133.4C126.87,124.56 133.55,114.94 144.78,112.17Z"
android:strokeWidth="4.91558"
android:fillColor="#C3C4CE"
android:strokeColor="#C3C4CE"/>
</group>
<path
android:pathData="M146.25,124.96C137.3,127.5 128,122.44 125.24,113.61L158.14,104.26C160.44,113.21 155.19,122.42 146.25,124.96Z"
android:strokeWidth="4.21335"
android:fillColor="#00000000"
android:strokeColor="#C3C4CE"/>
</group>
</vector>
Binary file not shown.
34 changes: 34 additions & 0 deletions presentation/src/main/res/layout/fragment_completed_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,40 @@
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_dash_board_completed" />

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

<TextView
android:id="@+id/tv_dashboard_empty"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:gravity="center"
android:text="@string/dashboard_tv_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toTopOf="@id/iv_dashboard_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/iv_dashboard_empty"
android:layout_width="210dp"
android:layout_height="324dp"
android:layout_marginBottom="100dp"
android:src="@drawable/ic_empty_dashboard_doorip"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
35 changes: 35 additions & 0 deletions presentation/src/main/res/layout/fragment_ongoing_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,47 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_dash_board_ongoing" />

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

<TextView
android:id="@+id/tv_dashboard_empty"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:gravity="center"
android:text="@string/dashboard_tv_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toTopOf="@id/iv_dashboard_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/iv_dashboard_empty"
android:layout_width="210dp"
android:layout_height="324dp"
android:layout_marginBottom="100dp"
android:src="@drawable/ic_empty_dashboard_doorip"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>

0 comments on commit 48e7291

Please sign in to comment.