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

Commit

Permalink
Removed deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hebertialmeida committed Feb 12, 2018
1 parent fe3f81a commit 8e3a2db
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 269 deletions.
4 changes: 2 additions & 2 deletions FolioReaderKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@
isa = PBXGroup;
children = (
1A958F041D397BE900D56699 /* EPUBCore */,
1A958F1D1D397BE900D56699 /* Models */,
1A958F251D397BE900D56699 /* Resources */,
3A27F08B1FD9BE5800D84A57 /* Extensions.swift */,
1A958F0F1D397BE900D56699 /* FolioReaderAudioPlayer.swift */,
1A958F101D397BE900D56699 /* FolioReaderCenter.swift */,
Expand All @@ -253,10 +255,8 @@
1A958F1C1D397BE900D56699 /* FolioReaderSharingProvider.swift */,
3A27F08A1FD9BE5800D84A57 /* FolioReaderUserDefaults.swift */,
3AD5EEB81D9433C100E42810 /* FolioReaderWebView.swift */,
1A958F1D1D397BE900D56699 /* Models */,
1A958F241D397BE900D56699 /* PageViewController.swift */,
1A65DDD41DA744410033C277 /* QuoteImage.swift */,
1A958F251D397BE900D56699 /* Resources */,
1A958F901D397BE900D56699 /* ScrollScrubber.swift */,
);
path = Source;
Expand Down
98 changes: 0 additions & 98 deletions Source/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,121 +10,44 @@ import Foundation
import UIKit

extension UICollectionViewScrollDirection {

@available(*, deprecated, message: "Use 'direction(withConfiguration:)' instead.")
static func direction() -> UICollectionViewScrollDirection {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return .vertical
}

return UICollectionViewScrollDirection.direction(withConfiguration: readerConfig)
}

static func direction(withConfiguration readerConfig: FolioReaderConfig) -> UICollectionViewScrollDirection {
return readerConfig.isDirection(.vertical, .horizontal, .horizontal)
}
}

extension UICollectionViewScrollPosition {

@available(*, deprecated, message: "Use 'direction(withConfiguration:)' instead.")
static func direction() -> UICollectionViewScrollPosition {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return .top
}

return UICollectionViewScrollPosition.direction(withConfiguration: readerConfig)
}

static func direction(withConfiguration readerConfig: FolioReaderConfig) -> UICollectionViewScrollPosition {
return readerConfig.isDirection(.top, .left, .left)
}
}

extension CGPoint {

@available(*, deprecated, message: "Use 'forDirection(withConfiguration:)' instead.")
func forDirection() -> CGFloat {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.y
}

return self.forDirection(withConfiguration: readerConfig)
}

func forDirection(withConfiguration readerConfig: FolioReaderConfig, scrollType: ScrollType = .page) -> CGFloat {
return readerConfig.isDirection(self.y, self.x, ((scrollType == .page) ? self.y : self.x))
}
}

extension CGSize {

@available(*, deprecated, message: "Use 'forDirection(withConfiguration:)' instead.")
func forDirection() -> CGFloat {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.height
}
return self.forDirection(withConfiguration: readerConfig)
}

func forDirection(withConfiguration readerConfig: FolioReaderConfig) -> CGFloat {
return readerConfig.isDirection(height, width, height)
}

@available(*, deprecated, message: "Use 'forReverseDirection(withConfiguration:)' instead.")
func forReverseDirection() -> CGFloat {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.width
}

return self.forReverseDirection(withConfiguration: readerConfig)
}

func forReverseDirection(withConfiguration readerConfig: FolioReaderConfig) -> CGFloat {
return readerConfig.isDirection(width, height, width)
}
}

extension CGRect {

@available(*, deprecated, message: "Use 'forDirection(withConfiguration:)' instead.")
func forDirection() -> CGFloat {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.height
}

return self.forDirection(withConfiguration: readerConfig)
}

func forDirection(withConfiguration readerConfig: FolioReaderConfig) -> CGFloat {
return readerConfig.isDirection(height, width, height)
}
}

extension ScrollDirection {

@available(*, deprecated, message: "Use 'negative(withConfiguration:)' instead.")
static func negative() -> ScrollDirection {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.down
}

return self.negative(withConfiguration: readerConfig)
}

static func negative(withConfiguration readerConfig: FolioReaderConfig, scrollType: ScrollType = .page) -> ScrollDirection {
return readerConfig.isDirection(.down, .right, .right)
}

