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,
singleQuote: true,
trailingComma: 'all',
};
semi: false,
}

56
App.tsx
View File

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

View File

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

View File

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

View File

@ -1,3 +1,3 @@
module.exports = {
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
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import {AppRegistry} from 'react-native'
import App from './App'
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",
"scale" : "2x",
"size" : "20x20"
"idiom": "iphone",
"scale": "2x",
"size": "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
"idiom": "iphone",
"scale": "3x",
"size": "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
"idiom": "iphone",
"scale": "2x",
"size": "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
"idiom": "iphone",
"scale": "3x",
"size": "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
"idiom": "iphone",
"scale": "2x",
"size": "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
"idiom": "iphone",
"scale": "3x",
"size": "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
"idiom": "iphone",
"scale": "2x",
"size": "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
"idiom": "iphone",
"scale": "3x",
"size": "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
"idiom": "ios-marketing",
"scale": "1x",
"size": "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"author": "xcode",
"version": 1
}
}

View File

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

View File

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

View File

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