How to use the react-native-safe-area-context.useSafeArea function in react-native-safe-area-context

To help you get started, we’ve selected a few react-native-safe-area-context examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EvanBacon / Expo-Crossy-Road / screens / GameOverScreen.js View on Github external
//     this.setState({result: 'shared with an activityType: ' + result.activityType});
    //   } else {
    //     this.setState({result: 'shared'});
    //   }
    // } else if (result.action === Share.dismissedAction) {
    //   this.setState({result: 'dismissed'});
    // }
  };

  const select = () => {

    // props.setCharacter(characters[currentIndex]);
    dismiss();
  };

  const { top, bottom, left, right } = useSafeArea();

  const imageStyle = { width: 60, height: 48 };

  return (
github EvanBacon / Expo-Crossy-Road / components / ScoreText.js View on Github external
function Score({ gameOver, score, highScore, ...props }) {

  React.useEffect(() => {
    if (gameOver) {
      if (score > highScore) {
        // setHighScore(score);
      }


    }
  }, [gameOver])


  const { top, left } = useSafeArea();

  return (
github expo / expo / apps / test-suite / components / RunnerError.js View on Github external
export default function RunnerError({ children }) {
  const { top } = useSafeArea();

  return (
    
  );
}
github syousif94 / frugalmaps / buncha / components / EventList.js View on Github external
const MenuButton = () => {
  const insets = useSafeArea();
  return (
github EvanBacon / Sunset-Cyberspace / screens / LicensesScreen.js View on Github external
export default function LicensesScreen({ navigation }) {
  const [top, left, bottom, right] = useSafeArea();
  return (
github react-navigation / navigation-ex / packages / drawer / src / views / DrawerNavigatorItems.tsx View on Github external
activeTintColor,
  activeBackgroundColor,
  inactiveTintColor,
  inactiveBackgroundColor,
  getLabel,
  renderIcon,
  onItemPress,
  itemsContainerStyle,
  itemStyle,
  labelStyle,
  activeLabelStyle,
  inactiveLabelStyle,
  iconContainerStyle,
  drawerPosition,
}: DrawerNavigationItemsProps) => {
  const insets = useSafeArea();

  return (
github wcandillon / can-it-be-done-in-react-native / season3 / src / UberEats / Header.tsx View on Github external
export default ({ y, tabs, scrollView }: HeaderProps) => {
  const { goBack } = useNavigation();
  const [toggle] = useValues<0 | 1>([0], []);
  const insets = useSafeArea();
  const transition = withTimingTransition(toggle, { duration: 100 });
  const { top: paddingTop } = insets;
  const translateX = interpolate(y, {
    inputRange: [0, HEADER_IMAGE_HEIGHT],
    outputRange: [-ICON_SIZE - PADDING, 0],
    extrapolate: Extrapolate.CLAMP
  });
  const translateY = interpolate(y, {
    inputRange: [-100, 0, HEADER_IMAGE_HEIGHT],
    outputRange: [
      HEADER_IMAGE_HEIGHT - MIN_HEADER_HEIGHT + 100,
      HEADER_IMAGE_HEIGHT - MIN_HEADER_HEIGHT,
      0
    ],
    extrapolateRight: Extrapolate.CLAMP
  });
github EvanBacon / Expo-Crossy-Road / screens / HomeScreen.js View on Github external
if (!hasShownTitle) {
      hasShownTitle = true;
      InteractionManager.runAfterInteractions(_ => {
        Animated.timing(animation, {
          toValue: 1,
          duration: 800,
          delay: 0,
          easing: Easing.in(Easing.qubic),
        }).start();
      });
    }

  }, []);


  const { top, bottom, left, right } = useSafeArea();

  const animatedTitleStyle = {
    transform: [
      {
        translateX: animation.interpolate({
          inputRange: [0, 1],
          outputRange: [-Dimensions.get('window').width, 0],
        }),
      },
      {
        translateY: animation.interpolate({
          inputRange: [0, 1],
          outputRange: [-100, 0],
        }),
      },
    ],
github EvanBacon / apple-notes / App.js View on Github external
function App() {
  const [text, setText] = React.useState(
    'Change code in the editor and watch it change on your phone! Save to get a shareable url.'
  );
  const realColorScheme = useColorScheme();
  const [show, setShow] = React.useState(true);
  const [colorScheme, setScheme] = React.useState(realColorScheme);
  const {
    top: paddingTop,
    bottom: paddingBottom,
    left,
    right: paddingRight,
  } = useSafeArea();

  const paddingLeft = left || 12;

  const isDark = colorScheme === 'dark';

  const textColor = isDark ? 'white' : 'black';
  const borderColor = isDark ? 'rgba(255,255,255,0.2)' : 'rgba(0,0,0,0.2)';
  const backgroundColor = isDark ? '#000' : '#ecf0f1';

  const isTabletOrMobileDevice = useMediaQuery({
    query: '(orientation: landscape)',
  });

  const drawerWidth =
    Dimensions.get('window').width * (isTabletOrMobileDevice ? 0.45 : 1);
  const drawerRight = show ? drawerWidth : 0;

react-native-safe-area-context

A flexible way to handle safe area, also works on Android and web.

MIT
Latest version published 21 days ago

Package Health Score

91 / 100
Full package analysis