Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Energy tooltip #330

Merged
merged 19 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/effect/AnimatedFlask.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from 'react';
import { Animated, StyleSheet, TouchableOpacity, View } from 'react-native';
import { Animated, StyleSheet, View } from 'react-native';
import Svg, { Path } from 'react-native-svg';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { useIsFocused } from '@react-navigation/native';
Expand Down
14 changes: 13 additions & 1 deletion src/components/map/DropyMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import MapLoadingOverlay from '../overlays/MapLoadingOverlay';
import DebugText from '../other/DebugText';
import FadeInWrapper from '../effect/FadeInWrapper';
import EnergyPopup from '../overlays/EnergyPopup';
import Storage from '../../utils/storage';
import EnergyTooltip from './EnergyTooltip';
import RetrievedDropyMapMarker from './RetrievedDropyMapMarker';
import Sonar from './Sonar';
Expand Down Expand Up @@ -49,6 +50,8 @@ const DropyMap = ({
const osMap = useRef(null);
const [mapIsReady, setMapIsReady] = useState(false);

const [isFirstLaunch, setIsFirstLaunch] = useState(false);

const handleDropyPressed = async (dropy) => {
try {
if (dropy == null)
Expand Down Expand Up @@ -108,6 +111,15 @@ const DropyMap = ({
retrievedDropies
]);

useEffect(() => {
Storage.getItem('alreadyLaunched').then((value) => {
if (value === null) {
Storage.setItem('alreadyLaunched', true);
setIsFirstLaunch(true);
}
});
}, []);

enzo-mourany marked this conversation as resolved.
Show resolved Hide resolved
const setMapCameraPosition = async (forceHeading = false, forceZoom = false) => {
const currentCamera = await osMap.current?.getMapRef()?.getCamera();
if (currentCamera == null)
Expand Down Expand Up @@ -208,7 +220,7 @@ const DropyMap = ({

<SafeAreaView style={styles.controlsView}>
<FadeInWrapper visible={!museumVisible}>
<EnergyTooltip>
<EnergyTooltip isFirstLaunch={isFirstLaunch}>
<AnimatedFlask />
</EnergyTooltip>
<FadeInWrapper visible={currentZoom < Map.MAX_ZOOM - 0.1}>
Expand Down
12 changes: 3 additions & 9 deletions src/components/map/EnergyTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@ import { Animated, StyleSheet, Text, TouchableOpacity, View } from 'react-native
import { MaterialCommunityIcons } from '@expo/vector-icons';
import Styles, { Colors, Fonts } from '../../styles/Styles';
import useCurrentUser from '../../hooks/useCurrentUser';
import Storage from '../../utils/storage';

const EnergyTooltip = ({ style, children }) => {
const EnergyTooltip = ({ style, isFirstLaunch, children }) => {
const { user } = useCurrentUser();
const tooltipAnimatedValue = useRef(new Animated.Value(0)).current;

const [isPressed, setIsPressed] = useState(false);

Storage.getItem('alreadyLaunched').then((value) => {
if (value === null) {
Storage.setItem('alreadyLaunched', true);
setIsPressed(true);
}
});

useEffect(() => {
isFirstLaunch && setIsPressed(true);
const anim = Animated.timing(tooltipAnimatedValue, {
toValue: isPressed ? 1 : 0,
duration: 200,
Expand All @@ -32,6 +25,7 @@ const EnergyTooltip = ({ style, children }) => {
<View style={{ ...Styles.center, ...style }}>
<Animated.View style={{ ...styles.tooltipContainer, opacity: tooltipAnimatedValue }}>
<TouchableOpacity
activeOpacity={1}
onPressIn={() => setIsPressed(false)}
>
<View style={styles.titleView}>
Expand Down