2022-12-18 18:32:44 +13:00
|
|
|
import {useState} from 'react'
|
|
|
|
import {Button, View} from 'react-native'
|
|
|
|
import AppIntroSlider from 'react-native-app-intro-slider'
|
2022-12-15 16:31:35 +13:00
|
|
|
import DocumentPicker, {
|
|
|
|
DocumentPickerResponse,
|
2022-12-18 18:32:44 +13:00
|
|
|
} from 'react-native-document-picker'
|
|
|
|
import {backgroundColor} from './constants'
|
|
|
|
import Item from './Item'
|
2022-12-15 16:31:35 +13:00
|
|
|
|
|
|
|
export default function App() {
|
2022-12-18 18:32:44 +13:00
|
|
|
const [files, setFiles] = useState<DocumentPickerResponse[]>([])
|
|
|
|
const [slide, setSlide] = useState(0)
|
2022-12-15 16:31:35 +13:00
|
|
|
|
|
|
|
const pick = async () => {
|
2022-12-18 18:32:44 +13:00
|
|
|
const picked = await DocumentPicker.pickMultiple()
|
|
|
|
console.log(`Picked ${picked.length} files.`)
|
|
|
|
setFiles(picked)
|
|
|
|
}
|
2022-12-15 16:31:35 +13:00
|
|
|
|
|
|
|
const renderItem = ({
|
|
|
|
item,
|
|
|
|
index,
|
|
|
|
}: {
|
2022-12-18 18:32:44 +13:00
|
|
|
item: DocumentPickerResponse
|
|
|
|
index: number
|
2022-12-15 16:31:35 +13:00
|
|
|
}) => {
|
2022-12-18 18:32:44 +13:00
|
|
|
return <Item index={index} slide={slide} value={item} />
|
|
|
|
}
|
2022-12-15 16:31:35 +13:00
|
|
|
|
|
|
|
return (
|
2022-12-18 18:32:44 +13:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
backgroundColor,
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
flex: 1,
|
|
|
|
flexGrow: 1,
|
|
|
|
padding: 10,
|
|
|
|
}}>
|
|
|
|
<Item />
|
2022-12-15 16:31:35 +13:00
|
|
|
<AppIntroSlider
|
|
|
|
style={{backgroundColor}}
|
|
|
|
data={files}
|
|
|
|
renderItem={renderItem}
|
2022-12-18 18:32:44 +13:00
|
|
|
onSlideChange={setSlide}
|
2022-12-15 16:31:35 +13:00
|
|
|
showDoneButton={false}
|
2022-12-18 18:32:44 +13:00
|
|
|
initialNumToRender={3}
|
2022-12-15 16:31:35 +13:00
|
|
|
/>
|
2022-12-18 18:32:44 +13:00
|
|
|
<Button title="Pick" onPress={pick} />
|
2022-12-15 16:31:35 +13:00
|
|
|
</View>
|
2022-12-18 18:32:44 +13:00
|
|
|
)
|
2022-12-15 16:31:35 +13:00
|
|
|
}
|