Skip to content

Commit 129b0e4

Browse files
committed
[화면수정] 홈화면 로딩 시 PlaceHolder 보여지도록 수정 (Lib : ShimmerEffect)
1 parent 0af4ae9 commit 129b0e4

File tree

8 files changed

+152
-3
lines changed

8 files changed

+152
-3
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id("com.android.application") version ("7.4.1") apply false
3-
id("com.android.library") version ("7.4.1") apply false
2+
id("com.android.application") version ("7.3.1") apply false
3+
id("com.android.library") version ("7.3.1") apply false
44
id("org.jetbrains.kotlin.android") version ("1.8.0") apply false
55

66
// AAC Navigation

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object Dependencies {
1414
private const val VERSION_GSON = "2.10.1"
1515
private const val VERSION_RECYCLER_VIEW = "1.2.1"
1616
private const val VERSION_CARD_VIEW = "1.0.0"
17+
private const val VERSION_SHIMMER_EFFECT = "0.5.0"
1718

1819
const val VERSION_ANDROIDX_NAVIGATION = "2.5.3"
1920
const val VERSION_HILT = "2.45"
@@ -69,4 +70,8 @@ object Dependencies {
6970
const val GSON = "com.google.code.gson:gson:${VERSION_GSON}"
7071
}
7172

73+
object ShimmerEffect {
74+
const val SHIMMER_EFFECT = "com.facebook.shimmer:shimmer:${VERSION_SHIMMER_EFFECT}"
75+
}
76+
7277
}

presentation/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ dependencies {
8888

8989
// CardView
9090
implementation(Dependencies.AndroidX.CARD_VIEW)
91+
92+
// ShimmerEffect
93+
implementation(Dependencies.ShimmerEffect.SHIMMER_EFFECT)
9194
}
9295

9396
// Hilt

