-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also refactored report text styles to an extension in a separate file
- Loading branch information
Showing
3 changed files
with
106 additions
and
82 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// ReportStyles.swift | ||
// | ||
// | ||
// Created by Quinn McHenry on 6/18/20. | ||
// | ||
|
||
import UIKit | ||
|
||
extension Report { | ||
|
||
var title1: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .center | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .largeTitle), | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var title2: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .title1), | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var title3: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .title2), | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var body: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
style.lineBreakMode = .byWordWrapping | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body), | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var unispacedBody: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
style.lineBreakMode = .byWordWrapping | ||
let font = UIFont(name: "Menlo-Regular", size: 12) ?? UIFont.systemFont(ofSize: 12, weight: .regular) | ||
return [NSAttributedString.Key.font: font, | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var detail: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
style.lineBreakMode = .byWordWrapping | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption1), | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var warning: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body), | ||
NSAttributedString.Key.foregroundColor: UIColor.black, | ||
NSAttributedString.Key.backgroundColor: UIColor.yellow, | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
var error: [NSAttributedString.Key: Any] { | ||
let style = NSMutableParagraphStyle() | ||
style.alignment = .left | ||
return [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body), | ||
NSAttributedString.Key.foregroundColor: UIColor.white, | ||
NSAttributedString.Key.backgroundColor: UIColor.red, | ||
NSAttributedString.Key.paragraphStyle: style] | ||
} | ||
|
||
func style(severity: QAFindingSeverity) -> [NSAttributedString.Key: Any] { | ||
if case QAFindingSeverity.error = severity { | ||
return error | ||
} | ||
return warning | ||
} | ||
|
||
func color(severity: QAFindingSeverity) -> UIColor { | ||
if case QAFindingSeverity.error = severity { | ||
return UIColor.red | ||
} | ||
return UIColor.yellow | ||
} | ||
|
||
} | ||
|
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