Skip to content

Commit

Permalink
Naprawione, działa szybko
Browse files Browse the repository at this point in the history
  • Loading branch information
Given22 committed Nov 8, 2022
1 parent b32b42b commit 86d768d
Show file tree
Hide file tree
Showing 8 changed files with 2,980 additions and 240 deletions.
2 changes: 1 addition & 1 deletion assets/words.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"pl": "ja",
"eng": "I",
"link": "https://www.opensymbols.org/symbols/arasaac/i-69ca1b97?id=315",
"link": "https://d18vdu4p71yql0.cloudfront.net/libraries/arasaac/us_2.png",
"rodzaj": "rzeczownik"
},
{
Expand Down
1 change: 1 addition & 0 deletions components/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Card({ text, type, color = "#FB5607", size = 60 }) {
const styles = StyleSheet.create({
card: {
marginRight: 10,
marginLeft: 10,
backgroundColor: "#EAF4F4",
borderRadius: 12,
marginBottom: 10,
Expand Down
283 changes: 145 additions & 138 deletions components/header.js
Original file line number Diff line number Diff line change
@@ -1,156 +1,163 @@
import react, { useState, useEffect, useContext } from "react"
import react, { useState, useEffect, useContext } from "react";

import {
StyleSheet,
Text,
View,
Button,
ScrollView,
TouchableOpacity,
FlatList,
} from "react-native"
StyleSheet,
Text,
View,
Button,
ScrollView,
TouchableOpacity,
FlatList,
} from "react-native";

import { AntDesign } from "@expo/vector-icons"
import { AntDesign } from "@expo/vector-icons";

import NoCard from "./noCard"
import Card from "./card"
import TrashCard from "./trashCard"
import NoCard from "./noCard";
import Card from "./card";
import TrashCard from "./trashCard";

import { Context } from "../context/DataContext"
import { Context } from "../context/DataContext";
import { FlashList } from "@shopify/flash-list";

import useSpeech from "../hooks/useSpeech"
import useSpeech from "../hooks/useSpeech";

export default function Header() {
const {
sentence,
activeSentence,
addToSentence,
removeFromSentence,
removeAll,
} = useContext(Context)
const [text, setText] = useState(
activeSentence.map((item) => item.name).join(" ")
)
const {
sentence,
activeSentence,
addToSentence,
removeFromSentence,
removeAll,
} = useContext(Context);
const [text, setText] = useState(
activeSentence.map((item) => item.name).join(" ")
);

const [cards, setCards] = useState(activeSentence)
const [cards, setCards] = useState(activeSentence);

useEffect(() => {
setText(activeSentence.map((item) => item.name).join(" "))
setCards(activeSentence)
}, [activeSentence, removeFromSentence])
useEffect(() => {
setText(activeSentence.map((item) => item.name).join(" "));
setCards(activeSentence);
}, [activeSentence, removeFromSentence]);

const pressHandler = () => {
useSpeech(sentence, { languages: "pl-PL" })
}
const pressHandler = () => {
useSpeech(sentence, { languages: "pl-PL" });
};

const renderItem = ({ item }) => (
<>
{item ? (
<TouchableOpacity
onPress={() => {
removeFromSentence(item.id)
}}>
<Card type={item.rodzaj} text={item.pl} />
</TouchableOpacity>
) : (
<NoCard />
)}
</>
)
const renderItem = ({ item }) => (
<>
{item ? (
<TouchableOpacity
onPress={() => {
removeFromSentence(item.id);
}}
>
<Card type={item.rodzaj} text={item.pl} />
</TouchableOpacity>
) : (
<NoCard />
)}
</>
);

return (
<View style={styles.header}>
<View style={styles.headerTextContent}>
<ScrollView horizontal style={styles.sentenceContener}>
<Text style={styles.sentence}>{sentence}</Text>
</ScrollView>
</View>
<TouchableOpacity onPress={pressHandler}>
<View style={styles.headerButtonContent}>
<View style={styles.headerButton}>
<AntDesign
style={styles.icon}
name='caretright'
size={20}
color='black'
/>
</View>
</View>
</TouchableOpacity>
<View style={styles.cardContener}>
{cards.length > 0 ? (
<View style={styles.cardList}>
<TouchableOpacity onPress={removeAll}>
<TrashCard />
</TouchableOpacity>
<FlatList
data={cards}
renderItem={renderItem}
horizontal={true}
keyExtractor={(item) => item.id}
/>
</View>
) : (
<NoCard />
)}
</View>
</View>
)
return (
<View style={styles.header}>
<View style={styles.headerTextContent}>
<ScrollView horizontal style={styles.sentenceContener}>
<Text style={styles.sentence}>{sentence}</Text>
</ScrollView>
</View>
<TouchableOpacity onPress={pressHandler}>
<View style={styles.headerButtonContent}>
<View style={styles.headerButton}>
<AntDesign
style={styles.icon}
name="caretright"
size={20}
color="black"
/>
</View>
</View>
</TouchableOpacity>
<View style={styles.cardContener}>
{cards.length > 0 ? (
<View style={styles.cardList}>
<TouchableOpacity onPress={removeAll}>
<TrashCard />
</TouchableOpacity>
<ScrollView horizontal style={styles.activeSentenceCards}>
<FlashList
data={activeSentence}
renderItem={renderItem}
horizontal={true}
keyExtractor={(item) => item.id}
estimatedItemSize={100}
extraData={activeSentence}
/>
</ScrollView>
</View>
) : (
<NoCard />
)}
</View>
</View>
);
}




const styles = StyleSheet.create({
header: {
height: 250,
backgroundColor: "#A4C3B2",
borderBottomLeftRadius: 20,
borderBottomRightRadius: 20,
},
headerTextContent: {
padding: 30,
paddingBottom: 20,
paddingTop: 45,
marginLeft: 32,
marginRight: 32,
backgroundColor: "#EAF4F4",
borderBottomLeftRadius: 20,
borderBottomRightRadius: 20,
},
sentence: {
fontSize: 20,
color: "#6B9080",
minWidth: "100%",
},
sentenceContener: {
borderColor: "#A4C3B2",
borderStyle: "solid",
borderBottomWidth: 2,
},
headerButton: {
backgroundColor: "#6B9080",
borderRadius: 8,
height: 25,
width: 200,
alignItems: "center",
justifyContent: "center",
},
headerButtonContent: {
marginTop: 15,
alignItems: "center",
},
icon: {
color: "#EAF4F4",
},
cardContener: {
flexDirection: "row",
marginTop: 15,
marginLeft: 32,
marginRight: 32,
marginBottom: 15,
},
cardList: {
header: {
height: 250,
backgroundColor: "#A4C3B2",
borderBottomLeftRadius: 20,
borderBottomRightRadius: 20,
},
headerTextContent: {
padding: 30,
paddingBottom: 20,
paddingTop: 45,
marginLeft: 32,
marginRight: 32,
backgroundColor: "#EAF4F4",
borderBottomLeftRadius: 20,
borderBottomRightRadius: 20,
},
sentence: {
fontSize: 20,
color: "#6B9080",
minWidth: "100%",
},
sentenceContener: {
borderColor: "#A4C3B2",
borderStyle: "solid",
borderBottomWidth: 2,
},
headerButton: {
backgroundColor: "#6B9080",
borderRadius: 8,
height: 25,
width: 200,
alignItems: "center",
justifyContent: "center",
},
headerButtonContent: {
marginTop: 15,
alignItems: "center",
},
icon: {
color: "#EAF4F4",
},
cardContener: {
flexDirection: "row",
marginTop: 15,
marginLeft: 32,
marginRight: 32,
marginBottom: 15,
},
cardList: {
flexDirection: "row",
width: "100%",
},
activeSentenceCards: {
flexDirection: "row",
},
})
});
Loading

0 comments on commit 86d768d

Please sign in to comment.