Commit e5d4abe1 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

UI: conversation

- send file: hide default image when preview is available
- message panel: update placeholder

Change-Id: Id70f88a9aa0f57d8496146f5695e069db40994c8
parent ea7984ad
......@@ -369,16 +369,7 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
if (conv == nil)
return;
NSString* name = bestNameForConversation(*conv, *convModel_);
NSString *placeholder = [NSString stringWithFormat:@"%@%@", @"Write to ", name];
NSFont *fontName = [NSFont systemFontOfSize: 14.0 weight: NSFontWeightRegular];
NSColor *color = [NSColor tertiaryLabelColor];
NSDictionary *nameAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
fontName, NSFontAttributeName,
color, NSForegroundColorAttributeName,
nil];
NSAttributedString* attributedPlaceholder = [[NSAttributedString alloc] initWithString: placeholder attributes:nameAttrs];
messageView.placeholderAttributedString = attributedPlaceholder;
[self updatePlaceholder];
[self reloadPendingFiles];
conversationView.alphaValue = 0.0;
[conversationView reloadData];
......@@ -397,6 +388,24 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
}
}
-(void)updatePlaceholder {
auto* conv = [self getCurrentConversation];
if (conv == nil)
return;
NSString* name = bestNameForConversation(*conv, *convModel_);
NSString *placeholder = [NSString stringWithFormat:@"%@%@", @"Write to ", name];
NSFont *fontName = [NSFont systemFontOfSize: 14.0 weight: NSFontWeightRegular];
NSColor *color = [NSColor tertiaryLabelColor];
NSDictionary *nameAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
fontName, NSFontAttributeName,
color, NSForegroundColorAttributeName,
nil];
NSAttributedString* attributedPlaceholder = [[NSAttributedString alloc] initWithString: placeholder attributes:nameAttrs];
messageView.placeholderAttributedString = attributedPlaceholder;
}
#pragma mark - configure cells
-(NSTableCellView*) makeGenericInteractionViewForTableView:(NSTableView*)tableView withText:(NSString*)text andTime:(NSString*) time
......@@ -1134,6 +1143,7 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
}
-(void) resetSendMessagePanelToDefaultSize {
[self updatePlaceholder];
if(messageHeight.constant != MESSAGE_VIEW_DEFAULT_HEIGHT) {
sendPanelHeight.constant = SEND_PANEL_DEFAULT_HEIGHT;
messageHeight.constant = MESSAGE_VIEW_DEFAULT_HEIGHT;
......@@ -1217,6 +1227,9 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
-(void)textDidChange:(NSNotification *)notification {
[self checkIfComposingMsg];
if (self.message.length) {
[self updatePlaceholder];
}
self.enableSendButton = self.message.length > 0 || [(NSMutableArray*)MessagesVC. pendingFiles[convUid_.toNSString()] count] > 0;
}
......@@ -1285,6 +1298,7 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
- (NSCollectionViewItem*)collectionView:(NSCollectionView *)collectionView itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath {
FileToSendCollectionItem* fileCell = [collectionView makeItemWithIdentifier:@"FileToSendCollectionItem" forIndexPath:indexPath];
PendingFile* file = MessagesVC.pendingFiles[convUid_.toNSString()][indexPath.item];
fileCell.placeholderPreview.hidden = file.preview != nil;
fileCell.filePreview.image = file.preview;
fileCell.fileName.stringValue = file.name;
fileCell.fileName.toolTip = file.name;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment