diff --git a/README.md b/README.md index f7e795d..d337628 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ npm i react-native-header-search-bar "react-native": ">= 0.55.x", "react-native-androw": ">= 0.0.33", "react-native-vector-icons": ">= 6.6.0", +"react-native-safe-area-context": ">= 0.6.1", "react-native-dynamic-vector-icons": ">= 0.2.1", "@freakycoder/react-native-helpers": ">= 0.0.21" ``` diff --git a/example/package.json b/example/package.json index a0f4c5f..1921a91 100644 --- a/example/package.json +++ b/example/package.json @@ -17,6 +17,7 @@ "react-native-dynamic-vector-icons": "^0.2.1", "react-native-header-search-bar": "0.1.3", "react-native-material-ripple": "^0.9.1", + "react-native-safe-area-context": "^0.6.1", "react-native-vector-icons": "^6.6.0" }, "devDependencies": { diff --git a/lib/src/HeaderClassicSearchBar/HeaderClassicSearchBar.js b/lib/src/HeaderClassicSearchBar/HeaderClassicSearchBar.js index 3ca00a6..4f0cb31 100644 --- a/lib/src/HeaderClassicSearchBar/HeaderClassicSearchBar.js +++ b/lib/src/HeaderClassicSearchBar/HeaderClassicSearchBar.js @@ -3,19 +3,22 @@ import PropTypes from "prop-types"; import { View } from "react-native"; import styles, { shadowStyle, - container + container, + searchboxContainer } from "../HeaderClassicSearchBar/HeaderClassicSearchBar.style"; import Androw from "react-native-androw"; import SearchBox from "../components/SearchBox/SearchBox"; import Icon from "react-native-dynamic-vector-icons"; import Ripple from "react-native-material-ripple"; +import { useSafeArea } from "react-native-safe-area-context"; const HeaderClassicSearchBar = props => { const { shadowColor, backgroundColor, onPress } = props; + const insets = useSafeArea(); return ( - - + + { }; }; -export const container = backgroundColor => { +export const container = (backgroundColor, insets) => { return { - height: isAndroid ? 70 : 115, width: "100%", backgroundColor, borderBottomEndRadius: 24, - borderBottomStartRadius: 24 + borderBottomStartRadius: 24, + height: isAndroid ? insets.top + 70 : 115 }; }; +export const searchboxContainer = insets => ({ + flexDirection: "row", + alignItems: "center", + justifyContent: "space-around", + marginTop: hasNotch() + ? getStatusBarHeight() + 16 + : isAndroid + ? insets.top + 16 + : 0 +}); + export default { - searchboxContainer: { - flexDirection: "row", - alignItems: "center", - justifyContent: "space-around", - marginTop: hasNotch() ? getStatusBarHeight() + 16 : isAndroid? 16 : 0 - }, rippleContainer: { bottom: 2, width: 35, diff --git a/package.json b/package.json index 75b8c9b..cefa548 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-header-search-bar", - "version": "0.1.3", + "version": "0.1.4", "description": "Fully customizable header search bar for React Native", "keywords": [ "header", @@ -30,6 +30,7 @@ "react-native": ">= 0.55.x", "react-native-androw": ">= 0.0.33", "react-native-vector-icons": ">= 6.6.0", + "react-native-safe-area-context": ">= 0.6.1", "react-native-dynamic-vector-icons": ">= 0.2.1", "@freakycoder/react-native-helpers": ">= 0.0.21" }