### Start the example app packager Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Starts the Metro server for the example application. ```sh yarn example start ``` -------------------------------- ### Run example app on Web Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Launches the example application in a web browser. ```sh yarn example web ``` -------------------------------- ### Install dependencies Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/configuration.md Commands to install the library and its required peer dependencies. ```bash # Using Expo expo install react-native-wheel-picker-expo expo-linear-gradient expo-haptics # Or npm npm install react-native-wheel-picker-expo expo-linear-gradient expo-haptics ``` -------------------------------- ### Install react-native-wheel-picker-expo Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/README.md Installation commands for Expo and npm environments. ```sh expo install react-native-wheel-picker-expo ``` ```sh npm install react-native-wheel-picker-expo ``` -------------------------------- ### Run example app on Android Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Launches the example application on an Android device or emulator. ```sh yarn example android ``` -------------------------------- ### Run example app on iOS Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Launches the example application on an iOS device or simulator. ```sh yarn example ios ``` -------------------------------- ### Install dependencies Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Run this command in the root directory to install all required project dependencies. ```sh yarn ``` -------------------------------- ### Install Dependencies Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/README.md Commands to install the library and its required dependencies using Expo or npm. ```bash expo install react-native-wheel-picker-expo expo-linear-gradient expo-haptics ``` ```bash npm install react-native-wheel-picker-expo expo-linear-gradient expo-haptics ``` -------------------------------- ### Implement WheelPickerExpo Component Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/README.md Basic usage example showing how to import and render the WheelPickerExpo component with a list of items. ```js import React from 'react'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; const CITIES = 'Jakarta,Bandung,Sumbawa,Taliwang,Lombok,Bima'.split(','); function App() { return ( ({ label: name, value: '' }))} onChange={({ item }) => setCity(item.label)} /> ); } ``` -------------------------------- ### Full Component Configuration Example Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/configuration.md A complete implementation showing how to configure layout, data, styling, callbacks, and behavior for the WheelPickerExpo component. ```typescript import React, { useState } from 'react'; import { View, Text } from 'react-native'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; const items = [ { label: 'Option 1', value: 1 }, { label: 'Option 2', value: 2 }, { label: 'Option 3', value: 3 }, ]; export default function ConfiguredPicker() { const [selected, setSelected] = useState(null); return ( { setSelected(item); }} // Customization renderItem={(props) => ( {props.label} )} // Behavior haptics={true} flatListProps={{ scrollEventThrottle: 16, }} /> Selected: {selected?.label} ); } ``` -------------------------------- ### Basic Wheel Picker Implementation Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/wheel-picker-expo.md Standard setup for a wheel picker using a list of city objects and state management. ```typescript import React, { useState } from 'react'; import { View } from 'react-native'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; export default function App() { const [selectedCity, setSelectedCity] = useState(''); const CITIES = [ { label: 'Jakarta', value: 'JKT' }, { label: 'Bandung', value: 'BDG' }, { label: 'Sumbawa', value: 'SBW' }, ]; return ( setSelectedCity(item.label)} /> ); } ``` -------------------------------- ### Handle Touch Start Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/rendering-system.md Sets the userTouch flag for haptic feedback and delegates to custom props if defined. ```typescript onTouchStart={(e) => { this.userTouch = true; !!flatListProps?.onTouchStart && flatListProps.onTouchStart(e); }} ``` -------------------------------- ### Apply transparency to colors Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Examples of applying partial opacity to hex color strings. ```typescript const color = setAlphaColor('#FFFFFF', 0.5); // Returns: '#FFFFFF80' (white at 50% opacity) const darkColor = setAlphaColor('#202124', 0.2); // Returns: '#20212433' (dark gray at 20% opacity) ``` -------------------------------- ### Project Directory Structure Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Visual representation of the project file hierarchy, including source code, build outputs, and example applications. ```text react-native-wheel-picker-expo/ ├── src/ │ ├── index.tsx (Main component, 256 lines) │ ├── types.ts (Type definitions, 33 lines) │ ├── util.ts (Utility functions, 30 lines) │ └── __tests__/ │ └── index.test.tsx (Jest test file) ├── lib/ (Build output) │ ├── commonjs/ │ │ ├── index.js │ │ ├── types.js │ │ └── util.js │ ├── module/ │ │ ├── index.js │ │ ├── types.js │ │ └── util.js │ └── typescript/ │ ├── index.d.ts │ ├── types.d.ts │ ├── util.d.ts │ └── index.tsx ├── example/ (Demo application) │ ├── src/ │ │ └── App.tsx │ ├── package.json │ └── tsconfig.json ├── package.json (Package configuration) ├── tsconfig.json (TypeScript configuration) └── tsconfig.build.json (Build-specific TypeScript config) ``` -------------------------------- ### Apply full opacity to color Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Example of using setAlphaColor with full opacity, which returns the original hex string. ```typescript import { setAlphaColor } from 'react-native-wheel-picker-expo'; const color = setAlphaColor('#F00F00', 1); // Returns: '#F00F00' (unchanged, full opacity) ``` -------------------------------- ### Calculate adaptive text color for light backgrounds Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Examples of using adaptiveColor with light-colored backgrounds, which should return black text. ```typescript import { adaptiveColor } from 'react-native-wheel-picker-expo'; const textColor1 = adaptiveColor('#FFFFFF'); // Returns: '#000000' (black text on white) const textColor2 = adaptiveColor('#F0F0F0'); // Returns: '#000000' (black text on light gray) const textColor3 = adaptiveColor('#FFFF00'); // Returns: '#000000' (black text on yellow) ``` -------------------------------- ### Integrate adaptiveColor in PickerItem Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Example of using adaptiveColor within a component to dynamically set font color based on background style. ```typescript // In PickerItem function (line 220) const fontColor = adaptiveColor(style.backgroundColor); return ( {renderItem ? ( renderItem({ fontSize, fontColor, label: item.label, textAlign }) ) : ( )} ); ``` -------------------------------- ### Calculate adaptive text color for dark backgrounds Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Examples of using adaptiveColor with dark-colored backgrounds, which should return white text. ```typescript const textColor4 = adaptiveColor('#000000'); // Returns: '#FFFFFF' (white text on black) const textColor5 = adaptiveColor('#1F1F1F'); // Returns: '#FFFFFF' (white text on dark gray) const textColor6 = adaptiveColor('#202124'); // Returns: '#FFFFFF' (white text on dark gray) ``` -------------------------------- ### Internal usage in WheelPickerExpo Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Examples of how the function is utilized internally within the component class. ```typescript // Internal usage in WheelPickerExpo backgroundColor = setAlphaColor(this.props.backgroundColor as any, 1); get gradientColor(): string { return Platform.select({ ios: setAlphaColor(this.backgroundColor, 0.2), android: setAlphaColor(this.backgroundColor, 0.4), web: setAlphaColor(this.backgroundColor, 0.4), }) as string; } ``` -------------------------------- ### Padded Data Array Initialization Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/rendering-system.md Adds empty padding items to the start and end of the data array to ensure smooth scrolling and correct center alignment. ```typescript setData() { const { itemHeight, listHeight } = this.state; const { items, height } = this.props; if (items?.length) { const additionalItem = { label: '', value: null }; const data = [ additionalItem, additionalItem, ...items, additionalItem, additionalItem, ] as ItemType[]; // Update state... } } ``` -------------------------------- ### File Structure Overview Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/README.md Displays the directory structure of the project documentation. ```text output/ ├── README.md (this file) ├── api-reference/ │ ├── wheel-picker-expo.md (main component) │ └── utility-functions.md (helper functions) ├── types.md (type definitions) ├── configuration.md (props and config) ├── module-structure.md (file organization) ├── lifecycle-and-state.md (component internals) ├── rendering-system.md (visual rendering) └── usage-patterns.md (implementation examples) ``` -------------------------------- ### Project File Structure Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/INDEX.md Displays the directory layout and documentation file organization. ```text output/ ├── README.md (Start here - 350 lines) ├── INDEX.md (This file) ├── MANIFEST.md (Documentation summary) │ ├── api-reference/ │ ├── wheel-picker-expo.md (Component API - 450 lines) │ └── utility-functions.md (Helpers - 380 lines) │ ├── types.md (Type definitions - 420 lines) ├── configuration.md (All props - 520 lines) ├── module-structure.md (Files & imports - 380 lines) ├── lifecycle-and-state.md (Lifecycle & state - 420 lines) ├── rendering-system.md (How it renders - 480 lines) └── usage-patterns.md (50+ examples - 450 lines) Total: 10 files, ~3,600 lines ``` -------------------------------- ### Publish new versions Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Uses release-it to handle version bumping, tagging, and publishing to npm. ```sh yarn release ``` -------------------------------- ### Implement Responsive Sizing Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/usage-patterns.md Calculate picker width dynamically based on window dimensions using the useWindowDimensions hook. ```typescript import { useWindowDimensions } from 'react-native'; export default function ResponsivePicker() { const { width } = useWindowDimensions(); const pickerWidth = width * 0.8; return ( console.log(item)} /> ); } ``` -------------------------------- ### Configure react-native-builder-bob Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Build configuration defining source, output, and target formats for the package. ```json { "react-native-builder-bob": { "source": "src", "output": "lib", "targets": [ "commonjs", "module", ["typescript", { "project": "tsconfig.build.json" }] ] } } ``` -------------------------------- ### Package source mapping configuration Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md The package.json configuration defining entry points for different module systems and environments. ```json { "main": "lib/commonjs/index", "module": "lib/module/index", "types": "lib/typescript/index.d.ts", "react-native": "src/index", "source": "src/index" } ``` -------------------------------- ### Importing Components and Types Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/README.md Standard import patterns for the main component, type definitions, and internal utility functions. ```typescript // Main component import WheelPickerExpo from 'react-native-wheel-picker-expo'; // Types (direct import from compiled output) import type { ItemType } from 'react-native-wheel-picker-expo/lib/typescript/types'; // Utilities (rare; primarily internal) import { setAlphaColor } from 'react-native-wheel-picker-expo/lib/commonjs/util'; ``` -------------------------------- ### Custom Picker Theme Integration Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/utility-functions.md Demonstrates applying adaptiveColor and setAlphaColor within a custom component theme. ```typescript import { setAlphaColor, adaptiveColor } from 'react-native-wheel-picker-expo'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; const THEME = { primary: '#2196F3', dark: '#1A237E', light: '#E3F2FD', }; export function ThemedPicker() { const itemColor = adaptiveColor(THEME.primary); const gradientColor = setAlphaColor(THEME.primary, 0.3); return ( console.log(item)} renderItem={(props) => ( {props.label} )} /> ); } ``` -------------------------------- ### Run unit tests Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/CONTRIBUTING.md Executes the project's unit test suite using Jest. ```sh yarn test ``` -------------------------------- ### Minimal Wheel Picker Configuration Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/usage-patterns.md The simplest implementation requiring only the items array and an onChange handler. ```typescript import React, { useState } from 'react'; import { View } from 'react-native'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; export default function App() { const [selected, setSelected] = useState(null); const items = [ { label: 'Option A', value: 'a' }, { label: 'Option B', value: 'b' }, { label: 'Option C', value: 'c' }, ]; return ( setSelected(item.label)} /> ); } ``` -------------------------------- ### Importing Components and Types Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Use default imports for the main component and specific paths for utility functions or types. Avoid named imports from the root package as they are not supported. ```typescript // ✓ Good - simple component usage import WheelPickerExpo from 'react-native-wheel-picker-expo'; // ✓ Good - with type annotations import WheelPickerExpo from 'react-native-wheel-picker-expo'; import type { ItemType } from 'react-native-wheel-picker-expo/lib/typescript/types'; // ✓ Good - utility for advanced use (rare) import { adaptiveColor } from 'react-native-wheel-picker-expo/lib/commonjs/util'; // ✗ Avoid - named imports from root don't exist import { WheelPickerExpo } from 'react-native-wheel-picker-expo'; // ✗ Avoid - types from root not exported import type { ItemType } from 'react-native-wheel-picker-expo'; ``` -------------------------------- ### Configure TypeScript for build Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Build-specific TypeScript configuration extending the base development settings. ```json { "extends": "./tsconfig", "compilerOptions": { "declaration": true, "declarationMap": true, "sourceMap": true }, "include": ["src"], "exclude": ["**/__tests__", "example"] } ``` -------------------------------- ### Basic WheelPickerExpo Usage Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/README.md Demonstrates the basic implementation of the WheelPickerExpo component with required props. ```typescript import WheelPickerExpo from 'react-native-wheel-picker-expo'; console.log(item)} /> ``` -------------------------------- ### Custom Styling and Haptics Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/wheel-picker-expo.md Configures visual appearance, initial selection, and haptic feedback for the picker. ```typescript { console.log(`Selected: ${item.label} at index ${index}`); }} haptics={true} /> ``` -------------------------------- ### Data Flow Visualization Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/INDEX.md Represents the lifecycle of data from input array to selection callback. ```text Items array → Padded with empty items → Rendered with adaptive styles → User scrolls/taps → onChange callback fires with selection ``` -------------------------------- ### Importing Utilities Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Utility functions are not available via root exports and must be imported from the lib/commonjs/util path. ```typescript // ✗ Utilities not exported from root import { setAlphaColor } from 'react-native-wheel-picker-expo'; // Error: not exported // ✓ Direct import from source import { setAlphaColor } from 'react-native-wheel-picker-expo/lib/commonjs/util'; ``` -------------------------------- ### Implement render Method Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/lifecycle-and-state.md Returns the component's visual tree or undefined if no data is present. ```typescript render(): JSX.Element | undefined { const { data, itemHeight, listHeight, selectedIndex } = this.state; const { width, initialSelectedIndex, flatListProps, selectedStyle } = this.props; if (!data.length) return; // Exit early if no data return ( ); } ``` -------------------------------- ### ES Module Usage Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/module-structure.md Use standard import syntax when working with ES modules. ```typescript import WheelPickerExpo from 'react-native-wheel-picker-expo'; import { setAlphaColor } from 'react-native-wheel-picker-expo/lib/module/util'; ``` -------------------------------- ### Programmatic Scrolling with Ref Source: https://github.com/adityamr15/react-native-wheel-picker-expo/blob/master/_autodocs/api-reference/wheel-picker-expo.md Demonstrates attaching a ref to the component to track selection changes. ```typescript import React, { useRef } from 'react'; import { Button } from 'react-native'; import WheelPickerExpo from 'react-native-wheel-picker-expo'; export default function App() { const wheelRef = useRef(null); return ( <>