Compare commits

..

1 Commits

Author SHA1 Message Date
Adrian Castro
0ff855ce2a Merge 8f5d0247bb into a3f184979e 2024-04-06 20:27:59 +00:00
2 changed files with 45 additions and 63 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Keyboard } from "react-native"; import { Keyboard, ScrollView } from "react-native";
import Animated, { import Animated, {
Easing, Easing,
useAnimatedStyle, useAnimatedStyle,
@@ -7,7 +7,7 @@ import Animated, {
withTiming, withTiming,
} from "react-native-reanimated"; } from "react-native-reanimated";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { View, ZStack } from "tamagui"; import { View, XStack } from "tamagui";
import { getMediaPoster, searchTitle } from "@movie-web/tmdb"; import { getMediaPoster, searchTitle } from "@movie-web/tmdb";
@@ -98,46 +98,48 @@ export default function SearchScreen() {
}; };
return ( return (
<ZStack flex={1}> <ScreenLayout>
<ScreenLayout <XStack flex={1}>
onScrollBeginDrag={handleScrollBegin} <ScrollView
onMomentumScrollEnd={handleScrollEnd} onScrollBeginDrag={handleScrollBegin}
scrollEnabled={searchResultsLoaded ? true : false} onMomentumScrollEnd={handleScrollEnd}
keyboardDismissMode="on-drag" scrollEnabled={searchResultsLoaded ? true : false}
keyboardShouldPersistTaps="handled" keyboardDismissMode="on-drag"
contentContainerStyle={{ flexGrow: 1 }} keyboardShouldPersistTaps="handled"
> contentContainerStyle={{ flexGrow: 1 }}
<View> >
<Animated.View style={[searchResultsStyle, { flex: 1 }]}> <View>
<View flexDirection="row" flexWrap="wrap"> <Animated.View style={[searchResultsStyle, { flex: 1 }]}>
{data?.map((item, index) => ( <View flexDirection="row" flexWrap="wrap">
<View {data?.map((item, index) => (
key={index} <View
paddingHorizontal={12} key={index}
paddingBottom={12} paddingHorizontal={12}
width="50%" paddingBottom={12}
> width="50%"
<Item data={item} /> >
</View> <Item data={item} />
))} </View>
</View> ))}
</Animated.View> </View>
</View> </Animated.View>
</ScreenLayout> </View>
<Animated.View </ScrollView>
style={[ <Animated.View
{ style={[
position: "absolute", {
bottom: 5, position: "absolute",
left: 0, bottom: 0,
right: 0, left: 0,
}, right: 0,
animatedStyle, },
]} animatedStyle,
> ]}
<SearchBar onSearchChange={setQuery} /> >
</Animated.View> <SearchBar onSearchChange={setQuery} />
</ZStack> </Animated.View>
</XStack>
</ScreenLayout>
); );
} }

View File

@@ -5,23 +5,9 @@ import { Header } from "./Header";
interface Props { interface Props {
children?: React.ReactNode; children?: React.ReactNode;
onScrollBeginDrag?: () => void;
onMomentumScrollEnd?: () => void;
scrollEnabled?: boolean;
keyboardDismissMode?: "none" | "on-drag" | "interactive";
keyboardShouldPersistTaps?: "always" | "never" | "handled";
contentContainerStyle?: Record<string, unknown>;
} }
export default function ScreenLayout({ export default function ScreenLayout({ children }: Props) {
children,
onScrollBeginDrag,
onMomentumScrollEnd,
scrollEnabled,
keyboardDismissMode,
keyboardShouldPersistTaps,
contentContainerStyle,
}: Props) {
return ( return (
<LinearGradient <LinearGradient
flex={1} flex={1}
@@ -41,12 +27,6 @@ export default function ScreenLayout({
> >
<Header /> <Header />
<ScrollView <ScrollView
onScrollBeginDrag={onScrollBeginDrag}
onMomentumScrollEnd={onMomentumScrollEnd}
scrollEnabled={scrollEnabled}
keyboardDismissMode={keyboardDismissMode}
keyboardShouldPersistTaps={keyboardShouldPersistTaps}
contentContainerStyle={contentContainerStyle}
marginTop="$4" marginTop="$4"
flexGrow={1} flexGrow={1}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}