Skip to content

Commit 67c1ca9

Browse files
olifer97chortas
andauthored
Connect appserver (#8)
* Init mobile app * Fix typo * Move project to root. * Add login layout. Add aliases for folders. * Add linter and run it. * Add pull request template. * Add expo-av and example of video in HomeScreen. * Organize video player for more clean example with reference to video second. * Add tabnavigator with init structure of screens. * Add user button to navigate tu user profile. * Add screens missing, empty. * Add register screen. * Add modal when sign up. * Add wall layout with videos mock and video screen layout. * Upload video to firebase first atempt. TODO: Mayor refactor. * Refactor over uploading videos to firebase. * Add text to icon buttons. * Add modal when video uploaded. * OkModal now a general component. * Schema por env file. * Restore gitignore. * Change styles in login /signup to nacho's suggestions. * Add env example. * Add validation in upload video button . * Change upload to firebase function name. * Upload video (#7) * Upload video to firebase first atempt. TODO: Mayor refactor. * Refactor over uploading videos to firebase. * Add text to icon buttons. * Add modal when video uploaded. * OkModal now a general component. * Schema por env file. * Restore gitignore. * Change styles in login /signup to nacho's suggestions. * Add env example. * Add validation in upload video button . * Change upload to firebase function name. * Add connection to appserver with apisauce and redux for the store. * Update readme with tutorial to connect to appserver locally. * Add login logic with appserver (mock). * Fix initial loading styles. * Update readme with credentials for login. * Add logic of register. * Move clean form into another function. * Changes due to changes in endpoints. * Fixes. * Add error to login and signup. * Add user in upload video screen. * Add error in upload video screen. * Merge with master. * Fix styles logout for now. Co-authored-by: chortas <[email protected]>
1 parent 75f42e6 commit 67c1ca9

File tree

27 files changed

+551
-210
lines changed

27 files changed

+551
-210
lines changed

.env.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ FIREBASE_PROJECT_ID=
55
FIREBASE_STORAGE_BUCKET=
66
FIREBASE_MESSAGING_SENDER_ID=
77
FIREBASE_APP_ID=
8-
FIREBASE_MEASUREMENT_ID=
8+
FIREBASE_MEASUREMENT_ID=
9+
10+
API_BASE_URL=http://localhost:5000

App.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import 'react-native-gesture-handler';
22
import React from 'react';
3+
import { Provider } from 'react-redux';
4+
5+
import store from '@redux/store';
36

47
import AppWithNavigation from './src/app';
58

69
export default function App() {
7-
return <AppWithNavigation />;
10+
return (
11+
<Provider store={store}>
12+
<AppWithNavigation />
13+
</Provider>
14+
);
815
}

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,21 @@
1515

1616
- Escanear el código QR en la aplicación Expo si es android o desde la camára si es iOS
1717

18-
- Listo!
18+
- Listo!
19+
20+
## Conectar con el appserver localmente
21+
22+
- Levantar el appserver
23+
24+
- Levantar la app desde un emulador
25+
26+
- En una terminal correr `adb reverse tcp:5000 tcp:5000` donde 5000 es el puerto donde esta corriendo el appserver y lo forwardeamos a la app.
27+
28+
- Ahora las pegadas a localhost:5000 desde la app deberian pegarle al appserver levantado localmente
29+
30+
- Para loguearse por ahora se puede usar:
31+
32+
```
33+
username: 'user1'
34+
password: '123'
35+
```

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@react-navigation/native": "^5.1.5",
2121
"@react-navigation/stack": "^5.2.10",
2222
"@react-navigation/web": "~1.0.0-alpha.9",
23+
"apisauce": "^1.1.1",
2324
"eslint": "^6.8.0",
2425
"eslint-config-prettier": "^6.11.0",
2526
"eslint-plugin-import": "^2.20.2",
@@ -40,7 +41,10 @@
4041
"react-native-gesture-handler": "~1.6.0",
4142
"react-native-safe-area-context": "0.7.3",
4243
"react-native-screens": "~2.2.0",
43-
"react-native-web": "~0.11.7"
44+
"react-native-web": "~0.11.7",
45+
"react-redux": "^7.2.0",
46+
"redux": "^4.0.5",
47+
"redux-thunk": "^2.3.0"
4448
},
4549
"devDependencies": {
4650
"@babel/core": "^7.8.6",
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { useCallback } from 'react';
2+
import { useDispatch } from 'react-redux';
3+
4+
import { FontAwesome } from '@expo/vector-icons';
5+
import { ROUTES } from '@constants/routes';
6+
import { COLORS } from '@constants/colors';
7+
import actionCreator from '@redux/auth/actions';
8+
9+
export default function LoginButton({ navigation }) {
10+
const dispatch = useDispatch();
11+
12+
const onLogout = useCallback(() => {
13+
dispatch(actionCreator.logout());
14+
navigation.navigate(ROUTES.Login);
15+
}, [navigation, dispatch]);
16+
17+
return (
18+
<>
19+
<FontAwesome.Button
20+
name="sign-out"
21+
backgroundColor={COLORS.white}
22+
color={COLORS.main}
23+
size={30}
24+
onPress={onLogout}
25+
/>
26+
</>
27+
);
28+
}

src/app/components/VideoPlayer/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Video } from 'expo-av';
44

