Simplify the peek view of exercises from Plan

This commit is contained in:
Brandon Presley 2023-11-15 16:03:58 +13:00
parent 1b164aaaf1
commit 086e3ea2df
5 changed files with 33 additions and 21 deletions

View File

@ -4,7 +4,12 @@ import React, { useCallback, useMemo } from "react";
import { Image } from "react-native"; import { Image } from "react-native";
import { List, Text, useTheme } from "react-native-paper"; import { List, Text, useTheme } from "react-native-paper";
import { StackParams } from "./AppStack"; import { StackParams } from "./AppStack";
import { DARK_RIPPLE, LIGHT_RIPPLE } from "./constants"; import {
DARK_RIPPLE,
DARK_SUBDUED,
LIGHT_RIPPLE,
LIGHT_SUBDUED,
} from "./constants";
import GymSet from "./gym-set"; import GymSet from "./gym-set";
import Settings from "./settings"; import Settings from "./settings";
@ -60,7 +65,7 @@ const SetItem = React.memo(
title={item.name} title={item.name}
description={ description={
settings.showDate ? ( settings.showDate ? (
<Text style={{ color: dark ? "#909090ff" : "#717171ff" }}> <Text style={{ color: dark ? DARK_SUBDUED : LIGHT_SUBDUED }}>
{format(new Date(item.created), settings.date || "P")} {format(new Date(item.created), settings.date || "P")}
</Text> </Text>
) : null ) : null
@ -72,7 +77,7 @@ const SetItem = React.memo(
<Text <Text
style={{ style={{
alignSelf: "center", alignSelf: "center",
color: dark ? "#909090ff" : "#717171ff", color: dark ? DARK_SUBDUED : LIGHT_SUBDUED,
}} }}
> >
{`${item.reps} x ${item.weight}${item.unit || "kg"}`} {`${item.reps} x ${item.weight}${item.unit || "kg"}`}

View File

@ -1,15 +1,16 @@
import { RouteProp, useRoute } from "@react-navigation/native"; import { RouteProp, useRoute } from "@react-navigation/native";
import { format } from "date-fns";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { FlatList } from "react-native"; import { FlatList } from "react-native";
import { List, useTheme } from "react-native-paper"; import { List, Text, useTheme } from "react-native-paper";
import { Like } from "typeorm"; import { Like } from "typeorm";
import { StackParams } from "./AppStack"; import { StackParams } from "./AppStack";
import { LIMIT } from "./constants"; import SetItem from "./SetItem";
import StackHeader from "./StackHeader";
import { DARK_SUBDUED, LIGHT_SUBDUED, LIMIT } from "./constants";
import { setRepo, settingsRepo } from "./db"; import { setRepo, settingsRepo } from "./db";
import GymSet from "./gym-set"; import GymSet from "./gym-set";
import SetItem from "./SetItem";
import Settings from "./settings"; import Settings from "./settings";
import StackHeader from "./StackHeader";
interface ColorSet extends GymSet { interface ColorSet extends GymSet {
color?: string; color?: string;
@ -18,7 +19,7 @@ interface ColorSet extends GymSet {
export default function ViewSetList() { export default function ViewSetList() {
const [sets, setSets] = useState<ColorSet[]>(); const [sets, setSets] = useState<ColorSet[]>();
const [settings, setSettings] = useState<Settings>(); const [settings, setSettings] = useState<Settings>();
const { colors } = useTheme(); const { colors, dark } = useTheme();
const { params } = useRoute<RouteProp<StackParams, "ViewSetList">>(); const { params } = useRoute<RouteProp<StackParams, "ViewSetList">>();
useEffect(() => { useEffect(() => {
@ -52,14 +53,18 @@ export default function ViewSetList() {
}, [params.name, colors]); }, [params.name, colors]);
const renderItem = ({ item }: { item: ColorSet; index: number }) => ( const renderItem = ({ item }: { item: ColorSet; index: number }) => (
<SetItem <List.Item
settings={settings} title={format(new Date(item.created), settings.date || "P")}
item={item} style={{ backgroundColor: item.color }}
key={item.id} right={() => (
ids={[]} <Text
setIds={() => null} style={{
disablePress alignSelf: "center",
customBg={item.color} }}
>
{`${item.reps} x ${item.weight}${item.unit || "kg"}`}
</Text>
)}
/> />
); );

View File

@ -1,6 +1,6 @@
import { DefaultTheme, MD3DarkTheme } from "react-native-paper"; import { DefaultTheme, MD3DarkTheme } from "react-native-paper";
export const lightColors = [ export const LIGHT_COLORS = [
{ hex: MD3DarkTheme.colors.primary, name: "Purple" }, { hex: MD3DarkTheme.colors.primary, name: "Purple" },
{ hex: "#B3E5FC", name: "Blue" }, { hex: "#B3E5FC", name: "Blue" },
{ hex: "#FA8072", name: "Salmon" }, { hex: "#FA8072", name: "Salmon" },
@ -11,7 +11,7 @@ export const lightColors = [
{ hex: "#00CED1", name: "Dark Turquoise" }, { hex: "#00CED1", name: "Dark Turquoise" },
]; ];
export const darkColors = [ export const DARK_COLORS = [
{ hex: DefaultTheme.colors.primary, name: "Purple" }, { hex: DefaultTheme.colors.primary, name: "Purple" },
{ hex: "#0051a9", name: "Blue" }, { hex: "#0051a9", name: "Blue" },
{ hex: "#000000", name: "Black" }, { hex: "#000000", name: "Black" },

View File

@ -3,4 +3,6 @@ export const PADDING = 10;
export const ITEM_PADDING = 8; export const ITEM_PADDING = 8;
export const DARK_RIPPLE = "#444444"; export const DARK_RIPPLE = "#444444";
export const LIGHT_RIPPLE = "#c2c2c2"; export const LIGHT_RIPPLE = "#c2c2c2";
export const DARK_SUBDUED = "#909090ff";
export const LIGHT_SUBDUED = "#717171ff";
export const LIMIT = 15; export const LIMIT = 15;

View File

@ -1,4 +1,4 @@
import { darkColors, lightColors } from "./colors"; import { DARK_COLORS, LIGHT_COLORS } from "./colors";
export const themeOptions = [ export const themeOptions = [
{ label: "System", value: "system" }, { label: "System", value: "system" },
@ -6,13 +6,13 @@ export const themeOptions = [
{ label: "Light", value: "light" }, { label: "Light", value: "light" },
]; ];
export const lightOptions = lightColors.map((color) => ({ export const lightOptions = LIGHT_COLORS.map((color) => ({
label: color.name, label: color.name,
value: color.hex, value: color.hex,
color: color.hex, color: color.hex,
})); }));
export const darkOptions = darkColors.map((color) => ({ export const darkOptions = DARK_COLORS.map((color) => ({
label: color.name, label: color.name,
value: color.hex, value: color.hex,
color: color.hex, color: color.hex,