Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Dark Theme - Bug Fix #343

Merged
merged 4 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MatrixKit/Controllers/MXKCallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ - (void)viewDidLoad

updateStatusTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimeStatusLabel) userInfo:nil repeats:YES];

self.callerImageView.backgroundColor = [UIColor clearColor];
self.callerImageView.defaultBackgroundColor = [UIColor clearColor];
self.backToAppButton.backgroundColor = [UIColor clearColor];
self.audioMuteButton.backgroundColor = [UIColor clearColor];
self.videoMuteButton.backgroundColor = [UIColor clearColor];
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Controllers/MXKRoomMemberDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ - (void)updateMemberInfo

// set the thumbnail info
self.memberThumbnail.contentMode = UIViewContentModeScaleAspectFill;
self.memberThumbnail.backgroundColor = [UIColor clearColor];
self.memberThumbnail.defaultBackgroundColor = [UIColor clearColor];
[self.memberThumbnail.layer setCornerRadius:self.memberThumbnail.frame.size.width / 2];
[self.memberThumbnail setClipsToBounds:YES];

Expand Down
8 changes: 8 additions & 0 deletions MatrixKit/Controllers/MXKRoomViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ extern NSString *const kCmdChangeRoomTopic;
*/
- (void)setAttachmentsViewerClass:(Class)attachmentsViewerClass;

/**
Register the view class used to display the details of an event.
MXKEventDetailsView is used by default.

@param eventDetailsViewClass a MXKEventDetailsView-inherited class.
*/
- (void)setEventDetailsViewClass:(Class)eventDetailsViewClass;

/**
Detect and process potential IRC command in provided string.

Expand Down
25 changes: 24 additions & 1 deletion MatrixKit/Controllers/MXKRoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ @interface MXKRoomViewController ()
*/
Class attachmentsViewerClass;

/**
The class used to display event details.
*/
Class customEventDetailsViewClass;

/**
The reconnection animated view.
*/
Expand Down Expand Up @@ -1264,6 +1269,17 @@ - (void)setAttachmentsViewerClass:(Class)theAttachmentsViewerClass
attachmentsViewerClass = theAttachmentsViewerClass;
}

- (void)setEventDetailsViewClass:(Class)eventDetailsViewClass
{
if (eventDetailsViewClass)
{
// Sanity check: accept only MXKEventDetailsView classes or sub-classes
NSParameterAssert([eventDetailsViewClass isSubclassOfClass:MXKEventDetailsView.class]);
}

customEventDetailsViewClass = eventDetailsViewClass;
}

- (BOOL)isIRCStyleCommand:(NSString*)string
{
// Check whether the provided text may be an IRC-style command
Expand Down Expand Up @@ -2085,7 +2101,14 @@ - (void)showEventDetails:(MXEvent *)event
// Remove potential existing subviews
[self dismissTemporarySubViews];

eventDetailsView = [[MXKEventDetailsView alloc] initWithEvent:event andMatrixSession:roomDataSource.mxSession];
if (customEventDetailsViewClass)
{
eventDetailsView = [[customEventDetailsViewClass alloc] initWithEvent:event andMatrixSession:roomDataSource.mxSession];
}
else
{
eventDetailsView = [[MXKEventDetailsView alloc] initWithEvent:event andMatrixSession:roomDataSource.mxSession];
}

// Add shadow on event details view
eventDetailsView.layer.cornerRadius = 5;
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/Account/MXKAccountTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ - (void)customizeTableViewCellRendering
{
[super customizeTableViewCellRendering];

self.accountPicture.backgroundColor = [UIColor clearColor];
self.accountPicture.defaultBackgroundColor = [UIColor clearColor];
}

- (void)setMxAccount:(MXKAccount *)mxAccount
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/Contact/MXKContactTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (void)customizeTableViewCellRendering
{
[super customizeTableViewCellRendering];

self.thumbnailView.backgroundColor = [UIColor clearColor];
self.thumbnailView.defaultBackgroundColor = [UIColor clearColor];
}

- (void)layoutSubviews
Expand Down
18 changes: 14 additions & 4 deletions MatrixKit/Views/DeviceView/MXKDeviceView.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ @interface MXKDeviceView ()

@implementation MXKDeviceView

+ (UINib *)nib
{
// Check whether a nib file is available
NSBundle *mainBundle = [NSBundle mxk_bundleForClass:self.class];

NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
if (path)
{
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:mainBundle];
}
return [UINib nibWithNibName:NSStringFromClass([MXKDeviceView class]) bundle:[NSBundle mxk_bundleForClass:[MXKDeviceView class]]];
}

