Skip to content

Commit

Permalink
Add share button
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Mar 19, 2024
1 parent ca39b35 commit c547fbe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Expand Up @@ -15,7 +15,8 @@
"react-native-markdown-display": "^7.0.2",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"swr": "^2.2.5"
"swr": "^2.2.5",
"@expo/vector-icons": "^14.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/hooks/useEntryDetail.tsx
@@ -1,5 +1,6 @@
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useEffect } from "react";
import { Text, Pressable, TouchableOpacity, Share } from "react-native";
import { Share, TouchableOpacity } from "react-native";
import useSWR from "swr";
import { useNavigation, useRoute } from "@/hooks/useNavigation";
import type { EntryDetail } from "@/types/EntryDetail";
Expand All @@ -21,6 +22,22 @@ export function useEntryDetail(): {
useEffect(() => {
navigation.setOptions({
title: date,
headerRight: () => (
<TouchableOpacity
onPress={() => {
void Share.share({
message: `https://blog.bouzuya.net/${date.replaceAll("-", "/")}/`,
});
}}
>
<MaterialCommunityIcons
color="black"
name="share-variant-outline"
size={24}
style={{ marginRight: 4 }}
/>
</TouchableOpacity>
),
});
}, [date, entryDetail, navigation]);

Expand Down

0 comments on commit c547fbe

Please sign in to comment.