diff --git a/ANAChat/Classes/DBHelpers/CarouselItem+CoreDataProperties.swift b/ANAChat/Classes/DBHelpers/CarouselItem+CoreDataProperties.swift
index c633b72..6ea9da6 100644
--- a/ANAChat/Classes/DBHelpers/CarouselItem+CoreDataProperties.swift
+++ b/ANAChat/Classes/DBHelpers/CarouselItem+CoreDataProperties.swift
@@ -19,6 +19,7 @@ extension CarouselItem {
@NSManaged public var previewUrl: String?
@NSManaged public var title: String?
@NSManaged public var url: String?
+ @NSManaged public var mediaData: NSObject?
@NSManaged public var carousel: Carousel?
@NSManaged public var options: NSSet?
diff --git a/ANAChat/Classes/DBHelpers/Chat_iOSSDK.xcdatamodeld/Chat_iOSSDK.xcdatamodel/contents b/ANAChat/Classes/DBHelpers/Chat_iOSSDK.xcdatamodeld/Chat_iOSSDK.xcdatamodel/contents
index 75452e6..6984b16 100644
--- a/ANAChat/Classes/DBHelpers/Chat_iOSSDK.xcdatamodeld/Chat_iOSSDK.xcdatamodel/contents
+++ b/ANAChat/Classes/DBHelpers/Chat_iOSSDK.xcdatamodeld/Chat_iOSSDK.xcdatamodel/contents
@@ -8,6 +8,7 @@
+
@@ -91,6 +92,7 @@
+
@@ -108,7 +110,7 @@
-
+
@@ -122,7 +124,7 @@
-
+
\ No newline at end of file
diff --git a/ANAChat/Classes/DBHelpers/Simple+CoreDataProperties.swift b/ANAChat/Classes/DBHelpers/Simple+CoreDataProperties.swift
index 6cadba2..ab6b1d2 100644
--- a/ANAChat/Classes/DBHelpers/Simple+CoreDataProperties.swift
+++ b/ANAChat/Classes/DBHelpers/Simple+CoreDataProperties.swift
@@ -16,5 +16,6 @@ extension Simple {
@NSManaged public var mediaUrl: String?
@NSManaged public var previewUrl: String?
@NSManaged public var text: String?
+ @NSManaged public var mediaData: NSObject?
}
diff --git a/ANAChat/Classes/UIComponents/Cells/ChatCarouselCollectionCell.swift b/ANAChat/Classes/UIComponents/Cells/ChatCarouselCollectionCell.swift
index 9e12367..ea542bc 100644
--- a/ANAChat/Classes/UIComponents/Cells/ChatCarouselCollectionCell.swift
+++ b/ANAChat/Classes/UIComponents/Cells/ChatCarouselCollectionCell.swift
@@ -41,6 +41,11 @@ class ChatCarouselCollectionCell: UICollectionViewCell {
imageView.layer.masksToBounds = true
}
+ override func prepareForReuse() {
+ super.prepareForReuse()
+ self.imageView.image = nil
+ }
+
func configureCell(_ item:CarouselItem, showOptions : Bool){
self.playButton.isHidden = true
self.showOptions = showOptions
@@ -52,21 +57,42 @@ class ChatCarouselCollectionCell: UICollectionViewCell {
if item.mediaType == 0{
self.playButton.isHidden = true
if let url = item.mediaUrl{
- ImageCache.sharedInstance.getImageFromURL(url as String, successBlock: { (data) in
- self.imageView.image = UIImage(data: (data as NSData) as Data)
- })
- { (error) in
+ if item.mediaData is UIImage{
+ self.imageView.image = item.mediaData as? UIImage
+ }else{
+ ImageCache.sharedInstance.getImageFromURL(url as String, successBlock: { (data) in
+ if url.hasSuffix("gif"){
+ self.imageView.image = ImageCache.sharedInstance.gifImageWithData(data)
+ item.mediaData = ImageCache.sharedInstance.gifImageWithData(data)
+ }else{
+ self.imageView.image = UIImage(data: (data as NSData) as Data)
+ item.mediaData = UIImage(data: (data as NSData) as Data)
+ }
+
+ })
+ { (error) in
+ }
}
}
}else if item.mediaType == 2{
self.playButton.isHidden = false
if let previewUrl = item.previewUrl{
- ImageCache.sharedInstance.getImageFromURL(previewUrl as String, successBlock: { (data) in
- self.imageView.image = UIImage(data: (data as NSData) as Data)
- })
- { (error) in
+ if item.mediaData is UIImage{
+ self.imageView.image = item.mediaData as? UIImage
+ }else{
+ ImageCache.sharedInstance.getImageFromURL(previewUrl as String, successBlock: { (data) in
+ if previewUrl.hasSuffix("gif"){
+ self.imageView.image = ImageCache.sharedInstance.gifImageWithData(data)
+ item.mediaData = ImageCache.sharedInstance.gifImageWithData(data)
+ }else{
+ self.imageView.image = UIImage(data: (data as NSData) as Data)
+ item.mediaData = UIImage(data: (data as NSData) as Data)
+ }
+
+ })
+ { (error) in
+ }
}
-
}
}
diff --git a/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.swift b/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.swift
index 549189b..53de77b 100644
--- a/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.swift
+++ b/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.swift
@@ -34,9 +34,11 @@ class ChatReceiveCarouselCell: UITableViewCell ,ChatCarouselCollectionCellDelega
self.sortedItems = carousel.items?.sortedArray(using: [sortDescriptor])
self.collectionview.reloadData()
self.collectionview.scrollRectToVisible(CGRect.zero, animated: false)
+ /*
if (self.sortedItems?.count)! > 0{
self.collectionview.scrollToItem(at: IndexPath(item: 0, section: 0), at: .left, animated: false)
}
+ */
}
}
diff --git a/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.xib b/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.xib
index ae70bf8..fd74e0a 100644
--- a/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.xib
+++ b/ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.xib
@@ -4,14 +4,13 @@
-
-
+
diff --git a/ANAChat/Classes/UIComponents/Cells/ChatReceiverMediaCell.swift b/ANAChat/Classes/UIComponents/Cells/ChatReceiverMediaCell.swift
index e798d49..fb10465 100644
--- a/ANAChat/Classes/UIComponents/Cells/ChatReceiverMediaCell.swift
+++ b/ANAChat/Classes/UIComponents/Cells/ChatReceiverMediaCell.swift
@@ -29,6 +29,11 @@ class ChatReceiverMediaCell: UITableViewCell {
self.addTapGestureRecognizer()
}
+ override func prepareForReuse() {
+ super.prepareForReuse()
+ self.cellImage.image = nil
+ }
+
func addTapGestureRecognizer() {
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(sender:)))
tap.delegate = self
@@ -101,32 +106,41 @@ class ChatReceiverMediaCell: UITableViewCell {
self.mediaTypeImageView.backgroundColor = UIColor.clear
self.playButton.isHidden = true
if let url = simpleMessage.mediaUrl{
+ if simpleMessage.mediaData is UIImage{
+ self.cellImage.image = simpleMessage.mediaData as? UIImage
+ }else{
ImageCache.sharedInstance.getImageFromURL(url, successBlock: { (data) in
if url.hasSuffix("gif"){
self.cellImage.image = ImageCache.sharedInstance.gifImageWithData(data)
+ simpleMessage.mediaData = ImageCache.sharedInstance.gifImageWithData(data)
}else{
self.cellImage.image = UIImage(data: (data as NSData) as Data)
+ simpleMessage.mediaData = UIImage(data: (data as NSData) as Data)
}
})
{ (error) in
}
}
+ }
case Int16(MessageSimpleType.MessageSimpleTypeVideo.rawValue):
self.descriptionLabel.text = "Video"
self.mediaTypeImageView.image = CommonUtility.getImageFromBundle(name: "videoImage")
self.mediaTypeImageView.backgroundColor = UIColor.clear
self.playButton.isHidden = false
if let url = simpleMessage.previewUrl{
- DispatchQueue.global(qos: .default).async {
- do{
- let imgData : Data = try Data(contentsOf: URL(string: url)!)
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.1){
- self.cellImage.image = UIImage(data: (imgData as NSData) as Data)
- myActivityIndicator.stopAnimating()
- myActivityIndicator.removeFromSuperview()
+ if simpleMessage.mediaData is UIImage{
+ self.cellImage.image = simpleMessage.mediaData as? UIImage
+ }else{
+ ImageCache.sharedInstance.getImageFromURL(url, successBlock: { (data) in
+ if url.hasSuffix("gif"){
+ self.cellImage.image = ImageCache.sharedInstance.gifImageWithData(data)
+ simpleMessage.mediaData = ImageCache.sharedInstance.gifImageWithData(data)
+ }else{
+ self.cellImage.image = UIImage(data: (data as NSData) as Data)
+ simpleMessage.mediaData = UIImage(data: (data as NSData) as Data)
}
- }
- catch{
+ })
+ { (error) in
}
}
}
diff --git a/ANAChat/Classes/UIComponents/ViewControllers/ChatViewController.swift b/ANAChat/Classes/UIComponents/ViewControllers/ChatViewController.swift
index 70352dd..7abeb57 100644
--- a/ANAChat/Classes/UIComponents/ViewControllers/ChatViewController.swift
+++ b/ANAChat/Classes/UIComponents/ViewControllers/ChatViewController.swift
@@ -364,9 +364,9 @@ import MobileCoreServices
self.textContainerView.addSubview(self.inputTextView!)
self.inputTextView.translatesAutoresizingMaskIntoConstraints = false
- ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: 40, superView: self.textContainerView, subView: self.inputTextView)
+ ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: CGFloat(CellHeights.textInputViewHeight), superView: self.textContainerView, subView: self.inputTextView)
- self.textContainerViewHeightConstraint.constant = 40
+ self.textContainerViewHeightConstraint.constant = CGFloat(CellHeights.textInputViewHeight)
}
self.inputOptionsView = CommonUtility.getFrameworkBundle().loadNibNamed("InputOptionsView", owner: self, options: nil)?[0] as? InputOptionsView
@@ -410,9 +410,9 @@ import MobileCoreServices
self.textContainerView.addSubview(self.inputTextView!)
self.inputTextView.translatesAutoresizingMaskIntoConstraints = false
- ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: 40, superView: self.textContainerView, subView: self.inputTextView)
+ ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: CGFloat(CellHeights.textInputViewHeight), superView: self.textContainerView, subView: self.inputTextView)
- self.textContainerViewHeightConstraint.constant = 40
+ self.textContainerViewHeightConstraint.constant = CGFloat(CellHeights.textInputViewHeight)
}
self.inputTypeButton = CommonUtility.getFrameworkBundle().loadNibNamed("InputTypeButton", owner: self, options: nil)?[0] as? InputTypeButton
@@ -454,9 +454,9 @@ import MobileCoreServices
self.textContainerView.addSubview(self.inputTextView!)
self.inputTextView.translatesAutoresizingMaskIntoConstraints = false
- ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: 40, superView: self.textContainerView, subView: self.inputTextView)
+ ConstraintsHelper.addConstraints(0, trailing: 0, top: 0, height: CGFloat(CellHeights.textInputViewHeight), superView: self.textContainerView, subView: self.inputTextView)
- self.textContainerViewHeightConstraint.constant = 40
+ self.textContainerViewHeightConstraint.constant = CGFloat(CellHeights.textInputViewHeight)
}
self.inputTypeButton = CommonUtility.getFrameworkBundle().loadNibNamed("InputTypeButton", owner: self, options: nil)?[0] as? InputTypeButton
diff --git a/ANAChat/Classes/UIComponents/Views/InputTextFieldView.swift b/ANAChat/Classes/UIComponents/Views/InputTextFieldView.swift
index 27ec6d2..2c2c26f 100644
--- a/ANAChat/Classes/UIComponents/Views/InputTextFieldView.swift
+++ b/ANAChat/Classes/UIComponents/Views/InputTextFieldView.swift
@@ -24,6 +24,7 @@ public class InputTextFieldView: UIView , UITextViewDelegate{
inputBtn.setImage(tintedImage, for: .normal)
inputBtn.imageEdgeInsets = UIEdgeInsetsMake(12, 10, 12, 14)
textView.tintColor = PreferencesManager.sharedInstance.getBaseThemeColor()
+ textView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 15)
}
public func configure(messageObject :Message?){
@@ -218,11 +219,11 @@ public class InputTextFieldView: UIView , UITextViewDelegate{
#if swift(>=4.0)
let rect: CGRect = totalText.boundingRect(with: CGSize(width: UIScreen.main.bounds.size.width - 90, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: PreferencesManager.sharedInstance.getContentFont(),NSAttributedStringKey.paragraphStyle:parastyle], context: nil)
- self.delegate?.configureTextViewHeight?(max(min(rect.size.height + 23 , 113),CGFloat(CellHeights.textInputViewHeight)))
+ self.delegate?.configureTextViewHeight?(max(min(rect.size.height + 30 , 125),CGFloat(CellHeights.textInputViewHeight)))
#else
let rect: CGRect = totalText.boundingRect(with: CGSize(width: UIScreen.main.bounds.size.width - 90, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: PreferencesManager.sharedInstance.getContentFont(),NSParagraphStyleAttributeName:parastyle], context: nil)
- self.delegate?.configureTextViewHeight?(max(min(rect.size.height + 23 , 113),CGFloat(CellHeights.textInputViewHeight)))
+ self.delegate?.configureTextViewHeight?(max(min(rect.size.height + 30 , 125),CGFloat(CellHeights.textInputViewHeight)))
#endif
return true
diff --git a/ANAChat/Classes/UIComponents/Views/InputTextFieldView.xib b/ANAChat/Classes/UIComponents/Views/InputTextFieldView.xib
index 729b1d7..9a95973 100644
--- a/ANAChat/Classes/UIComponents/Views/InputTextFieldView.xib
+++ b/ANAChat/Classes/UIComponents/Views/InputTextFieldView.xib
@@ -4,23 +4,26 @@
-
-
+
+
+
+
+
-
+
+
@@ -43,25 +47,28 @@
-
+
-
+
-
+
-
+
+
+
+
+
-
-
-
-
+
+
+
diff --git a/ANAChat/Classes/Utilities/Constants.swift b/ANAChat/Classes/Utilities/Constants.swift
index a74a646..11a3055 100644
--- a/ANAChat/Classes/Utilities/Constants.swift
+++ b/ANAChat/Classes/Utilities/Constants.swift
@@ -72,7 +72,7 @@ struct AlertTexts {
struct CellHeights {
static let optionsViewCellHeight = 65
static let carouselOptionsViewHeight = 45
- static let textInputViewHeight = 45
+ static let textInputViewHeight = 50
static let typingIndicatorViewHeight = 45
}
diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj
index c86f263..39ff859 100644
--- a/Example/Pods/Pods.xcodeproj/project.pbxproj
+++ b/Example/Pods/Pods.xcodeproj/project.pbxproj
@@ -75,7 +75,6 @@
30BE4AE11FA7594500F64363 /* InputOptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputOptionsView.swift; sourceTree = ""; };
30BE4AE21FA7594500F64363 /* InputOptionsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InputOptionsView.xib; sourceTree = ""; };
30BE4AE31FA7594500F64363 /* InputTextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputTextFieldView.swift; sourceTree = ""; };
- 30BE4AE41FA7594500F64363 /* InputTextFieldView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InputTextFieldView.xib; sourceTree = ""; };
30BE4AE51FA7594500F64363 /* InputTypeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputTypeButton.swift; sourceTree = ""; };
30BE4AE61FA7594500F64363 /* InputTypeButton.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InputTypeButton.xib; sourceTree = ""; };
30BE4AE71FA7594500F64363 /* PickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerView.swift; sourceTree = ""; };
@@ -144,6 +143,7 @@
30BE4B2C1FA7594500F64363 /* Simple+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Simple+CoreDataProperties.swift"; sourceTree = ""; };
30BE4B2D1FA7594500F64363 /* TimeRange+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeRange+CoreDataClass.swift"; sourceTree = ""; };
30BE4B2E1FA7594500F64363 /* TimeRange+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeRange+CoreDataProperties.swift"; sourceTree = ""; };
+ 30F60ED81FACB0120010C26F /* InputTextFieldView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InputTextFieldView.xib; sourceTree = ""; };
3AA8E5965D48453B1D3AD48D2FC928BD /* ANAChat-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ANAChat-umbrella.h"; sourceTree = ""; };
3B0AFD2491288033548D6D938C0DCED9 /* Pods-ANAChat_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ANAChat_Tests-acknowledgements.markdown"; sourceTree = ""; };
407A1607E52CA14B02A588AC5B3844AF /* Pods-ANAChat_Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-ANAChat_Example.modulemap"; sourceTree = ""; };
@@ -327,7 +327,7 @@
30BE4AE11FA7594500F64363 /* InputOptionsView.swift */,
30BE4AE21FA7594500F64363 /* InputOptionsView.xib */,
30BE4AE31FA7594500F64363 /* InputTextFieldView.swift */,
- 30BE4AE41FA7594500F64363 /* InputTextFieldView.xib */,
+ 30F60ED81FACB0120010C26F /* InputTextFieldView.xib */,
30BE4AE51FA7594500F64363 /* InputTypeButton.swift */,
30BE4AE61FA7594500F64363 /* InputTypeButton.xib */,
30BE4AE71FA7594500F64363 /* PickerView.swift */,