- (void)awakeFromNib
{
[super awakeFromNib];
Expand Down Expand Up @@ -121,10 +134,7 @@ - (void)removeFromSuperviewDidUpdate:(BOOL)isUpdated

- (instancetype)initWithDevice:(MXDevice*)device andMatrixSession:(MXSession*)session
{
NSArray *nibViews = [[NSBundle bundleForClass:[MXKDeviceView class]] loadNibNamed:NSStringFromClass([MXKDeviceView class])
owner:nil
options:nil];
self = nibViews.firstObject;
self = [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
if (self)
{
mxDevice = device;
Expand Down
23 changes: 15 additions & 8 deletions MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ @interface MXKEncryptionInfoView ()

@implementation MXKEncryptionInfoView

+ (UINib *)nib
{
// Check whether a nib file is available
NSBundle *mainBundle = [NSBundle mxk_bundleForClass:self.class];

NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
if (path)
{
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:mainBundle];
}
return [UINib nibWithNibName:NSStringFromClass([MXKEncryptionInfoView class]) bundle:[NSBundle mxk_bundleForClass:[MXKEncryptionInfoView class]]];
}

- (void)awakeFromNib
{
[super awakeFromNib];
Expand Down Expand Up @@ -94,10 +107,7 @@ -(void)customizeViewRendering

- (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)session
{
NSArray *nibViews = [[NSBundle bundleForClass:[MXKEncryptionInfoView class]] loadNibNamed:NSStringFromClass([MXKEncryptionInfoView class])
owner:nil
options:nil];
self = nibViews.firstObject;
self = [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
if (self)
{
mxEvent = event;
Expand All @@ -114,10 +124,7 @@ - (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)sessi

- (instancetype)initWithDeviceInfo:(MXDeviceInfo*)deviceInfo andMatrixSession:(MXSession*)session
{
NSArray *nibViews = [[NSBundle bundleForClass:[MXKEncryptionInfoView class]] loadNibNamed:NSStringFromClass([MXKEncryptionInfoView class])
owner:nil
options:nil];
self = nibViews.firstObject;
self = [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
if (self)
{
mxEvent = nil;
Expand Down
18 changes: 14 additions & 4 deletions MatrixKit/Views/MXKEventDetailsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ @interface MXKEventDetailsView ()

@implementation MXKEventDetailsView

+ (UINib *)nib
{
// Check whether a nib file is available
NSBundle *mainBundle = [NSBundle mxk_bundleForClass:self.class];

NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
if (path)
{
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:mainBundle];
}
return [UINib nibWithNibName:NSStringFromClass([MXKEventDetailsView class]) bundle:[NSBundle mxk_bundleForClass:[MXKEventDetailsView class]]];
}

- (void)awakeFromNib
{
[super awakeFromNib];
Expand All @@ -49,10 +62,7 @@ - (void)awakeFromNib

- (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)session
{
NSArray *nibViews = [[NSBundle bundleForClass:[MXKEventDetailsView class]] loadNibNamed:NSStringFromClass([MXKEventDetailsView class])
owner:nil
options:nil];
self = nibViews.firstObject;
self = [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
if (self)
{
mxEvent = event;
Expand Down
6 changes: 6 additions & 0 deletions MatrixKit/Views/MXKImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ typedef void (^blockMXKImageView_onClick)(MXKImageView *imageView, NSString* tit
*/
- (void)showFullScreen;

/**
The default background color.
Default is [UIColor blackColor].
*/
@property (nonatomic) UIColor *defaultBackgroundColor;

// Use this boolean to hide activity indicator during image downloading
@property (nonatomic) BOOL hideActivityIndicator;

Expand Down
28 changes: 27 additions & 1 deletion MatrixKit/Views/MXKImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ @implementation MXKImageView

#define CUSTOM_IMAGE_VIEW_BUTTON_WIDTH 100

- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
_defaultBackgroundColor = [UIColor blackColor];
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
_defaultBackgroundColor = [UIColor blackColor];
}
return self;
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down Expand Up @@ -86,7 +106,7 @@ -(void)customizeViewRendering
{
[super customizeViewRendering];

self.backgroundColor = [UIColor blackColor];
self.backgroundColor = self.defaultBackgroundColor;

self.contentMode = UIViewContentModeScaleAspectFit;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
Expand Down Expand Up @@ -192,6 +212,12 @@ - (void)stopActivityIndicator

#pragma mark - setters/getters

- (void)setDefaultBackgroundColor:(UIColor *)defaultBackgroundColor
{
_defaultBackgroundColor = defaultBackgroundColor;
self.backgroundColor = defaultBackgroundColor;
}

- (void)setImage:(UIImage *)anImage
{
// remove the observers
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/MXKReceiptSendersContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)refreshReceiptSenders:(NSArray<MXRoomMember*>*)roomMembers withPlaceHold
}

MXKImageView *imageView = [[MXKImageView alloc] initWithFrame:CGRectMake(xOff, 0, side, side)];
imageView.backgroundColor = [UIColor clearColor];
imageView.defaultBackgroundColor = [UIColor clearColor];

if (alignment == ReadReceiptAlignmentRight)
{
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/MXKView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
Customize the rendering of the view and its subviews (Do nothing by default).
This method is called when the view is initialized.
This method is called automatically when the view is loaded from an Interface Builder archive, or nib file.

Override this method to customize the view instance at the application level.
It may be used to handle different rendering themes. In this case this method should be called whenever the theme has changed.
Expand Down
10 changes: 0 additions & 10 deletions MatrixKit/Views/MXKView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ - (void)awakeFromNib
[self customizeViewRendering];
}

- (instancetype)init
{
self = [super init];
if (self)
{
[self customizeViewRendering];
}
return self;
}

- (void)customizeViewRendering
{
// Do nothing by default.
Expand Down
6 changes: 2 additions & 4 deletions MatrixKit/Views/RoomBubbleList/MXKRoomBubbleTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ - (void)customizeTableViewCellRendering
{
[super customizeTableViewCellRendering];

self.pictureView.backgroundColor = [UIColor blackColor];
// Clear the default background color of a MXKImageView instance
self.pictureView.defaultBackgroundColor = [UIColor clearColor];
}

- (void)layoutSubviews
Expand Down Expand Up @@ -332,9 +333,6 @@ - (void)originalRender:(MXKCellData *)cellData
}
self.pictureView.enableInMemoryCache = YES;
[self.pictureView setImageURL:avatarThumbURL withType:nil andImageOrientation:UIImageOrientationUp previewImage: bubbleData.senderAvatarPlaceholder ? bubbleData.senderAvatarPlaceholder : self.picturePlaceholder];

// Clear the default background color of a MXKImageView instance
self.pictureView.backgroundColor = [UIColor clearColor];
}

if (self.attachmentView && bubbleData.isAttachmentWithThumbnail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (void)customizeTableViewCellRendering
{
[super customizeTableViewCellRendering];

self.pictureView.backgroundColor = [UIColor clearColor];
self.pictureView.defaultBackgroundColor = [UIColor clearColor];
}

- (UIImage*)picturePlaceholder
Expand Down
4 changes: 2 additions & 2 deletions MatrixKit/Views/Search/MXKSearchTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (void)render:(MXKCellData *)cellData
if (_attachmentImageView)
{
_attachmentImageView.image = nil;
self.attachmentImageView.backgroundColor = [UIColor clearColor];
self.attachmentImageView.defaultBackgroundColor = [UIColor clearColor];

if (searchCellData.isAttachmentWithThumbnail)
{
Expand All @@ -64,7 +64,7 @@ - (void)render:(MXKCellData *)cellData
{
self.attachmentImageView.enableInMemoryCache = YES;
[self.attachmentImageView setImageURL:url withType:mimetype andImageOrientation:searchCellData.attachment.thumbnailOrientation previewImage:preview];
self.attachmentImageView.backgroundColor = [UIColor whiteColor];
self.attachmentImageView.defaultBackgroundColor = [UIColor whiteColor];
}
}
}
Expand Down