Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed rnpm link error #15

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ local.properties
node_modules/
npm-debug.log
*.iml
/.project
5 changes: 4 additions & 1 deletion DateTime.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class DateTimePicker extends Component {

showDatePicker(date, callback) {
date = date || new Date();
callback = callback || this.props.onDateChange;
var options = {
...this.props,
year:date.getFullYear(),
Expand All @@ -44,6 +45,7 @@ export default class DateTimePicker extends Component {

showTimePicker(date, callback) {
date = date || new Date();
callback = callback || this.props.onDateChange;
var options = {
...this.props,
hour:date.getHours(),
Expand All @@ -58,6 +60,7 @@ export default class DateTimePicker extends Component {

showDateTimePicker(date, callback) {
date = date || new Date();
callback = callback || this.props.onDateChange;
var options = {
...this.props,
year:date.getFullYear(),
Expand All @@ -79,4 +82,4 @@ export default class DateTimePicker extends Component {
render() {
return null;
}
}
}
33 changes: 15 additions & 18 deletions DateTime.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class DateTimePicker extends Component {
}

showDatePicker(date, callback) {
this.callback = callback;
this.callback = callback || this.props.onDateChange;
date = (date || new Date());

this.setState({
Expand All @@ -47,7 +47,7 @@ export default class DateTimePicker extends Component {
}

showTimePicker(date, callback) {
this.callback = callback;
this.callback = callback || this.props.onDateChange;
date = (date || new Date());

this.setState({
Expand All @@ -58,7 +58,7 @@ export default class DateTimePicker extends Component {
}

showDateTimePicker(date, callback) {
this.callback = callback;
this.callback = callback || this.props.onDateChange;
date = (date || new Date());

this.setState({
Expand All @@ -78,7 +78,7 @@ export default class DateTimePicker extends Component {
this.setState({
visible: false
});
this.callback(this.state.date);
this.callback(this.props.date);
}

onDateChange(date) {
Expand All @@ -94,22 +94,19 @@ export default class DateTimePicker extends Component {
style={styles.touchableOpacity}
activeOpacity={1}
onPress={()=>this.onClose()} />
<DatePickerIOS
date={this.state.date}
mode={this.state.mode}
onDateChange={(date)=>this.onDateChange(date)}
style = {styles.datePicker}
/>
<View style={styles.separator}/>
<TouchableOpacity
onPress={()=>this.onComplete()}
style={styles.button}>
<Text>{ this.props.okText }</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.touchableOpacity}
activeOpacity={1}
onPress={()=>this.onClose()} />
<View style={styles.separator}/>
<DatePickerIOS
// date={this.state.date}
// mode={this.state.mode}
// onDateChange={(date)=>this.onDateChange(date)}
style = {styles.datePicker}
{...this.props}
/>
</View>
</View>
);
Expand All @@ -132,16 +129,16 @@ const _styles = StyleSheet.create({
},
datePicker: {
backgroundColor: 'white',
alignItems: 'center',
},
touchableOpacity: {
flex: 1,
},
button: {
paddingHorizontal: 10,
paddingVertical: 10,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center'
justifyContent: 'flex-end',
alignItems: 'flex-end'
},
separator: {
height: 1,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A datetime-picker for react-native support for android and ios(base on @remobile

## Installation
```sh
npm install react-native-datetime --save
npm install react-native-yunpeng-datetime --save
```

### Installation (iOS)
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.facebook.react:react-native:0.25.+'
compile 'com.facebook.react:react-native:0.20.+'
}
12 changes: 5 additions & 7 deletions android/src/main/java/com/keyee/datetime/RCTDateTimePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import com.facebook.react.bridge.ReadableMap;

public class RCTDateTimePicker extends ReactContextBaseJavaModule {
private Activity activity;

public RCTDateTimePicker(ReactApplicationContext reactContext, Activity activity) {
public RCTDateTimePicker(ReactApplicationContext reactContext) {
super(reactContext);
this.activity = activity;
}

@Override
Expand All @@ -25,18 +23,18 @@ public String getName() {
@ReactMethod
public void showDatePicker(ReadableMap options, Callback callback) {
DialogFragment datePicker = new DatePicker(options, callback);
datePicker.show(activity.getFragmentManager(), "datePicker");
datePicker.show(getCurrentActivity().getFragmentManager(), "datePicker");
}

@ReactMethod
public void showTimePicker(ReadableMap options, Callback callback) {
DialogFragment timePicker = new TimePicker(options, callback);
timePicker.show(activity.getFragmentManager(), "timePicker");
timePicker.show(getCurrentActivity().getFragmentManager(), "timePicker");
}

@ReactMethod
public void showDateTimePicker(ReadableMap options, Callback callback) {
DialogFragment datetimePicker = new DateTimePicker(options, callback);
datetimePicker.show(activity.getFragmentManager(), "datetimePicker");
datetimePicker.show(getCurrentActivity().getFragmentManager(), "datetimePicker");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
import android.app.Activity;

public class RCTDateTimePickerPackage implements ReactPackage {

private Activity activity;

private RCTDateTimePicker mModuleInstance;

public RCTDateTimePickerPackage(Activity activity) {
public RCTDateTimePickerPackage() {
super();
this.activity = activity;
}

@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();

modules.add(new RCTDateTimePicker(reactContext, activity));
modules.add(new RCTDateTimePicker(reactContext));

return modules;
}
Expand All @@ -41,4 +39,4 @@ public List<Class<? extends JavaScriptModule>> createJSModules() {
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "react-native-datetime",
"version": "0.1.2",
"name": "react-native-yunpeng-datetime",
"version": "0.1.4",
"description": "A datetime-picker for react-native support for android and ios",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/cnjon/react-native-datetime.git"
"url": "git+https://github.com/yptech/react-native-datetime.git"
},
"keywords": [
"react-component",
Expand All @@ -17,11 +17,11 @@
"datetime"
],
"author": {
"name": "cnjon",
"url": "https://github.com/cnjon"
"name": "iday",
"url": "https://github.com/iday"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/cnjon/react-native-datetime/issues"
"url": "https://github.com/yptech/react-native-datetime/issues"
}
}