You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
import {FlatList, SafeAreaView, StyleSheet, Text, View} from "react-native";
|
|
import React, {useEffect} from "react";
|
|
import {JokeListItems} from "../components/ListeJokeComponent";
|
|
import {indigo, purpleColor} from "../Theme";
|
|
import {CustomJoke} from "../model/CustomJoke";
|
|
import {useDispatch, useSelector} from 'react-redux';
|
|
import {getLatestJokes, getSampleJoke, setSample} from "../redux/actions/sampleAction";
|
|
|
|
|
|
|
|
export function ListJokeScreen() {
|
|
const DataGen = useSelector((state: any) => state.sampleReducer.sampleJoke);
|
|
const dispatch = useDispatch();
|
|
useEffect(() => {
|
|
const getJokes = async () => {
|
|
dispatch(setSample(await getSampleJoke()));
|
|
};
|
|
getJokes();
|
|
}, [dispatch]);
|
|
return (
|
|
<SafeAreaView style={styles.container}>
|
|
<FlatList
|
|
data={DataGen}
|
|
renderItem={JokeListItems}
|
|
keyExtractor={(item: CustomJoke) => item.id.toString()}
|
|
/>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
title: {
|
|
fontSize: 24,
|
|
color: 'darksalmon',
|
|
textAlign: 'center',
|
|
fontWeight: 'bold',
|
|
marginVertical: 20,
|
|
},
|
|
titleResume: {
|
|
fontSize: 15,
|
|
fontWeight: 'bold',
|
|
marginBottom: 20,
|
|
},
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: purpleColor ,
|
|
|
|
},
|
|
top: {
|
|
backgroundColor : indigo,
|
|
},
|
|
|
|
|
|
});
|