
























Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!

























App 1 HomeScreen 1 SEARCH BAR 10 selected 10 SearchBarFilter 11 SearchBar 14 ListHorizontal 14 index 16 Heart 16 FetchLike 17 Fetch 19 App 21 ToDoList 22 Card 25 useSerieList 27 SearchBar 28 TIMER 30 App 30
import React from 'react'; import { View } from 'react-native'; import HomeScreen from './src/HomeScreen'; const App = () => { return ( <View style={{ flex: 1 }}>
import React, { useState } from 'react'; import { View, Text, ScrollView, StyleSheet, Image, TouchableOpacity, SafeAreaView } from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome'; // Componente per la barra superiore const HeaderBar = () => { return (
</> ) : (
height: 60, borderRadius: 30, }, storyName: { marginTop: 5, }, postContainer: { backgroundColor: '#EEE', marginBottom: 10, padding: 10, }, postImage: { width: '100%', height: 300, }, postInfo: { marginTop: 5, }, postActions: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, likesContainer: { flexDirection: 'row', alignItems: 'center', }, likes: { marginLeft: 5, fontWeight: 'bold', }, bookmarkIcon: { padding: 5, }, nickname: { fontWeight: 'bold', }, description: { marginBottom: 5, }, commentsContainer: { marginTop: 5, marginBottom: 10, }, commentContainer: { flexDirection: 'row', alignItems: 'center', marginBottom: 5,
flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 10, marginBottom: 10, }, profileContainer: { flexDirection: 'row', alignItems: 'center', }, profileImageContainer: { width: 30, height: 30, borderRadius: 15, overflow: 'hidden', marginRight: 10, }, profileImage: { width: '100%', height: '100%', }, profileName: { fontWeight: 'bold', }, }); export default HomeScreen; SEARCH BAR
import React, { useState } from "react"; import { FlatList, SafeAreaView, StatusBar, StyleSheet, Text, TouchableOpacity } from "react-native"; const DATA = [ { id: "1", title: "First Item", }, { id: "2", title: "Second Item", },
id: "3", title: "Third Item", }, ]; const Item = ({ item, onPress, backgroundColor, textColor }) => ( <TouchableOpacity onPress={onPress} style={[styles.item, backgroundColor]}> <Text style={[styles.title, textColor]}>{item.title} ); const Selected = () => { const [selectedId, setSelectedId] = useState(null); const renderItem = ({ item }) => { const backgroundColor = item.id === selectedId? "#6e3b6e" : "#f9c2ff"; const color = item.id === selectedId? 'white' : 'black'; return ( <Item item={item} onPress={() => setSelectedId(item.id)} backgroundColor={{ backgroundColor }} textColor={{ color }} /> ); }; return (
// Applying filter for the inserted text in search bar const itemData = item.title ? item.title.toUpperCase() : ''.toUpperCase(); const textData = text.toUpperCase(); return itemData.indexOf(textData) > -1; }); setFilteredDataSource(newData); setSearch(text); } else { // Inserted text is blank // Update FilteredDataSource with masterDataSource setFilteredDataSource(masterDataSource); setSearch(text); } }; const ItemView = ({ item }) => { return ( // Flat List Item <Text style={styles.itemStyle} onPress={() => getItem(item)}> {item.id} {'.'} {item.title.toUpperCase()} ); }; const ItemSeparatorView = () => { return ( // Flat List Item Separator <View style={{ height: 0.5, width: '100%', backgroundColor: '#C8C8C8', }} /> ); }; const getItem = (item) => { // Function for click on an item alert('Id : ' + item.id + ' Title : ' + item.title); }; return ( <SafeAreaView style={{ flex: 1}}>
import * as React from 'react'; import { Searchbar } from 'react-native-paper'; import { SafeAreaView } from 'react-native'; const SearchBar = () => { const [searchQuery, setSearchQuery] = React.useState('');
import { registerRootComponent } from 'expo'; import App from './App'; import Fetch from './Fetch'; import FetchLike from './FetchLike'; import Heart from './Heart'; import homeButton from './floating/homeButton'; import ListHorizontal from './ListHorizontal'; import SearchBar from './SearchBar'; import Selected from './selected'; import ToDoList from './ToDoList/ToDoList'; // registerRootComponent calls AppRegistry.registerComponent('main', () => App); // It also ensures that whether you load the app in Expo Go or in a native build, // the environment is set up appropriately registerRootComponent(ToDoList);
import React, {useState, useEffect, useCallback} from "react"; import { View, Text, TouchableOpacity, StyleSheet, SafeAreaView} from "react-native"; import Icon from 'react-native-vector-icons/FontAwesome5'; const Heart = () => { const [isFavorite, setIsFavorite] = useState(false); const tappedHeart = useCallback(() => { setIsFavorite(!isFavorite); }, [isFavorite]); return (
const tappedHeart = useCallback((index) => { //console.log(item.id, item.selected); /* setData((prev) => { const newArr = prev; newArr[index].selected = !newArr[index].selected; return newArr; }); / let newArr=[...data]; newArr[index].selected=!newArr[index].selected; setData(newArr); }, [data]); const renderItem = useCallback(({ item, index }) => { //console.log(item.selected); return( <View style={{flexDirection: 'row', alignItems: 'center', padding : 20,}}> <View style = {{marginLeft: 20}}> <TouchableOpacity onPress={() => tappedHeart(index)}> <Icon name="heart" solid={item.selected? true : false} size={26} color='red' />
); };
import React, { useEffect, useState } from 'react'; import { ActivityIndicator, FlatList, Text, View } from 'react-native'; export default Fetch = () => { const [isLoading, setLoading] = useState(true); const [data, setData] = useState([]); const getMovies = async () => { try { // const response = await fetch('https://reactnative.dev/movies.json'); const response = await fetch("https://api.themoviedb.org/3/tv/94997/season/{season_number}?api_key=a7c4848fcfb 89f8bef0757f282d0a463"); const data = await response.json(); setData(data.episodes); /* const json = await response.json(); setData(json.movies); */ } catch (error) { console.error(error); } finally { setLoading(false); } } useEffect(() => { getMovies(); }, []); return ( <View style={{ flex: 1, padding: 24 }}> {isLoading?