-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: break apart MapSearch file into components * feat: offline indicator for map search * feat: don't hit suggestions API when offline * refactor: give better names to search box components that get shown/hidden
- Loading branch information
1 parent
b5f4e85
commit 922e94f
Showing
7 changed files
with
145 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
dev-client/src/screens/SitesScreen/components/search/MapSearchOfflineAlertBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import {StyleSheet, View} from 'react-native'; | ||
|
||
import {DisableableText} from 'terraso-mobile-client/components/content/typography/DisableableText'; | ||
import {TranslatedContent} from 'terraso-mobile-client/components/content/typography/TranslatedContent'; | ||
import {convertColorProp} from 'terraso-mobile-client/components/util/nativeBaseAdapters'; | ||
|
||
export const MapSearchOfflineAlertBox = () => { | ||
return ( | ||
<View style={styles.container}> | ||
<DisableableText disabled={true}> | ||
<TranslatedContent i18nKey="site.search.offline" /> | ||
</DisableableText> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
backgroundColor: convertColorProp('background.default'), | ||
borderWidth: 1, | ||
borderColor: convertColorProp('grey.300'), | ||
paddingHorizontal: 12, | ||
paddingVertical: 4, | ||
marginHorizontal: 12, | ||
width: '92%', | ||
}, | ||
}); |
53 changes: 53 additions & 0 deletions
53
dev-client/src/screens/SitesScreen/components/search/MapSearchSuggestionBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import {useCallback} from 'react'; | ||
|
||
import {Pressable} from 'native-base'; | ||
|
||
import { | ||
Column, | ||
Text, | ||
} from 'terraso-mobile-client/components/NativeBaseAdapters'; | ||
|
||
type Props = { | ||
name: string; | ||
address: string; | ||
mapboxId: string; | ||
onPress: (name: string, mapboxId: string) => void; | ||
}; | ||
|
||
export const MapSearchSuggestionBox = ({ | ||
name, | ||
address, | ||
mapboxId, | ||
onPress, | ||
}: Props) => { | ||
const selectSuggestion = useCallback( | ||
() => onPress(name, mapboxId), | ||
[name, mapboxId, onPress], | ||
); | ||
|
||
return ( | ||
<Pressable w="100%" py={1} px={3} onPress={selectSuggestion}> | ||
<Column> | ||
<Text>{name}</Text> | ||
<Text>{address}</Text> | ||
</Column> | ||
</Pressable> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters