From 7160d3c137e30ec9e5dcc2f3778d5c2bf74fe5bd Mon Sep 17 00:00:00 2001 From: Jorrin Date: Sun, 24 Mar 2024 20:54:29 +0100 Subject: [PATCH] fix home title fontSize --- apps/expo/src/app/(tabs)/index.tsx | 12 +- .../expo/src/components/HomeScreenContent.tsx | 180 ------------------ 2 files changed, 2 insertions(+), 190 deletions(-) delete mode 100644 apps/expo/src/components/HomeScreenContent.tsx diff --git a/apps/expo/src/app/(tabs)/index.tsx b/apps/expo/src/app/(tabs)/index.tsx index 83877de..63a7c78 100644 --- a/apps/expo/src/app/(tabs)/index.tsx +++ b/apps/expo/src/app/(tabs)/index.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Text, View } from "tamagui"; +import { View } from "tamagui"; import { bookmarks, @@ -11,15 +11,7 @@ import ScreenLayout from "~/components/layout/ScreenLayout"; export default function HomeScreen() { return ( - - - Home - - - } - > + fetchSearchResults(query), - }); - - useEffect(() => { - if (data && data.length > 0 && query) { - searchResultsOpacity.value = withTiming(1, { duration: 500 }); - searchResultsScale.value = withTiming(1, { duration: 500 }); - setSearchResultsLoaded(true); - } else if (!query) { - searchResultsOpacity.value = withTiming(0, { duration: 500 }); - searchResultsScale.value = withTiming(0.95, { duration: 500 }); - setSearchResultsLoaded(false); - } - }, [data, query, searchResultsOpacity, searchResultsScale]); - - useEffect(() => { - const keyboardWillShowListener = Keyboard.addListener( - "keyboardWillShow", - (e) => { - translateY.value = withTiming( - -(e.endCoordinates.height - 110), // determines the height of the Searchbar above keyboard, use Platform.select to adjust value if needed - { - duration: e.duration ?? 250, // duration always returns 0 on Android, adjust value if needed - easing: Easing.out(Easing.ease), - }, - ); - }, - ); - - const keyboardWillHideListener = Keyboard.addListener( - "keyboardWillHide", - () => { - translateY.value = withTiming(0, { - duration: 250, - easing: Easing.out(Easing.ease), - }); - }, - ); - - return () => { - keyboardWillShowListener.remove(); - keyboardWillHideListener.remove(); - }; - }, [translateY]); - - const animatedStyle = useAnimatedStyle(() => { - return { - transform: [{ translateY: translateY.value }], - opacity: fadeAnim.value, - }; - }); - - const searchResultsStyle = useAnimatedStyle(() => { - return { - opacity: searchResultsOpacity.value, - transform: [{ scale: searchResultsScale.value }], - }; - }); - - const handleScrollBegin = () => { - fadeAnim.value = withTiming(0, { - duration: 100, - }); - }; - - const handleScrollEnd = () => { - fadeAnim.value = withTiming(1, { - duration: 100, - }); - }; - - return ( - - - - - Home - - - } - > - {searchResultsLoaded ? ( - - - {data?.map((item, index) => ( - - - - ))} - - - ) : ( - 0 || watching.length > 0 ? true : false - } - > - - - - )} - - - - - - - ); -} - -async function fetchSearchResults(query: string): Promise { - const results = await searchTitle(query); - - return results.map((result) => ({ - id: result.id.toString(), - title: result.media_type === "tv" ? result.name : result.title, - posterUrl: getMediaPoster(result.poster_path), - year: new Date( - result.media_type === "tv" ? result.first_air_date : result.release_date, - ).getFullYear(), - type: result.media_type, - })); -}