@available(*, deprecated, message: "Use 'positive(withConfiguration:)' instead.")
static func positive() -> ScrollDirection {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return self.up
}

return self.positive(withConfiguration: readerConfig)
}

static func positive(withConfiguration readerConfig: FolioReaderConfig, scrollType: ScrollType = .page) -> ScrollDirection {
return readerConfig.isDirection(.up, .left, .left)
}
Expand Down Expand Up @@ -416,18 +339,6 @@ internal extension UIImage {
self.init(named: readerImageNamed, in: Bundle.frameworkBundle(), compatibleWith: nil)
}

/// Forces the image to be colored with Reader Config tintColor
///
/// - Returns: Returns a colored image
@available(*, deprecated, message: "Use 'ignoreSystemTint(withConfiguration:)' instead.")
func ignoreSystemTint() -> UIImage? {
guard let readerConfig = FolioReader.shared.readerContainer?.readerConfig else {
return nil
}

return self.ignoreSystemTint(withConfiguration: readerConfig)
}

/// Forces the image to be colored with Reader Config tintColor
///
/// - Parameter readerConfig: Current folio reader configuration.
Expand Down Expand Up @@ -519,15 +430,6 @@ internal extension UIImage {

internal extension UIViewController {

@available(*, deprecated, message: "Use 'setCloseButton(withConfiguration:)' instead.")
func setCloseButton() {
guard let config = FolioReader.shared.readerContainer?.readerConfig else {
return
}

self.setCloseButton(withConfiguration: config)
}

func setCloseButton(withConfiguration readerConfig: FolioReaderConfig) {
let closeImage = UIImage(readerImageNamed: "icon-navbar-close")?.ignoreSystemTint(withConfiguration: readerConfig)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: closeImage, style: .plain, target: self, action: #selector(dismiss as () -> Void))
Expand Down
6 changes: 0 additions & 6 deletions Source/FolioReaderContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ open class FolioReaderContainer: UIViewController {

// Configure the folio reader.
self.folioReader.readerContainer = self

// Set the shared instance to support old version.
FolioReader.shared = self.folioReader
}

/// Common Initialization
Expand Down Expand Up @@ -109,9 +106,6 @@ open class FolioReaderContainer: UIViewController {
self.epubPath = path
self.unzipPath = unzipPath
self.shouldRemoveEpub = removeEpub

// Set the shared instance to support old version.
FolioReader.shared = self.folioReader
}

// MARK: - View life cicle
Expand Down
92 changes: 0 additions & 92 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ extension FolioReader {
self.readerContainer = readerContainer
parentViewController.present(readerContainer, animated: animated, completion: nil)
addObservers()

// Set the shared instance to support old version.
FolioReader.shared = self
}
}

Expand Down Expand Up @@ -363,94 +360,5 @@ extension FolioReader {
self.readerAudioPlayer?.stop(immediate: true)
self.defaults.set(0, forKey: kCurrentTOCMenu)
self.delegate?.folioReaderDidClose?(self)
self.delegate?.folioReaderDidClosed?()
}
}

// MARK: - Public static functions. All Deprecated function

@available(*, deprecated, message: "Shared instance removed. Use a local instance instead.")
extension FolioReader {

private static var _sharedInstance = FolioReader()
open static var shared : FolioReader {
get { return _sharedInstance }
set { _sharedInstance = newValue }
}

/// Check the current Media Overlay or TTS style
static var currentMediaOverlayStyle: MediaOverlayStyle {
return FolioReader.shared.currentMediaOverlayStyle
}

/// Check if current theme is Night mode
open class var nightMode: Bool {
get { return FolioReader.shared.nightMode }
set { FolioReader.shared.nightMode = newValue }
}

/// Check current font name
open class var currentFont: FolioReaderFont {
get { return FolioReader.shared.currentFont }
set { FolioReader.shared.currentFont = newValue }
}

/// Check current font size
open class var currentFontSize: FolioReaderFontSize {
get { return FolioReader.shared.currentFontSize }
set { FolioReader.shared.currentFontSize = newValue }
}

/// Check the current scroll direction
open class var currentScrollDirection: Int {
get { return FolioReader.shared.currentScrollDirection }
set { FolioReader.shared.currentScrollDirection = newValue }
}

/// Check current audio rate, the speed of speech voice
open class var currentAudioRate: Int {
get { return FolioReader.shared.currentAudioRate }
set { FolioReader.shared.currentAudioRate = newValue }
}

/// Check if reader is open and ready
open class var isReaderReady : Bool {
return FolioReader.shared.isReaderReady
}

/// Save Reader state, book, page and scroll are saved
@available(*, deprecated, message: "You no longer need to call `saveReaderState` for `applicationWillResignActive` and `applicationWillTerminate`. FolioReader Already handle that.")
open class func saveReaderState() {
FolioReader.shared.saveReaderState()
}

/// Closes and save the reader current instance
open class func close() {
FolioReader.shared.close()
}

/// Check the current highlight style
open class var currentHighlightStyle: Int {
get { return FolioReader.shared.currentHighlightStyle }
set { FolioReader.shared.currentHighlightStyle = newValue }
}

/// Check if layout needs to change to fit Right To Left
open class var needsRTLChange: Bool {
return FolioReader.shared.needsRTLChange
}
}

// MARK: - Global Functions

@available(*, deprecated, message: "Shared instance removed. Use a local instance instead.")
func isNight<T> (_ f: T, _ l: T) -> T {
return FolioReader.shared.isNight(f, l)
}

// MARK: - Scroll Direction Functions

@available(*, deprecated, message: "Shared instance removed. Use a local instance instead.")
func isDirection<T> (_ vertical: T, _ horizontal: T, _ horizontalContentVertical: T) -> T {
return FolioReader.shared.readerContainer!.readerConfig.isDirection(vertical, horizontal, horizontalContentVertical)
}
71 changes: 0 additions & 71 deletions Source/Models/Highlight+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,77 +199,6 @@ extension Highlight {
}
}

