From 77472cf538481f090e9d5c902226ece28e8697a6 Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Wed, 25 Jan 2023 16:58:11 +0100 Subject: [PATCH] commit to API & spotify Service starting --- .gitignore | 280 +++++++++--------- Api/package.json | 18 ++ FLAD/App.tsx | 56 +++- FLAD/FakeData/data.ts | 32 +- FLAD/components/Card.tsx | 150 +++++----- FLAD/pages/spot.tsx | 73 +++++ .../spotify/ApiSpotifyIdentification.tsx | 0 FLAD/services/spotify/spotify.service.ts | 23 ++ 8 files changed, 403 insertions(+), 229 deletions(-) create mode 100644 Api/package.json create mode 100644 FLAD/pages/spot.tsx create mode 100644 FLAD/services/spotify/ApiSpotifyIdentification.tsx create mode 100644 FLAD/services/spotify/spotify.service.ts diff --git a/.gitignore b/.gitignore index a179c40..e7c7ed1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,141 +1,141 @@ -# Xcode -!**/*.xcodeproj -!**/*.pbxproj -!**/*.xcworkspacedata -!**/*.xcsettings -!**/*.xcscheme -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate -project.xcworkspace -**/.xcode.env.local - -# Gradle -/build/ -/packages/react-native-gradle-plugin/build/ -/packages/rn-tester/build -/packages/rn-tester/android/app/.cxx/ -/packages/rn-tester/android/app/build/ -/packages/rn-tester/android/app/gradle/ -/packages/rn-tester/android/app/gradlew -/packages/rn-tester/android/app/gradlew.bat -/ReactAndroid/build/ -/ReactAndroid/.cxx/ -/ReactAndroid/gradle/ -/ReactAndroid/gradlew -/ReactAndroid/gradlew.bat -/ReactAndroid/external-artifacts/build/ -/ReactAndroid/external-artifacts/artifacts/ -/ReactAndroid/hermes-engine/build/ -/ReactAndroid/hermes-engine/.cxx/ -/template/android/app/build/ -/template/android/build/ - -# Buck -.buckd -buck-out -/.lsp.buckd -/.lsp-buck-out -/ReactAndroid/src/main/jni/prebuilt/lib/ -/ReactAndroid/src/main/gen - -# Android Studio -.project -.settings -.classpath - -# Watchman -.watchmanconfig - -# Android -.idea -.gradle -local.properties -*.iml -/android/* -!/android/README.md - -# Node -node_modules -*.log -.nvm -package-lock.json - -# OS X -.DS_Store - -# Test generated files -/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js -*.js.meta - -/coverage -/third-party - -# Test Reports -/reports - -# Stack Dumps generated when programs crash (Ex. bash.exe.stackdump on Win) -*.stackdump - -# Root dir shouldn't have Xcode project -/*.xcodeproj - -# ReactCommon subdir shouldn't have Xcode project -/ReactCommon/**/*.xcodeproj - -# Libs that shouldn't have Xcode project -/Libraries/FBLazyVector/**/*.xcodeproj -/Libraries/RCTRequired/**/*.xcodeproj -/React/CoreModules/**/*.xcodeproj -/React/FBReactNativeSpec/**/*.xcodeproj -/packages/react-native-codegen/**/*.xcodeproj - -# Ruby Gems (Bundler) -/vendor -/template/vendor - -# iOS / CocoaPods -/template/ios/build/ -/template/ios/Pods/ -/template/ios/Podfile.lock -/packages/rn-tester/Gemfile.lock - -# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here. -/packages/rn-tester/Pods/* -!/packages/rn-tester/Pods/__offline_mirrors_hermes__ -!/packages/rn-tester/Pods/__offline_mirrors_jsc__ - -# @react-native/codegen -/React/FBReactNativeSpec/FBReactNativeSpec -/packages/react-native-codegen/lib -/packages/react-native-codegen/tmp/ -/ReactCommon/react/renderer/components/rncore/ -/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec* - - -# Additional SDKs -/sdks/download -/sdks/hermes -/sdks/hermesc - -# Visual studio -.vscode -.vs - -# Android memory profiler files -*.hprof - -# Temporary files created by Metro to check the health of the file watcher +# Xcode +!**/*.xcodeproj +!**/*.pbxproj +!**/*.xcworkspacedata +!**/*.xcsettings +!**/*.xcscheme +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace +**/.xcode.env.local + +# Gradle +/build/ +/packages/react-native-gradle-plugin/build/ +/packages/rn-tester/build +/packages/rn-tester/android/app/.cxx/ +/packages/rn-tester/android/app/build/ +/packages/rn-tester/android/app/gradle/ +/packages/rn-tester/android/app/gradlew +/packages/rn-tester/android/app/gradlew.bat +/ReactAndroid/build/ +/ReactAndroid/.cxx/ +/ReactAndroid/gradle/ +/ReactAndroid/gradlew +/ReactAndroid/gradlew.bat +/ReactAndroid/external-artifacts/build/ +/ReactAndroid/external-artifacts/artifacts/ +/ReactAndroid/hermes-engine/build/ +/ReactAndroid/hermes-engine/.cxx/ +/template/android/app/build/ +/template/android/build/ + +# Buck +.buckd +buck-out +/.lsp.buckd +/.lsp-buck-out +/ReactAndroid/src/main/jni/prebuilt/lib/ +/ReactAndroid/src/main/gen + +# Android Studio +.project +.settings +.classpath + +# Watchman +.watchmanconfig + +# Android +.idea +.gradle +local.properties +*.iml +/android/* +!/android/README.md + +# Node +node_modules +*.log +.nvm +package-lock.json + +# OS X +.DS_Store + +# Test generated files +/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js +*.js.meta + +/coverage +/third-party + +# Test Reports +/reports + +# Stack Dumps generated when programs crash (Ex. bash.exe.stackdump on Win) +*.stackdump + +# Root dir shouldn't have Xcode project +/*.xcodeproj + +# ReactCommon subdir shouldn't have Xcode project +/ReactCommon/**/*.xcodeproj + +# Libs that shouldn't have Xcode project +/Libraries/FBLazyVector/**/*.xcodeproj +/Libraries/RCTRequired/**/*.xcodeproj +/React/CoreModules/**/*.xcodeproj +/React/FBReactNativeSpec/**/*.xcodeproj +/packages/react-native-codegen/**/*.xcodeproj + +# Ruby Gems (Bundler) +/vendor +/template/vendor + +# iOS / CocoaPods +/template/ios/build/ +/template/ios/Pods/ +/template/ios/Podfile.lock +/packages/rn-tester/Gemfile.lock + +# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here. +/packages/rn-tester/Pods/* +!/packages/rn-tester/Pods/__offline_mirrors_hermes__ +!/packages/rn-tester/Pods/__offline_mirrors_jsc__ + +# @react-native/codegen +/React/FBReactNativeSpec/FBReactNativeSpec +/packages/react-native-codegen/lib +/packages/react-native-codegen/tmp/ +/ReactCommon/react/renderer/components/rncore/ +/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec* + + +# Additional SDKs +/sdks/download +/sdks/hermes +/sdks/hermesc + +# Visual studio +.vscode +.vs + +# Android memory profiler files +*.hprof + +# Temporary files created by Metro to check the health of the file watcher .metro-health-check* \ No newline at end of file diff --git a/Api/package.json b/Api/package.json new file mode 100644 index 0000000..c2d9d25 --- /dev/null +++ b/Api/package.json @@ -0,0 +1,18 @@ +{ + "name": "api", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/express": "^4.17.16", + "nodemon": "^2.0.20", + "ts-node": "^10.9.1", + "typescript": "^4.9.4" + } +} diff --git a/FLAD/App.tsx b/FLAD/App.tsx index badd87e..e8bcfa7 100644 --- a/FLAD/App.tsx +++ b/FLAD/App.tsx @@ -3,16 +3,62 @@ import { useState, useTransition } from 'react'; import { Animated, StyleSheet, Text, View } from 'react-native'; import Card from './components/Card'; -// import { cards as cardArray } from './FakeData/data' +import { cards as cardArray } from './FakeData/data' export default function App() { +// const [currentCard, setCurrentCard] = useState(cardArray); +// const aIndex = useTransition(currentCard) +// ; +const [cards, setCards] = useState(cardArray); +const aIndex = useTransition(); +const onSwipe = (index: number, direction: 'left' | 'right') => { + if (direction === 'right') { + // Swiped right + console.log('Swiped right'); + + } else if (direction === 'left') { + console.log('Swiped left'); + } + // update the state of the card or the app + setCards(cards.filter((_, i) => i !== index)); +}; + +// const [currentCard, setCurrentCard] = useState(0); return ( - - + + + {cards.map((card, index) => ( + + onSwipe(index, direction)} + /> + + ))} - + + + + // + // Open up App.tsx to start working on your app! + // {/* + // + + // + // {cardArray.map( ({index}) => currentCard < index && step + step && ( + // + + // ) )} + + // */} + // + // + // + // + // ); } @@ -35,4 +81,4 @@ const styles = StyleSheet.create({ resizeMode : "cover", placeholder: "assets/images/loadingPlaceholder.gif" }, -}); +}); \ No newline at end of file diff --git a/FLAD/FakeData/data.ts b/FLAD/FakeData/data.ts index 7f5d487..26f9297 100644 --- a/FLAD/FakeData/data.ts +++ b/FLAD/FakeData/data.ts @@ -1,17 +1,17 @@ -export const cards = [{ - name : "blue", - sourceUrl : "https://images.unsplash.com/photo-1484589065579-248aad0d8b13?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1359&q=80", - index : 3 - }, - { - name : "red", - sourceUrl : "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80", - index : 2 - }, - { - name : "green", - sourceUrl : "https://images.unsplash.com/photo-1584679109597-c656b19974c9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=580&q=80", - index : 1 - } - +export const cards = [{ + name : "blue", + sourceUrl : "https://images.unsplash.com/photo-1484589065579-248aad0d8b13?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1359&q=80", + index : 3 + }, + { + name : "red", + sourceUrl : "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80", + index : 2 + }, + { + name : "green", + sourceUrl : "https://images.unsplash.com/photo-1584679109597-c656b19974c9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=580&q=80", + index : 1 + } + ] \ No newline at end of file diff --git a/FLAD/components/Card.tsx b/FLAD/components/Card.tsx index 31cf361..131e662 100644 --- a/FLAD/components/Card.tsx +++ b/FLAD/components/Card.tsx @@ -1,68 +1,82 @@ -import { View, Text, Image, Animated ,PanResponder, Dimensions } from 'react-native' -import React, { useRef } from 'react' - - -const {width : wWidht} = Dimensions.get("window"); -const width = wWidht *0.75; -const height = wWidht * (465/264); -const borderRadius = 24; - - - -interface CardProps { - title: string; - image: any; - onSwipe: (direction: "left" | "right") => void; - } - - - const Card: React.FC = ({ title, image, onSwipe }) => { - const pan = useRef(new Animated.ValueXY()).current; - const panResponder = useRef( - PanResponder.create({ - onMoveShouldSetPanResponder: (evt, gestureState) => { - // Only set the pan responder if the user has moved the card more than a certain threshold - if (Math.abs(gestureState.dx) > 10) { - return true; - } - return false; - }, - onPanResponderMove: (evt, gestureState) => { - // Update the position of the card as the user swipes it - pan.setValue({ x: gestureState.dx, y: 0 }); - console.log("Card"); - }, - onPanResponderRelease: (evt, gestureState) => { - // Handle the swipe action based on the swipe direction - if (gestureState.dx > 50) { - onSwipe("right"); - } else if (gestureState.dx < -50) { - onSwipe("left"); - } else { - // Swiped a small amount, reset the position of the card - Animated.spring(pan, { - toValue: { x: 0, y: 0 }, - useNativeDriver: true, - }).start(); - } - }, - }) - ).current; - - return ( - - - - - - ); - }; - - export default Card; - - - - +import { View, Text, Image, Animated ,PanResponder, Dimensions, StyleSheet } from 'react-native' +import React, { useRef, useState } from 'react' +import { eventMethod } from '@ionic/core/dist/types/utils/overlays'; + + +const {width : wWidht} = Dimensions.get("window"); +const width = wWidht *0.75; +const height = wWidht * (465/264); +const borderRadius = 24; + +interface CardProps { + title: string; + image: any; + onSwipe: (direction: "left" | "right") => void; + } + +// const [loading, setLoading] = useState(true); +// const [cards, setCards] = useState(cardArray); + +// useEffect(()=>{ +// setLoading(true); +// eventMethod().then( +// setLoading(false); +// ) +// }) + + const Card: React.FC = ({ title, image, onSwipe }) => { + const pan = useRef(new Animated.ValueXY()).current; + const panResponder = useRef( + PanResponder.create({ + onMoveShouldSetPanResponder: (evt, gestureState) => { + // Only set the pan responder if the user has moved the card more than a certain threshold + if (Math.abs(gestureState.dx) > 10) { + return true; + } + return false; + }, + onPanResponderMove: (evt, gestureState) => { + // Update the position of the card as the user swipes it + pan.setValue({ x: gestureState.dx, y: 0 }); + console.log("Card"); + }, + onPanResponderRelease: (evt, gestureState) => { + // Handle the swipe action based on the swipe direction + if (gestureState.dx > 50) { + onSwipe("right"); + } else if (gestureState.dx < -50) { + onSwipe("left"); + } else { + // Swiped a small amount, reset the position of the card + Animated.spring(pan, { + toValue: { x: 0, y: 0 }, + useNativeDriver: true, + }).start(); + } + }, + }) + ).current; + + return ( + + + + + + ); + }; + + +const nournous = StyleSheet.create({ + +}) + + + export default Card; + + + + diff --git a/FLAD/pages/spot.tsx b/FLAD/pages/spot.tsx new file mode 100644 index 0000000..0a3d1a6 --- /dev/null +++ b/FLAD/pages/spot.tsx @@ -0,0 +1,73 @@ +import { View, Text, Image, Animated ,PanResponder, Dimensions } from 'react-native' +import React, { useRef, useState, useTransition } from 'react' + +import Card from '../components/Card'; + +import { cards as cardArray } from '../FakeData/data' + +const {width : wWidht} = Dimensions.get("window"); +const width = wWidht *0.75; +const height = wWidht * (465/264); +const borderRadius = 24; + +interface SpotProps { + title: string; + image: any; + onSwipe: (direction: "left" | "right") => void; + } + + + const Spot: React.FC = ({ title, image, onSwipe }) => { + const [cards, setCards] = useState(cardArray); + const aIndex = useTransition(); + const onSwipe = (index: number, direction: 'left' | 'right') => { + if (direction === 'right') { + // Swiped right + console.log('Swiped right'); + + } else if (direction === 'left') { + console.log('Swiped left'); + } + // update the state of the card or the app + setCards(cards.filter((_, i) => i !== index)); + }; + +// const [currentCard, setCurrentCard] = useState(0); + + return ( + + + {cards.map((card, index) => ( + + onSwipe(index, direction)} + /> + + ))} + + + + + // + // Open up App.tsx to start working on your app! + // {/* + // + + // + // {cardArray.map( ({index}) => currentCard < index && step + step && ( + // + + // ) )} + + // */} + // + // + // + // + // + ); + }; + + export default Spot; \ No newline at end of file diff --git a/FLAD/services/spotify/ApiSpotifyIdentification.tsx b/FLAD/services/spotify/ApiSpotifyIdentification.tsx new file mode 100644 index 0000000..e69de29 diff --git a/FLAD/services/spotify/spotify.service.ts b/FLAD/services/spotify/spotify.service.ts new file mode 100644 index 0000000..97da609 --- /dev/null +++ b/FLAD/services/spotify/spotify.service.ts @@ -0,0 +1,23 @@ + +export class SpotifyService { + +private identification : ApiSpotifyIdentification; +public request : SpotifyRequest; + + constructor() { + + } + + get identification{ + + } + + async uploadName() { + + } + async apiAuth(url : string) { + await this.identification.setCode(url); + this.request = ApiSpotifyRequests(await this.identification.createToken()); + } + +}