Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from kjantzer/config-tint-color
Browse files Browse the repository at this point in the history
Adding a tintColor variable to config
  • Loading branch information
hebertialmeida committed Jan 13, 2016
2 parents 5196122 + 1b975cb commit 66e4a78
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ViewController: UIViewController {
let config = FolioReaderConfig()
config.shouldHideNavigationOnTap = sampleNum == 1 ? true : false
// config.allowSharing = false
// config.tintColor = UIColor.blueColor()
// config.toolBarTintColor = UIColor.redColor()
// config.toolBarBackgroundColor = UIColor.purpleColor()
// config.menuTextColor = UIColor.brownColor()
Expand Down
12 changes: 6 additions & 6 deletions Source/FolioReaderCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ScrollScrubber: NSObject, UIScrollViewDelegate {

super.init()

let color = readerConfig.toolBarBackgroundColor
let color = readerConfig.tintColor
slider = UISlider()
slider.layer.anchorPoint = CGPoint(x: 0, y: 0)
slider.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
Expand Down Expand Up @@ -303,7 +303,7 @@ class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICollectio

func configureNavBar() {
let navBackground = FolioReader.sharedInstance.nightMode ? readerConfig.nightModeMenuBackground : UIColor.whiteColor()
let tintColor = readerConfig.toolBarBackgroundColor
let tintColor = readerConfig.tintColor
let navText = FolioReader.sharedInstance.nightMode ? UIColor.whiteColor() : UIColor.blackColor()
let font = UIFont(name: "Avenir-Light", size: 17)!
setTranslucentNavigation(color: navBackground, tintColor: tintColor, titleColor: navText, andFont: font)
Expand All @@ -312,9 +312,9 @@ class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICollectio
func configureNavBarButtons() {

// Navbar buttons
let shareIcon = UIImage(readerImageNamed: "btn-navbar-share")!.imageTintColor(readerConfig.toolBarBackgroundColor).imageWithRenderingMode(.AlwaysOriginal)
let audioIcon = UIImage(readerImageNamed: "man-speech-icon")!.imageTintColor(readerConfig.toolBarBackgroundColor).imageWithRenderingMode(.AlwaysOriginal)
let menuIcon = UIImage(readerImageNamed: "btn-navbar-menu")!.imageTintColor(readerConfig.toolBarBackgroundColor).imageWithRenderingMode(.AlwaysOriginal)
let shareIcon = UIImage(readerImageNamed: "btn-navbar-share")!.imageTintColor(readerConfig.tintColor).imageWithRenderingMode(.AlwaysOriginal)
let audioIcon = UIImage(readerImageNamed: "man-speech-icon")!.imageTintColor(readerConfig.tintColor).imageWithRenderingMode(.AlwaysOriginal)
let menuIcon = UIImage(readerImageNamed: "btn-navbar-menu")!.imageTintColor(readerConfig.tintColor).imageWithRenderingMode(.AlwaysOriginal)

navigationItem.leftBarButtonItem = UIBarButtonItem(image: menuIcon, style: UIBarButtonItemStyle.Plain, target: self, action:"toggleMenu:")

Expand Down Expand Up @@ -435,7 +435,7 @@ class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICollectio
var html = try? String(contentsOfFile: resource.fullHref, encoding: NSUTF8StringEncoding)

if readerConfig.mediaOverlayColor == nil {
readerConfig.mediaOverlayColor = readerConfig.toolBarBackgroundColor.highlightColor()
readerConfig.mediaOverlayColor = readerConfig.tintColor.highlightColor()
}

let mediaOverlayStyle = "background: \(readerConfig.mediaOverlayColor.hexString(false)) !important; border-radius: 3px; padding-right: 4px; margin-right: -4px;"
Expand Down
4 changes: 3 additions & 1 deletion Source/FolioReaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit

public class FolioReaderConfig: NSObject {
// Reader Colors
public var tintColor: UIColor!
public var toolBarBackgroundColor: UIColor!
public var toolBarTintColor: UIColor!
public var menuBackgroundColor: UIColor!
Expand Down Expand Up @@ -47,7 +48,8 @@ public class FolioReaderConfig: NSObject {
// MARK: - Init with defaults

public override init() {
self.toolBarBackgroundColor = UIColor(rgba: "#6ACC50")
self.tintColor = UIColor(rgba: "#6ACC50")
self.toolBarBackgroundColor = self.tintColor
self.toolBarTintColor = UIColor.whiteColor()
self.menuBackgroundColor = UIColor(rgba: "#F5F5F5")
self.menuSeparatorColor = UIColor(rgba: "#D7D7D7")
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderFontsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate {
view.addSubview(menuView)

let normalColor = UIColor(white: 0.5, alpha: 0.7)
let selectedColor = readerConfig.toolBarBackgroundColor
let selectedColor = readerConfig.tintColor
let sun = UIImage(readerImageNamed: "icon-sun")
let moon = UIImage(readerImageNamed: "icon-moon")
let fontSmall = UIImage(readerImageNamed: "icon-font-small")
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderHighlightList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FolioReaderHighlightList: UITableViewController {

func configureNavBar() {
let navBackground = FolioReader.sharedInstance.nightMode ? readerConfig.nightModeMenuBackground : UIColor.whiteColor()
let tintColor = readerConfig.toolBarBackgroundColor
let tintColor = readerConfig.tintColor
let navText = FolioReader.sharedInstance.nightMode ? UIColor.whiteColor() : UIColor.blackColor()
let font = UIFont(name: "Avenir-Light", size: 17)!
setTranslucentNavigation(color: navBackground, tintColor: tintColor, titleColor: navText, andFont: font)
Expand Down
6 changes: 3 additions & 3 deletions Source/FolioReaderPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGestureRecogni

if #available(iOS 9.0, *) {
let safariVC = SFSafariViewController(URL: request.URL!)
safariVC.view.tintColor = readerConfig.toolBarBackgroundColor
safariVC.view.tintColor = readerConfig.tintColor
FolioReader.sharedInstance.readerCenter.presentViewController(safariVC, animated: true, completion: nil)
} else {
let webViewController = WebViewController(url: request.URL!)
let nav = UINavigationController(rootViewController: webViewController)
nav.view.tintColor = readerConfig.toolBarBackgroundColor
nav.view.tintColor = readerConfig.tintColor
FolioReader.sharedInstance.readerCenter.presentViewController(nav, animated: true, completion: nil)
}

Expand Down Expand Up @@ -413,7 +413,7 @@ extension UIWebView {
userInteractionEnabled = true

let vc = UIReferenceLibraryViewController(term: selectedText! )
vc.view.tintColor = readerConfig.toolBarBackgroundColor
vc.view.tintColor = readerConfig.tintColor
FolioReader.sharedInstance.readerContainer.showViewController(vc, sender: nil)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderPlayerMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FolioReaderPlayerMenu: UIViewController, SMSegmentViewDelegate {


let normalColor = UIColor(white: 0.5, alpha: 0.7)
let selectedColor = readerConfig.toolBarBackgroundColor
let selectedColor = readerConfig.tintColor
let size = 55
let padX = 32
// @NOTE: could this be improved/simplified with autolayout?
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderSidePanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class FolioReaderSidePanel: UIViewController, UITableViewDelegate, UITableViewDa
// Mark current reading chapter
if let currentPageNumber = currentPageNumber {
if let resource = book.spine.spineReferences[currentPageNumber-1].resource {
cell.indexLabel.textColor = tocReference.resource.href == resource.href ? readerConfig.toolBarBackgroundColor : readerConfig.menuTextColor
cell.indexLabel.textColor = tocReference.resource.href == resource.href ? readerConfig.tintColor : readerConfig.menuTextColor
}
}

Expand Down

0 comments on commit 66e4a78

Please sign in to comment.