// MARK: - Static functions

extension Highlight {

@available(*, deprecated, message: "Shared instance removed. Use a local instance instead.")
private static var readerConfig : FolioReaderConfig {
return FolioReader.shared.readerContainer!.readerConfig
}

/// Save a Highlight with completion block
///
/// - Parameter completion: Completion block
@available(*, deprecated, message: "Use 'persist(withConfiguration:completion:)' instead.")
public func persist(_ completion: Completion? = nil) {
self.persist(withConfiguration: Highlight.readerConfig, completion: completion)
}

/// Return all Highlights
///
/// - Returns: Return all Highlights
@available(*, deprecated, message: "Use 'all(withConfiguration:)' instead.")
public static func all() -> [Highlight] {
return Highlight.all(withConfiguration: Highlight.readerConfig)
}

/// Return a list of Highlights with a given ID
///
/// - Parameters:
/// - bookId: Book ID
/// - page: Page number
/// - Returns: Return a list of Highlights
@available(*, deprecated, message: "Use 'allByBookId(withConfiguration:bookId:andPage:)' instead.")
public static func allByBookId(_ bookId: String, andPage page: NSNumber? = nil) -> [Highlight] {
return Highlight.allByBookId(withConfiguration: Highlight.readerConfig, bookId: bookId, andPage: page)
}

/// Update a Highlight by ID
///
/// - Parameters:
/// - highlightId: The ID to be removed
/// - type: The `HighlightStyle`
@available(*, deprecated, message: "Use 'updateById(withConfiguration:highlightId:type:)' instead.")
public static func updateById(_ highlightId: String, type: HighlightStyle) {
Highlight.updateById(withConfiguration: Highlight.readerConfig, highlightId: highlightId, type: type)
}

/// Remove a Highlight by ID
///
/// - Parameter highlightId: The ID to be removed
@available(*, deprecated, message: "Use 'removeById(withConfiguration:highlightId:)' instead.")
public static func removeById(_ highlightId: String) {
Highlight.removeById(withConfiguration: Highlight.readerConfig, highlightId: highlightId)
}

/// Remove a Highlight
@available(*, deprecated, message: "Use 'remove(withConfiguration:)' instead.")
public func remove() {
self.remove(withConfiguration: Highlight.readerConfig)
}

/// Remove a Highlight from HTML by ID
///
/// - Parameter highlightId: The ID to be removed
/// - Returns: The removed id
@available(*, deprecated, message: "Use 'removeFromHTMLById(withinPage:highlightId:)' instead.")
@discardableResult public static func removeFromHTMLById(_ highlightId: String) -> String? {
let page = FolioReader.shared.readerCenter?.currentPage
return self.removeFromHTMLById(withinPage: page, highlightId: highlightId)
}
}

// MARK: - HTML Methods

extension Highlight {
Expand Down

0 comments on commit 8e3a2db

Please sign in to comment.