Commit 252a94ab authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk

UI/UX: refactor smartlist

Change-Id: Ibfd5154757908ebd85f4b0060da00a7c608a0e56
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 9d8b7923
......@@ -227,7 +227,9 @@ SET(ringclient_OTHERS
src/delegates/ImageManipulationDelegate.h
src/AccountSelectionManager.h
src/AccountSelectionManager.mm
src/utils.h)
src/utils.h
src/NSString+Extensions.h
src/NSString+Extensions.mm)
SET(ringclient_XIBS
......@@ -275,6 +277,7 @@ SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
SET(ring_ICONS
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_block.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_attachment.png
${CMAKE_CURRENT_SOURCE_DIR}/data/default_avatar_overlay.png
${CMAKE_CURRENT_SOURCE_DIR}/data/symbol_name.png
......
......@@ -88,6 +88,18 @@
return self;
}
-(void) clearData {
cachedConv_ = nil;
convUid_ = "";
convModel_ = nil;
[messagesViewVC clearData];
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(filterChangedConnection_);
QObject::disconnect(newConversationConnection_);
QObject::disconnect(conversationRemovedConnection_);
}
-(const lrc::api::conversation::Info*) getCurrentConversation
{
if (convModel_ == nil || convUid_.empty())
......@@ -282,6 +294,8 @@
return;
}
[self clearData];
if (!animate) {
[self.view setHidden:YES];
return;
......
......@@ -30,6 +30,7 @@
@interface MessagesVC : NSViewController
-(void)setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model;
-(void)clearData;
@property (retain, nonatomic) id <MessagesVCDelegate> delegate;
......
/*
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
......@@ -89,6 +90,16 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
[conversationView registerNib:cellNib forIdentifier:@"RightOngoingFileView"];
[conversationView registerNib:cellNib forIdentifier:@"RightFinishedFileView"];
}
-(void) clearData {
cachedConv_ = nil;
convUid_ = "";
convModel_ = nil;
QObject::disconnect(modelSortedSignal_);
QObject::disconnect(filterChangedSignal_);
QObject::disconnect(interactionStatusUpdatedSignal_);
QObject::disconnect(newInteractionSignal_);
}
-(const lrc::api::conversation::Info*) getCurrentConversation
{
......@@ -390,8 +401,6 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
} else {
result = [tableView makeViewWithIdentifier:@"LeftMessageView" owner:self];
}
if (interaction.status == lrc::api::interaction::Status::UNREAD)
convModel_->setInteractionRead(convUid_, it->first);
break;
case lrc::api::interaction::Type::INCOMING_DATA_TRANSFER:
case lrc::api::interaction::Type::OUTGOING_DATA_TRANSFER:
......
/*
* Copyright (C) 2018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Foundation/Foundation.h>
@interface NSString (Extensions)
- (NSString *) removeAllNewLinesAtTheEnd;
- (NSString *) removeEmptyLinesAtBorders;
@end
/*
* Copyright (C) 2018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "NSString+Extensions.h"
@implementation NSString (Extensions)
- (NSString *) removeAllNewLinesAtTheEnd {
NSString *result = self;
while ([result endedByEmptyLine]) {
result = [result removeLastWhiteSpaceAndNewLineCharacter];
}
return result;
}
- (NSString *) removeAllNewLinesAtBegining {
NSString *result = self;
while ([result startByEmptyLine]) {
result = [result removeFirstWhiteSpaceAndNewLineCharacter];
}
return result;
}
- (NSString *) removeEmptyLinesAtBorders {
NSString *result = self;
result = [result removeAllNewLinesAtBegining];
result = [result removeAllNewLinesAtTheEnd];
return result;
}
-(bool)endedByEmptyLine {
if ([self length] < 1) {
return false;
}
unichar last = [self characterAtIndex:[self length] - 1];
return [[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:last];
}
- (bool)startByEmptyLine {
if ([self length] < 1) {
return false;
}
unichar first = [self characterAtIndex:0];
return [[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:first];
}
- (NSString *) removeLastWhiteSpaceAndNewLineCharacter {
if ([self endedByEmptyLine]) {
return [self substringToIndex:[self length]-1];
}
return self;
}
- (NSString *) removeFirstWhiteSpaceAndNewLineCharacter {
if ([self startByEmptyLine]) {
return [self substringFromIndex:1];
}
return self;
}
@end
This diff is collapsed.
......@@ -277,13 +277,23 @@ namespace Interfaces {
return pxm;
} else {
char color = contact.profileInfo.uri.at(0);
contact.profileInfo.alias.erase(std::remove(contact.profileInfo.alias.begin(), contact.profileInfo.alias.end(), '\n'), contact.profileInfo.alias.end());
contact.profileInfo.alias.erase(std::remove(contact.profileInfo.alias.begin(), contact.profileInfo.alias.end(), ' '), contact.profileInfo.alias.end());
contact.profileInfo.alias.erase(std::remove(contact.profileInfo.alias.begin(), contact.profileInfo.alias.end(), '\r'), contact.profileInfo.alias.end());
if (!contact.profileInfo.alias.empty()) {
return drawDefaultUserPixmap(size, color, std::toupper(contact.profileInfo.alias.at(0)));
} else if((contact.profileInfo.type == lrc::api::profile::Type::RING ||
contact.profileInfo.type == lrc::api::profile::Type::PENDING) &&
!contact.registeredName.empty()) {
return drawDefaultUserPixmap(size, color, std::toupper(contact.registeredName.at(0)));
contact.registeredName.erase(std::remove(contact.registeredName.begin(), contact.registeredName.end(), '\n'), contact.registeredName.end());
contact.registeredName.erase(std::remove(contact.registeredName.begin(), contact.registeredName.end(), ' '), contact.registeredName.end());
contact.registeredName.erase(std::remove(contact.registeredName.begin(), contact.registeredName.end(), '\r'), contact.registeredName.end());
if(!contact.registeredName.empty()) {
return drawDefaultUserPixmap(size, color, std::toupper(contact.registeredName.at(0)));
} else {
return drawDefaultUserPixmapUriOnly(size, color);
}
} else {
return drawDefaultUserPixmapUriOnly(size, color);
}
......
......@@ -18,6 +18,7 @@
*/
#import <Foundation/Foundation.h>
#import "NSString+Extensions.h"
#import <api/conversation.h>
#import <api/conversationmodel.h>
#import <api/account.h>
......@@ -28,19 +29,39 @@
static inline NSString* bestIDForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{
auto contact = model.owner.contactModel->getContact(conv.participants[0]);
if (!contact.registeredName.empty())
return @(contact.registeredName.c_str());
if (!contact.registeredName.empty()) {
contact.registeredName.erase(std::remove(contact.registeredName.begin(), contact.registeredName.end(), '\n'), contact.registeredName.end());
contact.registeredName.erase(std::remove(contact.registeredName.begin(), contact.registeredName.end(), '\r'), contact.registeredName.end());
return [@(contact.registeredName.c_str()) removeEmptyLinesAtBorders];
}
else
return @(contact.profileInfo.uri.c_str());
return [@(contact.profileInfo.uri.c_str()) removeEmptyLinesAtBorders];
}
static inline NSString* bestNameForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{
auto contact = model.owner.contactModel->getContact(conv.participants[0]);
if (!contact.profileInfo.alias.empty())
return @(contact.profileInfo.alias.c_str());
else
if (contact.profileInfo.alias.empty()) {
return bestIDForConversation(conv, model);
}
auto alias = contact.profileInfo.alias;
alias.erase(std::remove(alias.begin(), alias.end(), '\n'), alias.end());
alias.erase(std::remove(alias.begin(), alias.end(), '\r'), alias.end());
if(alias.length() == 0) {
return bestIDForConversation(conv, model);
}
return @(alias.c_str());
}
static inline lrc::api::profile::Type profileType(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{
@try {
auto contact = model.owner.contactModel->getContact(conv.participants[0]);
return contact.profileInfo.type;
}
@catch (NSException *exception) {
lrc::api::profile::Type::INVALID;
}
}
/**
......
......@@ -52,7 +52,7 @@
/*
* Padding
* default value : 5.0
* default value : 8.0
*/
@property CGFloat imageInsets;
......
......@@ -103,12 +103,9 @@
//// Group
{
//// Oval Drawing
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:
NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5),
NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5),
floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5),
floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5))
xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:dirtyRect
xRadius:[self.cornerRadius floatValue]
yRadius:[self.cornerRadius floatValue]];
[backgroundColor setFill];
[ovalPath fill];
......
......@@ -32,6 +32,11 @@
*/
@property (nonatomic, strong) NSColor* borderColor;
/*
* default value : [NSNumber numberWithDouble:1.0];
*/
@property (nonatomic, strong) NSNumber* borderThickness;
/*
* default value : (self.frame) / 2;
*/
......
......@@ -34,6 +34,10 @@
self.borderColor = [self.bgColor darkenColorByValue:0.1];
}
if(!self.borderThickness) {
self.borderThickness = [NSNumber numberWithDouble:1.0];
}
self.backgroundColor = [NSColor controlColor];
}
......@@ -42,6 +46,7 @@
NSColor* backgroundColor = self.bgColor;
NSColor* borderColor = self.borderColor;
CGFloat borderThickness = [self.borderThickness floatValue];
NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5,
NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5,
......@@ -57,7 +62,7 @@
[backgroundColor setFill];
[ovalPath fill];
[borderColor setStroke];
[ovalPath setLineWidth: 1.0];
[ovalPath setLineWidth: borderThickness];
[ovalPath stroke];
NSDictionary *att = nil;
......
This diff is collapsed.
......@@ -65,5 +65,5 @@
/* Class = "NSTextFieldCell"; placeholderString = "Display Role"; ObjectID = "uSw-g5-kte"; */
"uSw-g5-kte.placeholderString" = "Display Role";
/* Class = "NSSearchFieldCell"; placeholderString = "Name, ringID"; ObjectID = "vvE-nM-kSl"; */
"vvE-nM-kSl.placeholderString" = "Name, ringID";
/* Class = "NSSearchFieldCell"; placeholderString = "Search for new or existing contact"; ObjectID = "vvE-nM-kSl"; */
"vvE-nM-kSl.placeholderString" = "Search for new or existing contact";
This diff is collapsed.
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