Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/jpush/aurora-imui into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLipan committed Aug 28, 2018
2 parents ed6d73e + 75760e8 commit 81f7049
Show file tree
Hide file tree
Showing 30 changed files with 1,540 additions and 859 deletions.
828 changes: 422 additions & 406 deletions ReactNative/ios/RCTAuroraIMUI.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions ReactNative/ios/RCTAuroraIMUI/MyMessageModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ open class RCTMessageModel: IMUIMessageModel {
static let kMsgKeyText = "text"
static let kMsgKeyisOutgoing = "isOutgoing"
static let kMsgKeyMediaFilePath = "mediaPath"
static let kMsgKeyImageUrl = "imageUrl"
static let kMsgKeyDuration = "duration"
static let kMsgKeyContentSize = "contentSize"
static let kMsgKeyContent = "content"
Expand All @@ -47,12 +48,17 @@ open class RCTMessageModel: IMUIMessageModel {
open var myTextMessage: String = ""

var mediaPath: String = ""
var imageUrl: String = ""
var extras: NSDictionary?

override open func mediaFilePath() -> String {
return mediaPath
}

override open func webImageUrl() -> String {
return imageUrl
}

@objc static open var outgoingBubbleImage: UIImage = {
var bubbleImg = UIImage.imuiImage(with: "outGoing_bubble")
bubbleImg = bubbleImg?.resizableImage(withCapInsets: UIEdgeInsetsMake(24, 10, 9, 15), resizingMode: .tile)
Expand All @@ -73,11 +79,12 @@ open class RCTMessageModel: IMUIMessageModel {
}
}

@objc public init(msgId: String, messageStatus: IMUIMessageStatus, fromUser: RCTUser, isOutGoing: Bool, time: String, type: String, text: String, mediaPath: String, layout: IMUIMessageCellLayoutProtocol, duration: CGFloat, extras: NSDictionary?) {
@objc public init(msgId: String, messageStatus: IMUIMessageStatus, fromUser: RCTUser, isOutGoing: Bool, time: String, type: String, text: String, mediaPath: String, imageUrl: String, layout: IMUIMessageCellLayoutProtocol, duration: CGFloat, extras: NSDictionary?) {

self.myTextMessage = text
self.mediaPath = mediaPath
self.extras = extras
self.imageUrl = imageUrl
super.init(msgId: msgId, messageStatus: messageStatus, fromUser: fromUser, isOutGoing: isOutGoing, time: time, type: type, cellLayout: layout, duration: duration)
}

Expand Down Expand Up @@ -109,8 +116,13 @@ open class RCTMessageModel: IMUIMessageModel {
}

var mediaPath = messageDic.object(forKey: RCTMessageModel.kMsgKeyMediaFilePath) as? String
var imgUrl = ""
if let _ = mediaPath {

if FileManager.default.fileExists(atPath: mediaPath!) {
} else {
imgUrl = mediaPath!
mediaPath = ""
}
} else {
mediaPath = ""
}
Expand Down Expand Up @@ -145,6 +157,8 @@ open class RCTMessageModel: IMUIMessageModel {
var imgSize = CGSize(width: 120, height: 160)
if let img = UIImage(contentsOfFile: mediaPath!) {
imgSize = RCTMessageModel.converImageSize(with: CGSize(width: img.size.width, height: img.size.height))
} else {
imgSize = CGSize(width: 120, height: 160)
}

messageLayout = MyMessageCellLayout(isOutGoingMessage: isOutgoing ?? true,
Expand Down Expand Up @@ -220,7 +234,7 @@ open class RCTMessageModel: IMUIMessageModel {

}

self.init(msgId: msgId, messageStatus: msgStatus, fromUser: user, isOutGoing: isOutgoing ?? true, time: timeString!, type: msgType!, text: text!, mediaPath: mediaPath!, layout: messageLayout!,duration: durationTime, extras: extras)
self.init(msgId: msgId, messageStatus: msgStatus, fromUser: user, isOutGoing: isOutgoing ?? true, time: timeString!, type: msgType!, text: text!, mediaPath: mediaPath!,imageUrl: imgUrl, layout: messageLayout!,duration: durationTime, extras: extras)

}

Expand Down
13 changes: 12 additions & 1 deletion ReactNative/ios/RCTAuroraIMUI/MyUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open class RCTUser: NSObject, IMUIUserProtocol {
open var rUserId: String?
open var rDisplayName: String?
open var rAvatarFilePath: String?

open var rAvatarUrl: String?
public override init() {
super.init()
}
Expand All @@ -23,6 +23,13 @@ open class RCTUser: NSObject, IMUIUserProtocol {
self.rUserId = userDic.object(forKey: "userId") as? String
self.rDisplayName = userDic.object(forKey: "displayName") as? String
self.rAvatarFilePath = userDic.object(forKey: "avatarPath") as? String
if FileManager.default.fileExists(atPath: self.rAvatarFilePath ?? "") {

} else {
self.rAvatarUrl = self.rAvatarFilePath
self.rAvatarFilePath = ""
}

}

public func userId() -> String {
Expand Down Expand Up @@ -50,4 +57,8 @@ open class RCTUser: NSObject, IMUIUserProtocol {
}
return UIImage()
}

public func avatarUrlString() -> String? {
return self.rAvatarUrl
}
}
3 changes: 3 additions & 0 deletions ReactNative/ios/RCTAuroraIMUI/RCTMessageListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
@property (nonatomic, copy) RCTBubblingEventBlock onPullToRefresh;

// custom layout
//maxBubbleWidth
@property(assign, nonatomic) CGFloat maxBubbleWidth;

@property(copy, nonatomic) NSString *messageListBackgroundColor;

@property(strong, nonatomic) NSDictionary *sendBubble;
Expand Down
6 changes: 6 additions & 0 deletions ReactNative/ios/RCTAuroraIMUI/RCTMessageListViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ - (UIView *)view

}

RCT_CUSTOM_VIEW_PROPERTY(maxBubbleWidth, NSNumber, RCTMessageListView) {
NSNumber *widthPercent = [RCTConvert NSNumber: json];

IMUIMessageCellLayout.bubbleMaxWidth = UIScreen.mainScreen.bounds.size.width * widthPercent.floatValue;
}

RCT_CUSTOM_VIEW_PROPERTY(sendBubbleTextColor, NSString, RCTMessageListView) {
NSString *colorString = [RCTConvert NSString: json];
UIColor *color = [UIColor hexStringToUIColorWithHex:colorString];
Expand Down
2 changes: 1 addition & 1 deletion ReactNative/messagelist.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ MessageList.propTypes = {
displayNameTextSize: PropTypes.number,
displayNameTextColor: PropTypes.string,
displayNamePadding: PropTypes.object,

maxBubbleWidth: PropTypes.number,
eventTextLineHeight: PropTypes.number, //TODO:
messageTextLineHeight: PropTypes.number, //TODO:
...ViewPropTypes
Expand Down
Loading

0 comments on commit 81f7049

Please sign in to comment.