├── .watchmanconfig ├── .DS_Store ├── assets ├── icon.png ├── MR_logo.png └── splash.png ├── babel.config.js ├── .gitignore ├── .expo-shared └── assets.json ├── App.js ├── app.json ├── package.json └── components ├── list.js ├── auth.js ├── edit.js └── detail.js /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nogostradamus/course-django-react-mobile/HEAD/.DS_Store -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nogostradamus/course-django-react-mobile/HEAD/assets/icon.png -------------------------------------------------------------------------------- /assets/MR_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nogostradamus/course-django-react-mobile/HEAD/assets/MR_logo.png -------------------------------------------------------------------------------- /assets/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nogostradamus/course-django-react-mobile/HEAD/assets/splash.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | api.cache(true); 3 | return { 4 | presets: ['babel-preset-expo'], 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | .expo/* 3 | npm-debug.* 4 | *.jks 5 | *.p8 6 | *.p12 7 | *.key 8 | *.mobileprovision 9 | *.orig.* 10 | web-build/ 11 | web-report/ 12 | -------------------------------------------------------------------------------- /.expo-shared/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true, 3 | "89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true 4 | } -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Auth from './components/auth'; 3 | import MovieList from './components/list'; 4 | import Detail from './components/detail'; 5 | import Edit from './components/edit'; 6 | 7 | import { createAppContainer } from 'react-navigation'; 8 | import { createStackNavigator } from 'react-navigation-stack'; 9 | 10 | const AppNavigator = createStackNavigator({ 11 | Auth: {screen: Auth}, 12 | MovieList: {screen: MovieList}, 13 | Detail: {screen: Detail}, 14 | Edit: {screen: Edit}, 15 | }) 16 | 17 | const App = createAppContainer(AppNavigator); 18 | 19 | export default App; 20 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "Movie Rater", 4 | "slug": "MovieRater", 5 | "privacy": "public", 6 | "sdkVersion": "34.0.0", 7 | "platforms": [ 8 | "ios", 9 | "android", 10 | "web" 11 | ], 12 | "version": "1.0.0", 13 | "orientation": "portrait", 14 | "icon": "./assets/icon.png", 15 | "splash": { 16 | "image": "./assets/splash.png", 17 | "resizeMode": "contain", 18 | "backgroundColor": "#ffffff" 19 | }, 20 | "updates": { 21 | "fallbackToCacheTimeout": 0 22 | }, 23 | "assetBundlePatterns": [ 24 | "**/*" 25 | ], 26 | "ios": { 27 | "supportsTablet": true 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "node_modules/expo/AppEntry.js", 3 | "scripts": { 4 | "start": "expo start", 5 | "android": "expo start --android", 6 | "ios": "expo start --ios", 7 | "web": "expo start --web", 8 | "eject": "expo eject" 9 | }, 10 | "dependencies": { 11 | "@fortawesome/fontawesome-svg-core": "^1.2.25", 12 | "@fortawesome/free-solid-svg-icons": "^5.11.2", 13 | "@fortawesome/react-native-fontawesome": "^0.1.0", 14 | "expo": "^34.0.1", 15 | "react": "16.8.3", 16 | "react-dom": "^16.8.6", 17 | "react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz", 18 | "react-native-gesture-handler": "~1.3.0", 19 | "react-native-svg": "^9.9.4", 20 | "react-native-web": "^0.11.4", 21 | "react-navigation": "^4.0.5", 22 | "react-navigation-stack": "^1.8.0" 23 | }, 24 | "devDependencies": { 25 | "babel-preset-expo": "^6.0.0" 26 | }, 27 | "private": true 28 | } 29 | -------------------------------------------------------------------------------- /components/list.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { StyleSheet, Text, View, FlatList, Image, TouchableOpacity, Button, AsyncStorage } from 'react-native'; 3 | 4 | export default function MovieList(props) { 5 | 6 | const [ movies, setMovies ] = useState([]); 7 | let token = null; 8 | 9 | const getData = async () => { 10 | token = await AsyncStorage.getItem('MR_Token'); 11 | if (token) { 12 | getMovies(); 13 | } else { 14 | props.navigation.navigate("Auth") 15 | } 16 | }; 17 | 18 | useEffect(() => { 19 | getData(); 20 | }, []); 21 | 22 | const getMovies = () => { 23 | console.log(token); 24 | fetch(`http://192.168.1.5:8000/api/movies/`, { 25 | method: 'GET', 26 | headers: { 27 | 'Authorization': `Token ${token}` 28 | } 29 | }) 30 | .then( res => res.json()) 31 | .then( jsonRes => setMovies(jsonRes)) 32 | .catch( error => console.log(error)); 33 | } 34 | 35 | const movieclicked = (movie) => { 36 | props.navigation.navigate("Detail", {movie: movie, title: movie.title, token: token}) 37 | } 38 | 39 | return ( 40 | 41 | 44 | 45 | ( 48 | movieclicked(item)}> 49 | 50 | {item.title} 51 | 52 | 53 | )} 54 | keyExtractor={(item, index) => index.toString()} 55 | /> 56 | 57 | ); 58 | } 59 | 60 | MovieList.navigationOptions = screenProps => ({ 61 | title: "List of movies", 62 | headerStyle: { 63 | backgroundColor: 'orange' 64 | }, 65 | headerTintColor: '#fff', 66 | headerTitleStyle: { 67 | fontWeight: 'bold', 68 | fontSize:24 69 | }, 70 | headerRight: ( 71 |