Add cache for avatars

This commit is contained in:
Rodrigo Nascimento 2017-08-09 16:02:09 -03:00
parent b4ffc7985b
commit d5fa6cb2ea
7 changed files with 35 additions and 6 deletions

View File

@ -133,6 +133,7 @@ android {
} }
dependencies { dependencies {
compile project(':react-native-fetch-blob')
compile project(':react-native-zeroconf') compile project(':react-native-zeroconf')
compile project(':realm') compile project(':realm')
compile fileTree(dir: "libs", include: ["*.jar"]) compile fileTree(dir: "libs", include: ["*.jar"])

View File

@ -3,6 +3,7 @@ package com.rocketchatrn;
import android.app.Application; import android.app.Application;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.balthazargronon.RCTZeroconf.ZeroconfReactPackage; import com.balthazargronon.RCTZeroconf.ZeroconfReactPackage;
import io.realm.react.RealmReactPackage; import io.realm.react.RealmReactPackage;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
@ -25,6 +26,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
new RNFetchBlobPackage(),
new ZeroconfReactPackage(), new ZeroconfReactPackage(),
new RealmReactPackage() new RealmReactPackage()
); );

View File

@ -1,4 +1,6 @@
rootProject.name = 'RocketChatRN' rootProject.name = 'RocketChatRN'
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-zeroconf' include ':react-native-zeroconf'
project(':react-native-zeroconf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zeroconf/android') project(':react-native-zeroconf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zeroconf/android')
include ':realm' include ':realm'

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { View, Text, StyleSheet, Image } from 'react-native'; import { View, Text, StyleSheet } from 'react-native';
import { CachedImage } from 'react-native-img-cache';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
message: { message: {
@ -9,13 +10,18 @@ const styles = StyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
transform: [{ scaleY: -1 }] transform: [{ scaleY: -1 }]
}, },
avatar: { avatarContainer: {
backgroundColor: '#ccc', backgroundColor: '#ccc',
width: 40, width: 40,
height: 40, height: 40,
marginRight: 10, marginRight: 10,
borderRadius: 5 borderRadius: 5
}, },
avatar: {
width: 40,
height: 40,
borderRadius: 5
},
texts: { texts: {
flex: 1 flex: 1
}, },
@ -42,7 +48,9 @@ export default class Message extends React.PureComponent {
return ( return (
<View style={[styles.message, extraStyle]}> <View style={[styles.message, extraStyle]}>
<Image style={styles.avatar} source={{ uri: `${ this.props.baseUrl }/avatar/${ this.props.item.u.username }` }} /> <View style={styles.avatarContainer}>
<CachedImage style={styles.avatar} source={{ uri: `${ this.props.baseUrl }/avatar/${ this.props.item.u.username }` }} />
</View>
<View style={styles.texts}> <View style={styles.texts}>
<Text onPress={this._onPress} style={styles.username}> <Text onPress={this._onPress} style={styles.username}>
{this.props.item.u.username} {this.props.item.u.username}

View File

@ -20,8 +20,6 @@ const styles = StyleSheet.create({
}, },
roomItem: { roomItem: {
lineHeight: 18, lineHeight: 18,
borderTopWidth: 2,
borderColor: '#aaa',
padding: 14, padding: 14,
flexGrow: 1 flexGrow: 1
} }

View File

@ -5,7 +5,6 @@
}; };
objectVersion = 46; objectVersion = 46;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -40,6 +39,7 @@
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
EF736EF520A64AE8820E684A /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF26CC845883492D8AC8869B /* libRealmReact.a */; }; EF736EF520A64AE8820E684A /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF26CC845883492D8AC8869B /* libRealmReact.a */; };
BED2B77AA660460E8BC9F8E0 /* libRNFetchBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6533FB90166345D29F1B91C0 /* libRNFetchBlob.a */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -307,6 +307,8 @@
B37C79D9BD0742CE936B6982 /* libc++.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; B37C79D9BD0742CE936B6982 /* libc++.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
BAAE4B947F5D44959F0A9D5A /* libRNZeroconf.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNZeroconf.a; sourceTree = "<group>"; }; BAAE4B947F5D44959F0A9D5A /* libRNZeroconf.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNZeroconf.a; sourceTree = "<group>"; };
DF26CC845883492D8AC8869B /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRealmReact.a; sourceTree = "<group>"; }; DF26CC845883492D8AC8869B /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRealmReact.a; sourceTree = "<group>"; };
4CD38E4891ED4601B7481448 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; name = "RNFetchBlob.xcodeproj"; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
6533FB90166345D29F1B91C0 /* libRNFetchBlob.a */ = {isa = PBXFileReference; name = "libRNFetchBlob.a"; path = "libRNFetchBlob.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -337,6 +339,7 @@
0C6E2DE448364EA896869ADF /* libc++.tbd in Frameworks */, 0C6E2DE448364EA896869ADF /* libc++.tbd in Frameworks */,
24A2AEF2383D44B586D31C01 /* libz.tbd in Frameworks */, 24A2AEF2383D44B586D31C01 /* libz.tbd in Frameworks */,
33647F7997A2493E9E1343B3 /* libRNZeroconf.a in Frameworks */, 33647F7997A2493E9E1343B3 /* libRNZeroconf.a in Frameworks */,
BED2B77AA660460E8BC9F8E0 /* libRNFetchBlob.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -525,6 +528,7 @@
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
5A8684E7C27E426C9206E980 /* RealmReact.xcodeproj */, 5A8684E7C27E426C9206E980 /* RealmReact.xcodeproj */,
41FE03CD3B554249859F01BA /* RNZeroconf.xcodeproj */, 41FE03CD3B554249859F01BA /* RNZeroconf.xcodeproj */,
4CD38E4891ED4601B7481448 /* RNFetchBlob.xcodeproj */,
); );
name = Libraries; name = Libraries;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1113,6 +1117,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = RocketChatRNTests/Info.plist; INFOPLIST_FILE = RocketChatRNTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -1121,6 +1126,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-ObjC", "-ObjC",
@ -1141,6 +1147,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = RocketChatRNTests/Info.plist; INFOPLIST_FILE = RocketChatRNTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -1149,6 +1156,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-ObjC", "-ObjC",
@ -1171,6 +1179,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = RocketChatRN/Info.plist; INFOPLIST_FILE = RocketChatRN/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1198,6 +1207,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = RocketChatRN/Info.plist; INFOPLIST_FILE = RocketChatRN/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1230,6 +1240,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist"; INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1237,6 +1248,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-ObjC", "-ObjC",
@ -1267,6 +1279,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/realm/src/**",
"$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf",
"$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**",
); );
INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist"; INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1274,6 +1287,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-ObjC", "-ObjC",
@ -1305,6 +1319,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests"; PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@ -1332,6 +1347,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
); );
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests"; PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";

View File

@ -14,6 +14,8 @@
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"react": "16.0.0-alpha.12", "react": "16.0.0-alpha.12",
"react-native": "0.46.1", "react-native": "0.46.1",
"react-native-fetch-blob": "^0.10.8",
"react-native-img-cache": "^1.4.0",
"react-native-meteor": "^1.1.0", "react-native-meteor": "^1.1.0",
"react-native-zeroconf": "^0.8.1", "react-native-zeroconf": "^0.8.1",
"react-navigation": "^1.0.0-beta.11", "react-navigation": "^1.0.0-beta.11",