yeet
This commit is contained in:
46
node_modules/react-native/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js
generated
vendored
Normal file
46
node_modules/react-native/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import type {ViewProps} from '../View/ViewPropTypes';
|
||||
import type {
|
||||
BubblingEventHandler,
|
||||
WithDefault,
|
||||
Int32,
|
||||
} from '../../Types/CodegenTypes';
|
||||
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
|
||||
|
||||
export type OnChangeEvent = $ReadOnly<{|
|
||||
value: Int32,
|
||||
selectedSegmentIndex: Int32,
|
||||
|}>;
|
||||
|
||||
type NativeProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
|
||||
// Props
|
||||
values?: $ReadOnlyArray<string>,
|
||||
selectedIndex?: WithDefault<Int32, 0>,
|
||||
enabled?: WithDefault<boolean, true>,
|
||||
tintColor?: ?ColorValue,
|
||||
textColor?: ?ColorValue,
|
||||
backgroundColor?: ?ColorValue,
|
||||
momentary?: WithDefault<boolean, false>,
|
||||
|
||||
// Events
|
||||
onChange?: ?BubblingEventHandler<OnChangeEvent>,
|
||||
|}>;
|
||||
|
||||
export default (codegenNativeComponent<NativeProps>(
|
||||
'RCTSegmentedControl',
|
||||
): HostComponent<NativeProps>);
|
46
node_modules/react-native/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js
generated
vendored
Normal file
46
node_modules/react-native/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const StyleSheet = require('../../StyleSheet/StyleSheet');
|
||||
const Text = require('../../Text/Text');
|
||||
const View = require('../View/View');
|
||||
|
||||
class DummySegmentedControlIOS extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={[styles.dummy, this.props.style]}>
|
||||
<Text style={styles.text}>
|
||||
SegmentedControlIOS is not supported on this platform!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
dummy: {
|
||||
width: 120,
|
||||
height: 50,
|
||||
backgroundColor: '#ffbcbc',
|
||||
borderWidth: 1,
|
||||
borderColor: 'red',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
text: {
|
||||
color: '#333333',
|
||||
margin: 5,
|
||||
fontSize: 10,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummySegmentedControlIOS;
|
123
node_modules/react-native/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js
generated
vendored
Normal file
123
node_modules/react-native/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as React from 'react';
|
||||
import StyleSheet from '../../StyleSheet/StyleSheet';
|
||||
import type {OnChangeEvent} from './RCTSegmentedControlNativeComponent';
|
||||
import type {ViewProps} from '../View/ViewPropTypes';
|
||||
import RCTSegmentedControlNativeComponent from './RCTSegmentedControlNativeComponent';
|
||||
import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';
|
||||
|
||||
type SegmentedControlIOSProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
/**
|
||||
* The labels for the control's segment buttons, in order.
|
||||
*/
|
||||
values?: $ReadOnlyArray<string>,
|
||||
/**
|
||||
* The index in `props.values` of the segment to be (pre)selected.
|
||||
*/
|
||||
selectedIndex?: ?number,
|
||||
/**
|
||||
* If false the user won't be able to interact with the control.
|
||||
*/
|
||||
enabled?: boolean,
|
||||
/**
|
||||
* Accent color of the control.
|
||||
*/
|
||||
tintColor?: ?string,
|
||||
/**
|
||||
* If true, then selecting a segment won't persist visually.
|
||||
* The `onValueChange` callback will still work as expected.
|
||||
*/
|
||||
momentary?: ?boolean,
|
||||
/**
|
||||
* Callback that is called when the user taps a segment
|
||||
*/
|
||||
onChange?: ?(event: SyntheticEvent<OnChangeEvent>) => void,
|
||||
/**
|
||||
* Callback that is called when the user taps a segment;
|
||||
* passes the segment's value as an argument
|
||||
*/
|
||||
onValueChange?: ?(value: number) => mixed,
|
||||
|}>;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
...SegmentedControlIOSProps,
|
||||
forwardedRef: ?React.Ref<typeof RCTSegmentedControlNativeComponent>,
|
||||
|}>;
|
||||
|
||||
/**
|
||||
* Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
|
||||
*
|
||||
* #### Programmatically changing selected index
|
||||
*
|
||||
* The selected index can be changed on the fly by assigning the
|
||||
* selectedIndex prop to a state variable, then changing that variable.
|
||||
* Note that the state variable would need to be updated as the user
|
||||
* selects a value and changes the index, as shown in the example below.
|
||||
*
|
||||
* ````
|
||||
* <SegmentedControlIOS
|
||||
* values={['One', 'Two']}
|
||||
* selectedIndex={this.state.selectedIndex}
|
||||
* onChange={(event) => {
|
||||
* this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
|
||||
* }}
|
||||
* />
|
||||
* ````
|
||||
*/
|
||||
|
||||
class SegmentedControlIOS extends React.Component<Props> {
|
||||
static defaultProps = {
|
||||
values: [],
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
_onChange = (event: SyntheticEvent<OnChangeEvent>) => {
|
||||
this.props.onChange && this.props.onChange(event);
|
||||
this.props.onValueChange &&
|
||||
this.props.onValueChange(event.nativeEvent.value);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {forwardedRef, onValueChange, style, ...props} = this.props;
|
||||
return (
|
||||
<RCTSegmentedControlNativeComponent
|
||||
{...props}
|
||||
ref={forwardedRef}
|
||||
style={[styles.segmentedControl, style]}
|
||||
onChange={this._onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
segmentedControl: {
|
||||
height: 28,
|
||||
},
|
||||
});
|
||||
|
||||
const SegmentedControlIOSWithRef = React.forwardRef(
|
||||
(
|
||||
props: SegmentedControlIOSProps,
|
||||
forwardedRef: ?React.Ref<typeof RCTSegmentedControlNativeComponent>,
|
||||
) => {
|
||||
return <SegmentedControlIOS {...props} forwardedRef={forwardedRef} />;
|
||||
},
|
||||
);
|
||||
|
||||
/* $FlowFixMe(>=0.89.0 site=react_native_ios_fb) This comment suppresses an
|
||||
* error found when Flow v0.89 was deployed. To see the error, delete this
|
||||
* comment and run Flow. */
|
||||
module.exports = (SegmentedControlIOSWithRef: NativeSegmentedControlIOS);
|
Reference in New Issue
Block a user