Skip to content

Commit

Permalink
Fix dark mode switch on 10.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nark committed Apr 9, 2020
1 parent 6edd830 commit 41999ed
Show file tree
Hide file tree
Showing 16 changed files with 723 additions and 548 deletions.
10 changes: 6 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PODS:
- "NSDate+TimeAgo (1.0.6)"
- OpenSSL-Universal (1.0.2.13)
- OpenSSL-Universal (1.0.2.19):
- OpenSSL-Universal/Static (= 1.0.2.19)
- OpenSSL-Universal/Static (1.0.2.19)
- SBJson4 (4.0.5)
- Sparkle (1.18.1)
- Sparkle (1.23.0)

DEPENDENCIES:
- "NSDate+TimeAgo"
Expand All @@ -19,9 +21,9 @@ SPEC REPOS:

SPEC CHECKSUMS:
"NSDate+TimeAgo": 35601c619b2d59290055e4fe76e61d97677a2360
OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327
OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355
SBJson4: e1aa705a4104e83fd250420709a57de5efae96ff
Sparkle: 06ea33170007c5937ee54da481b4481af98fac79
Sparkle: 55b1a87ba69d56913375a281546b7c82dec95bb0

PODFILE CHECKSUM: fa150038f6c8e2bd91237273cf2233fefb2dc11c

Expand Down
28 changes: 24 additions & 4 deletions Sources/WCBoardThreadController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ - (void)_reloadDataAndScrollToCurrentPosition:(BOOL)scrollToCurrentPosition sele
// get theme and template
theme = [[WCSettings settings] themeWithIdentifier:[[WCSettings settings] objectForKey:WCTheme]];
template = [[WCSettings settings] templateBundleWithIdentifier:[theme objectForKey:WCThemesTemplate]];

//[self reloadTemplate];

// load the webView
if(template) {
Expand All @@ -74,6 +72,8 @@ - (void)_reloadDataAndScrollToCurrentPosition:(BOOL)scrollToCurrentPosition sele

[[_threadWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:url]];
}

[self reloadTemplate];
}


