summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/ViewControllers/MessagesViewController.h3
-rw-r--r--Juick/ViewControllers/MessagesViewController.m13
-rw-r--r--Juick/Views/MessageCell.swift7
3 files changed, 18 insertions, 5 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h
index 55a2bde..d3e3f07 100644
--- a/Juick/ViewControllers/MessagesViewController.h
+++ b/Juick/ViewControllers/MessagesViewController.h
@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import "Message.h"
+@import SafariServices;
@protocol MessageCellDelegate;
@@ -17,7 +18,7 @@ extern NSString* const messageCellIdentifier;
-(void) loadMore;
@end
-@interface MessagesViewController : UITableViewController<MessageCellDelegate>
+@interface MessagesViewController : UITableViewController<MessageCellDelegate, SFSafariViewControllerDelegate>
@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 8563fca..9fad013 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -226,11 +226,18 @@ NSString* const messageCellIdentifier = @"messageCell";
[self performSegueWithIdentifier:@"profileSegue" sender:self];*/
}
+- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
+ [self dismissViewControllerAnimated:YES completion:nil];
+}
+
-(void)linkClicked:(NSString *)urlString {
NSURL *url = [NSURL URLWithString:urlString];
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
-
- }];
+ SFSafariViewControllerConfiguration *configuration = [[SFSafariViewControllerConfiguration alloc] init];
+ configuration.entersReaderIfAvailable = NO;
+ configuration.barCollapsingEnabled = YES;
+ SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url configuration:configuration];
+ safariViewController.delegate = self;
+ [self presentViewController:safariViewController animated:YES completion:nil];
}
- (void)dealloc
diff --git a/Juick/Views/MessageCell.swift b/Juick/Views/MessageCell.swift
index ebebec2..61867ce 100644
--- a/Juick/Views/MessageCell.swift
+++ b/Juick/Views/MessageCell.swift
@@ -14,7 +14,7 @@ import UIKit
}
@objc
-class MessageCell: UITableViewCell {
+class MessageCell: UITableViewCell, UITextViewDelegate {
@IBOutlet weak var avatar: UIImageView!
@IBOutlet weak var message: UITextView!
@IBOutlet weak var title: UILabel!
@@ -89,6 +89,7 @@ class MessageCell: UITableViewCell {
}
self.message.attributedText = nil
if (msg.text != nil) {
+ self.message.delegate = self
self.message.isHidden = false
self.message.isSelectable = selectable
self.message.isUserInteractionEnabled = selectable
@@ -159,6 +160,10 @@ class MessageCell: UITableViewCell {
self.delegate?.avatarClicked(name)
}
}
+ func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
+ self.delegate?.linkClicked(URL.absoluteString)
+ return false
+ }
@objc func linkClicked(_ sender: UITapGestureRecognizer){
self.delegate?.linkClicked(self.attachment!)
}