From d5fa6cb2ea3a7d3c843719f0530bfa9fa448d274 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 9 Aug 2017 16:02:09 -0300 Subject: [PATCH] Add cache for avatars --- android/app/build.gradle | 1 + .../java/com/rocketchatrn/MainApplication.java | 2 ++ android/settings.gradle | 2 ++ app/components/Message.js | 14 +++++++++++--- app/components/RoomItem.js | 2 -- ios/RocketChatRN.xcodeproj/project.pbxproj | 18 +++++++++++++++++- package.json | 2 ++ 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index fcb3f01a..fe2b0dab 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -133,6 +133,7 @@ android { } dependencies { + compile project(':react-native-fetch-blob') compile project(':react-native-zeroconf') compile project(':realm') compile fileTree(dir: "libs", include: ["*.jar"]) diff --git a/android/app/src/main/java/com/rocketchatrn/MainApplication.java b/android/app/src/main/java/com/rocketchatrn/MainApplication.java index 17b6b71b..7968d4e2 100644 --- a/android/app/src/main/java/com/rocketchatrn/MainApplication.java +++ b/android/app/src/main/java/com/rocketchatrn/MainApplication.java @@ -3,6 +3,7 @@ package com.rocketchatrn; import android.app.Application; import com.facebook.react.ReactApplication; +import com.RNFetchBlob.RNFetchBlobPackage; import com.balthazargronon.RCTZeroconf.ZeroconfReactPackage; import io.realm.react.RealmReactPackage; import com.facebook.react.ReactNativeHost; @@ -25,6 +26,7 @@ public class MainApplication extends Application implements ReactApplication { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNFetchBlobPackage(), new ZeroconfReactPackage(), new RealmReactPackage() ); diff --git a/android/settings.gradle b/android/settings.gradle index 9a71101a..2d578e9d 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ 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' project(':react-native-zeroconf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zeroconf/android') include ':realm' diff --git a/app/components/Message.js b/app/components/Message.js index fdf2a4c5..0ae5a4b9 100644 --- a/app/components/Message.js +++ b/app/components/Message.js @@ -1,6 +1,7 @@ import React from 'react'; 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({ message: { @@ -9,13 +10,18 @@ const styles = StyleSheet.create({ flexDirection: 'row', transform: [{ scaleY: -1 }] }, - avatar: { + avatarContainer: { backgroundColor: '#ccc', width: 40, height: 40, marginRight: 10, borderRadius: 5 }, + avatar: { + width: 40, + height: 40, + borderRadius: 5 + }, texts: { flex: 1 }, @@ -42,7 +48,9 @@ export default class Message extends React.PureComponent { return ( - + + + {this.props.item.u.username} diff --git a/app/components/RoomItem.js b/app/components/RoomItem.js index e06cae17..cd524e45 100644 --- a/app/components/RoomItem.js +++ b/app/components/RoomItem.js @@ -20,8 +20,6 @@ const styles = StyleSheet.create({ }, roomItem: { lineHeight: 18, - borderTopWidth: 2, - borderColor: '#aaa', padding: 14, flexGrow: 1 } diff --git a/ios/RocketChatRN.xcodeproj/project.pbxproj b/ios/RocketChatRN.xcodeproj/project.pbxproj index 501c6171..f00dfe70 100644 --- a/ios/RocketChatRN.xcodeproj/project.pbxproj +++ b/ios/RocketChatRN.xcodeproj/project.pbxproj @@ -5,7 +5,6 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.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 */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.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 */ /* 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; }; BAAE4B947F5D44959F0A9D5A /* libRNZeroconf.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNZeroconf.a; sourceTree = ""; }; DF26CC845883492D8AC8869B /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRealmReact.a; sourceTree = ""; }; + 4CD38E4891ED4601B7481448 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; name = "RNFetchBlob.xcodeproj"; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 6533FB90166345D29F1B91C0 /* libRNFetchBlob.a */ = {isa = PBXFileReference; name = "libRNFetchBlob.a"; path = "libRNFetchBlob.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -337,6 +339,7 @@ 0C6E2DE448364EA896869ADF /* libc++.tbd in Frameworks */, 24A2AEF2383D44B586D31C01 /* libz.tbd in Frameworks */, 33647F7997A2493E9E1343B3 /* libRNZeroconf.a in Frameworks */, + BED2B77AA660460E8BC9F8E0 /* libRNFetchBlob.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -525,6 +528,7 @@ 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 5A8684E7C27E426C9206E980 /* RealmReact.xcodeproj */, 41FE03CD3B554249859F01BA /* RNZeroconf.xcodeproj */, + 4CD38E4891ED4601B7481448 /* RNFetchBlob.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -1113,6 +1117,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = RocketChatRNTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -1121,6 +1126,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1141,6 +1147,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = RocketChatRNTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -1149,6 +1156,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1171,6 +1179,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = RocketChatRN/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1198,6 +1207,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = RocketChatRN/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1230,6 +1240,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1237,6 +1248,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1267,6 +1279,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/realm/src/**", "$(SRCROOT)/../node_modules/react-native-zeroconf/ios/RNZeroconf", + "$(SRCROOT)/../node_modules/react-native-fetch-blob/ios/**", ); INFOPLIST_FILE = "RocketChatRN-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1274,6 +1287,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1305,6 +1319,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1332,6 +1347,7 @@ "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.RocketChatRN-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/package.json b/package.json index 3807252c..ed744aa0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "prop-types": "^15.5.10", "react": "16.0.0-alpha.12", "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-zeroconf": "^0.8.1", "react-navigation": "^1.0.0-beta.11",