Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 1 | /* |
Sébastien Blin | 029ffa8 | 2019-01-02 17:43:48 -0500 | [diff] [blame] | 2 | * Copyright (C) 2016-2019 Savoir-faire Linux Inc. |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 4 | * Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #import "ConversationVC.h" |
| 22 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 23 | #import <qstring.h> |
| 24 | #import <QPixmap> |
| 25 | #import <QtMacExtras/qmacfunctions.h> |
Kateryna Kostiuk | 1ba5a01 | 2018-12-12 17:07:38 -0500 | [diff] [blame] | 26 | #import <QuartzCore/QuartzCore.h> |
Kateryna Kostiuk | 6ea9ac1 | 2019-07-18 15:02:07 -0400 | [diff] [blame] | 27 | #import <QuickLook/QuickLook.h> |
| 28 | #import <Quartz/Quartz.h> |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 29 | |
| 30 | #import "views/IconButton.h" |
Kateryna Kostiuk | db95b47 | 2018-04-17 16:35:57 -0400 | [diff] [blame] | 31 | #import "views/HoverButton.h" |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 32 | #import "views/IMTableCellView.h" |
| 33 | #import "views/NSColor+RingTheme.h" |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 34 | #import "delegates/ImageManipulationDelegate.h" |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 35 | #import "MessagesVC.h" |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 36 | #import "utils.h" |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 37 | #import "RingWindowController.h" |
Kateryna Kostiuk | a0f1686 | 2018-05-04 09:11:41 -0400 | [diff] [blame] | 38 | #import "NSString+Extensions.h" |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 39 | #import "LeaveMessageVC.h" |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 40 | |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 41 | @interface ConversationVC () <QLPreviewPanelDataSource, QLPreviewPanelDelegate>{ |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 42 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 43 | __unsafe_unretained IBOutlet NSTextField* conversationTitle; |
Olivier Soldano | 13c69e3 | 2018-01-05 12:01:36 -0500 | [diff] [blame] | 44 | __unsafe_unretained IBOutlet NSTextField *conversationID; |
Kateryna Kostiuk | db95b47 | 2018-04-17 16:35:57 -0400 | [diff] [blame] | 45 | __unsafe_unretained IBOutlet HoverButton *addContactButton; |
Kateryna Kostiuk | 78e1f12 | 2017-06-14 14:52:34 -0400 | [diff] [blame] | 46 | __unsafe_unretained IBOutlet NSLayoutConstraint* sentContactRequestWidth; |
Kateryna Kostiuk | 4f37d95 | 2018-12-04 13:19:17 -0500 | [diff] [blame] | 47 | |
Kateryna Kostiuk | 78e1f12 | 2017-06-14 14:52:34 -0400 | [diff] [blame] | 48 | __unsafe_unretained IBOutlet NSButton* sentContactRequestButton; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 49 | IBOutlet MessagesVC* messagesViewVC; |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 50 | LeaveMessageVC* leaveMessageVC; |
Anthony Léonard | ade9f9b | 2017-07-26 15:51:12 -0400 | [diff] [blame] | 51 | |
Olivier Soldano | f563e15 | 2018-01-09 16:08:32 -0500 | [diff] [blame] | 52 | IBOutlet NSLayoutConstraint *titleCenteredConstraint; |
Anthony Léonard | ade9f9b | 2017-07-26 15:51:12 -0400 | [diff] [blame] | 53 | IBOutlet NSLayoutConstraint* titleTopConstraint; |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 54 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 55 | QString convUid_; |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 56 | const lrc::api::conversation::Info* cachedConv_; |
| 57 | lrc::api::ConversationModel* convModel_; |
| 58 | |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 59 | RingWindowController* delegate; |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 60 | NSMutableArray* leaveMessageConversations; |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 61 | |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 62 | // All those connections are needed to invalidate cached conversation as pointer |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 63 | // may not be referencing the same conversation anymore |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 64 | QMetaObject::Connection modelSortedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | @end |
| 68 | |
Kateryna Kostiuk | 4f37d95 | 2018-12-04 13:19:17 -0500 | [diff] [blame] | 69 | NSInteger const MEESAGE_MARGIN = 21; |
| 70 | NSInteger const SEND_PANEL_DEFAULT_HEIGHT = 60; |
| 71 | NSInteger const SEND_PANEL_MAX_HEIGHT = 120; |
| 72 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 73 | @implementation ConversationVC |
| 74 | |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 75 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow aVModel:(lrc::api::AVModel*) avModel |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 76 | { |
| 77 | if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) |
| 78 | { |
| 79 | delegate = mainWindow; |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 80 | leaveMessageVC = [[LeaveMessageVC alloc] initWithNibName:@"LeaveMessageVC" bundle:nil]; |
| 81 | [[leaveMessageVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 82 | [self.view addSubview:[leaveMessageVC view] positioned:NSWindowAbove relativeTo:nil]; |
| 83 | [leaveMessageVC initFrame]; |
| 84 | [leaveMessageVC setAVModel: avModel]; |
| 85 | leaveMessageConversations = [[NSMutableArray alloc] init]; |
| 86 | leaveMessageVC.delegate = self; |
Kateryna Kostiuk | fbe1b2f | 2019-10-07 17:32:26 -0400 | [diff] [blame] | 87 | [messagesViewVC setAVModel: avModel]; |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 88 | } |
| 89 | return self; |
| 90 | } |
| 91 | |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 92 | -(NSViewController*) getMessagesView { |
| 93 | return messagesViewVC; |
| 94 | } |
| 95 | |
Andreas Traczyk | 252a94a | 2018-04-20 16:36:20 -0400 | [diff] [blame] | 96 | -(void) clearData { |
| 97 | cachedConv_ = nil; |
| 98 | convUid_ = ""; |
| 99 | convModel_ = nil; |
| 100 | |
| 101 | [messagesViewVC clearData]; |
| 102 | QObject::disconnect(modelSortedConnection_); |
| 103 | QObject::disconnect(filterChangedConnection_); |
| 104 | QObject::disconnect(newConversationConnection_); |
| 105 | QObject::disconnect(conversationRemovedConnection_); |
| 106 | } |
| 107 | |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 108 | -(const lrc::api::conversation::Info*) getCurrentConversation |
| 109 | { |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 110 | if (convModel_ == nil || convUid_.isEmpty()) |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 111 | return nil; |
| 112 | |
| 113 | if (cachedConv_ != nil) |
| 114 | return cachedConv_; |
| 115 | |
Kateryna Kostiuk | a7b909c | 2020-10-19 11:46:26 -0400 | [diff] [blame] | 116 | auto convOpt = getConversationFromUid(convUid_, *convModel_); |
| 117 | if (convOpt.has_value()) { |
kkostiuk | f81c637 | 2021-01-11 18:51:28 -0500 | [diff] [blame^] | 118 | lrc::api::conversation::Info& conversation = *convOpt; |
Kateryna Kostiuk | a7b909c | 2020-10-19 11:46:26 -0400 | [diff] [blame] | 119 | cachedConv_ = &conversation; |
Kateryna Kostiuk | 3541ae2 | 2020-08-17 12:26:14 -0400 | [diff] [blame] | 120 | } |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 121 | return cachedConv_; |
| 122 | } |
| 123 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 124 | -(void) setConversationUid:(const QString&)convUid model:(lrc::api::ConversationModel *)model { |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 125 | if (convUid_ == convUid && convModel_ == model) |
| 126 | return; |
Kateryna Kostiuk | 0f0ba99 | 2018-06-07 14:22:58 -0400 | [diff] [blame] | 127 | [self clearData]; |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 128 | cachedConv_ = nil; |
| 129 | convUid_ = convUid; |
| 130 | convModel_ = model; |
| 131 | |
| 132 | [messagesViewVC setConversationUid:convUid_ model:convModel_]; |
| 133 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 134 | if (convUid_.isEmpty() || convModel_ == nil) |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 135 | return; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 136 | if([leaveMessageConversations containsObject:convUid_.toNSString()]) { |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 137 | [leaveMessageVC setConversationUID: convUid_ conversationModel: convModel_]; |
| 138 | } else { |
| 139 | [leaveMessageVC hide]; |
| 140 | } |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 141 | |
| 142 | // Signals tracking changes in conversation list, we need them as cached conversation can be invalid |
| 143 | // after a reordering. |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 144 | QObject::disconnect(modelSortedConnection_); |
| 145 | QObject::disconnect(filterChangedConnection_); |
| 146 | QObject::disconnect(newConversationConnection_); |
| 147 | QObject::disconnect(conversationRemovedConnection_); |
Kateryna Kostiuk | a7b909c | 2020-10-19 11:46:26 -0400 | [diff] [blame] | 148 | modelSortedConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::modelChanged, |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 149 | [self](){ |
| 150 | cachedConv_ = nil; |
| 151 | }); |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 152 | filterChangedConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::filterChanged, |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 153 | [self](){ |
| 154 | cachedConv_ = nil; |
| 155 | }); |
Kateryna Kostiuk | 557f5ea | 2018-03-29 13:41:53 -0400 | [diff] [blame] | 156 | newConversationConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::newConversation, |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 157 | [self](){ |
| 158 | cachedConv_ = nil; |
| 159 | }); |
Kateryna Kostiuk | 557f5ea | 2018-03-29 13:41:53 -0400 | [diff] [blame] | 160 | conversationRemovedConnection_ = QObject::connect(convModel_, &lrc::api::ConversationModel::conversationRemoved, |
Anthony Léonard | 0163410 | 2017-12-27 16:37:16 -0500 | [diff] [blame] | 161 | [self](){ |
| 162 | cachedConv_ = nil; |
| 163 | }); |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 164 | |
| 165 | auto* conv = [self getCurrentConversation]; |
| 166 | |
| 167 | if (conv == nil) |
| 168 | return; |
| 169 | |
| 170 | // Setup UI elements according to new conversation |
Kateryna Kostiuk | 146cb9e | 2020-08-11 14:29:26 -0400 | [diff] [blame] | 171 | NSLog(@"account info, %@", conv->accountId.toNSString()); |
| 172 | NSLog(@"conv info, %@", conv->uid.toNSString()); |
| 173 | NSLog(@"paricipant info, %@", conv->participants[0].toNSString()); |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 174 | NSString* bestName = bestNameForConversation(*conv, *convModel_); |
Kateryna Kostiuk | 146cb9e | 2020-08-11 14:29:26 -0400 | [diff] [blame] | 175 | NSLog(@"account info, %@", conv->accountId.toNSString()); |
| 176 | NSLog(@"conv info, %@", conv->uid.toNSString()); |
| 177 | NSLog(@"paricipant info, %@", conv->participants[0].toNSString()); |
Olivier Soldano | 13c69e3 | 2018-01-05 12:01:36 -0500 | [diff] [blame] | 178 | NSString* bestId = bestIDForConversation(*conv, *convModel_); |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 179 | [conversationTitle setStringValue: bestName]; |
Olivier Soldano | 13c69e3 | 2018-01-05 12:01:36 -0500 | [diff] [blame] | 180 | [conversationID setStringValue: bestId]; |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 181 | |
Olivier Soldano | f563e15 | 2018-01-09 16:08:32 -0500 | [diff] [blame] | 182 | BOOL hideBestId = [bestNameForConversation(*conv, *convModel_) isEqualTo:bestIDForConversation(*conv, *convModel_)]; |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 183 | |
Olivier Soldano | f563e15 | 2018-01-09 16:08:32 -0500 | [diff] [blame] | 184 | [conversationID setHidden:hideBestId]; |
| 185 | [titleCenteredConstraint setActive:hideBestId]; |
| 186 | [titleTopConstraint setActive:!hideBestId]; |
Kateryna Kostiuk | db95b47 | 2018-04-17 16:35:57 -0400 | [diff] [blame] | 187 | auto accountType = convModel_->owner.profileInfo.type; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 188 | try { |
| 189 | [addContactButton setHidden:((convModel_->owner.contactModel->getContact(conv->participants[0]).profileInfo.type != lrc::api::profile::Type::TEMPORARY) || accountType == lrc::api::profile::Type::SIP)]; |
| 190 | } catch (std::out_of_range& e) { |
| 191 | NSLog(@"contact out of range"); |
| 192 | } |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 193 | } |
| 194 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 195 | - (void) initFrame |
| 196 | { |
| 197 | [self.view setFrame:self.view.superview.bounds]; |
| 198 | [self.view setHidden:YES]; |
| 199 | self.view.layer.position = self.view.frame.origin; |
| 200 | } |
| 201 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 202 | - (IBAction)placeCall:(id)sender |
| 203 | { |
Anthony Léonard | 2382b56 | 2017-12-13 15:51:28 -0500 | [diff] [blame] | 204 | auto* conv = [self getCurrentConversation]; |
| 205 | convModel_->placeCall(conv->uid); |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 206 | } |
| 207 | |
Kateryna Kostiuk | db95b47 | 2018-04-17 16:35:57 -0400 | [diff] [blame] | 208 | - (IBAction)placeAudioCall:(id)sender |
| 209 | { |
| 210 | auto* conv = [self getCurrentConversation]; |
| 211 | convModel_->placeAudioOnlyCall(conv->uid); |
| 212 | } |
| 213 | |
| 214 | - (IBAction)addContact:(id)sender |
| 215 | { |
| 216 | auto* conv = [self getCurrentConversation]; |
| 217 | convModel_->makePermanent(conv->uid); |
| 218 | } |
| 219 | |
Alexandre Lision | 01cf5e3 | 2016-01-21 15:54:30 -0500 | [diff] [blame] | 220 | - (IBAction)backPressed:(id)sender { |
Anthony Léonard | 8585cc0 | 2017-12-28 14:03:45 -0500 | [diff] [blame] | 221 | [delegate rightPanelClosed]; |
Andreas Traczyk | ecdc4fa | 2018-03-22 16:11:47 -0400 | [diff] [blame] | 222 | [self hideWithAnimation:false]; |
Kateryna Kostiuk | fbe1b2f | 2019-10-07 17:32:26 -0400 | [diff] [blame] | 223 | [messagesViewVC clearData]; |
Kateryna Kostiuk | 0ba1baf | 2017-05-12 16:51:27 -0400 | [diff] [blame] | 224 | } |
| 225 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 226 | # pragma mark private IN/OUT animations |
| 227 | |
Andreas Traczyk | ecdc4fa | 2018-03-22 16:11:47 -0400 | [diff] [blame] | 228 | -(void) showWithAnimation:(BOOL)animate |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 229 | { |
Andreas Traczyk | ecdc4fa | 2018-03-22 16:11:47 -0400 | [diff] [blame] | 230 | if (!animate) { |
| 231 | [self.view setHidden:NO]; |
| 232 | return; |
| 233 | } |
| 234 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 235 | CGRect frame = CGRectOffset(self.view.superview.bounds, -self.view.superview.bounds.size.width, 0); |
| 236 | [self.view setHidden:NO]; |
| 237 | |
| 238 | [CATransaction begin]; |
| 239 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; |
| 240 | [animation setFromValue:[NSValue valueWithPoint:frame.origin]]; |
| 241 | [animation setToValue:[NSValue valueWithPoint:self.view.superview.bounds.origin]]; |
| 242 | [animation setDuration:0.2f]; |
| 243 | [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; |
| 244 | [self.view.layer addAnimation:animation forKey:animation.keyPath]; |
| 245 | |
| 246 | [CATransaction commit]; |
| 247 | } |
| 248 | |
Andreas Traczyk | ecdc4fa | 2018-03-22 16:11:47 -0400 | [diff] [blame] | 249 | -(void) hideWithAnimation:(BOOL)animate |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 250 | { |
| 251 | if(self.view.frame.origin.x < 0) { |
| 252 | return; |
| 253 | } |
| 254 | |
Andreas Traczyk | 252a94a | 2018-04-20 16:36:20 -0400 | [diff] [blame] | 255 | [self clearData]; |
| 256 | |
Andreas Traczyk | ecdc4fa | 2018-03-22 16:11:47 -0400 | [diff] [blame] | 257 | if (!animate) { |
| 258 | [self.view setHidden:YES]; |
| 259 | return; |
| 260 | } |
| 261 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 262 | CGRect frame = CGRectOffset(self.view.frame, -self.view.frame.size.width, 0); |
| 263 | [CATransaction begin]; |
| 264 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; |
| 265 | [animation setFromValue:[NSValue valueWithPoint:self.view.frame.origin]]; |
| 266 | [animation setToValue:[NSValue valueWithPoint:frame.origin]]; |
| 267 | [animation setDuration:0.2f]; |
| 268 | [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; |
| 269 | |
| 270 | [CATransaction setCompletionBlock:^{ |
| 271 | [self.view setHidden:YES]; |
| 272 | }]; |
| 273 | [self.view.layer addAnimation:animation forKey:animation.keyPath]; |
| 274 | |
| 275 | [self.view.layer setPosition:frame.origin]; |
| 276 | [CATransaction commit]; |
| 277 | } |
| 278 | |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 279 | - (void) presentLeaveMessageView { |
| 280 | [leaveMessageVC setConversationUID: convUid_ conversationModel: convModel_]; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 281 | [leaveMessageConversations addObject:convUid_.toNSString()]; |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | -(void) messageCompleted { |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 285 | [leaveMessageConversations removeObject:convUid_.toNSString()]; |
Kateryna Kostiuk | f631742 | 2018-09-27 17:08:20 -0400 | [diff] [blame] | 286 | } |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 287 | |
| 288 | @end |