Ran prettier

This commit is contained in:
Brandon Presley 2022-12-18 18:32:44 +13:00
parent fff0bc97f5
commit ed1cb0d064
14 changed files with 102 additions and 97 deletions

View File

@ -13,4 +13,4 @@ module.exports = {
}, },
}, },
], ],
}; }

View File

@ -4,4 +4,5 @@ module.exports = {
bracketSpacing: false, bracketSpacing: false,
singleQuote: true, singleQuote: true,
trailingComma: 'all', trailingComma: 'all',
}; semi: false,
}

56
App.tsx
View File

@ -1,49 +1,51 @@
import {useState} from 'react'; import {useState} from 'react'
import {Button, View} from 'react-native'; import {Button, View} from 'react-native'
import AppIntroSlider from 'react-native-app-intro-slider'; import AppIntroSlider from 'react-native-app-intro-slider'
import DocumentPicker, { import DocumentPicker, {
DocumentPickerResponse, DocumentPickerResponse,
} from 'react-native-document-picker'; } from 'react-native-document-picker'
import {backgroundColor} from './constants'; import {backgroundColor} from './constants'
import Item from './Item'; import Item from './Item'
export default function App() { export default function App() {
const [files, setFiles] = useState<DocumentPickerResponse[]>([]); const [files, setFiles] = useState<DocumentPickerResponse[]>([])
const [slide, setSlide] = useState(0); const [slide, setSlide] = useState(0)
const pick = async () => { const pick = async () => {
const picked = await DocumentPicker.pickMultiple(); const picked = await DocumentPicker.pickMultiple()
console.log(`Picked ${picked.length} files.`); console.log(`Picked ${picked.length} files.`)
setFiles(picked); setFiles(picked)
}; }
const renderItem = ({ const renderItem = ({
item, item,
index, index,
}: { }: {
item: DocumentPickerResponse; item: DocumentPickerResponse
index: number; index: number
}) => { }) => {
return <Item index={index} slide={slide} value={item} />; return <Item index={index} slide={slide} value={item} />
}; }
const slideChange = (index: number) => {
setSlide(index);
};
return ( return (
<View style={{height: '100%'}}> <View
style={{
backgroundColor,
justifyContent: 'space-between',
flex: 1,
flexGrow: 1,
padding: 10,
}}>
<Item />
<AppIntroSlider <AppIntroSlider
style={{backgroundColor}} style={{backgroundColor}}
data={files} data={files}
renderItem={renderItem} renderItem={renderItem}
onSlideChange={setSlide}
showDoneButton={false} showDoneButton={false}
showNextButton={false} initialNumToRender={3}
onSlideChange={slideChange}
/> />
<View style={{padding: 20, backgroundColor}}> <Button title="Pick" onPress={pick} />
<Button title="Pick" onPress={pick} />
</View>
</View> </View>
); )
} }

View File

@ -1,34 +1,35 @@
import {Dimensions, View} from 'react-native'; import {useState} from 'react'
import {DocumentPickerResponse} from 'react-native-document-picker'; import {Dimensions, View} from 'react-native'
import Video from 'react-native-video'; import {DocumentPickerResponse} from 'react-native-document-picker'
import {backgroundColor} from './constants'; import Video from 'react-native-video'
export default function Item({ export default function Item({
slide, slide,
value, value,
index, index,
}: { }: {
slide: number; slide: number
value: DocumentPickerResponse; value: DocumentPickerResponse
index: number; index: number
}) { }) {
const height = Dimensions.get('screen').height; const [paused, setPaused] = useState(false)
const [width, setWidth] = useState(0)
return ( return (
<View <View style={{alignItems: 'center'}}>
style={{
height: '100%',
width: '100%',
justifyContent: 'center',
alignItems: 'center',
backgroundColor,
}}>
<Video <Video
key={value.name}
paused={slide !== index} paused={slide !== index}
style={{width: 200, height: height / 2}} style={{
height: Dimensions.get('screen').height - 125,
width,
alignItems: 'center',
}}
source={{uri: value.uri}} source={{uri: value.uri}}
resizeMode="contain"
onLoad={response => {
setWidth(response.naturalSize.width)
}}
/> />
</View> </View>
); )
} }

View File

@ -2,13 +2,13 @@
* @format * @format
*/ */
import 'react-native'; import 'react-native'
import React from 'react'; import React from 'react'
import App from '../App'; import App from '../App'
// Note: test renderer must be required after react-native. // Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer'
it('renders correctly', () => { it('renders correctly', () => {
renderer.create(<App />); renderer.create(<App />)
}); })

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
presets: ['module:metro-react-native-babel-preset'], presets: ['module:metro-react-native-babel-preset'],
}; }

View File

@ -1 +1 @@
export const backgroundColor = '#121212'; export const backgroundColor = '#121212'

View File

@ -2,8 +2,8 @@
* @format * @format
*/ */
import {AppRegistry} from 'react-native'; import {AppRegistry} from 'react-native'
import App from './App'; import App from './App'
import {name as appName} from './app.json'; import {name as appName} from './app.json'
AppRegistry.registerComponent(appName, () => App); AppRegistry.registerComponent(appName, () => App)

View File

@ -1,53 +1,53 @@
{ {
"images" : [ "images": [
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "2x", "scale": "2x",
"size" : "20x20" "size": "20x20"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "3x", "scale": "3x",
"size" : "20x20" "size": "20x20"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "2x", "scale": "2x",
"size" : "29x29" "size": "29x29"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "3x", "scale": "3x",
"size" : "29x29" "size": "29x29"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "2x", "scale": "2x",
"size" : "40x40" "size": "40x40"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "3x", "scale": "3x",
"size" : "40x40" "size": "40x40"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "2x", "scale": "2x",
"size" : "60x60" "size": "60x60"
}, },
{ {
"idiom" : "iphone", "idiom": "iphone",
"scale" : "3x", "scale": "3x",
"size" : "60x60" "size": "60x60"
}, },
{ {
"idiom" : "ios-marketing", "idiom": "ios-marketing",
"scale" : "1x", "scale": "1x",
"size" : "1024x1024" "size": "1024x1024"
} }
], ],
"info" : { "info": {
"author" : "xcode", "author": "xcode",
"version" : 1 "version": 1
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"info" : { "info": {
"version" : 1, "version": 1,
"author" : "xcode" "author": "xcode"
} }
} }

View File

@ -14,4 +14,4 @@ module.exports = {
}, },
}), }),
}, },
}; }

View File

@ -4,6 +4,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",
"release": "react-native run-android --variant=release",
"ios": "react-native run-ios", "ios": "react-native run-ios",
"start": "react-native start", "start": "react-native start",
"test": "jest", "test": "jest",