Commit 80907a2a authored by 刘阳's avatar 刘阳

Initial commit

parents
demo
doc
example
.gitignore
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = 'Picker'
s.version = package['version'].gsub(/v|-beta/, '')
s.summary = package['description']
s.author = package['author']
s.license = package['license']
s.homepage = package['homepage']
s.source = { :git => 'https://github.com/beefe/react-native-picker.git', :tag => "v#{s.version}"}
s.platform = :ios, '7.0'
s.preserve_paths = '*.js'
s.subspec 'Core' do |ss|
ss.dependency 'React'
ss.source_files = 'ios/RCTBEEPickerManager/*.{h,m}'
ss.public_header_files = ['ios/RCTBEEPickerManager/*.h']
end
end
# react-native-picker
[![npm version](https://img.shields.io/npm/v/react-native-picker.svg?style=flat-square)](https://www.npmjs.com/package/react-native-picker) <a href="https://david-dm.org/beefe/react-native-picker"><img src="https://david-dm.org/beefe/react-native-picker.svg?style=flat-square" alt="dependency status"></a>
![ui3](./doc/ui3.jpg)
![ui4](./doc/ui4.jpg)
### Documentation
#### Params
|Key | Type | Default| Support | Description |
| --- | --- | ---- | ------ | ----------- |
|isLoop | Boolean | false | Android | |
|pickerTextEllipsisLen | number | 6 | Android | |
|pickerConfirmBtnText | string | confirm | iOS/Android | |
|pickerCancelBtnText | string | cancel | iOS/Android | |
|pickerTitleText | string | pls select | iOS/Android | |
|pickerConfirmBtnColor | array | [1, 186, 245, 1] | iOS/Android | |
|pickerCancelBtnColor | array | [1, 186, 245, 1] | iOS/Android | |
|pickerTitleColor | array | [20, 20, 20, 1] | iOS/Android | |
|pickerToolBarBg | array | [232, 232, 232, 1] | iOS/Android | |
|pickerBg | array | [196, 199, 206, 1] | iOS/Android | |
|pickerToolBarFontSize | number | 16 | iOS/Android | |
|wheelFlex | array | [1, 1, 1] | iOS/Android | |
|pickerFontSize | number | 16 | iOS/Android | |
|pickerFontColor | array | [31, 31, 31, 1] | iOS/Android | |
|pickerFontFamily | string | | iOS/Android | |
|pickerRowHeight | number | 24 | iOS | |
|pickerData | array | | iOS/Android | |
|selectedValue | array | | iOS/Android | |
|onPickerConfirm | function| | iOS/Android | |
|onPickerCancel | function| | iOS/Android | |
|onPickerSelect | function| | iOS/Android | |
#### Methods
|Key | Support | Description |
| --- | ---- | ----------- |
|init | iOS/Android |init and pass parameters to picker |
|toggle | iOS/Android |show or hide picker |
|show | iOS/Android |show picker |
|hide | iOS/Android |hide picker |
|select | iOS/Android |select a row |
|isPickerShow | iOS/Android |get status of picker, return a boolean |
### Usage
#### Step 1 - install
```javascript
npm install react-native-picker --save
```
#### Step 2 - link
```
react-native link
```
#### Step 3 - import and use in project
```javascript
import Picker from 'react-native-picker';
let data = [];
for(var i=0;i<100;i++){
data.push(i);
}
Picker.init({
pickerData: data,
selectedValue: [59],
onPickerConfirm: data => {
console.log(data);
},
onPickerCancel: data => {
console.log(data);
},
onPickerSelect: data => {
console.log(data);
}
});
Picker.show();
```
### Integration With Existing Apps (`iOS`)
The `Podfile` will like below:
``` ruby
platform :ios, '8.0'
target 'YourTarget' do
pod 'React', :path => '../YOUR_REACT_NATIVE_PROJECT/node_modules/react-native', :subspecs => [
'Core',
...
]
pod 'Picker', :path => '../YOUR_REACT_NATIVE_PROJECT/node_modules/react-native-picker'
end
```
After you have updated the `Podfile` of the existing app, you can install `react-native-picker` like below:
``` bash
$ pod install
```
### Notice
#### support two modes:
<b>1. parallel:</b> such as time picker, wheels have no connection with each other
<b>2. cascade:</b> such as date picker, address picker .etc, when front wheel changed, the behind wheels will all be reset
#### parallel:
- single wheel:
```javascript
pickerData = [1,2,3,4];
selectedValue = 3;
```
- two or more wheel:
```javascript
pickerData = [
[1,2,3,4],
[5,6,7,8],
...
];
selectedValue = [1, 5];
```
#### cascade:
- two wheel
```javascript
pickerData = [
{
a: [1, 2, 3, 4]
},
{
b: [5, 6, 7, 8]
},
...
];
selectedValue = ['a', 2];
```
- three wheel
```javascript
pickerData = [
{
a: [
{
a1: [1, 2, 3, 4]
},
{
a2: [5, 6, 7, 8]
},
{
a3: [9, 10, 11, 12]
}
]
},
{
b: [
{
b1: [11, 22, 33, 44]
},
{
b2: [55, 66, 77, 88]
},
{
b3: [99, 1010, 1111, 1212]
}
]
},
{
c: [
{
c1: ['a', 'b', 'c']
},
{
c2: ['aa', 'bb', 'cc']
},
{
c3: ['aaa', 'bbb', 'ccc']
}
]
},
...
]
```
### For pure javascript version -> [v3.0.5](https://github.com/beefe/react-native-picker/tree/pure-javascript-version)
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
}
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.beefe.picker;
public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String LIBRARY_PACKAGE_NAME = "com.beefe.picker";
/**
* @deprecated APPLICATION_ID is misleading in libraries. For the library package name use LIBRARY_PACKAGE_NAME
*/
@Deprecated
public static final String APPLICATION_ID = "com.beefe.picker";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.beefe.picker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>
\ No newline at end of file
#Thu Jun 17 14:39:46 CST 2021
/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view_linkage.xml=/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/intermediates/packaged_res/release/layout/picker_view_linkage.xml
/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view_alone.xml=/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/intermediates/packaged_res/release/layout/picker_view_alone.xml
/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view.xml=/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/intermediates/packaged_res/release/layout/picker_view.xml
/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/anim/picker_enter.xml=/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/intermediates/packaged_res/release/anim/picker_enter.xml
/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/anim/picker_exit.xml=/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/intermediates/packaged_res/release/anim/picker_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">react-native-picker</string>
<style name="Dialog_Full_Screen">
<item name="android:windowIsFloating">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/PickerAnim</item>
<item name="android:background">@android:color/transparent</item>
</style>
<style name="PickerAnim">
<item name="android:windowEnterAnimation">@anim/picker_enter</item>
<item name="android:windowExitAnimation">@anim/picker_exit</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res"/><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/generated/res/rs/release"/><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/generated/res/resValues/release"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res"><file name="picker_enter" path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/anim/picker_enter.xml" qualifiers="" type="anim"/><file name="picker_exit" path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/anim/picker_exit.xml" qualifiers="" type="anim"/><file name="picker_view_alone" path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view_alone.xml" qualifiers="" type="layout"/><file name="picker_view_linkage" path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view_linkage.xml" qualifiers="" type="layout"/><file name="picker_view" path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/layout/picker_view.xml" qualifiers="" type="layout"/><file path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/values/styles.xml" qualifiers=""><style name="Dialog_Full_Screen">
<item name="android:windowIsFloating">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/PickerAnim</item>
<item name="android:background">@android:color/transparent</item>
</style><style name="PickerAnim">
<item name="android:windowEnterAnimation">@anim/picker_enter</item>
<item name="android:windowExitAnimation">@anim/picker_exit</item>
</style></file><file path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/res/values/strings.xml" qualifiers=""><string name="app_name">react-native-picker</string></file></source><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/generated/res/rs/release"/><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/build/generated/res/resValues/release"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="release$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/release/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="release" generated-set="release$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/release/res"/></dataSet><mergedItems/></merger>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.beefe.picker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>
\ No newline at end of file
R_DEF: Internal format may change without notice
local
anim picker_enter
anim picker_exit
id barLayout
id cancel
id confirm
id loopViewOne
id loopViewThree
id loopViewTwo
id pickerLayout
id pickerViewAlone
id pickerViewAloneLayout
id pickerViewLinkage
id title
layout picker_view
layout picker_view_alone
layout picker_view_linkage
string app_name
style Dialog_Full_Screen
style PickerAnim
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.beefe.picker"
4 android:versionCode="1"
5 android:versionName="1.0" >
6
7 <uses-sdk
8 android:minSdkVersion="16"
8-->/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
9 android:targetSdkVersion="27" />
9-->/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
10
11 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
11-->/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:2:7-79
11-->/Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:2:24-77
12
13</manifest>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="0"
android:fromYDelta="100%"
android:toXDelta="0"
android:toYDelta="0" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:duration="300"
android:toXDelta="0"
android:toYDelta="100%" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000">
<RelativeLayout
android:id="@+id/barLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/pickerLayout">
<TextView
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="9dp" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="9dp" />
<TextView
android:id="@+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="9dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/pickerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<com.beefe.picker.view.PickerViewLinkage
android:id="@+id/pickerViewLinkage"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.beefe.picker.view.PickerViewAlone
android:id="@+id/pickerViewAlone"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:id="@+id/pickerViewAloneLayout"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.beefe.picker.view.LoopView
android:id="@+id/loopViewOne"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="match_parent" />
<com.beefe.picker.view.LoopView
android:id="@+id/loopViewTwo"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="match_parent" />
<com.beefe.picker.view.LoopView
android:id="@+id/loopViewThree"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">react-native-picker</string>
<style name="Dialog_Full_Screen">
<item name="android:windowIsFloating">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/PickerAnim</item>
<item name="android:background">@android:color/transparent</item>
</style>
<style name="PickerAnim">
<item name="android:windowEnterAnimation">@anim/picker_enter</item>
<item name="android:windowExitAnimation">@anim/picker_exit</item>
</style>
</resources>
\ No newline at end of file
This diff is collapsed.
-- Merging decision tree log ---
manifest
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
package
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:70-96
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
android:versionName
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
android:versionCode
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:1-3:12
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
xmlns:android
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:1:11-69
uses-permission#android.permission.SYSTEM_ALERT_WINDOW
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:2:7-79
android:name
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml:2:24-77
uses-sdk
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml reason: use-sdk injection requested
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
android:targetSdkVersion
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
android:minSdkVersion
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
ADDED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
INJECTED from /Users/liuyang/Geek/GeekOperationApp/node_modules/react-native-picker/android/src/main/AndroidManifest.xml
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/heng/Desktop/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.beefe.picker">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
</manifest>
This diff is collapsed.
package com.beefe.picker;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Created by heng on 16/9/5.
*/
public class PickerViewPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new PickerViewModule(reactContext));
}
// Deprecated RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
package com.beefe.picker.util;
/**
* Created by geezer. on 2017/9/21.
*/
import android.os.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
public class BuildProperties {
private final Properties properties;
private BuildProperties() throws IOException {
properties = new Properties();
properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));
}
public boolean containsKey(final Object key) {
return properties.containsKey(key);
}
public boolean containsValue(final Object value) {
return properties.containsValue(value);
}
public Set<Entry<Object, Object>> entrySet() {
return properties.entrySet();
}
public String getProperty(final String name) {
return properties.getProperty(name);
}
public String getProperty(final String name, final String defaultValue) {
return properties.getProperty(name, defaultValue);
}
public boolean isEmpty() {
return properties.isEmpty();
}
public Enumeration<Object> keys() {
return properties.keys();
}
public Set<Object> keySet() {
return properties.keySet();
}
public int size() {
return properties.size();
}
public Collection<Object> values() {
return properties.values();
}
public static BuildProperties newInstance() throws IOException {
return new BuildProperties();
}
}
package com.beefe.picker.util;
import java.io.IOException;
/**
* Created by geezer. on 2017/9/21.
*/
public final class MIUIUtils {
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
public static boolean isMIUI() {
try {
final BuildProperties prop = BuildProperties.newInstance();
return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
} catch (final IOException e) {
return false;
}
}
}
package com.beefe.picker.view;
import java.util.TimerTask;
final class InertiaTimerTask extends TimerTask {
float a;
final float velocityY;
final LoopView loopView;
InertiaTimerTask(LoopView loopview, float velocityY) {
super();
loopView = loopview;
this.velocityY = velocityY;
a = Integer.MAX_VALUE;
}
@Override
public final void run() {
if (a == Integer.MAX_VALUE) {
if (Math.abs(velocityY) > 2000F) {
if (velocityY > 0.0F) {
a = 2000F;
} else {
a = -2000F;
}
} else {
a = velocityY;
}
}
if (Math.abs(a) >= 0.0F && Math.abs(a) <= 20F) {
loopView.cancelFuture();
loopView.handler.sendEmptyMessage(MessageHandler.WHAT_SMOOTH_SCROLL);
return;
}
int i = (int) ((a * 10F) / 1000F);
LoopView loopview = loopView;
loopview.totalScrollY = loopview.totalScrollY - i;
if (!loopView.isLoop) {
float itemHeight = loopView.lineSpacingMultiplier * loopView.maxTextHeight;
if (loopView.totalScrollY <= (int) ((float) (-loopView.initPosition) * itemHeight)) {
a = 40F;
loopView.totalScrollY = (int) ((float) (-loopView.initPosition) * itemHeight);
} else if (loopView.totalScrollY >= (int) ((float) (loopView.items.size() - 1 - loopView.initPosition) * itemHeight)) {
loopView.totalScrollY = (int) ((float) (loopView.items.size() - 1 - loopView.initPosition) * itemHeight);
a = -40F;
}
}
if (a < 0.0F) {
a = a + 20F;
} else {
a = a - 20F;
}
loopView.handler.sendEmptyMessage(MessageHandler.WHAT_INVALIDATE_LOOP_VIEW);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment