mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 19:44:13 +00:00
457a74cbc2
Summary: Moving out the requireNativeComponent call into a new file. We want this long term for all of our view managers to support codegen of the native side and so we can move the viewConfigs into JS. Reviewed By: yungsters Differential Revision: D9191214 fbshipit-source-id: d0bddbb50bb1cf6b5a727d72faf834b007ad9440
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const Platform = require('Platform');
|
|
const ReactNative = require('ReactNative');
|
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
import type {SwitchChangeEvent} from 'CoreEventTypes';
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
// @see ReactSwitchManager.java
|
|
export type NativeAndroidProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
enabled?: ?boolean,
|
|
on?: ?boolean,
|
|
onChange?: ?(event: SwitchChangeEvent) => mixed,
|
|
thumbTintColor?: ?string,
|
|
trackTintColor?: ?string,
|
|
|}>;
|
|
|
|
// @see RCTSwitchManager.m
|
|
export type NativeIOSProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
disabled?: ?boolean,
|
|
onChange?: ?(event: SwitchChangeEvent) => mixed,
|
|
onTintColor?: ?string,
|
|
thumbTintColor?: ?string,
|
|
tintColor?: ?string,
|
|
value?: ?boolean,
|
|
|}>;
|
|
|
|
type SwitchNativeComponentType = Class<
|
|
ReactNative.NativeComponent<
|
|
$ReadOnly<{|
|
|
...NativeAndroidProps,
|
|
...NativeIOSProps,
|
|
|}>,
|
|
>,
|
|
>;
|
|
|
|
const SwitchNativeComponent: SwitchNativeComponentType =
|
|
Platform.OS === 'android'
|
|
? (requireNativeComponent('AndroidSwitch'): any)
|
|
: (requireNativeComponent('RCTSwitch'): any);
|
|
|
|
module.exports = SwitchNativeComponent;
|