Skip to content
Snippets Groups Projects
Commit 394f74c7 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

UI: support light/dark mode

Change-Id: I99935ebe90c8d674a467e09381976450ce9b3c15
parent eaf1bc80
No related branches found
No related tags found
No related merge requests found
Showing
with 702 additions and 652 deletions
......@@ -454,7 +454,7 @@ typedef NS_ENUM(NSInteger, TagViews) {
CGFloat advancedHeight = self.advancedButtonMarginConstraint.constant;
self.advancedButtonMarginConstraint.constant = (height== 2) ? 40 : 30;
self.bannedContactHeightConstraint.constant = (height== 2) ? 150 : 2;
[[[self.blockedContactsTableView superview] superview] setHidden:![[[self.blockedContactsTableView superview] superview] isHidden]];
[[[[self.blockedContactsTableView superview] superview] superview] setHidden:![[[[self.blockedContactsTableView superview] superview] superview] isHidden]];
[blockedContactsTableView reloadData];
}
......
......@@ -63,14 +63,6 @@ CGFloat const VIEW_INSET = 20;
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setWantsLayer:YES];
[self.view setLayer:[CALayer layer]];
[self.view.layer setBackgroundColor:[NSColor ringGreyHighlight].CGColor];
[self.view.layer setCornerRadius:5.0f];
}
- (void) initFrame
{
[self.view setFrame:self.view.superview.bounds];
......
......@@ -41,15 +41,6 @@
@synthesize messageField,sendButton;
- (void)awakeFromNib
{
NSLog(@"Init ChatVC");
[self.view setWantsLayer:YES];
[self.view setLayer:[CALayer layer]];
[self.view.layer setBackgroundColor:[NSColor controlColor].CGColor];
}
-(void)setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel *)model
{
convUid_ = convUid;
......
......@@ -182,12 +182,6 @@
- (void)loadView {
[super loadView];
// Do view setup here.
[self.view setWantsLayer:YES];
[self.view setLayer:[CALayer layer]];
[self.view.layer setBackgroundColor:[NSColor ringGreyHighlight].CGColor];
[self.view.layer setCornerRadius:5.0f];
[messageField setFocusRingType:NSFocusRingTypeNone];
}
......
......@@ -31,6 +31,7 @@
#import "GeneralPrefsVC.h"
#import "AudioPrefsVC.h"
#import "VideoPrefsVC.h"
#import "views/NSColor+RingTheme.h"
@implementation PreferencesWC {
......@@ -49,6 +50,11 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{
[super windowDidLoad];
[self.window setMovableByWindowBackground:YES];
NSArray *items = [self.window.toolbar items];
for(NSToolbarItem *toolbarItem in items) {
NSImage * image = [NSColor image: [toolbarItem image] tintedWithColor: [NSColor secondaryLabelColor]];
toolbarItem.image = image;
}
[self.window.toolbar setSelectedItemIdentifier:kGeneralPrefsIdentifier];
[self displayGeneral:nil];
}
......
......@@ -52,7 +52,6 @@
#import "SmartViewVC.h"
#import "views/IconButton.h"
#import "views/NSColor+RingTheme.h"
#import "views/BackgroundView.h"
#import "views/HoverButton.h"
#import "utils.h"
#import "RingWizardWC.h"
......@@ -109,7 +108,6 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[super windowDidLoad];
[self.window setMovableByWindowBackground:YES];
[self.window setBackgroundColor:[NSColor colorWithRed:242.0/255 green:242.0/255 blue:242.0/255 alpha:1.0]];
self.window.titleVisibility = NSWindowTitleHidden;
currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
......@@ -178,6 +176,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[currentCallVC showWithAnimation:false];
[conversationVC hideWithAnimation:false];
[self accountSettingsShouldOpen: NO];
[welcomeContainer setHidden: YES];
});
QObject::connect(self.behaviorController,
......@@ -197,6 +196,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[currentCallVC showWithAnimation:false];
[conversationVC hideWithAnimation:false];
[self accountSettingsShouldOpen: NO];
[welcomeContainer setHidden: YES];
});
QObject::connect(self.behaviorController,
......@@ -209,6 +209,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[conversationVC showWithAnimation:false];
[currentCallVC hideWithAnimation:false];
[self accountSettingsShouldOpen: NO];
[welcomeContainer setHidden: YES];
});
}
......@@ -302,7 +303,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
for(int i = 0; i < width; ++i) {
for(int j = 0; j < width; ++j) {
if(*data & 1) {
CGContextSetFillColorWithColor(ctx, [NSColor ringDarkGrey].CGColor);
CGContextSetFillColorWithColor(ctx, [NSColor labelColor].CGColor);
rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
CGContextAddRect(ctx, rectDraw);
CGContextFillPath(ctx);
......@@ -444,6 +445,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
-(void)rightPanelClosed
{
[smartViewVC deselect];
[welcomeContainer setHidden:NO];
}
-(void)currentConversationTrusted
......@@ -455,6 +457,7 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
[conversationVC hideWithAnimation:false];
[currentCallVC hideWithAnimation:false];
[self accountSettingsShouldOpen: NO];
[welcomeContainer setHidden: NO];
}
#pragma mark - NSToolbarDelegate
......@@ -507,6 +510,8 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI
}
-(void) accountSettingsShouldOpen: (BOOL) open {
[smartViewVC.view setHidden:open];
[welcomeContainer setHidden: open];
if (open) {
@try {
[settingsVC setSelectedAccount: [chooseAccountVC selectedAccount].id];
......
......@@ -67,7 +67,6 @@
[chooseActiontWC setDelegate:self];
[linkAccountWC setDelegate:self];
[newAccountWC setDelegate:self];
[self.window setBackgroundColor:[NSColor ringGreyHighlight]];
[self showChooseWithCancelButton:isCancelable andAdvanced: withAdvanced];
}
......
......@@ -106,15 +106,6 @@ NSInteger const REQUEST_SEG = 1;
[smartView setShortcutsDelegate:self];
[smartView setDataSource: self];
[self.view setWantsLayer:YES];
[self.view setLayer:[CALayer layer]];
[self.view.layer setBackgroundColor:[NSColor whiteColor].CGColor];
[searchField setWantsLayer:YES];
[searchField setLayer:[CALayer layer]];
[searchField.layer setBackgroundColor:[NSColor colorWithCalibratedRed:0.949 green:0.949 blue:0.949 alpha:0.9].CGColor];
currentFilterType = lrc::api::profile::Type::RING;
selectorIsPresent = true;
......@@ -384,12 +375,8 @@ NSInteger const REQUEST_SEG = 1;
NSInteger rows = [smartView numberOfRows];
for (int i = 0; i< rows; i++) {
NSTableRowView* cellRowView = [smartView rowViewAtRow:i makeIfNecessary: NO];
if (i == row) {
cellRowView.backgroundColor = [NSColor controlColor];
} else {
cellRowView.backgroundColor = [NSColor whiteColor];
}
HoverTableRowView* cellRowView = [smartView rowViewAtRow:i makeIfNecessary: NO];
[cellRowView drawSelection: (i == row)];
}
if (row == -1)
......
......@@ -71,10 +71,11 @@
- (void) drawRect: (NSRect) rect {
NSMenuItem *menuItem = ([self enclosingMenuItem]);
BOOL isHighlighted = [menuItem isHighlighted];
NSColor* highlightBackground = @available(macOS 10.14, *) ? [NSColor controlColor] : [NSColor whiteColor];
if (isHighlighted) {
[self.backgroundView setFillColor:[NSColor whiteColor]];
[self.backgroundView setFillColor: highlightBackground];
} else {
[self.backgroundView setFillColor:[NSColor ringGreyHighlight]];
[self.backgroundView setFillColor:[NSColor windowBackgroundColor]];
}
[super drawRect: rect];
}
......
......@@ -54,8 +54,10 @@
}
@property BOOL highlightable;
- (void) drawSelection: (BOOL) isSelected;
@end
// Used by the HoverTableRowView and the RingTableView
void DrawSeparatorInRect(NSRect rect);
......@@ -51,6 +51,7 @@
@interface HoverTableRowView ()
@property BOOL mouseInside;
@property NSVisualEffectView* effect_view;
@end
@implementation HoverTableRowView
......@@ -59,7 +60,7 @@
- (instancetype)init
{
self.highlightable = YES;
[self configureView];
}
- (id)initWithFrame:(CGRect)aRect
......@@ -67,9 +68,8 @@
self = [super initWithFrame:aRect];
if (self) {
self.highlightable = YES;
[self configureView];
}
return self;
}
......@@ -77,14 +77,18 @@
{
self = [super initWithCoder:aDecoder];
if (self) {
self.highlightable = YES;
[self configureView];
}
return self;
}
- (void)dealloc {
- (void)configureView {
self.highlightable = YES;
self.effect_view = [[NSVisualEffectView alloc] initWithFrame: [self bounds]];
[self.effect_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
[self addSubview: self.effect_view positioned: NSWindowBelow relativeTo:nil];
[self.effect_view setHidden:YES];
[self.effect_view setMaterial: static_cast<NSVisualEffectMaterial>(6)];
}
- (void)setMouseInside:(BOOL)value {
......@@ -123,18 +127,18 @@
self.mouseInside = NO;
}
-(void) drawSelection: (BOOL) isSelected {
[self.effect_view setHidden: !isSelected];
[self.effect_view setMaterial: isSelected ? static_cast<NSVisualEffectMaterial>(4) : static_cast<NSVisualEffectMaterial>(6)];
}
- (void)drawBackgroundInRect:(NSRect)dirtyRect {
// Custom background drawing. We don't call super at all.
[self.backgroundColor set];
// Fill with the background color first
NSRectFill(self.bounds);
// Draw a gradient
if (self.mouseInside && self.highlightable) {
NSRect selectionRect = NSRect(self.bounds);
[[NSColor ringGreyHighlight] setFill];
NSBezierPath *selectionPath = [NSBezierPath bezierPathWithRoundedRect:selectionRect xRadius:2 yRadius:2];
[selectionPath fill];
[self.effect_view setHidden:YES];
if(!@available(macOS 10.14, *)) {
[super drawBackgroundInRect:dirtyRect];
}
if ((self.mouseInside) && self.highlightable) {
[self.effect_view setHidden:NO];
}
}
......@@ -153,14 +157,7 @@
// Only called if the 'selected' property is yes.
- (void)drawSelectionInRect:(NSRect)dirtyRect {
// Check the selectionHighlightStyle, in case it was set to None
if (self.selectionHighlightStyle != NSTableViewSelectionHighlightStyleNone) {
// We want a hard-crisp stroke, and stroking 1 pixel will border half on one side and half on another, so we offset by the 0.5 to handle this
NSRect selectionRect = NSRect(self.bounds);
[[NSColor ringGreyHighlight] setFill];
NSBezierPath *selectionPath = [NSBezierPath bezierPathWithRoundedRect:selectionRect xRadius:2 yRadius:2];
[selectionPath fill];
}
[self.effect_view setHidden:NO];
}
// interiorBackgroundStyle is normaly "dark" when the selection is drawn (self.selected == YES) and we are in a key window (self.emphasized == YES). However, we always draw a light selection, so we override this method to always return a light color.
......@@ -182,6 +179,12 @@
}
}
- (void)prepareForReuse {
[self.effect_view setHidden:YES];
self.mouseInside = NO;
[super prepareForReuse];
}
@end
void DrawSeparatorInRect(NSRect rect) {
......
......@@ -46,7 +46,7 @@ NSString* const TIME_BOX_HEIGHT = @"34";
}
else {
self.msgBackground.pointerDirection = LEFT;
self.msgBackground.bgColor = [NSColor whiteColor];
self.msgBackground.bgColor = @available(macOS 10.14, *) ? [NSColor controlColor] : [NSColor whiteColor];
}
}
......
......@@ -128,7 +128,6 @@
[backgroundColor setFill];
[ovalPath fill];
[NSGraphicsContext saveGraphicsState];
CGPoint top = CGPointMake(frame.size.width * 0.5, 0);
CGPoint right = CGPointMake(frame.size.width, frame.size.height * 0.5);
......
......@@ -27,7 +27,7 @@
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextSetRGBFillColor(context, 1, 1, 1, 0);
CGFloat defaultRadius = 16;
CGFloat radius = (self.cornerRadius) ? self.cornerRadius : defaultRadius;
CGFloat minx = CGRectGetMinX(dirtyRect);
......
......@@ -48,16 +48,8 @@
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,
floor(NSWidth(dirtyRect) * 0.96667) - floor(NSWidth(dirtyRect) * 0.03333),
floor(NSHeight(dirtyRect) * 0.96667) - floor(NSHeight(dirtyRect) * 0.03333));
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))
NSRect group = dirtyRect;
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(dirtyRect.origin.x + borderThickness * 0.5, dirtyRect.origin.y + borderThickness * 0.5, dirtyRect.size.width - borderThickness, dirtyRect.size.height - borderThickness)
xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
[backgroundColor setFill];
[ovalPath fill];
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,6 +2,7 @@
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -32,8 +33,8 @@
<rect key="frame" x="1" y="1" width="618" height="450"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<color key="borderColor" red="0.88235294117647056" green="0.88235294117647056" blue="0.88235294117647056" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="fillColor" red="0.91764705882352937" green="0.91764705882352937" blue="0.91764705882352937" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="borderColor" name="unemphasizedSelectedTextBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="fillColor" name="windowBackgroundColor" catalog="System" colorSpace="catalog"/>
</box>
<view translatesAutoresizingMaskIntoConstraints="NO" id="pL7-7S-saC">
<rect key="frame" x="110" y="0.0" width="400" height="513"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -13,13 +14,13 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<customView wantsLayer="YES" id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="820" height="828"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="FE5-WQ-UWb">
<scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" findBarPosition="aboveHorizontalRuler" translatesAutoresizingMaskIntoConstraints="NO" id="FE5-WQ-UWb">
<rect key="frame" x="0.0" y="0.0" width="820" height="828"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="AS0-K7-DN3" customClass="CenteredClipView">
<clipView key="contentView" copiesOnScroll="NO" id="AS0-K7-DN3" customClass="CenteredClipView">
<rect key="frame" x="0.0" y="0.0" width="820" height="828"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
......@@ -28,14 +29,14 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="alternatingContentBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<edgeInsets key="contentInsets" left="0.0" right="0.0" top="20" bottom="0.0"/>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="raF-h3-PC0">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="raF-h3-PC0">
<rect key="frame" x="-100" y="-100" width="670" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Pt7-JA-8ml">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Pt7-JA-8ml">
<rect key="frame" x="-100" y="-100" width="16" height="768"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment