Skip to content

Commit 070c1a7

Browse files
committed
update example app to use [email protected]
1 parent e481582 commit 070c1a7

Some content is hidden

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

59 files changed

+4626
-3516
lines changed

android/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

android/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>android</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=
2+
eclipse.preferences.version=1

android/src/main/java/com/rnziparchive/ZipTask.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import java.io.BufferedInputStream;
66
import java.io.BufferedOutputStream;
77
import java.io.File;
8-
import java.nio.file.Path;
9-
import java.nio.file.Paths;
108
import java.io.FileInputStream;
119
import java.io.FileOutputStream;
1210
import java.util.Timer;
@@ -29,7 +27,7 @@ public class ZipTask {
2927
public ZipTask(String[] files, String destFile, String fromDirectory, Promise promise, RNZipArchiveModule cb) {
3028
this.destFile = destFile;
3129
this.files = files;
32-
this.fromDirectory = fromDirectory;
30+
this.fromDirectory = fromDirectory.endsWith("/") ? fromDirectory : fromDirectory + "/";
3331
this.promise = promise;
3432
this.cb = cb;
3533
}
@@ -72,7 +70,7 @@ public void run() {
7270

7371
if (!new File(absoluteFilepath).isDirectory()) {
7472
FileInputStream fi = new FileInputStream(absoluteFilepath);
75-
String filename = Paths.get(fromDirectory).relativize(Paths.get(absoluteFilepath)).toString();
73+
String filename = absoluteFilepath.replace(fromDirectory, "");
7674
ZipEntry entry = new ZipEntry(filename);
7775
out.putNextEntry(entry);
7876
origin = new BufferedInputStream(fi, BUFFER_SIZE);

example/.babelrc

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

example/.flowconfig

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,59 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2328

2429
[options]
2530
emoji=true
2631

32+
esproposal.optional_chaining=enable
33+
esproposal.nullish_coalescing=enable
34+
2735
module.system=haste
36+
module.system.haste.use_name_reducers=true
37+
# get basename
38+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
39+
# strip .js or .js.flow suffix
40+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
41+
# strip .ios suffix
42+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
43+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
44+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
45+
module.system.haste.paths.blacklist=.*/__tests__/.*
46+
module.system.haste.paths.blacklist=.*/__mocks__/.*
47+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
48+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
2849

2950
munge_underscores=true
3051

3152
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3253

54+
module.file_ext=.js
55+
module.file_ext=.jsx
56+
module.file_ext=.json
57+
module.file_ext=.native.js
58+
3359
suppress_type=$FlowIssue
3460
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
61+
suppress_type=$FlowFixMeProps
62+
suppress_type=$FlowFixMeState
3663

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
64+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3966
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4067
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4168

42-
unsafe.enable_getters_and_setters=true
43-
4469
[version]
45-
^0.49.1
70+
^0.86.0

example/.gitignore

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,23 @@ local.properties
3434
#
3535
node_modules/
3636
npm-debug.log
37+
yarn-error.log
3738

3839
# BUCK
3940
buck-out/
4041
\.buckd/
41-
android/app/libs
4242
*.keystore
4343

4444
# fastlane
4545
#
4646
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4747
# screenshots whenever they are needed.
4848
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5050

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

example/App.js

Lines changed: 19 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,40 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
* @flow
5+
*/
6+
17
import React, { Component } from 'react'
28
import {
9+
AppRegistry,
310
StyleSheet,
4-
WebView,
5-
Platform
11+
View
612
} from 'react-native'
13+
import App from './App'
14+
import UnzipApp from './UnzipApp'
715

8-
import { readdir, copyFileAssets, MainBundlePath, DocumentDirectoryPath } from 'react-native-fs'
9-
import { unzip, subscribe } from 'react-native-zip-archive'
10-
11-
export default class App extends Component {
16+
export default class example extends Component {
1217
constructor () {
1318
super()
1419
this.state = {
15-
uri: 'https://github.com/plrthink/react-native-zip-archive'
20+
unzipWithPassword: true
1621
}
1722
}
1823

19-
componentWillMount () {
20-
this.zipProgress = subscribe((progress, filePath) => {
21-
console.log(progress, filePath)
22-
})
23-
}
24-
25-
componentDidMount () {
26-
let sourcePath
27-
const targetPath = DocumentDirectoryPath
28-
29-
if (Platform.OS === 'android') {
30-
// since I can't simply get absolute path of files in assets folder,
31-
// I am copying the file from assets folder to document folder as a workaround.
32-
sourcePath = `${DocumentDirectoryPath}/static.zip`
33-
34-
copyFileAssets('static.zip', sourcePath)
35-
.then(() => {
36-
return readdir(DocumentDirectoryPath)
37-
})
38-
.then((result) => {
39-
return unzip(sourcePath, DocumentDirectoryPath)
40-
})
41-
.then((path) => {
42-
console.log(`unzip file to ${path}`)
43-
this.setState({
44-
uri: `file://${path}/static/index.html`
45-
})
46-
})
47-
.catch((error) => {
48-
console.log(error)
49-
})
50-
} else {
51-
sourcePath = `${MainBundlePath}/static.zip`
52-
53-
unzip(sourcePath, targetPath)
54-
.then((path) => {
55-
console.log(`unzip file to ${path}`)
56-
this.setState({
57-
uri: `${path}/static/index.html`
58-
})
59-
})
60-
.catch((error) => {
61-
console.log(error)
62-
})
63-
}
64-
}
65-
66-
componentWillUnmount () {
67-
this.zipProgress.remove()
68-
}
69-
7024
render () {
71-
const { uri } = this.state
72-
73-
console.log(uri)
74-
7525
return (
76-
<WebView
77-
source={{uri: uri}}
78-
style={styles.webView}
79-
startInLoadingState={true}
80-
scalesPageToFit={true}
81-
/>
26+
<View style={styles.container}>
27+
{this.state.unzipWithPassword ? (<UnzipApp />) : (<App />)}
28+
</View>
8229
)
8330
}
8431
}
8532

8633
const styles = StyleSheet.create({
87-
webView: {
34+
container: {
8835
flex: 1,
89-
marginTop: 20
36+
alignItems: 'stretch'
9037
}
9138
})
39+
40+
AppRegistry.registerComponent('example', () => example)

0 commit comments

Comments
 (0)