|
|
|
@ -4,7 +4,6 @@ import { LinearGradient } from 'expo-linear-gradient';
|
|
|
|
|
import * as Haptics from 'expo-haptics';
|
|
|
|
|
import Animated from 'react-native-reanimated';
|
|
|
|
|
import Card from '../components/Card';
|
|
|
|
|
import { cards as cardArray, spotArray2 } from '../data/data'
|
|
|
|
|
import AdjustSize from '../components/AdjustSize';
|
|
|
|
|
import normalize from '../components/Normalize';
|
|
|
|
|
import LottieView from 'lottie-react-native'
|
|
|
|
@ -16,12 +15,13 @@ import { addFavoritesMusic } from '../redux/actions/appActions';
|
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
import { Spot } from '../model/Spot';
|
|
|
|
|
import { removeFromSpotList, setSpotList } from '../redux/actions/spotActions';
|
|
|
|
|
import { spotsData } from '../data/data';
|
|
|
|
|
|
|
|
|
|
export default function SpotScreen() {
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
const spotReducer = useSelector(state => state.appReducer.spot)
|
|
|
|
|
const [cards, setCards] = useState<Spot[]>(spotReducer);
|
|
|
|
|
|
|
|
|
|
const [cards, setCards] = useState<Spot[]>(spotReducer);
|
|
|
|
|
const [currentCard, setcurrentCard] = useState(cards[cards.length - 1]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setCards(spotReducer);
|
|
|
|
@ -31,15 +31,12 @@ export default function SpotScreen() {
|
|
|
|
|
const onSwipe = (direction: 'left' | 'right' | 'down') => {
|
|
|
|
|
|
|
|
|
|
if (direction === 'right') {
|
|
|
|
|
// Swiped right
|
|
|
|
|
addLike(currentCard);
|
|
|
|
|
} else if (direction === 'left') {
|
|
|
|
|
// Swiped left
|
|
|
|
|
console.log('Swiped left');
|
|
|
|
|
removeSpots(currentCard);
|
|
|
|
|
}
|
|
|
|
|
else if (direction === 'down') {
|
|
|
|
|
// Swiped down
|
|
|
|
|
addMockSpots();
|
|
|
|
|
console.log('Swiped down');
|
|
|
|
|
}
|
|
|
|
@ -65,18 +62,16 @@ export default function SpotScreen() {
|
|
|
|
|
|
|
|
|
|
function addMockSpots() {
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
dispatch(setSpotList(spotArray2))
|
|
|
|
|
dispatch(setSpotList(spotsData))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const navigator = useNavigation();
|
|
|
|
|
|
|
|
|
|
const { width: wWidht } = Dimensions.get("window");
|
|
|
|
|
const hapti = (card: Spot) => {
|
|
|
|
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Heavy)
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
navigator.navigate("DetailsSpot", { "music": card.music })
|
|
|
|
|
navigator.navigate("Detail", { "music": card.music })
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
|
@ -166,6 +161,7 @@ export default function SpotScreen() {
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
mainSafeArea: {
|
|
|
|
|
flex: 1,
|
|
|
|
|