Skip to content

Commit 6ff0ba8

Browse files
authored
Bookmark improvements on Android and iOS 18 (#87)
1 parent 6e6a67f commit 6ff0ba8

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

src/app/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { useReactConfStore } from "@/store/reactConfStore";
2424
import { osName } from "expo-device";
2525

2626
SplashScreen.setOptions({
27-
duration: 300,
27+
duration: 200,
2828
fade: true,
2929
});
3030

src/components/BaseBookmark.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import Animated, {
55
withSequence,
66
withTiming,
77
} from "react-native-reanimated";
8-
import { Pressable } from "react-native-gesture-handler";
8+
import { GestureDetector, Gesture } from "react-native-gesture-handler";
99

1010
import { theme } from "@/theme";
1111
import { Session } from "@/types";
1212
import { useBookmark } from "@/hooks/useBookmark";
1313
import { SymbolView } from "expo-symbols";
14-
15-
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
14+
import { StyleSheet } from "react-native";
1615

1716
export function BaseBookmark({
1817
session,
@@ -36,24 +35,39 @@ export function BaseBookmark({
3635
await toggleBookmark(session);
3736
};
3837

38+
const tapGesture = Gesture.Tap()
39+
.onStart(() => {
40+
handlePress();
41+
})
42+
.runOnJS(true);
43+
3944
const bookmarked = isBookmarked(session.id);
4045
const bookmarkColor = bookmarked
4146
? theme.color.reactBlue.light
4247
: theme.colorGrey;
4348

4449
return (
45-
<AnimatedPressable hitSlop={20} onPress={handlePress} style={animatedStyle}>
46-
<SymbolView
47-
name={bookmarked ? "bookmark.fill" : "bookmark"}
48-
tintColor={bookmarkColor}
49-
fallback={
50-
<MaterialCommunityIcons
51-
name={bookmarked ? "bookmark" : "bookmark-outline"}
52-
size={theme.fontSize28}
53-
color={bookmarkColor}
54-
/>
55-
}
56-
/>
57-
</AnimatedPressable>
50+
<GestureDetector gesture={tapGesture}>
51+
<Animated.View style={[styles.container, animatedStyle]}>
52+
<SymbolView
53+
name={bookmarked ? "bookmark.fill" : "bookmark"}
54+
tintColor={bookmarkColor}
55+
fallback={
56+
<MaterialCommunityIcons
57+
name={bookmarked ? "bookmark" : "bookmark-outline"}
58+
size={theme.fontSize28}
59+
color={bookmarkColor}
60+
/>
61+
}
62+
/>
63+
</Animated.View>
64+
</GestureDetector>
5865
);
5966
}
67+
68+
const styles = StyleSheet.create({
69+
container: {
70+
margin: -theme.space8,
71+
padding: theme.space8,
72+
},
73+
});

src/utils/registerForPushNotificationsAsync.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export async function registerForPushNotificationsAsync() {
1010
vibrationPattern: [0, 250, 250, 250],
1111
showBadge: false,
1212
});
13+
return (await Notifications.getPermissionsAsync()).status;
1314
}
1415

1516
if (Device.isDevice) {

0 commit comments

Comments
 (0)