Skip to content

Commit

Permalink
Feat/#485 빈화면문구추가 (#492)
Browse files Browse the repository at this point in the history
* feat: 내가 쓴 글 화면에 글이 없다면 문구가 보이도록 구현

* feat: 검색 페이지에 검색된 글이 없다면 문구가 보이도록 구현
- 키보드가 올라와도 텍스트 뷰 위치 동일하도록 함

* chore: 문구 수정

* refactor: 빈 검색어가 입력되었을 경우 문구가 보이도록 수정
  • Loading branch information
Choisehyeon authored Oct 17, 2023
1 parent 92d8152 commit 0ebec08
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
android:exported="true" />
<activity
android:name="com.app.edonymyeon.presentation.ui.main.MainActivity"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.RecyclerView
import app.edonymyeon.databinding.FragmentSearchBinding
Expand All @@ -19,7 +20,6 @@ class SearchFragment : BaseFragment<FragmentSearchBinding, SearchViewModel>({
}) {
override val viewModel: SearchViewModel by viewModels()
override val inflater: LayoutInflater by lazy { LayoutInflater.from(context) }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -41,7 +41,10 @@ class SearchFragment : BaseFragment<FragmentSearchBinding, SearchViewModel>({

binding.rvSearchResult.adapter = searchAdapter
viewModel.searchResult.observe(viewLifecycleOwner) {
searchAdapter.setPosts(it)
binding.tvEmptyPost.isVisible = it.isEmpty()
if (it.isNotEmpty()) {
searchAdapter.setPosts(it)
}
}
}

Expand All @@ -62,6 +65,7 @@ class SearchFragment : BaseFragment<FragmentSearchBinding, SearchViewModel>({
}

override fun onQueryTextChange(newText: String?): Boolean {
if (newText == "") binding.tvEmptyPost.isVisible = false
return true
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import app.edonymyeon.databinding.ActivityMyPostBinding
import com.app.edonymyeon.presentation.common.activity.BaseActivity
Expand Down Expand Up @@ -89,7 +90,10 @@ class MyPostActivity :

private fun setMyPostsObserver() {
viewModel.posts.observe(this) {
adapter.setMyPosts(it)
binding.tvEmptyPost.isVisible = it.isEmpty()
if (it.isNotEmpty()) {
adapter.setMyPosts(it)
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion android/app/src/main/res/layout/activity_my_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/space_my_post_list_top"
tools:listitem="@layout/item_my_post"/>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<TextView
android:id="@+id/tv_empty_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:visibility="gone"
android:textColor="@color/black_434343"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/my_post_empty"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
15 changes: 14 additions & 1 deletion android/app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,18 @@
app:layout_constraintTop_toBottomOf="@id/space_search_container_bottom"
tools:listitem="@layout/item_post" />

<TextView
android:id="@+id/tv_empty_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_empty"
android:textColor="@color/black_434343"
android:textSize="32sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</layout>
6 changes: 5 additions & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<string name="home_edonymyeon">이돈이면</string>
<string name="home_hot_post">HOT 게시물</string>
<string name="home_all_post">전체 게시글</string>
<string name="home_hot_post_not_content">이번 주 핫 게시글이 없습니다</string>
<string name="home_hot_post_not_content">3일간 핫 게시글이 없습니다</string>

<!-- post detail -->
<string name="post_detail_toolbar_menu_update">수정</string>
Expand Down Expand Up @@ -124,6 +124,7 @@
<string name="my_post_createdAt">%s</string>
<string name="my_post_purchase_text">%,d원 구매확정</string>
<string name="my_post_saving_text">절약확정</string>
<string name="my_post_empty">내가 쓴 글이 없습니다</string>

<!-- my_post_dialog -->
<string name="dialog_purchase_title">구매 금액과 날짜를 입력해주세요</string>
Expand Down Expand Up @@ -164,4 +165,7 @@
<string name="profile_update_image_delete">기본 이미지로 변경</string>
<string name="profile_update_nickname_title">닉네임</string>
<string name="profile_update_button_update">수정하기</string>

<!--search fragment -->
<string name="search_empty">검색된 게시글이 없습니다</string>
</resources>

0 comments on commit 0ebec08

Please sign in to comment.