-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from vjeux/update1
Updates from Fri 13 Mar
- Loading branch information
Showing
26 changed files
with
829 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* * Copyright 2004-present Facebook. All Rights Reserved. | ||
* */ | ||
'use strict'; | ||
|
||
var React = require('react-native'); | ||
var { | ||
StyleSheet, | ||
Text, | ||
View, | ||
} = React; | ||
var ActionSheetIOS = require('ActionSheetIOS'); | ||
var BUTTONS = [ | ||
'Button Index: 0', | ||
'Button Index: 1', | ||
'Button Index: 2', | ||
'Destruct', | ||
'Cancel', | ||
]; | ||
var DESTRUCTIVE_INDEX = 3; | ||
var CANCEL_INDEX = 4; | ||
|
||
var ActionSheetExample = React.createClass({ | ||
getInitialState() { | ||
return { | ||
clicked: 'none', | ||
}; | ||
}, | ||
|
||
render() { | ||
return ( | ||
<View> | ||
<Text onPress={this.showActionSheet} style={style.button}> | ||
Click to show the ActionSheet | ||
</Text> | ||
<Text> | ||
Clicked button at index: "{this.state.clicked}" | ||
</Text> | ||
</View> | ||
); | ||
}, | ||
|
||
showActionSheet() { | ||
ActionSheetIOS.showActionSheetWithOptions({ | ||
options: BUTTONS, | ||
cancelButtonIndex: CANCEL_INDEX, | ||
destructiveButtonIndex: DESTRUCTIVE_INDEX, | ||
}, | ||
(buttonIndex) => { | ||
this.setState({ clicked: BUTTONS[buttonIndex] }); | ||
}); | ||
} | ||
}); | ||
|
||
var ShareActionSheetExample = React.createClass({ | ||
getInitialState() { | ||
return { | ||
text: '' | ||
}; | ||
}, | ||
|
||
render() { | ||
return ( | ||
<View> | ||
<Text onPress={this.showShareActionSheet} style={style.button}> | ||
Click to show the Share ActionSheet | ||
</Text> | ||
<Text> | ||
{this.state.text} | ||
</Text> | ||
</View> | ||
); | ||
}, | ||
|
||
showShareActionSheet() { | ||
ActionSheetIOS.showShareActionSheetWithOptions({ | ||
url: 'https://code.facebook.com', | ||
}, | ||
(error) => { | ||
console.error(error); | ||
}, | ||
(success, method) => { | ||
var text; | ||
if (success) { | ||
text = `Shared via ${method}`; | ||
} else { | ||
text = 'You didn\'t share'; | ||
} | ||
this.setState({text}) | ||
}); | ||
} | ||
}); | ||
|
||
var style = StyleSheet.create({ | ||
button: { | ||
marginBottom: 10, | ||
fontWeight: 'bold', | ||
} | ||
}); | ||
|
||
exports.title = 'ActionSheetIOS'; | ||
exports.description = 'Interface to show iOS\' action sheets'; | ||
exports.examples = [ | ||
{ | ||
title: 'Show Action Sheet', | ||
render() { return <ActionSheetExample />; } | ||
}, | ||
{ | ||
title: 'Show Share Action Sheet', | ||
render() { return <ShareActionSheetExample />; } | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @providesModule ActionSheetIOS | ||
*/ | ||
'use strict'; | ||
|
||
var invariant = require('invariant'); | ||
var RCTActionSheetManager = require('NativeModulesDeprecated').RKActionSheetManager; | ||
|
||
var ActionSheetIOS = { | ||
showActionSheetWithOptions(options, callback) { | ||
invariant( | ||
typeof options === 'object' && options !== null, | ||
'Options must a valid object' | ||
); | ||
invariant( | ||
typeof callback === 'function', | ||
'Must provide a valid callback' | ||
); | ||
RCTActionSheetManager.showActionSheetWithOptions( | ||
options, | ||
() => {}, // RKActionSheet compatibility hack | ||
callback | ||
); | ||
}, | ||
|
||
showShareActionSheetWithOptions(options, failureCallback, successCallback) { | ||
invariant( | ||
typeof options === 'object' && options !== null, | ||
'Options must a valid object' | ||
); | ||
invariant( | ||
typeof failureCallback === 'function', | ||
'Must provide a valid failureCallback' | ||
); | ||
invariant( | ||
typeof successCallback === 'function', | ||
'Must provide a valid successCallback' | ||
); | ||
RCTActionSheetManager.showShareActionSheetWithOptions( | ||
options, | ||
failureCallback, | ||
successCallback | ||
); | ||
} | ||
}; | ||
|
||
module.exports = ActionSheetIOS; |
Oops, something went wrong.