dummy code

dummy code

Published April 21, 2022, 8:37 a.m. by Jagdeep singh

import React, {useState} from "react";
import { Button, Image, ScrollView, StyleSheet, Text, View } from "react-native";
import { AsyncStorage } from 'react-native';



const Tasks = [
{ id:1,
title:"Breakfast",
text:'Green smoothy',
score:10
},
{ id:2,
title:"Exercise",
text:'wo daily',
score:20
},
{ id:3,
title:"Meditate",
text:'good for calming',
score:30
}]

function Link(props) {
return (
<Text
{...props}
accessibilityRole="link"
style={StyleSheet.compose(styles.link, props.style)}
/>
);
}
function TaskCard({props, ondone}) {
return (
<View>
{props.done && props.done === true?
<Text> DONE2 </Text>
:<Text style={styles.title}>{props.title} </Text>
}
<Text style={styles.text}>{props.text} </Text>
<Button onPress={() => ondone(props.id -1)} title="done"/>
</View>
);
}

function App() {
const tsk = Tasks
const [tasks,settasks] = useState(tsk)
const [dones, setdones] =useState([0])

const onDone = (i) => {
console.log("calling for ",i)
tasks[i].done = true
settasks(tasks)
dones.push(i)
console.log(dones)
setdones( dones )
}

return (
<ScrollView style={styles.app}>
{
Object.keys(tasks).map( x =>
<TaskCard key={x.id} props={tasks[x]} ondone={onDone} />
//<Text key={x.id}>hi {x.id} {tasks[x].text} </Text>
)
}
</ScrollView>
);
}







const styles = StyleSheet.create({
app: {
marginHorizontal: "auto",
maxWidth: 500
},
logo: {
height: 80
},
header: {
padding: 20
},
title: {
fontWeight: "bold",
fontSize: "1.5rem",
marginVertical: "1em",
textAlign: "center"
},
text: {
lineHeight: "1.5em",
fontSize: "1.125rem",
marginVertical: "1em",
textAlign: "center"
},
link: {
color: "#1B95E0"
},
code: {
fontFamily: "monospace, monospace"
}
});

export default App;