presentation/src/main/java/com/gun/presentation/ui/home/HomeFragment.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ class HomeFragment : Fragment() {
6161
homeViewModel.homeUiStateFlow.collect {
6262
when (it) {
6363
is HomeUiState.ShowLoading -> {
64-
// TODO Show Loading
64+
if (it.loadingCount >= 1) { binding.shimmerViewContainer.visibility = View.VISIBLE
65+
binding.shimmerViewContainer.startShimmer()
66+
binding.shimmerViewContainer.visibility = View.VISIBLE
67+
} else {
68+
binding.shimmerViewContainer.visibility = View.GONE
69+
binding.shimmerViewContainer.stopShimmer()
70+
}
6571
}
6672
is HomeUiState.ShowMessage -> {
6773
// TODO Show Message

presentation/src/main/res/layout/fragment_home.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,35 @@
6565
android:layout_marginTop="20dp"
6666
android:orientation="vertical"
6767
android:paddingBottom="20dp"
68+
tools:listitem="@layout/holder_home_list"
6869
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
6970
app:layout_constraintEnd_toEndOf="parent"
7071
app:layout_constraintStart_toStartOf="parent"
7172
app:layout_constraintTop_toBottomOf="@id/dots_indicator" />
7273

74+
<com.facebook.shimmer.ShimmerFrameLayout
75+
android:id="@+id/shimmer_view_container"
76+
style="@style/Base.Size.0_0"
77+
android:visibility="gone"
78+
app:layout_constraintEnd_toEndOf="parent"
79+
app:layout_constraintStart_toStartOf="parent"
80+
app:layout_constraintTop_toTopOf="parent"
81+
app:layout_constraintBottom_toBottomOf="parent">
82+
83+
<LinearLayout
84+
android:layout_width="match_parent"
85+
android:layout_height="match_parent"
86+
android:orientation="vertical">
87+
88+
<include layout="@layout/layout_shimmer_home_banner"/>
89+
90+
<include layout="@layout/layout_shimmer_home_list" />
91+
92+
<include layout="@layout/layout_shimmer_home_list" />
93+
94+
</LinearLayout>
95+
96+
</com.facebook.shimmer.ShimmerFrameLayout>
7397
</androidx.constraintlayout.widget.ConstraintLayout>
7498

7599
</androidx.core.widget.NestedScrollView>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="wrap_content"
5+
xmlns:app="http://schemas.android.com/apk/res-auto">
6+
7+
<View
8+
android:id="@+id/view_shimmer_pager"
9+
style="@style/Base.Size.0_0"
10+
android:background="@color/color_common_shimmer_effect_bg"
11+
app:layout_constraintDimensionRatio="H,6:4"
12+
app:layout_constraintEnd_toEndOf="parent"
13+
app:layout_constraintStart_toStartOf="parent"
14+
app:layout_constraintTop_toTopOf="parent" />
15+
16+
<View
17+
android:id="@+id/view_shimmer_indicator"
18+
android:layout_width="150dp"
19+
android:layout_height="15dp"
20+
android:layout_marginTop="15dp"
21+
android:background="@color/color_common_shimmer_effect_bg"
22+
app:layout_constraintEnd_toEndOf="parent"
23+
app:layout_constraintStart_toStartOf="parent"
24+
app:layout_constraintTop_toBottomOf="@id/view_shimmer_pager"
25+
app:selectedDotColor="@color/color_indicator_active" />
26+
27+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:layout_marginTop="20dp"
7+
xmlns:app="http://schemas.android.com/apk/res-auto">
8+
9+
<View
10+
android:id="@+id/view_name"
11+
android:layout_width="150dp"
12+
android:layout_height="20dp"
13+
android:layout_marginStart="7dp"
14+
android:background="@color/color_common_shimmer_effect_bg"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent"/>
17+
18+
<LinearLayout
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:orientation="horizontal"
22+
app:layout_constraintStart_toStartOf="parent"
23+
app:layout_constraintEnd_toEndOf="parent"
24+
app:layout_constraintTop_toBottomOf="@id/view_name">
25+
26+
<com.google.android.material.card.MaterialCardView
27+
android:layout_width="100dp"
28+
android:layout_height="170dp"
29+
app:cardBackgroundColor="@color/color_common_shimmer_effect_bg"
30+
app:cardCornerRadius="8dp"
31+
app:cardElevation="3dp"
32+
app:cardUseCompatPadding="true"
33+
app:layout_constraintStart_toStartOf="parent"
34+
app:layout_constraintTop_toTopOf="parent"
35+
app:layout_constraintBottom_toTopOf="@id/tv_name"/>
36+
37+
<com.google.android.material.card.MaterialCardView
38+
android:layout_width="100dp"
39+
android:layout_height="170dp"
40+
app:cardBackgroundColor="@color/color_common_shimmer_effect_bg"
41+
app:cardCornerRadius="8dp"
42+
app:cardElevation="3dp"
43+
app:cardUseCompatPadding="true"
44+
app:layout_constraintStart_toStartOf="parent"
45+
app:layout_constraintTop_toTopOf="parent"
46+
app:layout_constraintBottom_toTopOf="@id/tv_name"/>
47+
48+
<com.google.android.material.card.MaterialCardView
49+
android:layout_width="100dp"
50+
android:layout_height="170dp"
51+
app:cardBackgroundColor="@color/color_common_shimmer_effect_bg"
52+
app:cardCornerRadius="8dp"
53+
app:cardElevation="3dp"
54+
app:cardUseCompatPadding="true"
55+
app:layout_constraintStart_toStartOf="parent"
56+
app:layout_constraintTop_toTopOf="parent"
57+
app:layout_constraintBottom_toTopOf="@id/tv_name"/>
58+
59+
<com.google.android.material.card.MaterialCardView
60+
android:layout_width="100dp"
61+
android:layout_height="170dp"
62+
app:cardBackgroundColor="@color/color_common_shimmer_effect_bg"
63+
app:cardCornerRadius="8dp"
64+
app:cardElevation="3dp"
65+
app:cardUseCompatPadding="true"
66+
app:layout_constraintStart_toStartOf="parent"
67+
app:layout_constraintTop_toTopOf="parent"
68+
app:layout_constraintBottom_toTopOf="@id/tv_name"/>
69+
70+
<com.google.android.material.card.MaterialCardView
71+
android:layout_width="100dp"
72+
android:layout_height="170dp"
73+
app:cardBackgroundColor="@color/color_common_shimmer_effect_bg"
74+
app:cardCornerRadius="8dp"
75+
app:cardElevation="3dp"
76+
app:cardUseCompatPadding="true"
77+
app:layout_constraintStart_toStartOf="parent"
78+
app:layout_constraintTop_toTopOf="parent"
79+
app:layout_constraintBottom_toTopOf="@id/tv_name"/>
80+
81+
</LinearLayout>
82+
83+
</androidx.constraintlayout.widget.ConstraintLayout>

presentation/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<color name="color_common_bg_default">#212122</color>
1616
<color name="color_appbar_semi_transparent">#90000000</color>
1717
<color name="color_common_transparent">@android:color/transparent</color>
18+
<color name="color_common_shimmer_effect_bg">#3a3a3a</color>
1819

1920
<color name="color_indicator_active">#FF3636</color>
2021
<color name="color_indicator_default">#C4C4C5</color>

0 commit comments

Comments
 (0)