Skip to content

Commit

Permalink
Merge branch 'master' into defense-timer
Browse files Browse the repository at this point in the history
  • Loading branch information
PramitaUp authored Feb 13, 2025
2 parents caf11f7 + 3bc27ff commit 1334e8d
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 32 deletions.
17 changes: 16 additions & 1 deletion app/api/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AlgaeLevel, CLIMB_TYPE, DRIVER_STATION, GamePhase, MatchData, ReefLevel, START_POSITION } from "./data_types";
import { AlgaeLevel, CLIMB_TYPE, DRIVER_STATION, GamePhase, MatchData, ReefLevel, START_POSITION, Tag } from "./data_types";
import AsyncStorage from "@react-native-async-storage/async-storage";

export function getMatchData(): Promise<MatchData> {
Expand Down Expand Up @@ -99,4 +99,19 @@ export function updateNotes(notes: string): Promise<void> {
data["notes"] = notes;
return data;
});
}

export function updateTags(tag: Tag, removeTag?: boolean): Promise<void> {
return modifyMatchData((data) => {
const tags = new Set(data["tags"]);

if (removeTag) {
tags.delete(tag);
} else {
tags.add(tag);
}

data["tags"] = [...tags];
return data;
});
}
2 changes: 1 addition & 1 deletion app/api/data_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ export class MatchData {
export type GamePhase = "teleop" | "autonomous";
export type Tag = "tag1" | "tag2";
export type ReefLevel = "L4" | "L3" | "L2" | "L1";
export type AlgaeLevel = "net" | "processor";
export type AlgaeLevel = "net" | "processor";
7 changes: 3 additions & 4 deletions app/auto.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import { Keyboard, ScrollView, StyleSheet, View } from 'react-native';
import PageHeader from './components/Header';
import NavButton from './components/NavButton';
import ReefAlgaeView from './views/ReefAlgaeView';
Expand All @@ -13,16 +13,15 @@ export default function App() {

<PageHeader title='Auto' pageNumber='2/4' previous='' />


<ScrollView>
<AutoStartPositionView/>

<ReefAlgaeView phase="autonomous" />
<AlgaeView phase="autonomous" />

<NavButton text="Next" pageName="teleop" />
<StatusBar style="auto" />


</ScrollView>
</View>
);
}
Expand Down
38 changes: 38 additions & 0 deletions app/components/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useState, useEffect} from 'react';
import { Checkbox as PaperCheckbox } from 'react-native-paper';
import { View, Text } from 'react-native';
import { BACKGROUND_COLOR } from '../consts';
import { Tag } from '../api/data_types';
import { getMatchData, updateTags } from '../api/data';

interface CheckboxProps {
tag: Tag;
}

function Checkbox({ tag }: CheckboxProps) {
const [checked, setChecked] = useState(false);

useEffect(() => {
getMatchData().then((data) => {
setChecked(!(data["tags"].includes(tag)));
});
}, []);

return (
<View style={[{ flexDirection: "row", alignItems: "center" }]}>

<PaperCheckbox.Android
color={BACKGROUND_COLOR}
status={checked ? 'checked' : 'unchecked'}
onPress={() => {
setChecked(!checked);
updateTags(tag, !checked);
}}
/>
<Text>{tag}</Text>

</View>
)
}

export default Checkbox;
6 changes: 1 addition & 5 deletions app/components/NavButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ function NavButton({ text, pageName, disabled }: NavButtonProps) {
const insets = useSafeAreaInsets();

return (
<View style={[{
position: "absolute",
bottom: 20 + insets.bottom,
right: 20 + insets.right
}]}>
<View style={[{ flexDirection: 'row-reverse' }]}>
<Link href={"/" + pageName} asChild>
<Button textColor={TEXT_COLOR} buttonColor={BACKGROUND_COLOR} mode="contained"
contentStyle={{ height: 80, width: 80 }} disabled={disabled}>{text}</Button>
Expand Down
4 changes: 2 additions & 2 deletions app/components/RadioButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { View, Text } from 'react-native'
import { View, Text, Keyboard } from 'react-native'
import { useEffect, useState } from 'react';
import { RadioButton as PaperRadioButton } from 'react-native-paper';
import { BACKGROUND_COLOR } from '../consts';
Expand Down Expand Up @@ -39,4 +39,4 @@ function RadioButton({ data, onSelect, oldSelected }: RadioButton) {
);
}

export default RadioButton;
export default RadioButton;
8 changes: 5 additions & 3 deletions app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import { Keyboard, ScrollView, StyleSheet, View } from 'react-native';
import NavButton from './components/NavButton';
import PageHeader from './components/Header';
import LabeledTextInput from './components/LabeledTextInput';
Expand All @@ -26,9 +26,10 @@ export default function App() {
})

