diff --git a/front/API.ts b/front/API.ts index faa9214..cebdcf4 100644 --- a/front/API.ts +++ b/front/API.ts @@ -6,6 +6,8 @@ import Song from "./models/Song"; import SongHistory from "./models/SongHistory"; import User from "./models/User"; +const delay = (seconds: number) => new Promise(resolve => setTimeout(resolve, seconds * 1000)); + declare type AuthenticationInput = { email: string, password: string }; export default class API { @@ -55,13 +57,13 @@ export default class API { * @param songId the id to find the song */ static async getSong(songId: number): Promise { - return { + return delay(1).then(() => ({ title: "Song", description: "A song", album: "Album", metrics: {}, id: songId - }; + })); } diff --git a/front/Navigation.tsx b/front/Navigation.tsx index 643f20f..ce99ff7 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -4,12 +4,14 @@ import AuthenticationView from './views/AuthenticationView'; import HomeView from './views/HomeView'; import { NavigationContainer } from '@react-navigation/native'; import { useSelector } from 'react-redux'; +import SongLobbyView from './views/SongLobbyView'; const Stack = createNativeStackNavigator(); -export const protectedRoutes = +export const protectedRoutes = <> -; + +; export const publicRoutes = diff --git a/front/Theme.tsx b/front/Theme.tsx index 65188b4..fa016c4 100644 --- a/front/Theme.tsx +++ b/front/Theme.tsx @@ -15,7 +15,7 @@ const Theme = { surface: '#F6F6F6', accent: '#00bdbd', error: '#B00020', - text: '#ffffff', + text: '#000000', onSurface: '#000000', placeholder: '#C9C9C9', notification: '#FF0000' diff --git a/front/components/loading.tsx b/front/components/loading.tsx new file mode 100644 index 0000000..04df863 --- /dev/null +++ b/front/components/loading.tsx @@ -0,0 +1,7 @@ +import { useTheme } from "@react-navigation/native"; +import Spinner from 'react-native-loading-spinner-overlay'; +const LoadingComponent = () => { + return +} + +export default LoadingComponent; \ No newline at end of file diff --git a/front/package.json b/front/package.json index a5dad4f..d476bbe 100644 --- a/front/package.json +++ b/front/package.json @@ -30,6 +30,7 @@ "react-dom": "17.0.2", "react-i18next": "^11.18.3", "react-native": "0.68.2", + "react-native-loading-spinner-overlay": "^3.0.1", "react-native-paper": "^4.12.2", "react-native-safe-area-context": "4.2.4", "react-native-screens": "~3.11.1", diff --git a/front/views/HomeView.tsx b/front/views/HomeView.tsx index 774e2f1..d17afb2 100644 --- a/front/views/HomeView.tsx +++ b/front/views/HomeView.tsx @@ -1,13 +1,15 @@ +import { useNavigation } from "@react-navigation/native"; import React from "react"; -import { Text, View } from 'react-native'; -import { Button } from "react-native-paper"; +import { View } from 'react-native'; +import { Button, Text } from "react-native-paper"; import { useDispatch, useSelector } from "react-redux"; -import i18n, { AvailableLanguages, DefaultLanguage, translate } from "../i18n/i18n"; +import { AvailableLanguages, DefaultLanguage, translate } from "../i18n/i18n"; import { useLanguage } from "../state/LanguageSlice"; import { unsetUserToken } from "../state/UserSlice"; const HomeView = () => { const dispatch = useDispatch(); + const navigation = useNavigation(); const language: AvailableLanguages = useSelector((state) => state.language.value); return ( @@ -24,6 +26,7 @@ const HomeView = () => { } dispatch(useLanguage(newLanguage)); }}>Change language + Current language: { language } ); diff --git a/front/views/SongLobbyView.tsx b/front/views/SongLobbyView.tsx new file mode 100644 index 0000000..ae3cfea --- /dev/null +++ b/front/views/SongLobbyView.tsx @@ -0,0 +1,25 @@ +import { useRoute } from "@react-navigation/native"; +import { View } from "react-native" +import { Text } from "react-native-paper"; +import API from "../API"; +import { useQuery } from 'react-query'; +import LoadingComponent from "../components/loading"; + +interface SongLobbyProps { + // The unique identifier to find a song + songId: number; +} + +const SongLobbyView = () => { + const route = useRoute(); + const props: SongLobbyProps = route.params as any; + const { isLoading, isError, data } = useQuery(['song', props.songId], API.getSong(props.songId)) + return + { isLoading && } + + {props.songId} + + +} + +export default SongLobbyView; \ No newline at end of file diff --git a/front/yarn.lock b/front/yarn.lock index 1d3780c..0cdc352 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -7010,6 +7010,11 @@ react-native-iphone-x-helper@^1.3.1: resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg== +react-native-loading-spinner-overlay@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/react-native-loading-spinner-overlay/-/react-native-loading-spinner-overlay-3.0.1.tgz#092481b8cce157d3af5ef942f845ad981f96bd36" + integrity sha512-4GdR54HQnKg2HPSSisVizfTLuyhSh4splY9eb8mKiYF1Ihjn/5EmdNo5bN3S7uKPFRC3WLzIZIouX6G6fXfnjw== + react-native-paper@^4.12.2: version "4.12.2" resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-4.12.2.tgz#31ed8011afd994d54dd403ed0099295fc1616d26"