Skip to content

Commit 267e58e

Browse files
committed
Update example app to react-native 0.70
1 parent 859ddb5 commit 267e58e

File tree

64 files changed

+27440
-9824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+27440
-9824
lines changed

example/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

example/.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
overrides: [
7+
{
8+
files: ['*.ts', '*.tsx'],
9+
rules: {
10+
'@typescript-eslint/no-shadow': ['error'],
11+
'no-shadow': 'off',
12+
'no-undef': 'off',
13+
},
14+
},
15+
],
16+
};

example/.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
ios/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
35+
# node.js
36+
#
37+
node_modules/
38+
npm-debug.log
39+
yarn-error.log
40+
41+
# BUCK
42+
buck-out/
43+
\.buckd/
44+
*.keystore
45+
!debug.keystore
46+
47+
# fastlane
48+
#
49+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
50+
# screenshots whenever they are needed.
51+
# For more information about the recommended setup visit:
52+
# https://docs.fastlane.tools/best-practices/source-control/
53+
54+
**/fastlane/report.xml
55+
**/fastlane/Preview.html
56+
**/fastlane/screenshots
57+
**/fastlane/test_output
58+
59+
# Bundle artifact
60+
*.jsbundle
61+
62+
# Ruby / CocoaPods
63+
/ios/Pods/
64+
/vendor/bundle/

example/.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

example/.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

example/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

example/.watchmanconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

example/App.js

Lines changed: 0 additions & 110 deletions
This file was deleted.

example/App.tsx

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import React, {useEffect, useState} from 'react';
2+
import {Alert, Button, StyleSheet, Switch, Text, View} from 'react-native';
3+
import {FileLogger, LogLevel} from 'react-native-file-logger';
4+
5+
export const App = () => {
6+
const [logLevel, setLogLevel] = useState(LogLevel.Debug);
7+
const [enabled, setEnabled] = useState(true);
8+
9+
useEffect(() => {
10+
FileLogger.configure({logLevel: LogLevel.Debug}).then(() =>
11+
console.log('File-logger configured'),
12+
);
13+
}, []);
14+
15+
const showLogFilePaths = async () => {
16+
Alert.alert('File paths', (await FileLogger.getLogFilePaths()).join('\n'));
17+
};
18+
19+
const changeEnabled = (value: boolean) => {
20+
if (value) {
21+
FileLogger.enableConsoleCapture();
22+
} else {
23+
FileLogger.disableConsoleCapture();
24+
}
25+
setEnabled(value);
26+
};
27+
28+
const changeLogLevel = () => {
29+
const nextLogLevel = (logLevel + 1) % 4;
30+
FileLogger.setLogLevel(nextLogLevel);
31+
setLogLevel(nextLogLevel);
32+
};
33+
34+
const sendLogFilesByEmail = () => {
35+
FileLogger.sendLogFilesByEmail({
36+
37+
subject: 'Log files',
38+
body: 'Please find attached the log files from your app',
39+
});
40+
};
41+
42+
const deleteLogFiles = async () => {
43+
FileLogger.deleteLogFiles();
44+
Alert.alert('Log files deleted');
45+
};
46+
47+
return (
48+
<View style={styles.container}>
49+
<View style={styles.buttonContainer}>
50+
<View style={styles.button}>
51+
<Button
52+
title="Log info"
53+
onPress={() => console.log('Log info', {nested: {data: 123}})}
54+
/>
55+
</View>
56+
<View style={styles.button}>
57+
<Button
58+
title="Log warning"
59+
onPress={() => console.warn('Log warning', {nested: {data: 456}})}
60+
/>
61+
</View>
62+
<View style={styles.button}>
63+
<Button title="Change log level" onPress={changeLogLevel} />
64+
</View>
65+
<View style={styles.button}>
66+
<Button title="Show file paths" onPress={showLogFilePaths} />
67+
</View>
68+
<View style={styles.button}>
69+
<Button title="Send files by email" onPress={sendLogFilesByEmail} />
70+
</View>
71+
<View style={styles.button}>
72+
<Button title="Delete files" onPress={deleteLogFiles} />
73+
</View>
74+
</View>
75+
<View style={styles.settingsRow}>
76+
<Text style={styles.settingsLabel}>Enabled</Text>
77+
<Switch value={enabled} onValueChange={changeEnabled} />
78+
</View>
79+
<View style={styles.settingsRow}>
80+
<Text style={styles.settingsLabel}>Log Level</Text>
81+
<Text style={styles.settingsValue}>{LogLevel[logLevel]}</Text>
82+
</View>
83+
</View>
84+
);
85+
};
86+
87+
const styles = StyleSheet.create({
88+
container: {
89+
flex: 1,
90+
padding: 25,
91+
backgroundColor: '#f5fcff',
92+
},
93+
buttonContainer: {
94+
flex: 1,
95+
justifyContent: 'center',
96+
},
97+
button: {
98+
marginVertical: 6,
99+
},
100+
settingsRow: {
101+
paddingHorizontal: 16,
102+
paddingVertical: 10,
103+
marginBottom: 20,
104+
minHeight: 50,
105+
flexDirection: 'row',
106+
alignItems: 'center',
107+
backgroundColor: '#dff4ff',
108+
borderRadius: 6,
109+
},
110+
settingsLabel: {
111+
flex: 1,
112+
fontWeight: '500',
113+
color: 'black',
114+
},
115+
settingsValue: {
116+
color: 'black',
117+
},
118+
});

0 commit comments

Comments
 (0)