From 6c555f5517913a10555cb34a8192c49d2a030bdf Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Fri, 10 Nov 2023 13:28:10 +0200 Subject: [PATCH] feat: Add Privacy Policy link to Android app --- src/hooks/react-native/useKeyboardVisible.tsx | 28 +++++++++++++++++++ src/screens/HomeScreen.tsx | 23 ++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/hooks/react-native/useKeyboardVisible.tsx diff --git a/src/hooks/react-native/useKeyboardVisible.tsx b/src/hooks/react-native/useKeyboardVisible.tsx new file mode 100644 index 0000000..53430d8 --- /dev/null +++ b/src/hooks/react-native/useKeyboardVisible.tsx @@ -0,0 +1,28 @@ +import { Keyboard } from "react-native"; +import { useState, useEffect } from "react"; + +export const useKeyboardVisible = () => { + const [isKeyboardVisible, setKeyboardVisible] = useState(false); + + useEffect(() => { + const keyboardDidShowListener = Keyboard.addListener( + "keyboardDidShow", + () => { + setKeyboardVisible(true); + } + ); + const keyboardDidHideListener = Keyboard.addListener( + "keyboardDidHide", + () => { + setKeyboardVisible(false); + } + ); + + return () => { + keyboardDidHideListener.remove(); + keyboardDidShowListener.remove(); + }; + }, []); + + return isKeyboardVisible; +}; diff --git a/src/screens/HomeScreen.tsx b/src/screens/HomeScreen.tsx index c5787f1..59ae864 100644 --- a/src/screens/HomeScreen.tsx +++ b/src/screens/HomeScreen.tsx @@ -1,4 +1,4 @@ -import { Text, View, Image } from "react-native"; +import { Text, View, Image, Platform } from "react-native"; import tw from "@src/utils/tailwind"; import { useState } from "react"; import { Screen } from "@src/components/Screen"; @@ -8,6 +8,7 @@ import { searchResultScreenProp, NavigatorTabsParamList, } from "@src/types"; +import { A as HTMLLink } from "@expo/html-elements"; import { trimTld, validate } from "@src/utils/validate"; import { isPubkey } from "@src/utils/publickey"; import { abbreviate } from "@src/utils/abbreviate"; @@ -21,6 +22,7 @@ import { CustomTextInput } from "@src/components/CustomTextInput"; import { UiButton } from "@src/components/UiButton"; import { LanguageHeader } from "@src/components/Header"; import { useStatusModalContext } from "@src/contexts/StatusModalContext"; +import { useKeyboardVisible } from "@src/hooks/react-native/useKeyboardVisible"; const Stack = createStackNavigator(); @@ -36,6 +38,7 @@ function HomeRoot() { const navigation = useNavigation< searchResultScreenProp | profileScreenProp >(); + const isKeyboardVisible = useKeyboardVisible(); const handle = async () => { if (!search) return; @@ -118,6 +121,24 @@ function HomeRoot() { ))} + + <> + {Platform.OS === "android" && ( + + + Privacy Policy + + + )} + ); }