Skip to content

Commit 59ebd46

Browse files
committed
fix: OF-529, OF-518 - just highlight help btn
1 parent 8b185ba commit 59ebd46

File tree

3 files changed

+132
-58
lines changed

3 files changed

+132
-58
lines changed
Lines changed: 99 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,114 @@
1-
import { Title } from "@/GlobalStyles";
1+
import { Color, Title } from "@/GlobalStyles";
22
import { MaterialIcons } from "@expo/vector-icons";
33
import * as React from "react";
4-
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
4+
import {
5+
Animated,
6+
Easing,
7+
StyleSheet,
8+
Text,
9+
TouchableOpacity,
10+
View,
11+
} from "react-native";
512

613
interface IOPagerHeaderProps {
714
title: string;
815
onHelpPress?: () => void;
16+
highlightHelpBtn?: boolean;
917
}
1018

11-
export const OPageHeader = ({ title, onHelpPress }: IOPagerHeaderProps) => {
19+
export const OPageHeader = ({
20+
title,
21+
onHelpPress,
22+
highlightHelpBtn,
23+
}: IOPagerHeaderProps) => {
24+
const scaleAnim = React.useRef(new Animated.Value(1)).current;
25+
const rotateAnim = React.useRef(new Animated.Value(0)).current;
26+
const colorAnim = React.useRef(new Animated.Value(0)).current;
27+
28+
React.useEffect(() => {
29+
if (highlightHelpBtn) {
30+
Animated.loop(
31+
Animated.sequence([
32+
Animated.timing(scaleAnim, {
33+
toValue: 1.3,
34+
duration: 800,
35+
easing: Easing.elastic(1),
36+
useNativeDriver: true,
37+
}),
38+
Animated.timing(scaleAnim, {
39+
toValue: 1,
40+
duration: 600,
41+
useNativeDriver: true,
42+
}),
43+
]),
44+
).start();
45+
46+
const createTiltAnimation = () => {
47+
return Animated.sequence([
48+
Animated.timing(rotateAnim, {
49+
toValue: Math.random() > 0.5 ? 0.3 : -0.3,
50+
duration: 150,
51+
easing: Easing.bounce,
52+
useNativeDriver: true,
53+
}),
54+
Animated.timing(rotateAnim, {
55+
toValue: Math.random() > 0.5 ? -0.25 : 0.25,
56+
duration: 150,
57+
useNativeDriver: true,
58+
}),
59+
Animated.timing(rotateAnim, {
60+
toValue: 0,
61+
duration: 150,
62+
useNativeDriver: true,
63+
}),
64+
]);
65+
};
66+
67+
Animated.loop(
68+
Animated.sequence([
69+
createTiltAnimation(),
70+
Animated.delay(Math.random() * 1000 + 500),
71+
]),
72+
).start();
73+
74+
Animated.loop(
75+
Animated.sequence([
76+
Animated.timing(colorAnim, {
77+
toValue: 1,
78+
duration: 1500,
79+
useNativeDriver: false,
80+
}),
81+
Animated.timing(colorAnim, {
82+
toValue: 0,
83+
duration: 1500,
84+
useNativeDriver: false,
85+
}),
86+
]),
87+
).start();
88+
}
89+
}, [highlightHelpBtn]);
90+
91+
const spin = rotateAnim.interpolate({
92+
inputRange: [-1, 1],
93+
outputRange: ["-30deg", "30deg"],
94+
});
95+
1296
return (
1397
<View style={styles.container}>
1498
<Text style={Title}>{title}</Text>
1599
{onHelpPress && (
16100
<TouchableOpacity onPress={onHelpPress}>
17-
<MaterialIcons
18-
name="help-outline"
19-
size={20}
20-
style={styles.icon}
21-
/>
101+
<Animated.View
102+
style={{
103+
transform: [{ scale: scaleAnim }, { rotate: spin }],
104+
}}
105+
>
106+
<MaterialIcons
107+
name="help-outline"
108+
size={20}
109+
style={styles.icon}
110+
/>
111+
</Animated.View>
22112
</TouchableOpacity>
23113
)}
24114
</View>
@@ -27,5 +117,5 @@ export const OPageHeader = ({ title, onHelpPress }: IOPagerHeaderProps) => {
27117

28118
const styles = StyleSheet.create({
29119
container: { flexDirection: "row", marginLeft: 12 },
30-
icon: { color: "#999", padding: 6, paddingTop: 16 },
120+
icon: { marginLeft: 3, padding: 6, paddingTop: 16, color: Color.primary },
31121
});

mobile/hooks/useSetupTourGuides.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

mobile/screens/main/MainScreenTabs.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import {
66
useEncountersContext,
77
} from "@/context/EncountersContext";
88
import { useNotifications } from "@/hooks/useNotifications";
9-
import { useSetupTourGuides } from "@/hooks/useSetupTourGuides";
109
import { TR, i18n } from "@/localization/translate.service";
1110
import { MainTabs } from "@/screens/main/MainScreenTabs.navigator";
12-
import { MOCK_ENCOUNTER } from "@/services/tourguide.service";
11+
import { LOCAL_VALUE, getLocalValue } from "@/services/storage.service";
12+
import { MOCK_ENCOUNTER, TOURKEY } from "@/services/tourguide.service";
1313
import { MaterialIcons } from "@expo/vector-icons";
14+
import * as Sentry from "@sentry/react-native";
1415
import * as React from "react";
15-
import { TourGuideZone } from "rn-tourguide";
16+
import { useEffect, useState } from "react";
17+
import { TourGuideZone, useTourGuideController } from "rn-tourguide";
1618
import { ROUTES } from "../routes";
1719
import { EncounterScreenStack } from "./EncounterStackNavigator";
1820
import FindPeople from "./FindPeople";
@@ -22,7 +24,32 @@ export const MainScreenTabs = ({ navigation }: any) => {
2224
useNotifications(navigation);
2325

2426
const { dispatch: dispatchEncounters } = useEncountersContext();
25-
const { tourKeyFind, startTourFind } = useSetupTourGuides();
27+
const { tourKey: tourKeyFind, start: startTourFind } =
28+
useTourGuideController(TOURKEY.FIND);
29+
30+
// @dev true by default to not unnecessarily distract user
31+
const [hasDoneFindWalkthrough, setHasDoneFindWalkthrough] = useState(true);
32+
const [hasDoneEncounterWalkthrough, setHasDoneEncounterWalkthrough] =
33+
useState(true);
34+
useEffect(() => {
35+
const getValues = [
36+
getLocalValue(LOCAL_VALUE.HAS_DONE_FIND_WALKTHROUGH),
37+
getLocalValue(LOCAL_VALUE.HAS_DONE_ENCOUNTER_WALKTHROUGH),
38+
];
39+
40+
Promise.all(getValues)
41+
.then((vals: boolean[]) => {
42+
setHasDoneFindWalkthrough(vals[0]);
43+
setHasDoneEncounterWalkthrough(vals[1]);
44+
})
45+
.catch((err) => {
46+
Sentry.captureException(err, {
47+
tags: {
48+
mainScreenTabs: "getLocalValue:hasDoneWalkthrough",
49+
},
50+
});
51+
});
52+
}, []);
2653

2754
return (
2855
<MainTabs.Navigator
@@ -55,6 +82,7 @@ export const MainScreenTabs = ({ navigation }: any) => {
5582
headerLeft: () => (
5683
<OPageHeader
5784
title={i18n.t(TR.findPeople)}
85+
highlightHelpBtn={!hasDoneFindWalkthrough}
5886
onHelpPress={() => {
5987
requestAnimationFrame(() => {
6088
startTourFind();
@@ -80,6 +108,7 @@ export const MainScreenTabs = ({ navigation }: any) => {
80108
headerLeft: () => (
81109
<OPageHeader
82110
title={i18n.t(TR.encounters)}
111+
highlightHelpBtn={!hasDoneEncounterWalkthrough}
83112
onHelpPress={() => {
84113
dispatchEncounters({
85114
type: EACTION_ENCOUNTERS.PUSH_MULTIPLE,

0 commit comments

Comments
 (0)