-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved public pagination structures to directory API (#378)
- Loading branch information
Showing
9 changed files
with
111 additions
and
121 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// PDFPagination.swift | ||
// TPPDF | ||
// | ||
// Created by Philip Niedertscheider on 11/08/2017. | ||
// | ||
|
||
#if os(iOS) | ||
import UIKit | ||
#elseif os(macOS) | ||
import AppKit | ||
#endif | ||
|
||
/** | ||
* Structure used to configure the pagination | ||
*/ | ||
public struct PDFPagination { | ||
/// Container where the pagination will be placed | ||
public var container: PDFContainer | ||
|
||
/// Style of the pagination | ||
public var style: PDFPaginationStyle | ||
|
||
/** | ||
* Range of pages which will be paginated | ||
* | ||
* This range starts at zero | ||
*/ | ||
public var range: (start: Int, end: Int) | ||
|
||
/** | ||
* Add a page number to this list to exclude it from the pagination | ||
* | ||
* This will not skip the page but instead not render the pagination object | ||
*/ | ||
public var hiddenPages: [Int] | ||
|
||
/** | ||
* Text attribtues are used to create the attributed pagination string | ||
* | ||
* See ``NSAttributedString`` for reference | ||
*/ | ||
public var textAttributes: [NSAttributedString.Key: Any] | ||
|
||
/** | ||
* Creates a new pagination configuration | ||
* | ||
* - Parameters; | ||
* - container: Container where pagination is placed, defaults to `PDFContainer.none`, meaning it won't be rendered | ||
* - style: Style of pagination | ||
* - range: Start and end of pages which will be included | ||
* - hiddenPages: List of numbers which are excluded from rendering | ||
*/ | ||
public init( | ||
container: PDFContainer = .none, | ||
style: PDFPaginationStyle = .default, | ||
range: (start: Int, end: Int) = (0, Int.max), | ||
hiddenPages: [Int] = [], | ||
textAttributes: [NSAttributedString.Key: Any] = [:] | ||
) { | ||
self.container = container | ||
self.style = style | ||
self.range = range | ||
self.hiddenPages = hiddenPages | ||
self.textAttributes = textAttributes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// PDFPaginationClosure.swift | ||
// TPPDF | ||
// | ||
// Created by Philip Niedertscheider on 04/11/2017. | ||
// | ||
|
||
/** | ||
* Closure for custom pagination formatting. | ||
* | ||
* - Parameter page: `Int` - Current page number | ||
* - Parameter total: `Int` - Total amount of pages | ||
* | ||
* - Returns: Formatted pagination string | ||
*/ | ||
public typealias PDFPaginationClosure = (_ page: Int, _ total: Int) -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters