From d014ad4cb2ebc2b4f5d3c116ced8fd3f35022885 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 25 Mar 2024 17:40:31 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B2=84=ED=8A=BC=20=ED=81=B4=EB=A6=AD?= =?UTF-8?q?=20=EC=8B=9C=20=EA=B2=80=EC=83=89=EC=96=B4=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/search/SearchFragment.kt | 18 ++++++++++++--- .../screen/ArtistSearchScreenViewHolder.kt | 13 +++++++++-- .../screen/FestivalSearchScreenViewHolder.kt | 7 ++++++ .../search/screen/ItemSearchScreenUiState.kt | 22 +++++++++++++------ .../screen/SchoolSearchScreenViewHolder.kt | 13 +++++++++-- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchFragment.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchFragment.kt index c32ca5278..069511de6 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchFragment.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchFragment.kt @@ -1,6 +1,8 @@ package com.festago.festago.presentation.ui.search import android.content.Context +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.KeyEvent import android.view.LayoutInflater @@ -152,9 +154,9 @@ class SearchFragment : Fragment() { private fun handleSuccessSearch(uiState: SearchUiState.SearchSuccess) { searchScreenAdapter.submitList( listOf( - FestivalSearchScreen(uiState.searchedFestivals), - ArtistSearchScreen(uiState.searchedArtists), - SchoolSearchScreen(uiState.searchedSchools), + FestivalSearchScreen(uiState.searchedFestivals, ::requestAddSearchQuery), + ArtistSearchScreen(uiState.searchedArtists, ::requestAddSearchQuery), + SchoolSearchScreen(uiState.searchedSchools, ::requestAddSearchQuery), ), ) initSearchTab() @@ -206,6 +208,16 @@ class SearchFragment : Fragment() { } } + private fun requestAddSearchQuery() { + startBrowser("https://forms.gle/y17dmCFw1jAYLR9H7") + } + + private fun startBrowser(url: String) { + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse(url) + startActivity(intent) + } + override fun onDestroyView() { _binding = null super.onDestroyView() diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ArtistSearchScreenViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ArtistSearchScreenViewHolder.kt index 02349daf7..fe9233a74 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ArtistSearchScreenViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ArtistSearchScreenViewHolder.kt @@ -18,8 +18,17 @@ class ArtistSearchScreenViewHolder( fun bind(item: ItemSearchScreenUiState.ArtistSearchScreen) { artistSearchAdapter.submitList(item.artistSearches) - binding.tvNoResult.visibility = - if (item.artistSearches.isEmpty()) View.VISIBLE else View.GONE + setNoResultVisibility(item) + binding.btnFestago.setOnClickListener { + item.onAddSearchQueryClick() + } + } + + private fun setNoResultVisibility(item: ItemSearchScreenUiState.ArtistSearchScreen) { + val visibility = if (item.artistSearches.isEmpty()) View.VISIBLE else View.GONE + binding.tvNoResult.visibility = visibility + binding.tvNoResultGuide.visibility = visibility + binding.btnFestago.visibility = visibility } companion object { diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/FestivalSearchScreenViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/FestivalSearchScreenViewHolder.kt index 7912ca714..eb33d7c81 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/FestivalSearchScreenViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/FestivalSearchScreenViewHolder.kt @@ -18,6 +18,13 @@ class FestivalSearchScreenViewHolder( fun bind(item: ItemSearchScreenUiState.FestivalSearchScreen) { festivalSearchAdapter.submitList(item.festivalSearches) + setNoResultVisibility(item) + binding.btnFestago.setOnClickListener { + item.onAddSearchQueryClick() + } + } + + private fun setNoResultVisibility(item: ItemSearchScreenUiState.FestivalSearchScreen) { val visibility = if (item.festivalSearches.isEmpty()) View.VISIBLE else View.GONE binding.tvNoResult.visibility = visibility binding.tvNoResultGuide.visibility = visibility diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ItemSearchScreenUiState.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ItemSearchScreenUiState.kt index c82fef343..78a886270 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ItemSearchScreenUiState.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/ItemSearchScreenUiState.kt @@ -4,15 +4,23 @@ import com.festago.festago.presentation.ui.search.uistate.ArtistSearchItemUiStat import com.festago.festago.presentation.ui.search.uistate.FestivalSearchItemUiState import com.festago.festago.presentation.ui.search.uistate.SchoolSearchItemUiState -sealed class ItemSearchScreenUiState(val screenPosition: Int) { - data class FestivalSearchScreen(val festivalSearches: List) : - ItemSearchScreenUiState(FESTIVAL_POSITION) +sealed class ItemSearchScreenUiState( + val screenPosition: Int, +) { + data class FestivalSearchScreen( + val festivalSearches: List, + val onAddSearchQueryClick: () -> Unit = {}, + ) : ItemSearchScreenUiState(FESTIVAL_POSITION) - data class ArtistSearchScreen(val artistSearches: List) : - ItemSearchScreenUiState(ARTIST_POSITION) + data class ArtistSearchScreen( + val artistSearches: List, + val onAddSearchQueryClick: () -> Unit = {}, + ) : ItemSearchScreenUiState(ARTIST_POSITION) - data class SchoolSearchScreen(val schoolSearches: List) : - ItemSearchScreenUiState(SCHOOL_POSITION) + data class SchoolSearchScreen( + val schoolSearches: List, + val onAddSearchQueryClick: () -> Unit = {}, + ) : ItemSearchScreenUiState(SCHOOL_POSITION) companion object { const val FESTIVAL_POSITION = 0 diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/SchoolSearchScreenViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/SchoolSearchScreenViewHolder.kt index 12984d979..8702fa879 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/SchoolSearchScreenViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/screen/SchoolSearchScreenViewHolder.kt @@ -16,8 +16,17 @@ class SchoolSearchScreenViewHolder(private val binding: ItemSchoolSearchScreenBi fun bind(item: ItemSearchScreenUiState.SchoolSearchScreen) { schoolSearchAdapter.submitList(item.schoolSearches) - binding.tvNoResult.visibility = - if (item.schoolSearches.isEmpty()) View.VISIBLE else View.GONE + setNoResultVisibility(item) + binding.btnFestago.setOnClickListener { + item.onAddSearchQueryClick() + } + } + + private fun setNoResultVisibility(item: ItemSearchScreenUiState.SchoolSearchScreen) { + val visibility = if (item.schoolSearches.isEmpty()) View.VISIBLE else View.GONE + binding.tvNoResult.visibility = visibility + binding.tvNoResultGuide.visibility = visibility + binding.btnFestago.visibility = visibility } companion object {