mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
add switch theme, remove unneeded search bar context
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Keyboard } from "react-native";
|
||||
import { FontAwesome5 } from "@expo/vector-icons";
|
||||
import { useIsFocused } from "@react-navigation/native";
|
||||
import { Input, styled, useTheme, View } from "tamagui";
|
||||
|
||||
import SearchTabContext from "./SearchTabContext";
|
||||
|
||||
const SearchInput = styled(Input, {
|
||||
backgroundColor: "$searchBackground",
|
||||
borderColor: "$colorTransparent",
|
||||
@@ -22,17 +21,16 @@ export function SearchBar({
|
||||
onSearchChange: (text: string) => void;
|
||||
}) {
|
||||
const theme = useTheme();
|
||||
const pageIsFocused = useIsFocused();
|
||||
const [keyword, setKeyword] = useState("");
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
const inputRef = useRef<Input>(null);
|
||||
|
||||
const { focusSearchInputRef } = useContext(SearchTabContext);
|
||||
|
||||
useEffect(() => {
|
||||
focusSearchInputRef.current = () => {
|
||||
if (pageIsFocused) {
|
||||
inputRef.current?.focus();
|
||||
};
|
||||
}, [focusSearchInputRef]);
|
||||
}
|
||||
}, [pageIsFocused]);
|
||||
|
||||
useEffect(() => {
|
||||
const keyboardDidShowListener = Keyboard.addListener(
|
||||
|
Reference in New Issue
Block a user