From aaa0bc8c2284b95187a51b10e44df26758e96718 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 15 May 2020 15:34:00 +0300 Subject: Selection style --- Juick/ViewControllers/MessagesViewController.h | 1 + Juick/ViewControllers/MessagesViewController.m | 3 ++- Juick/ViewControllers/ThreadViewController.m | 4 ++++ Juick/Views/MessageCell.h | 2 +- Juick/Views/MessageCell.m | 4 +++- Juick/Views/MessageCell.xib | 10 +++++----- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h index 7025e8b..d2fc935 100644 --- a/Juick/ViewControllers/MessagesViewController.h +++ b/Juick/ViewControllers/MessagesViewController.h @@ -19,6 +19,7 @@ extern NSString* const messageCellIdentifier; @property(nonatomic, strong) NSString *path; @property(nonatomic, strong) NSDictionary *params; @property(nonatomic, assign) BOOL shouldScrollToUnreadOnRefresh; +@property(nonatomic, assign) BOOL shouldAllowToSelectText; @property(nonatomic) NSNumber * firstUnread; -(void) refreshData; diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index f61d8b4..8fc6408 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -129,7 +129,7 @@ NSString* const messageCellIdentifier = @"messageCell"; } else { Message *msg = [self.messages objectAtIndex:indexPath.row]; MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier forIndexPath:indexPath]; - [cell configureWithMessage:msg]; + [cell configureWithMessage:msg selectable:self.shouldAllowToSelectText]; return cell; } } @@ -141,6 +141,7 @@ NSString* const messageCellIdentifier = @"messageCell"; -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Message *msg = [self.messages objectAtIndex:indexPath.row]; [self viewThreadForMessage:msg mid:msg.mid scrollTo:0]; + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; } -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index 8ee7623..fd754cf 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -49,4 +49,8 @@ [self refreshData]; } +- (BOOL)shouldAllowToSelectText { + return YES; +} + @end diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index 684a620..d50751b 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -26,5 +26,5 @@ @property (nonatomic, strong) id delegate; -- (void) configureWithMessage:(Message *)msg; +- (void) configureWithMessage:(Message *)msg selectable:(BOOL)selectable; @end diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index ad1a3a3..f02aa48 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -46,7 +46,7 @@ const NSString *unreadMarker = @"●"; _italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0]; } -- (void) configureWithMessage:(Message *)msg { +- (void) configureWithMessage:(Message *)msg selectable:(BOOL)selectable { self.avatar.image = nil; __weak UIImageView *weakAvatar = self.avatar; [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.user.avatar] callback:^(NSData *data) { @@ -101,6 +101,8 @@ const NSString *unreadMarker = @"●"; self.text.attributedText = nil; if (msg.text) { [self.text setHidden:NO]; + [self.text setSelectable:selectable]; + [self.text setUserInteractionEnabled:selectable]; NSMutableAttributedString *txt = [[NSMutableAttributedString alloc] initWithString:msg.text attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody], diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib index 5b5ebd3..e690318 100644 --- a/Juick/Views/MessageCell.xib +++ b/Juick/Views/MessageCell.xib @@ -1,16 +1,16 @@ - + - + - + @@ -49,9 +49,9 @@ - + - + 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. -- cgit v1.2.3