From b223a4095cd2be48f477655c8722af01ca6e3bcf Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sun, 18 Sep 2022 18:30:37 +1200 Subject: [PATCH] Show images on Best list and Workout list Closes #19 --- BestList.tsx | 14 ++++++++++++-- WorkoutItem.tsx | 47 ++++++++++++++++++++++------------------------- best.service.ts | 2 +- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/BestList.tsx b/BestList.tsx index dca9193..3e3068b 100644 --- a/BestList.tsx +++ b/BestList.tsx @@ -4,19 +4,23 @@ import { useNavigation, } from '@react-navigation/native'; import React, {useCallback, useEffect, useState} from 'react'; -import {FlatList} from 'react-native'; +import {FlatList, Image} from 'react-native'; import {List} from 'react-native-paper'; import {getBestReps, getBestWeights} from './best.service'; import {BestPageParams} from './BestPage'; import Page from './Page'; import Set from './set'; +import Settings from './settings'; +import {getSettings} from './settings.service'; export default function BestList() { const [bests, setBests] = useState([]); const [search, setSearch] = useState(''); + const [settings, setSettings] = useState(); const navigation = useNavigation>(); const refresh = useCallback(async () => { + getSettings().then(setSettings); const weights = await getBestWeights(search); console.log(`${BestList.name}.refresh:`, {length: weights.length}); let newBest: Set[] = []; @@ -44,8 +48,14 @@ export default function BestList() { navigation.navigate('ViewBest', {best: item})} + left={() => + (settings?.images && item.image && ( + + )) || + null + } /> ); diff --git a/WorkoutItem.tsx b/WorkoutItem.tsx index 7848892..f94bd81 100644 --- a/WorkoutItem.tsx +++ b/WorkoutItem.tsx @@ -39,33 +39,30 @@ export default function WorkoutItem({ onPress={() => navigation.navigate('EditWorkout', {value: item})} title={item.name} onLongPress={longPress} + left={() => + item.image && ( + + ) + } right={() => ( - <> - {item.image && ( - + setShowMenu(false)}> + { + setShowRemove(item.name); + setShowMenu(false); + }} + title="Delete" /> - )} - - setShowMenu(false)}> - { - setShowRemove(item.name); - setShowMenu(false); - }} - title="Delete" - /> - - - + + )} /> => { const select = ` - SELECT name, MAX(reps) as reps, unit, weight + SELECT name, MAX(reps) as reps, unit, weight, image FROM sets WHERE name = ? AND weight = ? AND NOT hidden GROUP BY name;