move permissions to record
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import React, { useCallback, useState } from "react";
|
||||
import {
|
||||
Alert,
|
||||
Keyboard,
|
||||
Platform,
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
@@ -8,6 +10,9 @@ import {
|
||||
View,
|
||||
} from "react-native";
|
||||
import DropDownPicker from "react-native-dropdown-picker";
|
||||
// @ts-ignore
|
||||
import { useCameraPermission } from "react-native-vision-camera";
|
||||
import { cameraPermissionsDenied } from "../../lib/alert-messages";
|
||||
import { recordStyles as styles } from "./styles";
|
||||
|
||||
interface CameraScreenParams {
|
||||
@@ -17,10 +22,14 @@ interface CameraScreenParams {
|
||||
location: string;
|
||||
}
|
||||
|
||||
// Record Screen
|
||||
// Precedes Camera.tsx
|
||||
// Can be made into Modal when ready
|
||||
export default function RecordScreen({ navigation }): React.JSX.Element {
|
||||
// Permissions
|
||||
const { hasPermission, requestPermission } = useCameraPermission();
|
||||
|
||||
if (!hasPermission) {
|
||||
requestPermission();
|
||||
}
|
||||
|
||||
// Game type dropdown
|
||||
const [gameTypeOpen, setGameTypeOpen] = useState<boolean>(false);
|
||||
const [gameType, setGameType] = useState<string | null>(null); // This is a dropdown
|
||||
@@ -63,7 +72,15 @@ export default function RecordScreen({ navigation }): React.JSX.Element {
|
||||
// Location
|
||||
const [location, setLocation] = useState<string>("");
|
||||
|
||||
const { android, ios } = cameraPermissionsDenied;
|
||||
|
||||
const handleSubmit = () => {
|
||||
// Next block's alert message are OS specific
|
||||
if (!hasPermission) {
|
||||
if (Platform.OS === 'android') return Alert.alert(android.title, android.message);
|
||||
else return Alert.alert(ios.title, ios.message);
|
||||
}
|
||||
|
||||
// needs to pass info as params or store in a context/state provider
|
||||
const params: CameraScreenParams = {
|
||||
gameType: gameType,
|
||||
|
||||
Reference in New Issue
Block a user