React Native Dropdown for iOS and Android
- Xcode 8+
- CocoaPods 1.1.1+
- SDK 16+
Run npm install --save tipsi-dropdown
to add the package to your app's dependencies.
Run react-native link tipsi-dropdown
so your project is linked against your Xcode project and all CocoaPods dependencies are installed.
- Setup your
Podfile
like the included example/ios/Podfile then runpod install
. - Open your project in Xcode workspace.
- Drag the following folder into your project:
node_modules/tipsi-dropdown/ios/TipsiDropdown/
Run react-native link tipsi-dropdown
so your project is linked against your Android project
In your android/app/build.gradle
add:
...
dependencies {
...
compile project(':tipsi-dropdown')
}
In your android/settings.gradle
add:
...
include ':tipsi-dropdown'
project(':tipsi-dropdown').projectDir = new File(rootProject.projectDir, '../node_modules/tipsi-dropdown/android')
In your android/build.gradle
add:
...
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
import React, { Component } from 'react'
import { StyleSheet } from 'react-native'
import Dropdown from 'tipsi-dropdown'
export default class Example extends Component {
state = {
value: 'three',
}
handleChange = (event) => {
console.log(event.nativeEvent)
}
handleValueChange = (item, index) => {
this.setState({ value: item })
}
render() {
return (
<Dropdown
style={styles.dropdown}
itemStyle={styles.item}
indicator={require('./arrow.png')}
selectedValue={this.state.value}
onChange={this.handleChange}
onValueChange={this.handleValueChange}>
<Dropdown.Item label="One" value="one" />
<Dropdown.Item label="Two" value="two" />
<Dropdown.Item label="Three" value="three" />
<Dropdown.Item label="Four" value="four" />
</Dropdown>
)
}
}
const styles = StyleSheet.create({
dropdown: {
margin: 25,
width: 156,
borderRadius: 20,
backgroundColor: '#AAAAAA',
separatorHeight: 2,
separatorColor: '#0000FF',
},
item: {
fontSize: 18,
fontFamily: 'Arial',
color: '#000000',
textAlign: 'left',
},
})
To run example
app e2e tests for all platforms you can use npm run ci
command:
npm run ci
- Go to example folder
cd example
- Install CocoaPods dependencies (iOS only)
pod install --project-directory=ios
- Install npm dependencies
npm install
- Build project:
npm run build:ios
- for iOSnpm run build:android
- for Androidnpm run build
- for both iOS and Android
- Open Appium in other tab
npm run appium
- Run tests:
npm run test:ios
- for iOSnpm run test:android
- for Androidnpm run test
- for both iOS and Android
You might encounter the following error while trying to run tests:
An unknown server-side error occurred while processing the command. Original error: Command \'/bin/bash Scripts/bootstrap.sh -d\' exited with code 1
You can fix it by installing Carthage
:
brew install carthage
To see more of the tipsi-dropdown
in action, you can check out the source in example folder.
tipsi-dropdown is available under the MIT license. See the LICENSE file for more info.