diff --git a/package.json b/package.json
index 7d6e7467..c2d25679 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,8 @@
"expo-camera": "~8.0.0",
"expo-constants": "~8.0.0",
"expo-font": "~8.0.0",
+ "expo-media-library": "~8.0.0",
+ "expo-permissions": "~8.0.0",
"expo-web-browser": "~8.0.0",
"express-session": "^1.17.0",
"mem": "^6.0.1",
diff --git a/src/screens/Main/RecordStack/RecordScreen/RecordScreen.tsx b/src/screens/Main/RecordStack/RecordScreen/RecordScreen.tsx
index 5da1a5ca..85351db5 100644
--- a/src/screens/Main/RecordStack/RecordScreen/RecordScreen.tsx
+++ b/src/screens/Main/RecordStack/RecordScreen/RecordScreen.tsx
@@ -1,7 +1,9 @@
import React, { useState, useEffect } from 'react'
-import { Text, View, TouchableOpacity, Image, StatusBar, Alert } from 'react-native'
+import { Text, View, TouchableOpacity, Image, StatusBar} from 'react-native'
import { Camera } from 'expo-camera'
import styles from './styles'
+import * as Permissions from 'expo-permissions'
+import * as MediaLibrary from 'expo-media-library'
import { NavigationScreenProp, NavigationState, NavigationParams } from 'react-navigation'
interface Props {
@@ -16,12 +18,41 @@ export default function RecordScreen(props: Props) {
const [camera, setCamera] = useState()
const [isRecording, setIsRecording] = useState(false)
const [cameraDirection, setCameraDirection] = useState(Camera.Constants.Type.front)
+ const [video, setVideo] = useState(null)
+
+ async function saveVideo(){
+ const asset = await MediaLibrary.createAssetAsync(video.uri)
+ if (asset) {
+ setVideo(null)
+ }
+ }
+
+ async function stopRecord(){
+ setIsRecording(false)
+ camera.stopRecording()
+ }
+
+ async function startRecord(){
+ if (camera) {
+ setIsRecording(true)
+ const data = await camera.recordAsync()
+ setVideo(data)
+ }
+ }
+
+ async function toogleRecord(){
+ if (isRecording) {
+ stopRecord()
+ } else {
+ startRecord()
+ }
+ }
useEffect(() => {
(async () => {
- const { status } = await Camera.requestPermissionsAsync()
- setHasPermission(status === 'granted')
-
+ const { status: cameraPermission } = await Camera.requestPermissionsAsync()
+ const { status: cameraRollPermission } = await Permissions.askAsync(Permissions.CAMERA_ROLL)
+ setHasPermission(cameraPermission === 'granted' && cameraRollPermission === 'granted')
})()
}, [])
@@ -41,10 +72,18 @@ export default function RecordScreen(props: Props) {
>
-
+ {video && (
+ saveVideo()}
+ style={styles.saveButton}
+ >
+ save
+
+ )}
-
-
+
+ {!video && (
+
Create a 3-4 Minute Video
@@ -52,42 +91,32 @@ export default function RecordScreen(props: Props) {
{question}
-
+ )}
- goBack()}
style={styles.whiteButtonOutline}
>
-
+ )}
- {
- if(camera) {
- if (isRecording) {
- setIsRecording(false)
- camera.stopRecording()
- } else {
- const video = camera.recordAsync()
- setIsRecording(true)
- }
- }
- }}
+ {!video && (toogleRecord()}
style={styles.recordOutline}
>
-
+
-
+ )}
- {
setCameraDirection(cameraDirection === Camera.Constants.Type.front ? Camera.Constants.Type.back : Camera.Constants.Type.front)
}}
>
-
+ )}
diff --git a/src/screens/Main/RecordStack/RecordScreen/styles.tsx b/src/screens/Main/RecordStack/RecordScreen/styles.tsx
index faecc3d4..59142103 100644
--- a/src/screens/Main/RecordStack/RecordScreen/styles.tsx
+++ b/src/screens/Main/RecordStack/RecordScreen/styles.tsx
@@ -23,6 +23,13 @@ const styles = StyleSheet.create({
borderRadius: 48,
alignSelf: 'center',
},
+ isRecordingButton: {
+ backgroundColor: '#FF3B30',
+ width: 16,
+ height: 16,
+ borderRadius: 4,
+ alignSelf: 'center',
+ },
recordOutline: {
display: 'flex',
justifyContent: 'center',
@@ -50,7 +57,6 @@ const styles = StyleSheet.create({
borderWidth: 4,
borderColor: '#fff',
},
-
middleSection: {
display: 'flex',
flexDirection: 'column',
@@ -58,11 +64,9 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'flex-start',
alignSelf: 'center',
-
},
overlay: {
position: 'absolute',
-
},
infoText: {
backgroundColor: 'rgba(51,51,51,0.4)',
@@ -94,6 +98,24 @@ const styles = StyleSheet.create({
bottomSection: {
flex: 1,
},
+ saveButton: {
+ backgroundColor: '#E5186E',
+ transform: [ { rotateZ: '270deg'}],
+ width: 79,
+ height: 48,
+ justifyContent: 'center',
+ left: '75%',
+ top: '15%',
+ borderRadius: 24,
+ right: -Dimensions.get('window').width + (Dimensions.get('window').width * 0.25)
+ },
+ saveText: {
+ textAlign: 'center',
+ color: '#fff',
+ fontSize: 18,
+ lineHeight: 21,
+ fontFamily: 'roboto-regular'
+ }
})
export default styles
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 817bde68..a29edb63 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4238,6 +4238,11 @@ expo-location@~8.0.0:
dependencies:
invariant "^2.2.4"
+expo-media-library@~8.0.0:
+ version "8.0.0"
+ resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-8.0.0.tgz#d763a2f39a81348d357171be5ea486679c2edb86"
+ integrity sha512-7TIcJjmQq+sH3deIVjwyQYa3nVsLZZUj6fQYA3R+DrFNRT6ehmd1Lai0klTa7ma3pflPEC4Uv2zOyf53alvD2w==
+
expo-permissions@~8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/expo-permissions/-/expo-permissions-8.0.0.tgz#5a45e8451dd7ff37c9e6ce5e2447818372547813"