file-picker.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* eslint-disable */
  2. import React from 'react'
  3. import {
  4. StyleSheet,
  5. Modal,
  6. Text,
  7. View,
  8. ScrollView,
  9. Button,
  10. TouchableOpacity,
  11. Image } from 'react-native'
  12. export default class App extends React.Component {
  13. constructor () {
  14. super()
  15. this.state = {
  16. providers: [
  17. { id: 'Local', name: 'Local' },
  18. { id: 'GoogleDrive', name: 'Google Drive' },
  19. { id: 'Instagram', name: 'Instagram' }
  20. ],
  21. openProvider: null
  22. }
  23. }
  24. componentDidMount () {
  25. }
  26. openProvider (id) {
  27. console.log('OPEN PROVIDER:', id)
  28. }
  29. render () {
  30. if (this.state.openProvider) {
  31. return 'show provider'
  32. }
  33. return (
  34. <Modal
  35. animationType="slide"
  36. transparent={false}
  37. visible={this.props.show}
  38. onRequestClose={() => {
  39. Alert.alert('Modal has been closed.');
  40. }}>
  41. <ScrollView
  42. contentContainerStyle={{
  43. flex: '1',
  44. marginTop: 22,
  45. // alignItems: 'center',
  46. justifyContent: 'center'
  47. }}>
  48. {this.state.providers.map((item, index) => {
  49. return (
  50. <TouchableOpacity
  51. style={{
  52. alignItems: 'center',
  53. backgroundColor: '#DDDDDD',
  54. marginBottom: 10,
  55. padding: 10
  56. }}
  57. key={index}
  58. onPress={this.openProvider.bind(this, item.id)}>
  59. <Text>{item.name}</Text>
  60. </TouchableOpacity>
  61. )
  62. })}
  63. </ScrollView>
  64. </Modal>
  65. )
  66. }
  67. }