Skip to content

Commit

Permalink
Merge pull request #80 from team-JMT/feat/search_status_icon_and_text
Browse files Browse the repository at this point in the history
맛집 등록 전 검색 페이지 상태에 따른 아이콘, 문구 적용
  • Loading branch information
dogdduddy authored Sep 25, 2023
2 parents c3282fe + a66f2f5 commit d5dea5d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.DrawableRes
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
Expand Down Expand Up @@ -62,6 +63,9 @@ class SearchRestaurantLocationInfoFragment : Fragment() {

setSearchEditTextDebounceWatcher {
if (binding.restaurantNameEditText.text.isNotEmpty()) {

setVisibleStatusContainer(false)

viewLifecycleOwner.lifecycleScope.launch {
val currentLocation = viewModel.getCurrentLocation()

Expand All @@ -70,19 +74,37 @@ class SearchRestaurantLocationInfoFragment : Fragment() {
val response =
viewModel.getRestaurantLocationInfo(
binding.restaurantNameEditText.text,
currentLocation.latitude.toString(), currentLocation.longitude.toString(), 1
currentLocation.latitude.toString(),
currentLocation.longitude.toString(),
1
)

// TODO: Error Handling
adapter.setTargetString(binding.restaurantNameEditText.text)
adapter.submitList(response)
if (response.isNotEmpty()) {
// TODO: Error Handling
adapter.setTargetString(binding.restaurantNameEditText.text)
adapter.submitList(response)
} else {
setVisibleStatusContainer(true)
setStatusImage(R.drawable.jmt_normal_character)
setStatusContainerText(getString(R.string.no_searched_result))
adapter.submitList(emptyList())
}


} else {
JmtSnackbar.make(binding.root, getString(R.string.get_location_error), Snackbar.LENGTH_SHORT)
JmtSnackbar.make(
binding.root,
getString(R.string.get_location_error),
Snackbar.LENGTH_SHORT
)
.setTextColor(R.color.unable_nickname_color).show()
}

}
} else {
setVisibleStatusContainer(true)
setStatusImage(R.drawable.jmt_wink_character)
setStatusContainerText(getString(R.string.search_for_recommendable_restaurant))
adapter.submitList(emptyList())
}

Expand Down Expand Up @@ -113,4 +135,16 @@ class SearchRestaurantLocationInfoFragment : Fragment() {
private fun setToolbarTitle() {
(requireActivity() as MainActivity).changeToolbarTitle("맛집등록")
}

private fun setVisibleStatusContainer(isVisible: Boolean) {
binding.statusContainer.visibility = if (isVisible) View.VISIBLE else View.GONE
}

private fun setStatusImage(@DrawableRes imageResId: Int) {
binding.statusImage.setImageResource(imageResId)
}

private fun setStatusContainerText(text: String) {
binding.statusText.text = text
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,27 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".view.restaurantregistration.SearchRestaurantLocationInfoFragment">

<org.gdsc.presentation.view.custom.JmtSearchEditText
android:id="@+id/restaurant_name_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:paddingBottom="16dp"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/restaurant_info_recycler_view"
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_toBottomOf="@id/restaurant_name_edit_text" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/status_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/restaurant_name_edit_text"
app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/status_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/jmt_wink_character"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/search_for_recommendable_restaurant"
android:textAlignment="center"
android:textAppearance="@style/text_large_bold"
android:textColor="@color/grey300"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_image"
android:layout_marginTop="16dp"
>

</TextView>

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@

<string name="service_not_yet">앗, 서비스 준비 중이에요!\n &#160;&#160;조금만 기다려주세요.</string>
<string name="jmt_character_image">존마탱 캐릭터 이미지</string>
<string name="search_for_recommendable_restaurant">추천 해주고 싶은\n 맛집을 검색해주세요!</string>
<string name="no_searched_result">검색 결과가 없어요.\n올바른 식당명인지 확인해주세요.</string>

</resources>

0 comments on commit d5dea5d

Please sign in to comment.