-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcardsTeste.js
More file actions
57 lines (46 loc) · 1.83 KB
/
cardsTeste.js
File metadata and controls
57 lines (46 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState } from 'react';
import { StyleSheet, View, TouchableOpacity, Text, Image } from 'react-native';
import { Card, TextInput } from 'react-native-paper';
import { styles } from './views/styles';
const MyComponent = () => {
const [cards, setCards] = useState([]);
const handleAddCard = () => {
setCards([...cards, { id: Date.now(), showContent: false }]);
};
const toggleCardContent = (cardId) => {
setCards((prevCards) =>
prevCards.map((card) =>
card.id === cardId ? { ...card, showContent: !card.showContent } : card
)
);
};
return (
<View style={s.container}>
<TouchableOpacity style={[styles.fichas__button, { marginTop: 40 }]}
onPress={handleAddCard}
>
<Image style={styles.icon} source={require('./assets/add.png')} />
<Text style={styles.fichas__text}>Criar Ficha</Text>
{/* onpress criar uma flatlist */}
</TouchableOpacity>
{cards.map((card) => (
<Card key={card.id} style={styles.card}>
<Card.Content>
<TouchableOpacity onPress={() => toggleCardContent(card.id)}>
<Text variant="titleLarge" style={styles.ficha_title}>Ficha</Text>
</TouchableOpacity>
{card.showContent && (
<Text variant="bodyMedium">Card contentaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</Text>
)}
</Card.Content>
</Card>
))}
</View>
);
};
const s = StyleSheet.create({
container: {
flex: 1,
},
});
export default MyComponent;