Skip to content

Commit

Permalink
feat: Add Privacy Policy link to Android app
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha committed Nov 10, 2023
1 parent b408a82 commit 6c555f5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/hooks/react-native/useKeyboardVisible.tsx
Original file line number Diff line number Diff line change
@@ -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;
};
23 changes: 22 additions & 1 deletion src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand All @@ -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<NavigatorTabsParamList>();

Expand All @@ -36,6 +38,7 @@ function HomeRoot() {
const navigation = useNavigation<
searchResultScreenProp | profileScreenProp
>();
const isKeyboardVisible = useKeyboardVisible();

const handle = async () => {
if (!search) return;
Expand Down Expand Up @@ -118,6 +121,24 @@ function HomeRoot() {
</View>
))}
</View>

<>
{Platform.OS === "android" && (
<View
style={[
tw`absolute left-0 right-0 mt-auto bottom-2 bg-background-primary`,
isKeyboardVisible && tw`hidden`,
]}
>
<HTMLLink
style={tw`mt-6 text-sm text-center underline`}
href="https://github.com/Bonfida/sns-manager/blob/master/PRIVACY.md"
>
<Trans>Privacy Policy</Trans>
</HTMLLink>
</View>
)}
</>
</Screen>
);
}
Expand Down

0 comments on commit 6c555f5

Please sign in to comment.