55
import styles from './styles';
66

7-
function VideoPlayer({ sources }) {
7+
function VideoPlayer({ source }) {
88
const [videoRef, setVideoRef] = useState(null);
99

1010
const handleVideoRef = useCallback((component) => {
@@ -16,7 +16,7 @@ function VideoPlayer({ sources }) {
1616
<Video
1717
ref={handleVideoRef}
1818
source={{
19-
uri: sources[0]
19+
uri: source
2020
}}
2121
rate={1.0}
2222
isMuted //={false}

src/app/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import VideoDetailScreen from '@screens/VideoDetailScreen';
1616
import UploadVideoScreen from '@screens/UploadVideoScreen';
1717
import TabBarIcon from '@components/TabBarIcon';
1818
import HeaderButtons from '@components/HeaderButtons';
19+
//import LogoutButton from '@components/LogoutButton';
1920

2021
const Stack = createStackNavigator();
2122
const WallStack = createStackNavigator();
@@ -29,6 +30,7 @@ function WallStackScreen() {
2930
component={HomeScreen}
3031
options={({ navigation }) => ({
3132
title: ROUTES.Wall,
33+
//headerLeft: () => <LogoutButton navigation={navigation} />,
3234
headerRightContainerStyle: { flexDirection: 'row' },
3335
headerRight: () => <HeaderButtons navigation={navigation} />
3436
})}
@@ -96,7 +98,9 @@ function TabNavigatorScreen() {
9698
export default function App() {
9799
return (
98100
<NavigationContainer>
99-
<Stack.Navigator initialRouteName={ROUTES.Login} headerMode="none">
101+
<Stack.Navigator
102+
initialRouteName={ROUTES.InitialLoading}
103+
headerMode="none">
100104
<Stack.Screen name={ROUTES.InitialLoading} component={InitialLoading} />
101105
<Stack.Screen name={ROUTES.Login} component={LoginScreen} />
102106
<Stack.Screen name={ROUTES.SignUp} component={SignUpScreen} />

src/app/screens/HomeScreen/constants.js

-154
This file was deleted.

src/app/screens/HomeScreen/index.js

+30-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
1-
import React, { useCallback } from 'react';
2-
import { SafeAreaView, FlatList, TouchableOpacity } from 'react-native';
1+
import React, { useCallback, useEffect } from 'react';
2+
import { useDispatch, useSelector } from 'react-redux';
3+
import {
4+
SafeAreaView,
5+
FlatList,
6+
TouchableOpacity,
7+
ActivityIndicator
8+
} from 'react-native';
39

410
import { ROUTES } from '@constants/routes';
11+
import { COLORS } from '@constants/colors';
512
import VideoCard from '@components/VideoCard';
13+
import actionCreators from '@redux/videos/actions';
614

7-
import { VIDEOS } from './constants';
815
import styles from './styles';
916

1017
function HomeScreen({ navigation }) {
18+
const dispatch = useDispatch();
19+
20+
const videos = useSelector((state) => state.videos.videos);
21+
const videosLoading = useSelector((state) => state.videos.loading);
22+
23+
useEffect(() => {
24+
dispatch(actionCreators.getVideos());
25+
}, [dispatch]);
26+
1127
const renderVideo = useCallback(
1228
({ item }) => (
1329
<TouchableOpacity
30+
style={styles.videoCard}
1431
onPress={() =>
1532
navigation.navigate(ROUTES.VideoScreen, { video: item })
1633
}>
1734
<VideoCard
1835
title={item.title}
1936
thumb={item.thumb}
20-
subtitle={item.subtitle}
37+
subtitle={item.author}
2138
/>
2239
</TouchableOpacity>
2340
),
@@ -28,11 +45,15 @@ function HomeScreen({ navigation }) {
2845

2946
return (
3047
<SafeAreaView style={styles.container}>
31-
<FlatList
32-
data={VIDEOS}
33-
renderItem={renderVideo}
34-
keyExtractor={keyExtractor}
35-
/>
48+
{videosLoading ? (
49+
<ActivityIndicator size="large" color={COLORS.main} />
50+
) : (
51+
<FlatList
52+
data={videos}
53+
renderItem={renderVideo}
54+
keyExtractor={keyExtractor}
55+
/>
56+
)}
3657
</SafeAreaView>
3758
);
3859
}

src/app/screens/HomeScreen/styles.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ const styles = StyleSheet.create({
66
alignItems: 'center',
77
justifyContent: 'center'
88
},
9-
addVideoButton: {
10-
position: 'absolute',
11-
right: 30,
12-
bottom: 30
9+
videoCard: {
10+
minWidth: '100%'
1311
}
1412
});
1513

0 commit comments

Comments
 (0)