feat: add perfectDraft webView

This commit is contained in:
marlon passos 2023-12-19 11:05:41 -03:00
parent 19471fdd5e
commit 2703998a65
3 changed files with 34 additions and 105 deletions

110
App.tsx
View File

@ -6,113 +6,19 @@
*/
import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
type SectionProps = PropsWithChildren<{
title: string;
}>;
function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
}
import { WebView } from 'react-native-webview';
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
<>
<WebView
source={{ uri: 'https://www.perfectdraft.com.br/' }}
style={{ marginTop: 0 }}
// clean localstorage
injectedJavaScript="(function(){window.localStorage.clear();})()"
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
}
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});
export default App;

24
package-lock.json generated
View File

@ -9,7 +9,8 @@
"version": "0.0.1",
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.1"
"react-native": "0.73.1",
"react-native-webview": "^13.6.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
@ -11770,6 +11771,27 @@
"react": "18.2.0"
}
},
"node_modules/react-native-webview": {
"version": "13.6.3",
"resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-13.6.3.tgz",
"integrity": "sha512-IApO0JSj0uAWsBGKWagyfgDYoX29piiMYLmkHtRjKeL1rIVjLoR/bMe7KJ/0X47y86b//a6u3cYQtphyay+F2A==",
"dependencies": {
"escape-string-regexp": "2.0.0",
"invariant": "2.2.4"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-webview/node_modules/escape-string-regexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
"engines": {
"node": ">=8"
}
},
"node_modules/react-native/node_modules/@jest/types": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz",

View File

@ -11,7 +11,8 @@
},
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.1"
"react-native": "0.73.1",
"react-native-webview": "^13.6.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
@ -33,4 +34,4 @@
"engines": {
"node": ">=18"
}
}
}