Commit 202bf9df authored by Carola Nitz's avatar Carola Nitz

VLCAboutViewController: adopt Themes and added toHex method for UIColor

parent ae04d8f9
<html>
<head>
</head>
<body style="background-color: #1f1f1f">
<body style="background-color: BACKGROUNDCOLOR">
<style type="text/css">
h3 {color: #aaaaaa}
h5 {text-decoration: plain; color: #aaaaaa}
A:link {text-decoration: underline; color: #aaaaaa}
A:visited {text-decoration: none; color: #aaaaaa}
A:active {text-decoration: none; color: #aaaaaa}
h3 {color: TEXTCOLOR}
h5 {text-decoration: plain; color: TEXTCOLOR}
A:link {text-decoration: underline; color: TEXTCOLOR}
A:visited {text-decoration: none; color: TEXTCOLOR}
A:active {text-decoration: none; color: TEXTCOLOR}
body { font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300; }
</style>
<div style="text-align:left; border:solid transparent 1px; padding:0.5em 1em 0.5em 1em; overflow:auto; font-size:10pt; font-family:Helvetica; color:#aaaaaa"; A:link {text-decoration: underline; color:#aaaaaa}>
<div style="text-align:left; border:solid transparent 1px; padding:0.5em 1em 0.5em 1em; overflow:auto; font-size:10pt; font-family:Helvetica; color:TEXTCOLOR"; A:link {text-decoration: underline; color:TEXTCOLOR}>
<p align="center">
<table cellspacing="0" cellpadding="0">
<tr>
......
......@@ -80,13 +80,37 @@ public class PresentationTheme : NSObject {
}
}
public extension UIColor {
@objc public extension UIColor {
public convenience init(_ rgbValue:UInt32, _ alpha:CGFloat = 1.0) {
let red = ((CGFloat)((rgbValue & 0xFF0000) >> 16))/255.0
let green = ((CGFloat)((rgbValue & 0xFF00) >> 8))/255.0
let blue = ((CGFloat)(rgbValue & 0xFF))/255.0
self.init(red: red, green: green, blue: blue, alpha: 1.0)
let r = CGFloat((rgbValue & 0xFF0000) >> 16)/255.0
let g = CGFloat((rgbValue & 0xFF00) >> 8)/255.0
let b = CGFloat(rgbValue & 0xFF)/255.0
self.init(red: r, green: g, blue: b, alpha: 1.0)
}
func toHex(alpha: Bool = false) -> String? {
guard let components = cgColor.components, components.count >= 3 else {
return nil
}
let r = Float(components[0])
let g = Float(components[1])
let b = Float(components[2])
var a = Float(1.0)
if components.count == 4 {
a = Float(components[3])
}
if alpha {
return String(format: "#%02lX%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255), lroundf(a * 255))
} else {
return String(format: "#%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255))
}
}
var toHex: String? {
return toHex()
}
}
......
......@@ -13,6 +13,7 @@
*****************************************************************************/
#import "VLCAboutViewController.h"
#import "VLC_iOS-Swift.h"
@interface VLCAboutViewController ()
{
......@@ -26,7 +27,7 @@
- (void)loadView
{
self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = PresentationTheme.current.colors.background;
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_webView = [[UIWebView alloc] initWithFrame:self.view.frame];
......@@ -37,6 +38,8 @@
_webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:_webView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange) name:kVLCThemeDidChangeNotification object:nil];
}
- (void)viewDidLoad
......@@ -49,13 +52,31 @@
contributeButton.tintColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem = contributeButton;
[self loadWebContent];
}
- (void)loadWebContent
{
NSBundle *mainBundle = [NSBundle mainBundle];
NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
[htmlContent replaceOccurrencesOfString:@"VLCFORIOSVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT", nil), [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]] stringByAppendingFormat:@" (%@)<br /><i>%@</i>", [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"], kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(800, 1000)];
[htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT", nil),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(800, 1100)];
[_webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
htmlContent = nil;
NSString *textColor = PresentationTheme.current.colors.cellTextColor.toHex;
NSString *backgroundColor = PresentationTheme.current.colors.background.toHex;
NSString *version = [NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT", nil), [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
NSString *versionBuildNumberAndCodeName = [version stringByAppendingFormat:@" (%@)<br /><i>%@</i>", [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"], kVLCVersionCodename];
NSString *vlcLibraryVersion = [NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT", nil),[[VLCLibrary sharedLibrary] version]];
NSString *htmlFilePath = [mainBundle pathForResource:@"About Contents" ofType:@"html"];
NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:htmlFilePath encoding:NSUTF8StringEncoding error:nil];
[htmlContent replaceOccurrencesOfString:@"VLCFORIOSVERSION" withString:versionBuildNumberAndCodeName options:NSLiteralSearch range:NSMakeRange(0, [htmlContent length])];
[htmlContent replaceOccurrencesOfString:@"TEXTCOLOR" withString:textColor options:NSLiteralSearch range:NSMakeRange(0, [htmlContent length])];
[htmlContent replaceOccurrencesOfString:@"BACKGROUNDCOLOR" withString:backgroundColor options:NSLiteralSearch range:NSMakeRange(0, [htmlContent length])];
[htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:vlcLibraryVersion options:NSLiteralSearch range:NSMakeRange(0, [htmlContent length])];
[_webView loadHTMLString:htmlContent baseURL:[NSURL fileURLWithPath:[mainBundle bundlePath]]];
}
- (void)themeDidChange
{
self.view.backgroundColor = PresentationTheme.current.colors.background;
_webView.backgroundColor = PresentationTheme.current.colors.background;
[self loadWebContent];
}
- (BOOL)shouldAutorotate
......@@ -77,7 +98,7 @@
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
_webView.backgroundColor = [UIColor VLCDarkBackgroundColor];
_webView.backgroundColor = PresentationTheme.current.colors.background;
_webView.opaque = YES;
}
......
......@@ -12,7 +12,7 @@
*****************************************************************************/
#import "VLCEqualizerView.h"
#import <MobileVLCKit/MobileVLCKit.h>
extern NSString *const VLCPlaybackControllerPlaybackDidStart;
extern NSString *const VLCPlaybackControllerPlaybackDidPause;
extern NSString *const VLCPlaybackControllerPlaybackDidResume;
......
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