Skip to content

Commit

Permalink
bruh
Browse files Browse the repository at this point in the history
  • Loading branch information
realjoshuau committed Dec 22, 2023
1 parent 9d93817 commit 9d5a9f8
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 15 deletions.
29 changes: 16 additions & 13 deletions apps/mobile/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,22 @@ export default function App() {
const handleBarCodeScanned = ({ type, data }) => {
setScanned(true);
alert(`Bar code with type ${type} and data ${data} has been scanned!`);
setTimeout(() => {
setScanned(false);
}, 5000);
};

return (
<View style={styles.container}>
<Text>Attendance!</Text>
<Image
style={{
width: 120,
height: 120,
}}
source={{
uri: 'https://i.imgur.com/7JX0ZSv.png',
}}
/>
{/* <HomeIcon style={{ fontSize: 64 }} /> */}
{/* <HomeScreen /> */}
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
style={StyleSheet.absoluteFillObject}
/>
<View style={styles.qrCodeContainer}>
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
style={StyleSheet.absoluteFillObject}
/>
</View>
<Text>Has permission: {hasPermission.toString()}</Text>

{scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}
Expand All @@ -96,4 +92,11 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
// Centered QR code container, with a fixed size
qrCodeContainer: {
alignItems: 'center',
justifyContent: 'center',
width: 200,
height: 200,
},
});
7 changes: 6 additions & 1 deletion apps/mobile/app/scouting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { TeamEventResponse } from '@acme/tba/team';
import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { Button } from 'tamagui';
import { Button, Progress } from 'tamagui';

import { API_URL } from '../constants';

Expand Down Expand Up @@ -44,6 +44,11 @@ export default function App() {
return (
<View style={styles.container}>
<Text style={styles.title}>Scouting</Text>
{events.length === 0 && (
<>
<Text>Loading...</Text>
</>
)}
{events.map((event) => {
return (
<View key={event.key}>
Expand Down
55 changes: 55 additions & 0 deletions apps/mobile/components/settings/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { deepFreeze } from '../../utils/deepFreeze';

export const SettingsSchemaVersion = 1;

export enum PushNotificationSound {
default = 'Default',
chime = 'Chime',
special_chime_f1 = 'Chime (1)', // The f1 radio chime
special_chime_otv = 'Chime (2)', // OfflineTV's chime
none = 'None',
}

export type UserSettingsSchema = {
pushNotificationsGlobal: boolean;
pushNotificationsSound: PushNotificationSound;
pushNotifications: {
upcomingMatches: boolean;
allianceSelection: boolean;
matchScorePublish: boolean;
upcomingScouting: boolean;
pageNotifications: boolean;
accountNotifications: boolean;
};
darkMode: boolean;
_meta: {
version: number; // Schema version. Increment when changing schema.
};
};

export const DefaultUserSettings: Readonly<UserSettingsSchema> = {
pushNotificationsGlobal: true,
pushNotificationsSound: PushNotificationSound.default,
pushNotifications: {
upcomingMatches: true,
allianceSelection: true,
matchScorePublish: true,
upcomingScouting: true,
pageNotifications: true,
accountNotifications: true,
},
darkMode: false,
_meta: {
version: SettingsSchemaVersion,
},
};

if (process.env.NODE_ENV !== 'production') {
deepFreeze(DefaultUserSettings);

// Check that DefaultUserSettings is actually immutable
DefaultUserSettings.pushNotifications.upcomingMatches = false;
if (!DefaultUserSettings.pushNotifications.upcomingMatches) {
throw new Error('DefaultUserSettings is not immutable!');
}
}
5 changes: 4 additions & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"ios": "expo start --ios",
"web": "expo start --web",
"eas-build-pre-install": "npm install --global pnpm@7.x",
"eas-build-post-install": "pnpm run -w build:mobile"
"eas-build-post-install": "pnpm run -w build:mobile",
"check:expo": "expo diagnostics -w"

},
"dependencies": {
"@tamagui/font-inter": "^1.78.0",
Expand All @@ -29,6 +31,7 @@
"expo-updates": "~0.18.10",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.48.2",
"react-native": "0.72.4",
"react-native-gesture-handler": "~2.12.0",
"react-native-prompt": "^1.0.0",
Expand Down
16 changes: 16 additions & 0 deletions apps/mobile/utils/deepFreeze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function deepFreeze<T>(object: T): Readonly<T> {
// Retrieve the property names defined on object
const propNames = Object.getOwnPropertyNames(object);

// Freeze properties before freezing self
for (const name of propNames) {
// @ts-expect-error
const value = object[name];

if ((value && typeof value === 'object') || typeof value === 'function') {
deepFreeze(value);
}
}

return Object.freeze(object);
}
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9d5a9f8

Please sign in to comment.