Handle loading of exercises in EditPlan
This commit is contained in:
parent
4dd8a2950f
commit
bec564e18b
13
EditPlan.tsx
13
EditPlan.tsx
|
@ -11,6 +11,7 @@ import {
|
||||||
IconButton,
|
IconButton,
|
||||||
Switch as PaperSwitch,
|
Switch as PaperSwitch,
|
||||||
Text,
|
Text,
|
||||||
|
ActivityIndicator,
|
||||||
} from "react-native-paper";
|
} from "react-native-paper";
|
||||||
import ReorderableList, {
|
import ReorderableList, {
|
||||||
ReorderableListRenderItemInfo,
|
ReorderableListRenderItemInfo,
|
||||||
|
@ -24,12 +25,13 @@ import { DrawerParams } from "./drawer-param-list";
|
||||||
import GymSet, { defaultSet } from "./gym-set";
|
import GymSet, { defaultSet } from "./gym-set";
|
||||||
import StackHeader from "./StackHeader";
|
import StackHeader from "./StackHeader";
|
||||||
import Switch from "./Switch";
|
import Switch from "./Switch";
|
||||||
|
import { ProgressCircle } from "react-native-svg-charts";
|
||||||
|
|
||||||
export default function EditPlan() {
|
export default function EditPlan() {
|
||||||
const { params } = useRoute<RouteProp<StackParams, "EditPlan">>();
|
const { params } = useRoute<RouteProp<StackParams, "EditPlan">>();
|
||||||
const { plan } = params;
|
const { plan } = params;
|
||||||
const [title, setTitle] = useState<string>(plan?.title);
|
const [title, setTitle] = useState<string>(plan?.title);
|
||||||
const [names, setNames] = useState<string[]>([]);
|
const [names, setNames] = useState<string[]>();
|
||||||
|
|
||||||
const [days, setDays] = useState<string[]>(
|
const [days, setDays] = useState<string[]>(
|
||||||
plan.days ? plan.days.split(",") : []
|
plan.days ? plan.days.split(",") : []
|
||||||
|
@ -170,13 +172,12 @@ export default function EditPlan() {
|
||||||
{DAYS.map((day) => renderDay(day))}
|
{DAYS.map((day) => renderDay(day))}
|
||||||
|
|
||||||
<Text style={[styles.title, { marginTop: MARGIN }]}>Exercises</Text>
|
<Text style={[styles.title, { marginTop: MARGIN }]}>Exercises</Text>
|
||||||
{names.length === 0 ? (
|
{names === undefined ? (
|
||||||
<View>
|
<ActivityIndicator />
|
||||||
<Text>No exercises found.</Text>
|
|
||||||
</View>
|
|
||||||
) : (
|
) : (
|
||||||
<ReorderableList
|
<ReorderableList
|
||||||
data={names}
|
data={names}
|
||||||
|
ListEmptyComponent={<Text>No exercises yet</Text>}
|
||||||
onReorder={({ fromIndex, toIndex }) =>
|
onReorder={({ fromIndex, toIndex }) =>
|
||||||
reorderExercise(fromIndex, toIndex)
|
reorderExercise(fromIndex, toIndex)
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,6 @@ export default function EditPlan() {
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={exercises.length === 0 && days.length === 0}
|
disabled={exercises.length === 0 && days.length === 0}
|
||||||
style={styles.button}
|
|
||||||
mode="outlined"
|
mode="outlined"
|
||||||
icon="content-save"
|
icon="content-save"
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
|
@ -212,5 +212,4 @@ const styles = StyleSheet.create({
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
marginBottom: MARGIN,
|
marginBottom: MARGIN,
|
||||||
},
|
},
|
||||||
button: {},
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user