Skip to content

Commit

Permalink
Merge pull request #851 from smart-village-solutions/feature/SVA-833-…
Browse files Browse the repository at this point in the history
…hide-results-based-on-input-data

feat: hide results based on input data
  • Loading branch information
ardasnturk authored Jun 26, 2023
2 parents 7a038c6 + 79426f8 commit 9bc9534
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/screens/WasteCollectionScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ export const WasteCollectionScreen = ({ navigation }) => {

const filteredCities = wasteAddressesTwoStep ? filterCities(inputValueCity, addressesData) : [];
const filteredStreets = filterStreets(inputValue, addressesData, inputValueCity);
/**
* The variable `isStreetResultsHidden` indicates whether the street results should be hidden based
* on the focused state of the street input and the auto-focus configuration, considering the presence
* of input value; it is set to `true` if the conditions are met, indicating that the street results
* should be hidden.
*/
const isStreetResultsHidden = !(
isStreetInputFocused &&
((!isInputAutoFocus && inputValue) || isInputAutoFocus)
);

return (
<SafeAreaViewFlex>
Expand All @@ -337,20 +347,17 @@ export const WasteCollectionScreen = ({ navigation }) => {
data={filteredCities}
disableFullscreenUI
flatListProps={{
renderItem: inputValueCitySelected ? null : renderSuggestionCities,
height: dimensions.height - normalize(170)
height: dimensions.height - normalize(170),
keyboardShouldPersistTaps: 'handled',
renderItem: inputValueCitySelected ? null : renderSuggestionCities
}}
listStyle={styles.autoCompleteList}
onChangeText={(text) => {
setInputValueCitySelected(false);
setSelectedStreetId(undefined);
setInputValueCity(text);
}}
onFocus={() => {
if (isInputAutoFocus) {
setIsStreetInputFocused(false);
}
}}
onFocus={() => setIsStreetInputFocused(false)}
placeholder="Ortschaft"
style={styles.autoCompleteInput}
value={inputValueCity}
Expand All @@ -365,16 +372,15 @@ export const WasteCollectionScreen = ({ navigation }) => {
data={filteredStreets}
disableFullscreenUI
flatListProps={{
renderItem: renderSuggestion,
height: dimensions.height - normalize(220)
height: dimensions.height - normalize(220),
keyboardShouldPersistTaps: 'handled',
renderItem: renderSuggestion
}}
hideResults={isStreetResultsHidden}
listStyle={styles.autoCompleteList}
onChangeText={(text) => setInputValue(text)}
onFocus={() => {
if (isInputAutoFocus) {
setIsStreetInputFocused(true);
}
}}
onBlur={() => setIsStreetInputFocused(false)}
onFocus={() => setIsStreetInputFocused(true)}
placeholder="Straße"
style={styles.autoCompleteInput}
value={inputValue}
Expand Down

0 comments on commit 9bc9534

Please sign in to comment.