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

Commit

Permalink
Add custom Navigation bar color config (#381)
Browse files Browse the repository at this point in the history
* add config

* fix navbar color playerMenu, QuoteShare
  • Loading branch information
illwss authored and hebertialmeida committed Jul 8, 2019
1 parent 01b6966 commit dc13fb1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Source/FolioReaderCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
}

func configureNavBar() {
let navBackground = folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white)
let navBackground = folioReader.isNight(self.readerConfig.nightModeNavBackground, self.readerConfig.daysModeNavBackground)
let tintColor = readerConfig.tintColor
let navText = folioReader.isNight(UIColor.white, UIColor.black)
let font = UIFont(name: "Avenir-Light", size: 17)!
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderChapterList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class FolioReaderChapterList: UITableViewController {
let reference = self.book.spine.spineReferences[safe: currentPageNumber - 1],
(tocReference.resource != nil) {
let resource = reference.resource
cell.indexLabel?.textColor = (tocReference.resource == resource ? self.readerConfig.tintColor : self.readerConfig.menuTextColor)
cell.indexLabel?.textColor = (tocReference.resource == resource ? self.readerConfig.menuTextColorSelected : self.readerConfig.menuTextColor)
}

cell.layoutMargins = UIEdgeInsets.zero
Expand Down
12 changes: 12 additions & 0 deletions Source/FolioReaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ open class FolioReaderConfig: NSObject {
/// Menu text color
open var menuTextColor = UIColor(rgba: "#767676")

/// Menu text color
open var menuTextColorSelected = UIColor(rgba: "#6ACC50")

// Day mode nav color
open var daysModeNavBackground = UIColor.white

// Day mode nav color
open var nightModeNavBackground = UIColor(rgba: "#131313")

/// Night mode background color
open var nightModeBackground = UIColor(rgba: "#131313")

Expand All @@ -132,6 +141,9 @@ open class FolioReaderConfig: NSObject {
/// Enable or disable hability to user change scroll direction on menu.
open var canChangeScrollDirection = true

/// Enable or disable hability to user change font style on menu.
open var canChangeFontStyle = true

/// Should hide navigation bar on user tap
open var shouldHideNavigationOnTap = true

Expand Down
8 changes: 5 additions & 3 deletions Source/FolioReaderFontsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate, UIGestureRe
view.addGestureRecognizer(tapGesture)

// Menu view
let visibleHeight: CGFloat = self.readerConfig.canChangeScrollDirection ? 222 : 170
var visibleHeight: CGFloat = self.readerConfig.canChangeScrollDirection ? 222 : 170
visibleHeight = self.readerConfig.canChangeFontStyle ? visibleHeight : visibleHeight - 55
menuView = UIView(frame: CGRect(x: 0, y: view.frame.height-visibleHeight, width: view.frame.width, height: view.frame.height))
menuView.backgroundColor = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white)
menuView.autoresizingMask = .flexibleWidth
Expand Down Expand Up @@ -151,7 +152,8 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate, UIGestureRe
menuView.addSubview(line)

// Fonts adjust
let fontName = SMSegmentView(frame: CGRect(x: 15, y: line.frame.height+line.frame.origin.y, width: view.frame.width-30, height: 55),
let fontNameHeight: CGFloat = self.readerConfig.canChangeFontStyle ? 55: 0
let fontName = SMSegmentView(frame: CGRect(x: 15, y: line.frame.height+line.frame.origin.y, width: view.frame.width-30, height: fontNameHeight),
separatorColour: UIColor.clear,
separatorWidth: 0,
segmentProperties: [
Expand Down Expand Up @@ -277,7 +279,7 @@ class FolioReaderFontsMenu: UIViewController, SMSegmentViewDelegate, UIGestureRe
self.folioReader.nightMode = Bool(index == 1)

UIView.animate(withDuration: 0.6, animations: {
self.menuView.backgroundColor = (self.folioReader.nightMode ? self.readerConfig.nightModeBackground : UIColor.white)
self.menuView.backgroundColor = (self.folioReader.nightMode ? self.readerConfig.nightModeBackground : self.readerConfig.daysModeNavBackground)
})

} else if segmentView.tag == 2 {
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, UIGestureR

// Menu view
menuView = UIView(frame: CGRect(x: 0, y: view.frame.height-165, width: view.frame.width, height: view.frame.height))
menuView.backgroundColor = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white)
menuView.backgroundColor = self.folioReader.isNight(self.readerConfig.nightModeNavBackground, self.readerConfig.daysModeNavBackground)
menuView.autoresizingMask = .flexibleWidth
menuView.layer.shadowColor = UIColor.black.cgColor
menuView.layer.shadowOffset = CGSize(width: 0, height: 0)
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderQuoteShare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class FolioReaderQuoteShare: UIViewController {
}

func configureNavBar() {
let navBackground = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white)
let navBackground = self.folioReader.isNight(self.readerConfig.nightModeNavBackground, self.readerConfig.daysModeNavBackground)
let tintColor = self.readerConfig.tintColor
let navText = self.folioReader.isNight(UIColor.white, UIColor.black)
let font = UIFont(name: "Avenir-Light", size: 17)!
Expand Down
2 changes: 1 addition & 1 deletion Source/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PageViewController: UIPageViewController {
}

func configureNavBar() {
let navBackground = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground, UIColor.white)
let navBackground = self.folioReader.isNight(self.readerConfig.nightModeMenuBackground,self.readerConfig.daysModeNavBackground)
let tintColor = self.readerConfig.tintColor
let navText = self.folioReader.isNight(UIColor.white, UIColor.black)
let font = UIFont(name: "Avenir-Light", size: 17)!
Expand Down

0 comments on commit dc13fb1

Please sign in to comment.