Skip to content

Commit

Permalink
Merge pull request #1 from steelhawks/dev
Browse files Browse the repository at this point in the history
Merge from dev to main 9/23/24
  • Loading branch information
FarhanJ2 authored Sep 23, 2024
2 parents 3bc52a4 + 845dec8 commit 3933d2a
Show file tree
Hide file tree
Showing 32 changed files with 1,425 additions and 619 deletions.
7 changes: 4 additions & 3 deletions AnimationLoader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const AnimatedLottieView = Animated.createAnimatedComponent(LottieView);
const animationSources = {
LOAD_01: require('./assets/anim_load_01.json'),
LOAD_02: require('./assets/anim_load_02.json'),
SUCCESS_01: require('./assets/anim_success.json')
SUCCESS_01: require('./assets/anim_success.json'),
QR_SCANNER: require('./assets/anim_scanner.json')
// Add more animation sources as needed
};

const AnimationLoader = ({ isLoading = false, loop = true, animationKey = 'LOAD_02', onAnimationComplete }) => {
const AnimationLoader = ({ isLoading = false, loop = true, animationKey = 'LOAD_02', onAnimationComplete, width = 200, height = 200 }) => {
const animationSource = animationSources[animationKey];

const setOn = (duration, callback) => {
Expand All @@ -29,7 +30,7 @@ const AnimationLoader = ({ isLoading = false, loop = true, animationKey = 'LOAD_
source={animationSource}
autoPlay
loop={loop}
style={{ width: 200, height: 200 }}
style={{ width: width, height: height }}
onAnimationFinish={() => setOn(0, onAnimationComplete)} // Use setOn to delay the callback
/>
</View>
Expand Down
24 changes: 22 additions & 2 deletions App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ManageAccount from './screens/ManageAccount';
// import Tutorial from './screens/Tutorial';
import {NavigationContainer} from '@react-navigation/native';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import {StyleSheet, StatusBar} from 'react-native';
import {StyleSheet, StatusBar, AppState} from 'react-native';
import {NewMatch} from '.';
import PitScoutingPage from './screens/PitScoutingPage';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
Expand All @@ -24,6 +24,8 @@ import {
} from './permissions/RequestPermissions';
import DeviceInfo from 'react-native-device-info';
import * as Sentry from '@sentry/react-native';
import {supabase} from "./supabase";
import { createStackNavigator } from '@react-navigation/stack';

Sentry.init({
dsn: 'https://08757a6e7744a5cd6a808c9c372f7ec8@o4506839099637760.ingest.us.sentry.io/4506839106060288',
Expand All @@ -33,6 +35,18 @@ Sentry.init({
tracesSampleRate: 1.0,
});

// Tells Supabase Auth to continuously refresh the session automatically if
// the app is in the foreground. When this is added, you will continue to receive
// `onAuthStateChange` events with the `TOKEN_REFRESHED` or `SIGNED_OUT` event
// if the user's session is terminated. This should only be registered once.
AppState.addEventListener('change', (state) => {
if (state === 'active') {
supabase.auth.startAutoRefresh()
} else {
supabase.auth.stopAutoRefresh()
}
})

const Tab = createBottomTabNavigator(); // new
const appVersion = 'v' + DeviceInfo.getVersion().toString();

Expand Down Expand Up @@ -100,7 +114,7 @@ const App = () => {
};

const LoginPageNavigate = props => {
const Tab = createMaterialTopTabNavigator();
const Tab = createStackNavigator();
// request permissions
RequestDefaultPermissions();

Expand All @@ -124,6 +138,9 @@ const App = () => {
name="Login"
component={LoginPage}
initialParams={{setUser: setUser}}
options={{
headerShown: false
}}
/>
<Tab.Screen
name="Create Account"
Expand Down Expand Up @@ -310,6 +327,9 @@ const App = () => {
<Tab.Screen
name="Login"
component={LoginPageNavigate}
options={{
headerShown: false,
}}
/>
</Tab.Navigator>
)}
Expand Down
1 change: 1 addition & 0 deletions assets/anim_scanner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"4.8.0","meta":{"g":"LottieFiles AE 1.0.0","a":"","k":"","d":"","tc":""},"fr":29.9700012207031,"ip":0,"op":201.000008186898,"w":687,"h":638,"nm":"SC-4-focus animation","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 6","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.235,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[373.5,169,0],"to":[0,53.333,0],"ti":[0,-53.333,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"t":33,"s":[373.5,489,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.224,"y":1},"o":{"x":0.297,"y":0},"t":39,"s":[373.5,489,0],"to":[0,-53.333,0],"ti":[0,0,0]},{"i":{"x":0.235,"y":1},"o":{"x":0.167,"y":0},"t":70,"s":[373.5,169,0],"to":[0,0,0],"ti":[0,-53.333,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"t":99,"s":[373.5,489,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.224,"y":1},"o":{"x":0.297,"y":0},"t":105,"s":[373.5,489,0],"to":[0,-53.333,0],"ti":[0,0,0]},{"i":{"x":0.235,"y":1},"o":{"x":0.167,"y":0},"t":136,"s":[373.5,169,0],"to":[0,0,0],"ti":[0,-53.333,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"t":163,"s":[373.5,489,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.224,"y":1},"o":{"x":0.297,"y":0},"t":169,"s":[373.5,489,0],"to":[0,-53.333,0],"ti":[0,53.333,0]},{"t":200.000008146167,"s":[373.5,169,0]}],"ix":2},"a":{"a":0,"k":[28,-20,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-156,-20],[212,-20]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.588706820619,0.588706820619,0.588706820619,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":12,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1978.00008056559,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":270,"ix":10},"p":{"a":0,"k":[159.5,513.5,0],"ix":2},"a":{"a":0,"k":[-194,-187.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-136,-244],[-252,-244],[-252,-131]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,0,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":20,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1978.00008056559,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":180,"ix":10},"p":{"a":0,"k":[586.5,513.5,0],"ix":2},"a":{"a":0,"k":[-194,-187.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-136,-244],[-252,-244],[-252,-131]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,0,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":20,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1978.00008056559,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"Shape Layer 5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":90,"ix":10},"p":{"a":0,"k":[584.5,131.5,0],"ix":2},"a":{"a":0,"k":[-194,-187.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-136,-244],[-252,-244],[-252,-131]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,0,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":20,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1978.00008056559,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[157.5,131.5,0],"ix":2},"a":{"a":0,"k":[-194,-187.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-136,-244],[-252,-244],[-252,-131]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,0,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":20,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1978.00008056559,"st":0,"bm":0}],"markers":[]}
Binary file added assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/frc_hawk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hawk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hawk1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hawk2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion authentication/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,32 @@ const eventNameSaveFilePath =
const formDataSaveFilePath = RNFS.DocumentDirectoryPath + '/data/formData.json';

// const SERVER_ENDPOINT = 'https://steelhawks.herokuapp.com'; // prod
const SERVER_ENDPOINT = 'http://192.168.1.183:8080'; //dev
const SERVER_ENDPOINT = 'http://192.168.1.175:8082'; //dev

export const fetchAfterLogin = async (username: string, osis: string, appVersion: string, accessToken: string) => {
try {
const response = await fetch(`${SERVER_ENDPOINT}/get_data_after_login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({username, osis, appVersion, accessToken}),
});

if (response.ok) {
return true;
} else {
console.log(response);
return false;
}
} catch (error) {
console.log(error);
throw new Error(
`Error checking user authenticity data from the server: ${error}`,
)
}
}

export const fetchUserCredentialsFromServer = async (
username: string,
osis: string,
Expand Down
96 changes: 87 additions & 9 deletions components/CameraView.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import {Alert, StyleSheet, Text, View} from 'react-native';
import {Alert, Image, StyleSheet, Text, View} from 'react-native';
import {Camera, CameraType} from 'expo-camera';
import Button from '../components/inputs/Button';
import fs from 'react-native-fs';
import {useState} from 'react';
import Animated, {FadeInDown} from 'react-native-reanimated';
import { RFValue } from 'react-native-responsive-fontsize';
import AnimationLoader from '../AnimationLoader';
import { SafeAreaView } from 'react-native-safe-area-context';

const docDir = fs.DocumentDirectoryPath;

export const CameraView = ({navigation}: any) => {
const [facing, setFacing] = useState('back');
const [permission, requestPermission] = Camera.useCameraPermissions();
const [scanned, setScanned] = useState(false);

if (!permission) {
// Camera permissions are still loading.
Expand Down Expand Up @@ -54,33 +59,103 @@ export const CameraView = ({navigation}: any) => {
const jsonData = JSON.stringify(data, null, 4);
await fs.writeFile(filePath, jsonData, 'utf8');
}

navigation.navigate('ManageAccount');
setScanned(true);
// navigation.navigate('ManageAccount');
};

return (
<View style={styles.container}>
<SafeAreaView style={styles.container}>
<Camera

style={styles.camera}
onBarCodeScanned={data => saveOfflineData(data.data)}
type={facing === 'back' ? CameraType.back : CameraType.front}>
<View style={styles.buttonContainer}>
{/* <View style={styles.buttonContainer}>
<Button label="Flip" onPress={toggleCameraFacing} />
</View> */}

<View style={styles.tooltipContainer}>
<Text style={styles.text}>Find a code to scan</Text>
<View style={{
alignSelf: 'center',
alignContent: 'center',
justifyContent: 'center',
position: 'absolute',
left: '47%',
}}>
<AnimationLoader
isLoading={!scanned}
loop={true}
animationKey={'QR_SCANNER'}
onAnimationComplete={undefined}
width={300}
height={300}
/>
</View>
</View>

{scanned && (
<Animated.View
style={styles.animationContainer}
entering={FadeInDown.delay(600)
.duration(1000)
.springify()}>
<Text style={styles.scannedText}>QR Code Scanned!</Text>
<Image
source={require('../assets/hawk1.png')}
style={styles.image}
/>
<Button
onPress={() => setScanned(false)}
label={'Close'}
/>
</Animated.View>
)}
</Camera>
</View>
</SafeAreaView>
);
};

const styles = StyleSheet.create({
image: {
width: 200,
height: 200,
resizeMode: 'contain',
},
scannedText: {
fontSize: 28,
fontWeight: 'bold',
color: '#fff',
},
tooltipContainer: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
justifyContent: 'center',
alignItems: 'center',
},
animationContainer: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0,0,0,0.6)',
},
container: {
flex: 1,
// backgroundColor: '#fff',
justifyContent: 'center',
},
camera: {
flex: 1,
borderRadius: 20,
bottom: 0,
left: 0,
right: 0,
// top: RFValue(-22.5),
},
buttonContainer: {
position: 'absolute',
Expand All @@ -97,8 +172,11 @@ const styles = StyleSheet.create({
marginHorizontal: 10,
},
text: {
alignSelf: 'center',
fontSize: 18,
fontWeight: 'bold',
color: '#000000',
// paddingBottom: RFValue(500),
height: '120%',
color: '#ffffff',
},
});
13 changes: 11 additions & 2 deletions components/NewMatch.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState, useEffect} from 'react';
import {ScrollView, Text, View, StyleSheet, Alert} from 'react-native';
import {ScrollView, Text, View, StyleSheet, Alert, Image} from 'react-native';
import AnimationLoader from '../AnimationLoader';
import Button from './inputs/Button';
import DriveStationUI from './inputs/DriveStationUI';
Expand All @@ -12,6 +12,7 @@ import {useDictStore, usePitDict} from '../contexts/dict.jsx';
import Icon from 'react-native-vector-icons/Feather';
import CounterBox from './inputs/CounterBox';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Animated, { FadeInDown, FadeInUp } from 'react-native-reanimated';

const NewMatch = ({
teamData,
Expand Down Expand Up @@ -135,7 +136,7 @@ const NewMatch = ({
/>

<DropdownComponent
value={matchType}
initialValue={matchType}
data={matchTypeData}
placeholder={'Select Match Type'}
// onValueChange={value => setDict('matchType', value)}
Expand Down Expand Up @@ -239,6 +240,9 @@ const NewMatch = ({
label={'Create Match'}
onPress={handleStartScouting}
/>
<View style={{alignItems: 'center'}}>
<Image source={require('../assets/hawk2.png')} style={styles.image} />
</View>
</View>
</ScrollView>
<AnimationLoader isLoading={isLoading} />
Expand All @@ -251,6 +255,11 @@ const NewMatch = ({
};

const styles = StyleSheet.create({
image: {
width: 200,
height: 200,
resizeMode: 'contain',
},
avoidTabBar: {
flex: 1,
backgroundColor: '#121212',
Expand Down
4 changes: 2 additions & 2 deletions components/scouting_components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import Heading from './Heading';

interface SectionProps {
title: string | null | undefined | number;
queries: JSX.Element | JSX.Element[];
title?: string | null;
queries?: any;
style: any;
}

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import App from './App';
import {name as appName} from './app.json';
import {createContext} from 'react';


// Components
export {default as NewMatch} from "./components/NewMatch";

Expand Down
Loading

0 comments on commit 3933d2a

Please sign in to comment.