When nothing is entered display so
This commit is contained in:
		@@ -50,7 +50,7 @@ class PokeSearchViewModel : ViewModel() {
 | 
			
		||||
            try {
 | 
			
		||||
                val response = service.getPokemonSpecies()
 | 
			
		||||
                _initialPokemonList.value = response.results
 | 
			
		||||
                _filteredPokemonList.value = response.results.take(SHOW_LIMIT)
 | 
			
		||||
                _filteredPokemonList.value = listOf(PokemonSpecies("Please enter a search term", ""));
 | 
			
		||||
            } catch (e: IOException) {
 | 
			
		||||
                /*TODO*/
 | 
			
		||||
            }
 | 
			
		||||
@@ -63,7 +63,7 @@ class PokeSearchViewModel : ViewModel() {
 | 
			
		||||
            val filteredList = initialPokemonList.filter { it.name.contains(query, ignoreCase = true) }
 | 
			
		||||
            _filteredPokemonList.value = filteredList.take(SHOW_LIMIT);
 | 
			
		||||
        } else {
 | 
			
		||||
            _filteredPokemonList.value = initialPokemonList?.take(SHOW_LIMIT);
 | 
			
		||||
            _filteredPokemonList.value = listOf(PokemonSpecies("Please enter a search term", ""));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -42,14 +42,16 @@ fun PokeSearch(pokeSearchViewModel: PokeSearchViewModel) {
 | 
			
		||||
 | 
			
		||||
        Spacer(modifier = Modifier.height(16.dp))
 | 
			
		||||
 | 
			
		||||
        searchResults?.let { results ->
 | 
			
		||||
            if (results.isNotEmpty()) {
 | 
			
		||||
                results.forEach { pokemon ->
 | 
			
		||||
        if (searchResults != null) {
 | 
			
		||||
            if (searchResults!!.isNotEmpty()) {
 | 
			
		||||
                searchResults!!.forEach { pokemon ->
 | 
			
		||||
                    Text(text = pokemon.name)
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                Text("No results found")
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            Text("Enter a pokemon name to search")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user