Skip to content

Commit c13d74a

Browse files
committed
WIP
1 parent 2b806e9 commit c13d74a

26 files changed

+5596
-1253
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ android {
126126
}
127127

128128
dependencies {
129+
compile project(':react-native-fs')
129130
compile project(':react-native-firestack')
130131
compile project(':react-native-vector-icons')
131132
compile fileTree(dir: "libs", include: ["*.jar"])

android/app/google-services.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
}
1515
},
1616
"oauth_client": [
17+
{
18+
"client_id": "223760557072-t6ine4mmot5ejmfg96k3huoqg9jsppnl.apps.googleusercontent.com",
19+
"client_type": 3
20+
},
1721
{
1822
"client_id": "223760557072-eif2ahnjm20m5gclajmfehc4oge3bbu9.apps.googleusercontent.com",
1923
"client_type": 3

android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
8+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
9+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10+
811

912
<uses-sdk
1013
android:minSdkVersion="16"

android/app/src/main/java/com/firestackapp/MainApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.util.Log;
55

66
import com.facebook.react.ReactApplication;
7+
import com.rnfs.RNFSPackage;
78
import io.fullstack.firestack.FirestackPackage;
89
import com.oblador.vectoricons.VectorIconsPackage;
910
import com.facebook.react.ReactInstanceManager;
@@ -26,7 +27,8 @@ protected boolean getUseDeveloperSupport() {
2627
protected List<ReactPackage> getPackages() {
2728
return Arrays.<ReactPackage>asList(
2829
new MainReactPackage(),
29-
new FirestackPackage(getApplicationContext()),
30+
new RNFSPackage(),
31+
new FirestackPackage(),
3032
new VectorIconsPackage()
3133
);
3234
}

android/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44

55

6+
67
<string name="app_name">FirestackApp</string>
78
</resources>

android/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
rootProject.name = 'FirestackApp'
22

33
include ':app'
4+
include ':react-native-fs'
5+
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
46
include ':react-native-firestack'
57
project(':react-native-firestack').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firestack/android')
68
include ':react-native-vector-icons'

app/assets/cat.jpg

17.7 KB
Loading

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "name": "app" }

app/views/Storage/Demos/Upload.js

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,29 @@ import React from 'react'
33
import {
44
View,
55
Text,
6-
Image
6+
Image,
7+
CameraRoll
78
} from 'react-native'
89

910
import {
1011
Container, Header, Title, Content, Button, Spinner
1112
} from 'native-base';
13+
import RNFS from 'react-native-fs';
14+
1215
import appStyles from '../../../styles/app';
1316
import { UploadedImage } from '../components/UploadedImage';
14-
const cat = require('image!cat');
1517

18+
let localFile;
1619
export class UploadDemo extends React.Component {
1720

1821
constructor(props) {
1922
super(props);
23+
24+
const {firestack} = this.props;
2025

26+
localDir = firestack.constants.DOCUMENT_DIRECTORY_PATH;
2127
this.state = {
28+
localFileExists: false,
2229
uploading: false,
2330
fileUploaded: null,
2431
error: null
@@ -28,6 +35,41 @@ export class UploadDemo extends React.Component {
2835
componentWillMount() {
2936
const {firestack} = this.props;
3037
firestack.storage.setStorageUrl('firestack-example.appspot.com');
38+
39+
CameraRoll.getPhotos({
40+
first: 1
41+
}).then(data => {
42+
const assets = data.edges.map(asset => asset.node.image);
43+
if (assets && assets.length > 0) {
44+
firestack.storage.getRealPathFromURI(assets[0].uri)
45+
.then(path => {
46+
localFile = path;
47+
this.setState({
48+
localFileExists: true
49+
});
50+
});
51+
} else {
52+
throw new Error('no assets yet');
53+
}
54+
}).catch(err => {
55+
this.setState({
56+
localFileExists: false,
57+
error: err
58+
});
59+
});
60+
// console.log('cat cat', cat);
61+
// RNFS.writeFile(localFile, cat, 'utf8')
62+
// .then((success) => {
63+
// this.setState({
64+
// localFileExists: true
65+
// });
66+
// })
67+
// .catch((err) => {
68+
// this.setState({
69+
// localFileExists: false,
70+
// error: err
71+
// });
72+
// });
3173
}
3274

3375
componentWillUnmount() {
@@ -37,17 +79,19 @@ export class UploadDemo extends React.Component {
3779
_uploadFile() {
3880
const {firestack} = this.props;
3981
const storage = firestack.storage;
82+
4083
this.setState({
4184
fileUploaded: null,
4285
uploading: true
4386
}, () => {
44-
storage.uploadFile(`/assets/images/cat.jpg`, cat.path, {
87+
storage.uploadFile(`/assets/images/cat.jpg`, localFile, {
4588
contentType: 'image/jpg'
4689
}).then(res => {
4790
// And store it
4891
const storageRef = firestack.storage.ref(res.fullPath);
4992
storageRef.downloadUrl()
5093
.then(filepath => {
94+
console.log('filepath ->', filepath);
5195
this.setState({
5296
fileUploaded: filepath,
5397
error: null,
@@ -66,15 +110,18 @@ export class UploadDemo extends React.Component {
66110
}
67111

68112
render() {
69-
const { uploading, fileUploaded } = this.state;
113+
const { localFileExists, uploading, fileUploaded } = this.state;
70114
return (
71115
<Container>
72116
<Content>
73-
<Button
117+
{ localFileExists ?
118+
(<Button
74119
block
75120
onPress={this._uploadFile.bind(this)}>
76121
Upload file
77-
</Button>
122+
</Button>) :
123+
( <Text>Not ready yet...</Text>)
124+
}
78125
{fileUploaded &&
79126
<UploadedImage image={fileUploaded} />}
80127
{uploading && <Spinner />}

ios/FirestackApp.xcodeproj/project.pbxproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1110
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -40,6 +39,7 @@
4039
D99D24541DA7AB91004C9CF4 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D99D24531DA7AB91004C9CF4 /* Security.framework */; };
4140
D99D24561DA7AB98004C9CF4 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D99D24551DA7AB98004C9CF4 /* libresolv.tbd */; };
4241
F4431358485C40019FF20AE7 /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 947FF5EAE6D9457D8D9A4EA2 /* Foundation.ttf */; };
42+
59577E629AC04BC782808B39 /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A6B1B7E628934FC0B6BBFE08 /* libRNFS.a */; };
4343
/* End PBXBuildFile section */
4444

4545
/* Begin PBXContainerItemProxy section */
@@ -201,6 +201,8 @@
201201
DB12A55C1C7B48E6B67B7F38 /* Firestack.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 0; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = Firestack.xcodeproj; path = "../node_modules/react-native-firestack/ios/Firestack.xcodeproj"; sourceTree = "<group>"; };
202202
F0F6BD6002274B96B0321DBF /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 0; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf"; sourceTree = "<group>"; };
203203
FD86BD6E5B684A7DB8D05C0E /* libOAuthManager.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 0; includeInIndex = 0; lastKnownFileType = archive.ar; path = libOAuthManager.a; sourceTree = "<group>"; };
204+
08A096EC48E74C2C9EA3A14D /* RNFS.xcodeproj */ = {isa = PBXFileReference; name = "RNFS.xcodeproj"; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
205+
A6B1B7E628934FC0B6BBFE08 /* libRNFS.a */ = {isa = PBXFileReference; name = "libRNFS.a"; path = "libRNFS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
204206
/* End PBXFileReference section */
205207

206208
/* Begin PBXFrameworksBuildPhase section */
@@ -234,6 +236,7 @@
234236
B914148F5A434E5A9680EC2C /* libFirestack.a in Frameworks */,
235237
AAE721A98E364AC2A301BE95 /* StoreKit.framework in Frameworks */,
236238
B3A490F679244BD2B74989C9 /* libOAuthManager.a in Frameworks */,
239+
59577E629AC04BC782808B39 /* libRNFS.a in Frameworks */,
237240
);
238241
runOnlyForDeploymentPostprocessing = 0;
239242
};
@@ -359,6 +362,7 @@
359362
5D4DBCF5A4BA4854BBD023F0 /* RNVectorIcons.xcodeproj */,
360363
DB12A55C1C7B48E6B67B7F38 /* Firestack.xcodeproj */,
361364
8108D6CBBAC940E79F7B2091 /* OAuthManager.xcodeproj */,
365+
08A096EC48E74C2C9EA3A14D /* RNFS.xcodeproj */,
362366
);
363367
name = Libraries;
364368
sourceTree = "<group>";
@@ -830,6 +834,7 @@
830834
LIBRARY_SEARCH_PATHS = (
831835
"$(inherited)",
832836
"\"$(SRCROOT)/$(TARGET_NAME)\"",
837+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
833838
);
834839
PRODUCT_NAME = "$(TARGET_NAME)";
835840
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirestackApp.app/FirestackApp";
@@ -847,6 +852,7 @@
847852
LIBRARY_SEARCH_PATHS = (
848853
"$(inherited)",
849854
"\"$(SRCROOT)/$(TARGET_NAME)\"",
855+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
850856
);
851857
PRODUCT_NAME = "$(TARGET_NAME)";
852858
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirestackApp.app/FirestackApp";
@@ -878,6 +884,7 @@
878884
"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingiOS",
879885
"$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager",
880886
"$(SRCROOT)/../node_modules/react-native-oauth/ios/**",
887+
"$(SRCROOT)/../node_modules/react-native-fs/**",
881888
);
882889
INFOPLIST_FILE = FirestackApp/Info.plist;
883890
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -922,6 +929,7 @@
922929
"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingiOS",
923930
"$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager",
924931
"$(SRCROOT)/../node_modules/react-native-oauth/ios/**",
932+
"$(SRCROOT)/../node_modules/react-native-fs/**",
925933
);
926934
INFOPLIST_FILE = FirestackApp/Info.plist;
927935
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -985,6 +993,7 @@
985993
"$(SRCROOT)/../node_modules/react-native-firestack/ios/Firestack",
986994
"$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager",
987995
"$(SRCROOT)/../node_modules/react-native-oauth/ios/**",
996+
"$(SRCROOT)/../node_modules/react-native-fs/**",
988997
);
989998
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
990999
MTL_ENABLE_DEBUG_INFO = YES;
@@ -1030,6 +1039,7 @@
10301039
"$(SRCROOT)/../node_modules/react-native-firestack/ios/Firestack",
10311040
"$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager",
10321041
"$(SRCROOT)/../node_modules/react-native-oauth/ios/**",
1042+
"$(SRCROOT)/../node_modules/react-native-fs/**",
10331043
);
10341044
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
10351045
MTL_ENABLE_DEBUG_INFO = NO;

ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ end
1717

1818
target 'FirestackApp' do
1919
firestack_pods
20+
pod 'RNFS', :path => './node_modules/react-native-fs'
2021
pod 'DCTAuth', :git => 'https://github.com/danielctull/DCTAuth.git'
2122
end

ios/Pods/Headers/Private/Firebase/Firebase.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/Pods/Headers/Private/FirebaseInstanceID/FIRInstanceID.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/Pods/Headers/Private/FirebaseMessaging/FIRMessaging.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/Pods/Headers/Public/Firebase/Firebase.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/Pods/Headers/Public/FirebaseInstanceID/FIRInstanceID.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/Pods/Headers/Public/FirebaseMessaging/FIRMessaging.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)