Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ emoji=true
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.ts
module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
Expand Down
51 changes: 51 additions & 0 deletions codegen/SegmentedControlNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type {ViewProps} from 'ViewPropTypes';
import type {HostComponent, ColorValue} from 'react-native';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';

import type {
BubblingEventHandler,
Int32,
WithDefault,
Float,
} from 'react-native/Libraries/Types/CodegenTypes';

type RNCSegmentedControlValue = {
type: Int32; // 1: text, 2: image
stringValue?: string; // title
imgValue?: {
// ImageResolvedAssetSource
height: Int32;
width: Int32;
scale: Float;
uri: string;
};
};

type OnChangeEvent = {
// works only with text values (not with images)
value: string;
selectedSegmentIndex: Int32;
};

type SCFontStyle = {
color?: ColorValue;
fontSize?: WithDefault<Int32, 13>;
fontFamily?: string;
};

export interface NativeProps extends ViewProps {
values: Array<RNCSegmentedControlValue>;
selectedIndex?: WithDefault<Int32, -1>;
tintColor?: ColorValue;
backgroundColor?: ColorValue;
momentary?: WithDefault<boolean, false>;
enabled?: WithDefault<boolean, true>;
onChange?: BubblingEventHandler<OnChangeEvent, 'onChange'>;
appearance?: string;
fontStyle?: SCFontStyle;
activeFontStyle?: SCFontStyle;
}

export default codegenNativeComponent<NativeProps>(
'RNCSegmentedControl',
) as HostComponent<NativeProps>;
Loading