Expand Down Expand Up @@ -107,6 +107,12 @@ - (id)init {
_defaultIconBase64String = [[[[NSImage imageNamed:@"DefaultIcon"] TIFFRepresentation] base64EncodedString] retain];

_smileyBase64Strings = [[NSMutableDictionary alloc] init];

[[NSDistributedNotificationCenter defaultCenter]
addObserver:self
selector:@selector(appleInterfaceThemeChanged:)
name:@"AppleInterfaceThemeChangedNotification"
object: nil];

return self;
}
Expand Down Expand Up @@ -250,6 +256,17 @@ - (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elemen




#pragma mark -

- (void)appleInterfaceThemeChanged:(NSNotification *) notification {
[self reloadTemplate];
}





#pragma mark -

- (void)setBoard:(WCBoard *)board {
Expand Down Expand Up @@ -390,14 +407,17 @@ - (void)reloadDataAndSelectPost:(WCBoardPost *)selectPost {
#pragma mark -
#pragma mark Reload CSS Template

- (void)reloadTemplate {
- (void)reloadTemplate {
WITemplateBundle *template;

template = [WITemplateBundle templateWithPath:_templatePath];

[template setCSSValue:[_font fontName] toAttribute:WITemplateAttributesFontName ofType:WITemplateTypeBoards];
[template setCSSValue:[NSSWF:@"%.0fpx", [_font pointSize]] toAttribute:WITemplateAttributesFontSize ofType:WITemplateTypeBoards];
[template setCSSValue:[NSSWF:@"#%.6x", (unsigned int)[_textColor HTMLValue]] toAttribute:WITemplateAttributesFontColor ofType:WITemplateTypeBoards];

[template setCSSValue:[NSApp darkModeEnabled] ? @"gainsboro" : @"dimgray"
toAttribute:WITemplateAttributesFontColor
ofType:WITemplateTypeBoards];

[template setCSSValue:[NSApp darkModeEnabled] ? @"#383838" : @"white"
toAttribute:WITemplateAttributesBackgroundColor
Expand Down
26 changes: 12 additions & 14 deletions Sources/WCBoards.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,23 @@ - (void)_setupSplitViews {

#pragma mark -

- (void)appleInterfaceThemeChanged:(NSNotification *) notification {

}




- (void)_themeDidChange {
NSDictionary *theme;
NSString *templatePath;
WITemplateBundle *templateBundle;
NSColor *textColor;
NSColor *backgroundColor;

theme = [[WCSettings settings] themeWithIdentifier:[[WCSettings settings] objectForKey:WCTheme]];
templateBundle = [[WCSettings settings] templateBundleWithIdentifier:[theme objectForKey:WCThemesTemplate]];
templatePath = [templateBundle bundlePath];

textColor = [NSApp darkModeEnabled] ? [NSColor whiteColor] : [NSColor textColor];
backgroundColor = [NSApp darkModeEnabled] ? [NSColor darkGrayColor] : [NSColor whiteColor];

[_threadController setFont:WIFontFromString([theme objectForKey:WCThemesBoardsFont])];
[_threadController setTextColor:WIColorFromString([theme objectForKey:WCThemesBoardsTextColor])];
[_threadController setBackgroundColor:WIColorFromString([theme objectForKey:WCThemesBoardsBackgroundColor])];
[_threadController setTextColor:textColor];
[_threadController setBackgroundColor:backgroundColor];
[_threadController setTemplatePath:templatePath];

[_threadController reloadTemplate];
Expand Down Expand Up @@ -653,7 +651,7 @@ - (void)_reloadThread {

board = [self _selectedBoard];
thread = [self _selectedThread];

if(thread) {
if(![thread isLoaded]) {
[thread removeAllPosts];
Expand All @@ -665,7 +663,7 @@ - (void)_reloadThread {

[_threadController setBoard:board];
[_threadController setThread:thread];

if([thread isLoaded])
[_threadController reloadData];
}
Expand All @@ -674,8 +672,6 @@ - (void)_reloadThread {
[_threadController setThread:NULL];
[_threadController reloadData];
}

[self _themeDidChange];
}


Expand Down Expand Up @@ -1710,7 +1706,6 @@ - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {


- (void)themeDidChange:(NSDictionary *)theme {
NSLog(@"Boards themeDidChange:");
[self _themeDidChange];
}

Expand Down Expand Up @@ -2824,6 +2819,9 @@ - (void)replyToThread {
thread = [self _selectedThread];
board = [_boardsByThreadID objectForKey:[thread threadID]];

if (board == nil)
return;

[self _reloadBoardListsSelectingBoard:board];

[_postLocationPopUpButton setEnabled:NO];
Expand Down
27 changes: 13 additions & 14 deletions Sources/WCMessages.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ - (void)_themeDidChange {

templateBundle = [[WCSettings settings] templateBundleWithIdentifier:[theme objectForKey:WCThemesTemplate]];



font = WIFontFromString([theme objectForKey:WCThemesMessagesFont]);
textColor = WIColorFromString([theme objectForKey:WCThemesMessagesTextColor]);
backgroundColor = WIColorFromString([theme objectForKey:WCThemesMessagesBackgroundColor]);
textColor = [NSApp darkModeEnabled] ? [NSColor whiteColor] : [NSColor textColor];
backgroundColor = [NSApp darkModeEnabled] ? [NSColor darkGrayColor] : [NSColor whiteColor];
templatePath = [templateBundle bundlePath];


Expand All @@ -217,16 +215,15 @@ - (void)_themeDidChange {
[_conversationController setTextColor:textColor];
[_conversationController setBackgroundColor:backgroundColor];

[_messageTextField setFont:font];
[_messageTextField setTextColor:textColor];
//[_messageTextField setInsertionPointColor:textColor];
[[_messageTextField.cell fieldEditorForView:_messageTextField] setInsertionPointColor:textColor];
[_messageTextField setBackgroundColor:backgroundColor];

// [_broadcastTextView setFont:font];
[_broadcastTextView setTextColor:textColor];
[_broadcastTextView setInsertionPointColor:textColor];
[_broadcastTextView setBackgroundColor:backgroundColor];
// [_messageTextField setFont:font];
// [_messageTextField setTextColor:textColor];
// [[_messageTextField.cell fieldEditorForView:_messageTextField] setInsertionPointColor:textColor];
// [_messageTextField setBackgroundColor:backgroundColor];
//
//// [_broadcastTextView setFont:font];
// [_broadcastTextView setTextColor:textColor];
// [_broadcastTextView setInsertionPointColor:textColor];
// [_broadcastTextView setBackgroundColor:backgroundColor];

[_conversationController reloadTemplate];
[_conversationController reloadData];
Expand Down Expand Up @@ -1039,6 +1036,8 @@ - (void)windowDidBecomeKey:(NSWindow *)window {
[self _sortConversations];
}
}

[self _themeDidChange];
}


Expand Down
174 changes: 0 additions & 174 deletions Templates/Neo/htdocs/css/default_boards.css
Original file line number Diff line number Diff line change
@@ -1,175 +1 @@
* {
padding:0;
margin:0;
}

html {
background-color: <? backgroundcolor ?>;
}

body {
font: normal <? fontsize ?> "<? fontname ?>", sans-serif;
color: <? textcolor ?>;
background-color: <? backgroundcolor ?>;
line-height: 16px;
}

#thread-content {
padding-left: 10px;
padding-right: 12px;
padding-top: 10px;
}


div.post {
margin-bottom: 20px;
background-color: <? backgroundcolor ?>;
border-radius: 3px;
border: 1px solid #999;
}


div.postheader {
font: normal 12px "Helvetica", sans-serif;
background-color: <? headerbackground ?>;
padding: 7px;
min-height: 33px;
border-bottom: 1px solid #999;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}

div.postinfo {
width: 165px;
float: left;
}


div.postheadertitles {
float: left;
}

span.postheadertitle {
font-weight: bold;
display: block;
color: gray;
text-align: right;
width: 45px;
margin-left: 10px;
padding-right: 5px;
}

div.postheadervalues {

}

span.postheadervalue {
display: block;
}


span.postfrom {
min-width: 400px;
text-align: left;
display: inline-block;
margin-left: 10px;
font-weight: bold;
}

span.postpostdatestring, span.posteditdatestring {
font-size: 9px;
}

span.postpostdate, span.posteditdate {
font-size: 9px;
}


div.posticon { float: left; }

.postunread {
float: right;
display: block;
padding-top: 6px;
}

div.postbuttons {
padding: 5px;
margin-right: 5px;
text-align: right;
width: auto;
float: right;
}

input.replybutton {
background: transparent url("../img/reply.svg") no-repeat;
}

input.quotebutton {
background: transparent url("../img/quote.svg") no-repeat;
}

input.editbutton {
background: transparent url("../img/edit.svg") no-repeat;
}

input.deletebutton {
background: transparent url("../img/delete.svg") no-repeat;
}

.postbuttons input[type="button"] {
margin-left: 16px;
}

input[type="button"] {
height: 20px;
width: 16px;
background-size: 16px 20px;
background-position: center center;
text-align: center;
cursor: pointer;
display: inline-block;
opacity: 0.3;
border: none;

-webkit-appearance: none;
-webkit-transition: opacity 0.2s ease-in-out;
}

input[type="button"]:not(.disabled):hover {
opacity: 0.75;
}


div.postbody {
padding: 10px;
clear: both;
}

div.postbody img, div.postbody iframe, div.postbody embed {
max-width: 100%;
}

div.reply {
padding: 10px;
background-color: <? headerbackground ?>;
}

div.reply input {
display: inline-block;
min-width: 80px;
padding-left: 15px;
padding-right: 15px;
background-color: rgba(0,255,10,0.1);
}

blockquote {
margin: 0px 0px 0px 15px;
padding: 8px;
border: 1px solid #bfbfbf;
background-color: <? backgroundcolor ?>;
}

pre { margin: 0px; }

div.center { text-align: center; };
Loading

0 comments on commit 41999ed

Please sign in to comment.