react-native#ViewProps TypeScript Examples

The following examples show how to use react-native#ViewProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Ripple.tsx    From mobile with Apache License 2.0 6 votes vote down vote up
Ripple = ({
  children,
  disabled = false,
  backgroundColor = 'transparent',
  borderRadius = 4,
  onPress,
  ...props
}: RippleProps & ViewProps) => {
  return (
    <RectButton
      enabled={!disabled}
      style={{
        backgroundColor,
        borderRadius,
      }}
      onPress={onPress}
      rippleColor="rgb(200,200,200)"
      activeOpacity={0.8}
    >
      <View accessible {...props}>
        {children}
      </View>
    </RectButton>
  );
}
Example #2
Source File: Screens.tsx    From nlw2-proffy with MIT License 6 votes vote down vote up
// The web implementation in react-native-screens seems buggy.
// The view doesn't become visible after coming back in some cases.
// So we use our custom implementation.
class WebScreen extends React.Component<
  ViewProps & {
    active: number;
    children: React.ReactNode;
  }
> {
  render() {
    const { active, style, ...rest } = this.props;

    return (
      <View
        // @ts-expect-error: hidden exists on web, but not in React Native
        hidden={!active}
        style={[style, { display: active ? 'flex' : 'none' }]}
        {...rest}
      />
    );
  }
}
Example #3
Source File: Screens.tsx    From nlw2-proffy with MIT License 6 votes vote down vote up
MaybeScreenContainer = ({
  enabled,
  ...rest
}: ViewProps & {
  enabled: boolean;
  children: React.ReactNode;
}) => {
  if (enabled && Platform.OS !== 'web' && Screens && Screens.screensEnabled()) {
    return <Screens.ScreenContainer {...rest} />;
  }

  return <View {...rest} />;
}
Example #4
Source File: Screens.tsx    From nlw2-proffy with MIT License 6 votes vote down vote up
MaybeScreen = ({
  enabled,
  active,
  ...rest
}: ViewProps & {
  enabled: boolean;
  active: 0 | 1 | Animated.AnimatedInterpolation;
  children: React.ReactNode;
}) => {
  if (enabled && Platform.OS === 'web') {
    return <AnimatedWebScreen active={active} {...rest} />;
  }

  if (enabled && Screens && Screens.screensEnabled()) {
    // @ts-expect-error: stackPresentation is incorrectly marked as required
    return <Screens.Screen active={active} {...rest} />;
  }

  return <View {...rest} />;
}
Example #5
Source File: SafeContainer.tsx    From react-native-notifier with MIT License 6 votes vote down vote up
constructor(props: ViewProps) {
    super(props);

    const { height, width } = Dimensions.get('window');
    this.state = {
      displayPadding: height > width,
    };
    this.onSizeChange = this.onSizeChange.bind(this);
  }
Example #6
Source File: SafeContainer.tsx    From react-native-notifier with MIT License 6 votes vote down vote up
// This component used instead of SafeAreaView on iOS 10 because of bug
// Details: https://github.com/seniv/react-native-notifier/issues/3
class StatusBarSpacer extends React.Component<ViewProps, StatusBarSpacerState> {
  constructor(props: ViewProps) {
    super(props);

    const { height, width } = Dimensions.get('window');
    this.state = {
      displayPadding: height > width,
    };
    this.onSizeChange = this.onSizeChange.bind(this);
  }

  componentDidMount() {
    Dimensions.addEventListener('change', this.onSizeChange);
  }

  componentWillUnmount() {
    Dimensions.removeEventListener('change', this.onSizeChange);
  }

  onSizeChange({ window }: { window: ScaledSize }) {
    this.setState({
      displayPadding: window.height > window.width,
    });
  }

  render() {
    const { style, ...props } = this.props;
    const { displayPadding } = this.state;
    return <View style={[displayPadding && s.statusBarPadding, style]} {...props} />;
  }
}
Example #7
Source File: a11y-element.tsx    From protect-scotland with Apache License 2.0 5 votes vote down vote up
A11yView = React.forwardRef<View, ViewProps>((props, ref) => (
  <View
    ref={ref}
    accessible={Platform.OS === 'android'}
    style={StyleSheet.absoluteFill}
    {...props}
  />
))
Example #8
Source File: MyView.tsx    From vsinder with Apache License 2.0 5 votes vote down vote up
MyView: React.FC<ViewProps> = ({ children, style, ...props }) => {
  const [{ editorBackground }] = useContext(ThemeContext);
  return (
    <View {...props} style={[style, { backgroundColor: editorBackground }]}>
      {children}
    </View>
  );
}
Example #9
Source File: Screens.d.ts    From nlw2-proffy with MIT License 5 votes vote down vote up
MaybeScreenContainer: ({ enabled, ...rest }: ViewProps & {
    enabled: boolean;
    children: React.ReactNode;
}) => JSX.Element
Example #10
Source File: Screens.d.ts    From nlw2-proffy with MIT License 5 votes vote down vote up
MaybeScreen: ({ enabled, active, ...rest }: ViewProps & {
    enabled: boolean;
    active: 0 | 1 | Animated.AnimatedInterpolation;
    children: React.ReactNode;
}) => JSX.Element
Example #11
Source File: CardSheet.d.ts    From nlw2-proffy with MIT License 5 votes vote down vote up
_default: React.ForwardRefExoticComponent<ViewProps & {
    enabled: boolean;
    layout: {
        width: number;
        height: number;
    };
    children: React.ReactNode;
} & React.RefAttributes<View>>
Example #12
Source File: Divider.tsx    From jellyfin-audio-player with MIT License 5 votes vote down vote up
function Divider({ style }: ViewProps) {
    const defaultStyles = useDefaultStyles();
    return (
        <Container style={[defaultStyles.divider, style]} />
    );
}
Example #13
Source File: index.tsx    From react-native-wheel-scrollview-picker with MIT License 5 votes vote down vote up
isViewStyle = (style: ViewProps["style"]): style is ViewStyle => {
  return (
    typeof style === "object" &&
    style !== null &&
    Object.keys(style).includes("height")
  );
}