Skip to content

Commit 9f0eeda

Browse files
committed
initial commit
0 parents  commit 9f0eeda

File tree

16 files changed

+707
-0
lines changed

16 files changed

+707
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
13+
# Xcode
14+
#
15+
build/
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
xcuserdata
25+
*.xccheckout
26+
*.moved-aside
27+
DerivedData
28+
*.hmap
29+
*.ipa
30+
*.xcuserstate
31+
project.xcworkspace
32+
33+
34+
# Android/IntelliJ
35+
#
36+
build/
37+
.idea
38+
.gradle
39+
local.properties
40+
*.iml
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Rumors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
# react-native-firebase-ui
3+
4+
## Getting started
5+
6+
`$ npm install react-native-firebase-ui --save`
7+
8+
### Mostly automatic installation
9+
10+
`$ react-native link react-native-firebase-ui`
11+
12+
### Manual installation
13+
14+
15+
#### iOS
16+
17+
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
18+
2. Go to `node_modules``react-native-firebase-ui` and add `RNFirebaseUi.xcodeproj`
19+
3. In XCode, in the project navigator, select your project. Add `libRNFirebaseUi.a` to your project's `Build Phases``Link Binary With Libraries`
20+
4. Run your project (`Cmd+R`)<
21+
22+
#### Android
23+
24+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25+
- Add `import io.rumors.reactnativefirebaseui.RNFirebaseUiPackage;` to the imports at the top of the file
26+
- Add `new RNFirebaseUiPackage()` to the list returned by the `getPackages()` method
27+
2. Append the following lines to `android/settings.gradle`:
28+
```
29+
include ':react-native-firebase-ui'
30+
project(':react-native-firebase-ui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase-ui/android')
31+
```
32+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
33+
```
34+
compile project(':react-native-firebase-ui')
35+
```
36+
37+
#### Windows
38+
[Read it! :D](https://github.com/ReactWindows/react-native)
39+
40+
1. In Visual Studio add the `RNFirebaseUi.sln` in `node_modules/react-native-firebase-ui/windows/RNFirebaseUi.sln` folder to their solution, reference from their app.
41+
2. Open up your `MainPage.cs` app
42+
- Add `using Com.Reactlibrary.RNFirebaseUi;` to the usings at the top of the file
43+
- Add `new RNFirebaseUiPackage()` to the `List<IReactPackage>` returned by the `Packages` method
44+
45+
46+
## Usage
47+
```javascript
48+
import RNFirebaseUi from 'react-native-firebase-ui';
49+
50+
// TODO: What to do with the module?
51+
RNFirebaseUi;
52+
```
53+

android/build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
buildscript {
3+
repositories {
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.3.1'
9+
}
10+
}
11+
12+
apply plugin: 'com.android.library'
13+
14+
android {
15+
compileSdkVersion 23
16+
buildToolsVersion "23.0.1"
17+
18+
defaultConfig {
19+
minSdkVersion 16
20+
targetSdkVersion 22
21+
versionCode 1
22+
versionName "1.0"
23+
}
24+
lintOptions {
25+
abortOnError false
26+
}
27+
}
28+
29+
repositories {
30+
mavenCentral()
31+
}
32+
33+
dependencies {
34+
compile 'com.facebook.react:react-native:+'
35+
36+
//glide dependencies
37+
compile 'com.github.bumptech.glide:glide:3.5.2'
38+
compile 'com.android.support:support-v4:22.0.0'
39+
40+
// FirebaseUI Storage only
41+
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
42+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="io.rumors.reactnativefirebaseui">
4+
5+
</manifest>
6+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
package io.rumors.reactnativefirebaseui;
3+
4+
import com.facebook.react.bridge.ReactApplicationContext;
5+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
6+
import com.facebook.react.bridge.ReactMethod;
7+
import com.facebook.react.bridge.Callback;
8+
9+
public class RNFirebaseUiModule extends ReactContextBaseJavaModule {
10+
11+
private final ReactApplicationContext reactContext;
12+
13+
public RNFirebaseUiModule(ReactApplicationContext reactContext) {
14+
super(reactContext);
15+
this.reactContext = reactContext;
16+
}
17+
18+
@Override
19+
public String getName() {
20+
return "RNFirebaseUi";
21+
}
22+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
package io.rumors.reactnativefirebaseui;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.bridge.NativeModule;
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
import com.facebook.react.uimanager.ViewManager;
12+
import com.facebook.react.bridge.JavaScriptModule;
13+
import io.rumors.reactnativefirebaseui.storage.FirebaseImageViewManager;
14+
15+
public class RNFirebaseUiPackage implements ReactPackage {
16+
@Override
17+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
18+
return Arrays.<NativeModule>asList(new RNFirebaseUiModule(reactContext));
19+
}
20+
21+
@Override
22+
public List<Class<? extends JavaScriptModule>> createJSModules() {
23+
return Collections.emptyList();
24+
}
25+
26+
@Override
27+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
28+
return Arrays.<ViewManager>asList(
29+
new FirebaseImageViewManager()
30+
);
31+
}
32+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
package io.rumors.reactnativefirebaseui.storage;
3+
4+
import javax.annotation.Nullable;
5+
6+
import android.widget.ImageView;
7+
import android.util.Log;
8+
import android.widget.ImageView.ScaleType;
9+
10+
import com.firebase.ui.storage.images.FirebaseImageLoader;
11+
import com.google.firebase.storage.StorageReference;
12+
import com.google.firebase.storage.FirebaseStorage;
13+
import com.bumptech.glide.Glide;
14+
15+
import com.facebook.react.uimanager.ViewProps;
16+
import com.facebook.react.uimanager.annotations.ReactProp;
17+
import com.facebook.react.uimanager.SimpleViewManager;
18+
import com.facebook.react.uimanager.ThemedReactContext;
19+
20+
public class FirebaseImageViewManager extends SimpleViewManager<ImageView>{
21+
public static final String REACT_CLASS = "RCTFirebaseImageView";
22+
23+
private static String TAG = "FirebaseImageViewManager";
24+
protected ThemedReactContext mContext = null;
25+
26+
@Override
27+
public String getName() {
28+
return REACT_CLASS;
29+
}
30+
31+
@Override
32+
public ImageView createViewInstance(ThemedReactContext context) {
33+
mContext = context;
34+
return new ImageView(context);
35+
}
36+
37+
@ReactProp(name = "path")
38+
public void setPath(ImageView imageView, @Nullable String path) {
39+
StorageReference storageReference = FirebaseStorage.getInstance().getReference(path);
40+
Glide.with(mContext)
41+
.using(new FirebaseImageLoader())
42+
.load(storageReference)
43+
.into(imageView);
44+
}
45+
46+
@ReactProp(name = ViewProps.RESIZE_MODE)
47+
public void setResizeMode(ImageView view, @Nullable String resizeMode) {
48+
ScaleType scaleType = ScaleType.CENTER;
49+
if ("cover".equals(resizeMode)) {
50+
scaleType = ScaleType.CENTER_CROP;
51+
} else if ("contain".equals(resizeMode)) {
52+
scaleType = ScaleType.CENTER_INSIDE;
53+
} else if ("stretch".equals(resizeMode)) {
54+
scaleType = ScaleType.FIT_XY;
55+
}
56+
view.setScaleType(scaleType);
57+
}
58+
}

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import PropTypes from 'prop-types';
2+
import { requireNativeComponent, Image } from 'react-native';
3+
4+
var iface = {
5+
name: 'FirebaseImage',
6+
propTypes: {
7+
...Image.propTypes,
8+
path: PropTypes.string,
9+
resizeMode: PropTypes.oneOf(['cover', 'contain', 'stretch']),
10+
},
11+
};
12+
13+
module.exports = requireNativeComponent('RCTFirebaseImageView', iface);

0 commit comments

Comments
 (0)