return (
<View style={styles.container}>
<View style={styles.container} onTouchStart={Keyboard.dismiss}>
<PageHeader title='Main' pageNumber='1/4' showTeam={false} />

<ScrollView>

<LabeledTextInput label="Name" editable={true} submit={(e) => {
updateName(e.nativeEvent.text);
setNameFilled(e.nativeEvent.text !== "");
Expand Down Expand Up @@ -61,6 +62,7 @@ export default function App() {
disabled={ !(nameFilled && teamNumberFilled && matchFilled) } />

<StatusBar style="auto" />
</ScrollView>
</View>
);
}
Expand Down
21 changes: 15 additions & 6 deletions app/summary.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import Dropdown from './components/Dropdown';
import { Keyboard, ScrollView, StyleSheet, View } from 'react-native';
import LabeledTextInput from './components/LabeledTextInput';
import { getMatchData, updateNotes } from './api/data';
import PageHeader from './components/Header';
import SummaryTableView from './views/SummaryTableView';
import Checkbox from './components/Checkbox';

export default function App() {
return (
<View style={styles.container}>
<View style={styles.container} onTouchStart={Keyboard.dismiss}>
<PageHeader title="Summary" pageNumber="4/4" previous='teleop' />

<ScrollView>
<SummaryTableView />

<LabeledTextInput label="Notes" editable={true} multiline={true}
submit={(e) => {
updateNotes(e.nativeEvent.text);
}} oldValue={getMatchData().then((data) => data["notes"])} required />
<Dropdown label="Tags" items={["tag 1", "tag 2"]} placeholder="tag"></Dropdown>
}} oldValue={getMatchData().then((data) => data["notes"])} />

<SummaryTableView />
<Checkbox tag='Caught on fire'/>
<Checkbox tag='Stuck on gamepiece'/>
<Checkbox tag='Broke'/>
<Checkbox tag='Tipped over'/>
<Checkbox tag='Gamepiece stuck'/>
<StatusBar style="auto" />
</ScrollView>
</View>
);
}
Expand All @@ -31,4 +40,4 @@ const styles = StyleSheet.create({
// alignItems: 'center',
// justifyContent: 'center',
},
});
});
11 changes: 6 additions & 5 deletions app/teleop.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import { Keyboard, ScrollView, StyleSheet, View } from 'react-native';
import NavButton from './components/NavButton';
import ReefAlgaeView from './views/ReefAlgaeView';
import EndgameView from './views/EndgameView';
Expand All @@ -10,8 +10,9 @@ import { Divider } from 'react-native-paper';

export default function App() {
return (
<View style={styles.container}>
<View style={styles.container} onTouchStart={Keyboard.dismiss}>
<PageHeader title='Teleop' pageNumber='3/4' previous="auto" />
<ScrollView>

<Stopwatch/>
<Divider />
Expand All @@ -22,9 +23,9 @@ export default function App() {



<NavButton pageName='summary' text='Next' />
<StatusBar style="auto" />

<NavButton pageName='summary' text='Next' />
</ScrollView>
</View>
);
}
Expand All @@ -38,4 +39,4 @@ const styles = StyleSheet.create({
// alignItems: 'center',
// justifyContent: 'center',
},
});
});
4 changes: 1 addition & 3 deletions app/views/SummaryTableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function SummaryTableView() {
<DataTable>
<TableHeader titles={[ "Match Summary" ]} />
<TableRow label="Scouter" data={ getMatchData().then((data) => data["scouterName"]) } />
<TableRow label="Team Number" data={getMatchData().then((data) => data["teamNumber"].toString())} />
<TableRow label="Match Number" data={getMatchData().then((data) => data["matchNumber"].toString())} />
<TableRow label="Driver Station" data={getMatchData().then((data) => data["driverStation"])} />
<TableRow label="Start Position" data={getMatchData().then((data) => data["autonomous"]["startPosition"])} />
<TableRow label="Left Start" data={getMatchData().then((data) => data["autonomous"]["leftStart"].toString())} />
<TableRow label="Climb Type" data={getMatchData().then((data) => data["teleop"]["climb"].toString())} />
Expand All @@ -21,4 +19,4 @@ function SummaryTableView() {
)
}

export default SummaryTableView;
export default SummaryTableView;
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"typescript": "^5.3.3"
},
"private": true
}
}

0 comments on commit 1334e8d

Please sign in to comment.