Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved scroll performance #9

Merged
merged 10 commits into from
Jun 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*.xcuserstate

*.xcsettings

*.xcuserdatad
24 changes: 18 additions & 6 deletions DemoProject/SOSimpleChatDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
277BCE8F1950D7FE00413CF5 /* SOPhotoMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 277BCE8A1950D7FE00413CF5 /* SOPhotoMessageCell.m */; };
277BCE901950D7FE00413CF5 /* SOTextMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 277BCE8C1950D7FE00413CF5 /* SOTextMessageCell.m */; };
277BCE911950D7FE00413CF5 /* SOVideoMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 277BCE8E1950D7FE00413CF5 /* SOVideoMessageCell.m */; };
3E207894193DFC6300EC9FA4 /* Message.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E207893193DFC6300EC9FA4 /* Message.m */; };
3E3FB9A81920C3DC00986D8E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E3FB9A71920C3DC00986D8E /* AppDelegate.m */; };
3E70D69A1918D10D00D77D8B /* arturdev.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3E70D6991918D10D00D77D8B /* arturdev.jpg */; };
Expand Down Expand Up @@ -37,7 +40,6 @@
75493C3D19070071006C6BCD /* SOSimpleChatDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 75493C3C19070071006C6BCD /* SOSimpleChatDemoTests.m */; };
75493C52190703C7006C6BCD /* Type1VC.m in Sources */ = {isa = PBXBuildFile; fileRef = 75493C51190703C7006C6BCD /* Type1VC.m */; };
75586C551908FFA1003BDEB1 /* doggy.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 75586C541908FFA1003BDEB1 /* doggy.jpg */; };
75B35A2D1922B80800513423 /* NSString+Calculation.m in Sources */ = {isa = PBXBuildFile; fileRef = 75B35A101922B80800513423 /* NSString+Calculation.m */; };
75B35A2E1922B80800513423 /* attachment.png in Resources */ = {isa = PBXBuildFile; fileRef = 75B35A121922B80800513423 /* attachment.png */; };
75B35A2F1922B80800513423 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 75B35A131922B80800513423 /* [email protected] */; };
75B35A301922B80800513423 /* bubble.png in Resources */ = {isa = PBXBuildFile; fileRef = 75B35A141922B80800513423 /* bubble.png */; };
Expand Down Expand Up @@ -67,6 +69,12 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
277BCE891950D7FE00413CF5 /* SOPhotoMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SOPhotoMessageCell.h; sourceTree = "<group>"; };
277BCE8A1950D7FE00413CF5 /* SOPhotoMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SOPhotoMessageCell.m; sourceTree = "<group>"; };
277BCE8B1950D7FE00413CF5 /* SOTextMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SOTextMessageCell.h; sourceTree = "<group>"; };
277BCE8C1950D7FE00413CF5 /* SOTextMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SOTextMessageCell.m; sourceTree = "<group>"; };
277BCE8D1950D7FE00413CF5 /* SOVideoMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SOVideoMessageCell.h; sourceTree = "<group>"; };
277BCE8E1950D7FE00413CF5 /* SOVideoMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SOVideoMessageCell.m; sourceTree = "<group>"; };
3E207892193DFC6300EC9FA4 /* Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.h; sourceTree = "<group>"; };
3E207893193DFC6300EC9FA4 /* Message.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Message.m; sourceTree = "<group>"; };
3E3FB9A61920C3DC00986D8E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -106,8 +114,6 @@
75493C50190703C7006C6BCD /* Type1VC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Type1VC.h; sourceTree = "<group>"; };
75493C51190703C7006C6BCD /* Type1VC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Type1VC.m; sourceTree = "<group>"; };
75586C541908FFA1003BDEB1 /* doggy.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = doggy.jpg; sourceTree = "<group>"; };
75B35A0F1922B80800513423 /* NSString+Calculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Calculation.h"; sourceTree = "<group>"; };
75B35A101922B80800513423 /* NSString+Calculation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Calculation.m"; sourceTree = "<group>"; };
75B35A121922B80800513423 /* attachment.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = attachment.png; sourceTree = "<group>"; };
75B35A131922B80800513423 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
75B35A141922B80800513423 /* bubble.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bubble.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -339,14 +345,18 @@
75B35A0E1922B80800513423 /* SOMessaging */ = {
isa = PBXGroup;
children = (
75B35A0F1922B80800513423 /* NSString+Calculation.h */,
75B35A101922B80800513423 /* NSString+Calculation.m */,
75B35A111922B80800513423 /* Resources */,
75B35A1C1922B80800513423 /* SOImageBrowserView.h */,
75B35A1D1922B80800513423 /* SOImageBrowserView.m */,
75B35A1E1922B80800513423 /* SOMessage.h */,
75B35A201922B80800513423 /* SOMessageCell.h */,
75B35A211922B80800513423 /* SOMessageCell.m */,
277BCE891950D7FE00413CF5 /* SOPhotoMessageCell.h */,
277BCE8A1950D7FE00413CF5 /* SOPhotoMessageCell.m */,
277BCE8B1950D7FE00413CF5 /* SOTextMessageCell.h */,
277BCE8C1950D7FE00413CF5 /* SOTextMessageCell.m */,
277BCE8D1950D7FE00413CF5 /* SOVideoMessageCell.h */,
277BCE8E1950D7FE00413CF5 /* SOVideoMessageCell.m */,
75B35A221922B80800513423 /* SOMessageInputView.h */,
75B35A231922B80800513423 /* SOMessageInputView.m */,
75B35A241922B80800513423 /* SOMessageType.h */,
Expand Down Expand Up @@ -497,15 +507,17 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
277BCE8F1950D7FE00413CF5 /* SOPhotoMessageCell.m in Sources */,
3EBD810C191A4D2B0007B68A /* Type3VC.m in Sources */,
75B35A3C1922B80800513423 /* SOMessagingViewController.m in Sources */,
75B35A3A1922B80800513423 /* SOMessageCell.m in Sources */,
3E207894193DFC6300EC9FA4 /* Message.m in Sources */,
3EBD8109191A4D0A0007B68A /* Type2VC.m in Sources */,
75493C1E19070071006C6BCD /* main.m in Sources */,
277BCE911950D7FE00413CF5 /* SOVideoMessageCell.m in Sources */,
75B35A381922B80800513423 /* SOImageBrowserView.m in Sources */,
75B35A2D1922B80800513423 /* NSString+Calculation.m in Sources */,
3EBD8113191A566B0007B68A /* ContentManager.m in Sources */,
277BCE901950D7FE00413CF5 /* SOTextMessageCell.m in Sources */,
75B35A3E1922B80800513423 /* UINavigationController+Rotation.m in Sources */,
75B35A3B1922B80800513423 /* SOMessageInputView.m in Sources */,
75B35A3D1922B80800513423 /* SOPlaceholderedTextView.m in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions DemoProject/SOSimpleChatDemo/Sources/Controllers/Type1VC.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ - (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)
// Adjusting content for 3pt. (In this demo the width of bubble's tail is 6pt)
if (!message.fromMe) {
cell.contentInsets = UIEdgeInsetsMake(0, 3.0f, 0, 0); //Move content for 3 pt. to right
cell.textView.textColor = [UIColor blackColor];
} else {
cell.contentInsets = UIEdgeInsetsMake(0, 0, 0, 3.0f); //Move content for 3 pt. to left
cell.textView.textColor = [UIColor whiteColor];
}
}

Expand Down
2 changes: 0 additions & 2 deletions DemoProject/SOSimpleChatDemo/Sources/Controllers/Type2VC.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ - (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)
// Adjusting content for 3pt. (In this demo the width of bubble's tail is 3pt)
if (!message.fromMe) {
cell.contentInsets = UIEdgeInsetsMake(0, 3.0f, 0, 0); //Move content for 3 pt. to right
cell.textView.textColor = [UIColor blackColor];
} else {
cell.contentInsets = UIEdgeInsetsMake(0, 0, 0, 3.0f); //Move content for 3 pt. to left
cell.textView.textColor = [UIColor whiteColor];
}

cell.userImageView.layer.cornerRadius = self.userImageSize.width/2;
Expand Down
7 changes: 6 additions & 1 deletion DemoProject/SOSimpleChatDemo/Sources/Controllers/Type3VC.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "Type3VC.h"
#import "ContentManager.h"
#import "Message.h"
#import "SOTextMessageCell.h"

@interface Type3VC ()

Expand Down Expand Up @@ -73,7 +74,9 @@ - (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)
cell.contentInsets = UIEdgeInsetsMake(0, 0, 0, 4.0f); //Move content for 4 pt. to left
}

cell.textView.textColor = [UIColor blackColor];
if([cell isKindOfClass:[SOTextMessageCell class]]){
((SOTextMessageCell*)cell).textView.textColor = [UIColor blackColor];
}

cell.userImageView.layer.cornerRadius = 3;

Expand All @@ -90,6 +93,8 @@ - (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)
//-----------------------------------------------//
// Adding datetime label under balloon
//-----------------------------------------------//
[cell adjustCell];

UILabel *label = [self generateLabelForCell:cell];

UILabel *existingLabel = [[cell.contentView.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"tag == %d",label.tag]] lastObject];;
Expand Down
62 changes: 0 additions & 62 deletions SOMessaging/NSString+Calculation.m

This file was deleted.

13 changes: 6 additions & 7 deletions SOMessaging/SOMessageCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define kBubbleRightMargin 7
#define kBubbleBottomMargin 20

static const int userImageViewLeftMargin = 3;

@class SOMessageCell;
@protocol SOMessageCellDelegate <NSObject>

Expand All @@ -47,10 +49,7 @@
@property (strong, nonatomic) UIFont *messageFont;

@property (strong, nonatomic) UIImageView *userImageView;
@property (strong, nonatomic) UITextView *textView;
@property (strong, nonatomic) UILabel *timeLabel; //appears while dragging cell
@property (strong, nonatomic) UIImageView *mediaImageView;
@property (strong, nonatomic) UIView *mediaOverlayView; // For video only

@property (strong, nonatomic) UIImageView *balloonImageView;

Expand All @@ -68,8 +67,6 @@
+ (CGFloat) maxContentOffsetX;
+ (void) setMaxContentOffsetX:(CGFloat)offsetX;

+ (void)setDefaultConfigs;

@property (nonatomic) CGFloat balloonMinWidth;
@property (nonatomic) CGFloat balloonMinHeight;
@property (nonatomic) CGFloat messageMaxWidth;
Expand All @@ -81,9 +78,11 @@
@property (weak, nonatomic) id<SOMessageCellDelegate> delegate;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier messageMaxWidth:(CGFloat)messageMaxWidth;
- (void)setMediaImageViewSize:(CGSize)size;
- (void)setUserImageViewSize:(CGSize)size;

@property (nonatomic) CGSize mediaImageViewSize;
@property (nonatomic) CGSize userImageViewSize;

- (void)adjustCell;
- (void)layoutChatBalloon;

@end
Loading