How to use react-native - 10 common examples

To help you get started, we’ve selected a few react-native 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 chetstone / react-native-palette / example / utils / ImagePicker.js View on Github external
export default function(storeImage, useNamed) {
  var max = Math.max(Dimensions.get('window').width,Dimensions.get('window').height);

  const options = {
    quality: 0.5,
    maxWidth: max|0, /* convert double to int by bitwise OR */
    maxHeight: max|0,
  };


  let pickOptions = {quality: "low"};

  //console.log("In ImagePicker");
  ImagePicker.launchImageLibrary(options, (response) => {
    var colors = {};

    //console.log('Response = ', response);
    if (response.didCancel) {
github gre / react-native-view-shot / src / index.js View on Github external
export function captureRef(
  view: number | ?View | Ref,
  optionsObject?: Object
): Promise {
  ensureModuleIsLoaded();
  if (view && typeof view === "object" && "current" in view && view.current) {
    // React.RefObject
    view = view.current;
    if (!view) {
      return Promise.reject(new Error("ref.current is null"));
    }
  }
  if (typeof view !== "number") {
    const node = findNodeHandle(view);
    if (!node) {
      return Promise.reject(
        new Error("findNodeHandle failed to resolve view=" + String(view))
      );
    }
    view = node;
  }
  const { options, errors } = validateOptions(optionsObject);
  if (__DEV__ && errors.length > 0) {
    console.warn(
      "react-native-view-shot: bad options:\n" +
        errors.map(e => `- ${e}`).join("\n")
    );
  }
  return RNViewShot.captureRef(view, options);
}
github vobi-io / markdown-editor / editor / src / TextToolbar.js View on Github external
selectColor = ({ color = 'default' }) => () => {
    const { activeView } = this.state
    let newColor = color

    if(activeView === VIEWS.COLOR && color === 'default') {
      newColor = 'black'
    }

    if(activeView === VIEWS.FILL && color === 'default') {
      newColor = 'transparent'
    }

    InteractionManager.runAfterInteractions(() => {
      this.emit(EVENTS.CHANGE_COLOR_STYLE,  { color: newColor, type: activeView })()
    })
    // this.setDefaultView()
  }
github kriskate / pocket-dota / src / components / Drawer.js View on Github external
{ Object.keys(SCREEN_LABELS).map(label =>
          label.substr(0, 6) == 'HEADER'
            ? 
            : 
        ) }
      
    );
  }
}

const wrapperHeight = 150;
const logoRatio = 1600/ 450;
const logoHeight = wrapperHeight/2 - Layout.padding_small;
const styles = StyleSheet.create({
  imgIconWrapper: {
    paddingTop: getStatusBarHeight(),
    padding: Layout.padding_regular,
    alignItems: 'center',
    justifyContent: 'center',
    height: wrapperHeight + getStatusBarHeight(),
    backgroundColor: Colors.dota_ui1+'99',
  },
  imgIcon: {
    // borderColor: Colors.disabled,
    borderRadius: 10,
    // borderWidth: 1,
    width: logoHeight * logoRatio,
    height: logoHeight,
  },
  imgBackground: {
github jiasongs / cnodeRN / src / page / Find / find.js View on Github external
},
  headerView: {
    flex: 1,
    width: 375,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#3c5e91',
    marginTop: 0,
    zIndex: 999
  },
  searchBarView: {
    backgroundColor: "#2D2D2D",
    height: searchBarHeight,
    paddingTop: Platform.OS == 'android' ? 0 : (height == 815 ? 37 : 27),
    paddingLeft: 15,
    justifyContent: Platform.OS == 'android' ? 'center' : 'flex-start',
    // opacity: 0.5,
  },
  titleView: {
    marginBottom: 15
  },
  title: {
    color: "#999999",
    fontSize: FONT_SIZE(12)
  },
  contentContainerStyle: {
    flexDirection: 'row',//设置横向布局
    flexWrap: 'wrap',
    justifyContent: 'space-between',
    // backgroundColor: 'blue'
  },
  hotsRow: {
github mini-eggs / Flippour / src / configs / modal.js View on Github external
import { Text, Button } from "native-base";
import { connect } from "react-redux";
import { SettingsDecorator } from "../decorators/settings";
import { ModalActions } from "../actions/";

const styles = {
  ToastContainer: {
    position: "absolute",
    zIndex: 99,
    top: 0,
    width: Dimensions.get("window").width,
    alignItems: "stretch"
  },
  Background: {
    backgroundColor: "#c3524c",
    paddingTop: Platform.OS === "ios" ? 22 : 10,
    paddingBottom: 10
  },
  Text: {
    color: "white",
    textAlign: "center"
  }
};

// @SoundDecorator(["notification_in"])
@SettingsDecorator()
class ModalComponent extends Component {
  animation = {
    fadeAnim: new Animated.Value(0),
    positionAnim: new Animated.Value(-50)
  };
github expo / expo / home / api / ApiV2HttpClient.ts View on Github external
async _requestAsync(methodName: string, options: RequestOptions): Promise {
    let url = `${Config.api.host}/--/api/v2/${encodeURI(methodName)}`;
    if (options.queryParameters) {
      url += '?' + querystring.stringify(options.queryParameters);
    }

    let { session } = Store.getState();
    let fetchOptions: any = {
      method: options.httpMethod,
      headers: {
        'Expo-SDK-Version': Kernel.sdkVersions,
        'Expo-Platform': Platform.OS,
        ...(session.sessionSecret ? { 'expo-session': session.sessionSecret } : null),
      },
    };
    if (options.body) {
      fetchOptions.headers['Content-Type'] = 'application/json';
      fetchOptions.body = JSON.stringify(options.body);
    }

    // We expect the result to be JSON
    let response = await fetch(url, fetchOptions);
    let resultText = await response.text();
    let result: any;
    try {
      result = JSON.parse(resultText);
    } catch (e) {
      let error: any = new Error(`There was a problem understanding the server.`);
github sophister / react-native-pull-to-refresh-custom / lib / PullToRefresh.js View on Github external
componentDidUpdate(prevProps, prevState) {
        if (!prevProps.refreshing && this.props.refreshing) {
            // 从 未加载 变化到 加载中
            const holdHeight = this.props.refreshingHoldHeight || this.props.headerHeight;
            Animated.timing(this.state.containerTop, {
                toValue: holdHeight,
                duration: 150,
                useNativeDriver: true,
            }).start();
        }
        else if (prevProps.refreshing && !this.props.refreshing) {
            // 从 加载中 变化到 未加载
            Animated.timing(this.state.containerTop, {
                toValue: 0,
                duration: 250,
                useNativeDriver: true,
            }).start();
        }
    }
    componentWillUnmount() {
github didi / mand-mobile-rn / src / components / popup / index.web.tsx View on Github external
private setVisible (show: boolean) {
    const { onBeforeShow, onBeforeHide } = this.props;
    show ? onBeforeShow && onBeforeShow() : onBeforeHide && onBeforeHide();
    if (!show) {
      // out
      Animated.timing(this.state.animTime, {
        toValue: 0,
        duration: 250,
      }).start(() => {
        this.setState({
          isVisible: show,
        });
      });
    } else {
      // in
      this.setState(
        {
          isVisible: show,
        },
        () => {
          Animated.timing(this.state.animTime, {
            toValue: 1,