summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/ViewControllers/FeedViewController.h2
-rw-r--r--Juick/ViewControllers/FeedViewController.m10
-rw-r--r--Juick/ViewControllers/MessagesViewController.h2
-rw-r--r--Juick/ViewControllers/MessagesViewController.m15
-rw-r--r--Juick/Views/MessageCell.h2
-rw-r--r--Juick/Views/MessageCell.m15
-rw-r--r--Juick/Views/MessageCell.xib112
7 files changed, 87 insertions, 71 deletions
diff --git a/Juick/ViewControllers/FeedViewController.h b/Juick/ViewControllers/FeedViewController.h
index 76388aa..a669bcb 100644
--- a/Juick/ViewControllers/FeedViewController.h
+++ b/Juick/ViewControllers/FeedViewController.h
@@ -9,6 +9,6 @@
#import <UIKit/UIKit.h>
#import "MessagesViewController.h"
-@interface FeedViewController : MessagesViewController<MessagesDelegate, MessageCellDelegate>
+@interface FeedViewController : MessagesViewController<MessagesDelegate>
@end
diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m
index c492f2e..3575f16 100644
--- a/Juick/ViewControllers/FeedViewController.m
+++ b/Juick/ViewControllers/FeedViewController.m
@@ -14,11 +14,6 @@
NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated";
-@interface FeedViewController ()
-
-@property NSString *selectedUser;
-@end
-
@implementation FeedViewController
-(void) viewDidLoad {
@@ -29,11 +24,6 @@ NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated";
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidSignedIn:) name:UserChangedNotificationName object:nil];
}
--(void)avatarClicked:(NSString *)uname {
- self.selectedUser = uname;
- [self performSegueWithIdentifier:@"profileSegue" sender:self];
-}
-
-(void) loadMore {
Message *lastMsg = [self.messages lastObject];
if (lastMsg != nil) {
diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h
index 3b466f0..6d2c7e2 100644
--- a/Juick/ViewControllers/MessagesViewController.h
+++ b/Juick/ViewControllers/MessagesViewController.h
@@ -15,7 +15,7 @@ extern NSString* const messageCellIdentifier;
-(void) loadMore;
@end
-@interface MessagesViewController : UITableViewController
+@interface MessagesViewController : UITableViewController<MessageCellDelegate>
@property(nonatomic, strong) NSString *path;
@property(nonatomic, strong) NSDictionary *params;
@property(nonatomic, assign) BOOL shouldScrollToUnreadOnRefresh;
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index 12f8176..10b7c37 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -27,6 +27,8 @@ NSString* const messageCellIdentifier = @"messageCell";
-(void) applicationActivated;
+@property NSString *selectedUser;
+
@end
@implementation MessagesViewController
@@ -155,6 +157,7 @@ NSString* const messageCellIdentifier = @"messageCell";
Message *msg = [self.messages objectAtIndex:indexPath.row];
MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier forIndexPath:indexPath];
[cell configureWithMessage:msg selectable:self.shouldAllowToSelectText];
+ cell.delegate = self;
return cell;
}
}
@@ -219,6 +222,18 @@ NSString* const messageCellIdentifier = @"messageCell";
return configuration;
}
+-(void)avatarClicked:(NSString *)uname {
+ /*self.selectedUser = uname;
+ [self performSegueWithIdentifier:@"profileSegue" sender:self];*/
+}
+
+-(void)linkClicked:(NSString *)urlString {
+ NSURL *url = [NSURL URLWithString:urlString];
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
+
+ }];
+}
+
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h
index d50751b..f568bdc 100644
--- a/Juick/Views/MessageCell.h
+++ b/Juick/Views/MessageCell.h
@@ -11,6 +11,8 @@
@protocol MessageCellDelegate
-(void) avatarClicked:(NSString *)uname;
+-(void) linkClicked:(NSString *)url;
+
@end
@interface MessageCell : UITableViewCell
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index ceb2ac5..9b1b593 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -16,6 +16,7 @@
@property(nonatomic, readonly) UIFont *boldFont;
@property(nonatomic, readonly) UIFont *italicFont;
- (void) updateAvatarWithUrl:(NSString *)avatarUrl;
+@property(nonatomic, strong) NSString *attachment;
@end
@implementation MessageCell
@@ -72,14 +73,15 @@ const NSString *unreadMarker = @"●";
}];
}
if ([msg.attach length] > 0) {
- CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale];
- CGFloat imageWidth = [msg.attachment.small.width floatValue] / [[UIScreen mainScreen] scale];
+ self.attachment = msg.attachment.url;
+ CGFloat imageHeight = [msg.attachment.medium.height floatValue] / [[UIScreen mainScreen] scale];
+ CGFloat imageWidth = [msg.attachment.medium.width floatValue] / [[UIScreen mainScreen] scale];
self.attach.image = [UIImage placeholderImageWithColor:[UIColor colorNamed:@"Muted"] size:CGSizeMake(imageWidth, imageHeight)];
self.attachmentHeight.constant = imageHeight;
self.attachmentWidth.constant = imageWidth;
__weak UIImageView *weakAttach = self.attach;
- [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.small.url] callback:^(NSData *data) {
+ [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.medium.url] callback:^(NSData *data) {
[UIView transitionWithView:weakAttach
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
@@ -88,6 +90,10 @@ const NSString *unreadMarker = @"●";
}
completion:nil];
}];
+ UITapGestureRecognizer *attachmentTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(linkClicked:)];
+ [attachmentTapGestureRecognizer setEnabled:YES];
+ [self.attach addGestureRecognizer:attachmentTapGestureRecognizer];
+ [self.attach setUserInteractionEnabled:YES];
} else {
self.attachmentHeight.constant = 0;
self.attach.image = nil;
@@ -174,5 +180,8 @@ const NSString *unreadMarker = @"●";
-(void) avatarClicked:(UIGestureRecognizer *)gestureRecognizer {
[self.delegate avatarClicked:self.title.text];
}
+-(void) linkClicked:(UIGestureRecognizer *)gestureRecognizer {
+ [self.delegate linkClicked:self.attachment];
+}
@end
diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib
index 53a2408..5d35561 100644
--- a/Juick/Views/MessageCell.xib
+++ b/Juick/Views/MessageCell.xib
@@ -18,68 +18,71 @@
<rect key="frame" x="0.0" y="0.0" width="572" height="604"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Azj-pa-GEC">
- <rect key="frame" x="20" y="20" width="532" height="564"/>
+ <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="7FT-kJ-84d" userLabel="Item header">
+ <rect key="frame" x="20" y="20" width="532" height="76"/>
<subviews>
- <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="7FT-kJ-84d">
- <rect key="frame" x="0.0" y="0.0" width="532" height="76"/>
- <subviews>
- <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="CZk-Q8-JqS">
- <rect key="frame" x="0.0" y="14" width="48" height="48"/>
- <constraints>
- <constraint firstAttribute="height" priority="999" constant="48" id="ZnT-UD-xga"/>
- <constraint firstAttribute="width" constant="48" id="khZ-DB-qfq"/>
- </constraints>
- </imageView>
- <stackView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="o3h-ci-LWF">
- <rect key="frame" x="56" y="16" width="476" height="44.5"/>
- <subviews>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CHd-h0-hPk">
- <rect key="frame" x="0.0" y="0.0" width="476" height="20.5"/>
- <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
- <nil key="textColor"/>
- <nil key="highlightedColor"/>
- </label>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AVu-qV-q84">
- <rect key="frame" x="0.0" y="28.5" width="476" height="16"/>
- <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
- <nil key="textColor"/>
- <nil key="highlightedColor"/>
- </label>
- </subviews>
- </stackView>
- </subviews>
- </stackView>
- <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalHuggingPriority="1000" verticalCompressionResistancePriority="749" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt">
- <rect key="frame" x="0.0" y="84" width="532" height="192"/>
- <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
- <string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
- <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
- <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
- </textView>
- <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Uha-ow-kFJ">
- <rect key="frame" x="0.0" y="284" width="532" height="256"/>
+ <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="CZk-Q8-JqS">
+ <rect key="frame" x="0.0" y="14" width="48" height="48"/>
<constraints>
- <constraint firstAttribute="height" priority="999" constant="256" identifier="attachHeight" id="Cuq-dQ-VYU"/>
- <constraint firstAttribute="width" priority="999" constant="256" identifier="attachWidth" id="oJg-1R-jp3"/>
+ <constraint firstAttribute="height" priority="999" constant="48" id="ZnT-UD-xga"/>
+ <constraint firstAttribute="width" constant="48" id="khZ-DB-qfq"/>
</constraints>
</imageView>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aJE-mZ-MCS">
- <rect key="frame" x="0.0" y="548" width="532" height="16"/>
- <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
- <nil key="textColor"/>
- <nil key="highlightedColor"/>
- </label>
+ <stackView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="o3h-ci-LWF">
+ <rect key="frame" x="56" y="16" width="476" height="44.5"/>
+ <subviews>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CHd-h0-hPk">
+ <rect key="frame" x="0.0" y="0.0" width="476" height="20.5"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AVu-qV-q84">
+ <rect key="frame" x="0.0" y="28.5" width="476" height="16"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ </subviews>
+ </stackView>
</subviews>
- <color key="backgroundColor" name="TextBackground"/>
</stackView>
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt">
+ <rect key="frame" x="20" y="104" width="532" height="192"/>
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+ <string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
+ <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+ </textView>
+ <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Uha-ow-kFJ">
+ <rect key="frame" x="0.0" y="304" width="572" height="256"/>
+ <constraints>
+ <constraint firstAttribute="height" priority="999" constant="256" identifier="attachHeight" id="Cuq-dQ-VYU"/>
+ <constraint firstAttribute="width" priority="999" constant="256" identifier="attachWidth" id="oJg-1R-jp3"/>
+ </constraints>
+ </imageView>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aJE-mZ-MCS">
+ <rect key="frame" x="20" y="568" width="532" height="16"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
</subviews>
<color key="backgroundColor" name="Background"/>
<constraints>
- <constraint firstAttribute="bottom" secondItem="Azj-pa-GEC" secondAttribute="bottom" constant="20" symbolic="YES" id="OWY-DI-0dv"/>
- <constraint firstItem="Azj-pa-GEC" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="Ohz-6B-bYr"/>
- <constraint firstItem="Azj-pa-GEC" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" symbolic="YES" id="biD-O8-Mwb"/>
- <constraint firstAttribute="trailing" secondItem="Azj-pa-GEC" secondAttribute="trailing" constant="20" symbolic="YES" id="ymN-qs-0pB"/>
+ <constraint firstItem="nZn-a4-oSt" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="0zm-OK-XwQ"/>
+ <constraint firstItem="nZn-a4-oSt" firstAttribute="top" secondItem="7FT-kJ-84d" secondAttribute="bottom" constant="8" symbolic="YES" id="4aL-eh-Hr1"/>
+ <constraint firstAttribute="trailing" secondItem="Uha-ow-kFJ" secondAttribute="trailing" id="53k-cb-1Id"/>
+ <constraint firstItem="aJE-mZ-MCS" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="7ly-7o-0Hz"/>
+ <constraint firstAttribute="trailing" secondItem="7FT-kJ-84d" secondAttribute="trailing" constant="20" symbolic="YES" id="ISb-j0-2qS"/>
+ <constraint firstAttribute="bottom" secondItem="aJE-mZ-MCS" secondAttribute="bottom" constant="20" symbolic="YES" id="SVc-7q-7cq"/>
+ <constraint firstItem="7FT-kJ-84d" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" symbolic="YES" id="U1q-JA-Kje"/>
+ <constraint firstItem="7FT-kJ-84d" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="aQq-kz-fa6"/>
+ <constraint firstAttribute="trailing" secondItem="nZn-a4-oSt" secondAttribute="trailing" constant="20" symbolic="YES" id="mA7-MH-CBn"/>
+ <constraint firstItem="aJE-mZ-MCS" firstAttribute="top" secondItem="Uha-ow-kFJ" secondAttribute="bottom" constant="8" symbolic="YES" id="ukt-qs-QTa"/>
+ <constraint firstItem="Uha-ow-kFJ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="y52-pJ-8lj"/>
+ <constraint firstItem="Uha-ow-kFJ" firstAttribute="top" secondItem="nZn-a4-oSt" secondAttribute="bottom" constant="8" symbolic="YES" id="y6Y-nI-bRW"/>
+ <constraint firstAttribute="trailing" secondItem="aJE-mZ-MCS" secondAttribute="trailing" constant="20" symbolic="YES" id="zly-DV-unc"/>
</constraints>
</tableViewCellContentView>
<connections>
@@ -99,8 +102,5 @@
<namedColor name="Background">
<color red="0.99215686274509807" green="0.99215686274509807" blue="0.99607843137254903" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
- <namedColor name="TextBackground">
- <color red="1" green="1" blue="1" alpha="0.75" colorSpace="custom" customColorSpace="sRGB"/>
- </namedColor>
</resources>
</document>