mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-22 01:40:29 +00:00
* Update eslint dependencies. * standard --fix * build: disable handler name lint rule * status-bar: manually fix lint errors * webcam: manually fix lint errors * url: manually fix lint errors * react-native: manually fix lint errors * dashboard: manually fix lint errors * informer: manually fix linting errors * progress-bar: manually fix lint errors * provider-views: manually fix lint errors * redux-dev-tools: manually fix lint errors * build: disable buggy no-unused-vars rule * examples: manually fix lint errors * ` quotes for code things, ' for text things
112 lines
2.2 KiB
JavaScript
112 lines
2.2 KiB
JavaScript
import React from 'react'
|
|
|
|
import {
|
|
StyleSheet,
|
|
TouchableOpacity,
|
|
Text,
|
|
TextInput,
|
|
View
|
|
} from 'react-native'
|
|
import Url from '@uppy/url'
|
|
|
|
export default class UppyRNUrl extends React.Component {
|
|
constructor () {
|
|
super()
|
|
|
|
this.state = {
|
|
url: null
|
|
}
|
|
|
|
this.onPressImport = this.onPressImport.bind(this)
|
|
}
|
|
|
|
componentDidMount () {
|
|
const uppy = this.props.uppy
|
|
const options = Object.assign(
|
|
{ id: 'uppyRN:Url' },
|
|
this.props,
|
|
{ }
|
|
)
|
|
delete options.uppy
|
|
|
|
uppy.use(Url, options)
|
|
this.plugin = uppy.getPlugin(options.id)
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
const uppy = this.props.uppy
|
|
uppy.removePlugin(this.plugin)
|
|
}
|
|
|
|
onPressImport () {
|
|
this.plugin.addFile(this.state.url)
|
|
.then(this.props.onDone)
|
|
.catch((err) => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
|
|
render () {
|
|
return (
|
|
<View style={styles.container}>
|
|
<TextInput
|
|
style={styles.input}
|
|
autoFocus
|
|
onChangeText={(text) => this.setState({
|
|
url: text
|
|
})}
|
|
placeholder="Enter URL to import a file"
|
|
/>
|
|
<TouchableOpacity
|
|
style={styles.buttonImport}
|
|
onPress={this.onPressImport}
|
|
>
|
|
<Text style={styles.buttonImportText}>Import</Text>
|
|
</TouchableOpacity>
|
|
<TouchableOpacity
|
|
style={styles.buttonCancel}
|
|
onPress={ev => this.props.onDone()}
|
|
>
|
|
<Text style={styles.buttonCancelText}>Cancel</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
)
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
justifyContent: 'center'
|
|
},
|
|
input: {
|
|
width: '90%',
|
|
height: 40,
|
|
borderColor: '#7f8a93',
|
|
borderWidth: 1,
|
|
padding: 5,
|
|
borderRadius: 4,
|
|
marginBottom: 15
|
|
},
|
|
buttonImport: {
|
|
alignItems: 'center',
|
|
backgroundColor: '#2275d7',
|
|
paddingHorizontal: 25,
|
|
paddingVertical: 8,
|
|
borderRadius: 5,
|
|
marginBottom: 10
|
|
},
|
|
buttonCancel: {
|
|
alignItems: 'center',
|
|
paddingHorizontal: 15,
|
|
paddingVertical: 8,
|
|
borderRadius: 5
|
|
},
|
|
buttonImportText: {
|
|
color: '#fff'
|
|
},
|
|
buttonCancelText: {
|
|
color: '#0077cc'
|
|
}
|
|
})
|