-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dac979
commit 3556d34
Showing
12 changed files
with
216 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import PracticeView from "@/components/PracticeView"; | ||
import { useLocalSearchParams } from "expo-router"; | ||
import { Text } from "react-native"; | ||
|
||
export default function Practice() { | ||
const { id } = useLocalSearchParams<{ id: string }>(); | ||
|
||
return <PracticeView practiceId={id} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { View, FlatList } from "react-native"; | ||
import React from "react"; | ||
|
||
interface Props { | ||
nextRep: number; | ||
size: number; | ||
} | ||
|
||
export default function PracticeGrid({ nextRep, size }: Props) { | ||
function lightUpGrid(nextRep: number) { | ||
let newRepsGrid = Array.from({ length: 10 }, () => Array(10).fill(false)); | ||
|
||
let repsDone = nextRep - 1; | ||
let nextRow = 0; | ||
|
||
while (repsDone >= 10) { | ||
newRepsGrid[nextRow] = Array(10).fill(true); | ||
nextRow += 1; | ||
repsDone -= 10; | ||
} | ||
|
||
let nextCol = 0; | ||
while (repsDone > 0) { | ||
newRepsGrid[nextRow][nextCol] = true; | ||
nextCol += 1; | ||
repsDone -= 1; | ||
} | ||
return newRepsGrid; | ||
} | ||
|
||
const repsGrid = lightUpGrid(nextRep); | ||
|
||
const renderRepGridItem = ({ item }: { item: Array<[boolean, string]> }) => ( | ||
<View style={{ flexDirection: "row" }}> | ||
{item.map((isCompleted, index) => ( | ||
<View | ||
key={index} | ||
style={{ | ||
width: size, | ||
height: size, | ||
backgroundColor: isCompleted ? "green" : "gray", | ||
margin: size >= 10 ? 1 : 0, | ||
}} | ||
/> | ||
))} | ||
</View> | ||
); | ||
|
||
return ( | ||
<FlatList | ||
data={repsGrid} | ||
keyExtractor={(item, index) => index.toString()} | ||
renderItem={renderRepGridItem} | ||
scrollEnabled={false} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useState, useEffect } from "react"; | ||
import { View, Text, FlatList, Pressable } from "react-native"; | ||
import { Link } from "expo-router"; | ||
import { supabase } from "@/helpers/supabase"; | ||
import PracticeGrid from "@/components/PracticeGrid"; | ||
|
||
export default function PracticeList() { | ||
const [practices, setPractices] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
getPracticesFromSupabase(); | ||
}, []); | ||
|
||
async function getPracticesFromSupabase() { | ||
try { | ||
const { data } = await supabase | ||
.from("Practices") | ||
.select() | ||
.not("do100reps_title", "is", null); | ||
|
||
if (data) { | ||
setPractices(data); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
return ( | ||
<FlatList | ||
style={{ marginLeft: 12, marginRight: 12, marginTop: 12 }} | ||
data={practices} | ||
keyExtractor={(item) => item.do100reps_title} | ||
renderItem={({ item }) => ( | ||
<Link href={"/practice/" + item.id}> | ||
<View | ||
style={{ | ||
flexDirection: "row", | ||
backgroundColor: "#fff", | ||
borderRadius: 5, | ||
padding: 12, | ||
marginBottom: 12, | ||
elevation: 5, | ||
width: 360, | ||
}} | ||
> | ||
<View style={{ marginRight: 5 }}> | ||
<PracticeGrid nextRep={item.do100reps_count + 1} size={9} /> | ||
</View> | ||
<View style={{ marginLeft: 10, flex: 1 }}> | ||
<Text style={{ marginBottom: 5 }}>{item.name}</Text> | ||
<Text | ||
style={{ | ||
fontSize: 16, | ||
fontWeight: "bold", | ||
}} | ||
> | ||
{item.do100reps_title} | ||
</Text> | ||
<Text style={{ marginTop: 5 }}> | ||
Completed reps: {item.do100reps_count}/100 | ||
</Text> | ||
</View> | ||
</View> | ||
</Link> | ||
)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.