Allow text editing of created in SetForm

This commit is contained in:
Brandon Presley 2022-09-01 13:05:41 +12:00
parent 450d488089
commit d7330067bb

View File

@ -1,8 +1,8 @@
import React, {useContext, useEffect, useRef, useState} from 'react'; import React, {useContext, useEffect, useRef, useState} from 'react';
import {ScrollView, Text} from 'react-native'; import {ScrollView, Text, useColorScheme} from 'react-native';
import {Button} from 'react-native-paper'; import {Button, TextInput} from 'react-native-paper';
import {DatabaseContext} from './Routes';
import MassiveInput from './MassiveInput'; import MassiveInput from './MassiveInput';
import {DatabaseContext} from './Routes';
import Set from './set'; import Set from './set';
export default function SetForm({ export default function SetForm({
@ -19,18 +19,20 @@ export default function SetForm({
const [weight, setWeight] = useState(set.weight.toString()); const [weight, setWeight] = useState(set.weight.toString());
const [unit, setUnit] = useState(set.unit); const [unit, setUnit] = useState(set.unit);
const [uri, setUri] = useState(set.image); const [uri, setUri] = useState(set.image);
const [created, setCreated] = useState(set.created);
const [selection, setSelection] = useState({ const [selection, setSelection] = useState({
start: 0, start: 0,
end: set.reps.toString().length, end: set.reps.toString().length,
}); });
const weightRef = useRef<any>(null); const weightRef = useRef<any>(null);
const repsRef = useRef<any>(null); const repsRef = useRef<any>(null);
const dark = useColorScheme() === 'dark';
const handleSubmit = () => { const handleSubmit = () => {
if (!name) return; if (!name) return;
save({ save({
name, name,
reps: Number(reps), reps: Number(reps),
created: set.created, created,
weight: Number(weight), weight: Number(weight),
id: set.id, id: set.id,
unit, unit,
@ -85,9 +87,14 @@ export default function SetForm({
onSubmitEditing={handleSubmit} onSubmitEditing={handleSubmit}
/> />
{set.created && ( {set.created && (
<Text style={{marginBottom: 10}}> <TextInput
{set.created.replace('T', ' ')} label="Created"
</Text> value={created}
onChangeText={setCreated}
selectionColor={dark ? '#2A2A2A' : ''}
mode="outlined"
style={{marginBottom: 10}}
/>
)} )}
<Text style={{marginBottom: 10}}> <Text style={{marginBottom: 10}}>
{workouts?.map((workout, index) => ( {workouts?.map((workout, index) => (