Commit f0d2b907 by Orkhan Alikhanov

Moved hard-coded RobotoFont to Theme.font

parent 0b1d7707
...@@ -233,7 +233,7 @@ private extension DialogView { ...@@ -233,7 +233,7 @@ private extension DialogView {
/// Prepares titleTitle. /// Prepares titleTitle.
func prepareTitleLabel() { func prepareTitleLabel() {
titleArea.addSubview(titleLabel) titleArea.addSubview(titleLabel)
titleLabel.font = RobotoFont.bold(with: 20) titleLabel.font = Theme.font.bold(with: 20)
titleLabel.textColor = Color.darkText.primary titleLabel.textColor = Color.darkText.primary
titleLabel.numberOfLines = 0 titleLabel.numberOfLines = 0
} }
...@@ -250,7 +250,7 @@ private extension DialogView { ...@@ -250,7 +250,7 @@ private extension DialogView {
func prepareButtons() { func prepareButtons() {
[positiveButton, negativeButton, neutralButton].forEach { [positiveButton, negativeButton, neutralButton].forEach {
buttonArea.addSubview($0) buttonArea.addSubview($0)
$0.titleLabel?.font = RobotoFont.medium(with: 14) $0.titleLabel?.font = Theme.font.medium(with: 14)
$0.contentEdgeInsets = Constants.button.insets $0.contentEdgeInsets = Constants.button.insets
$0.cornerRadiusPreset = .cornerRadius1 $0.cornerRadiusPreset = .cornerRadius1
} }
......
...@@ -251,7 +251,7 @@ private extension Editor { ...@@ -251,7 +251,7 @@ private extension Editor {
/// Prepares the detailLabel. /// Prepares the detailLabel.
func prepareDetailLabel() { func prepareDetailLabel() {
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = Theme.font.regular(with: 12)
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
detailColor = Color.darkText.others detailColor = Color.darkText.others
addSubview(detailLabel) addSubview(detailLabel)
......
...@@ -83,7 +83,7 @@ open class ErrorTextField: TextField { ...@@ -83,7 +83,7 @@ open class ErrorTextField: TextField {
/// Prepares the errorLabel. /// Prepares the errorLabel.
func prepareErrorLabel() { func prepareErrorLabel() {
errorLabel.font = RobotoFont.regular(with: 12) errorLabel.font = Theme.font.regular(with: 12)
errorLabel.numberOfLines = 0 errorLabel.numberOfLines = 0
errorColor = { errorColor }() // call didSet errorColor = { errorColor }() // call didSet
addSubview(errorLabel) addSubview(errorLabel)
......
...@@ -129,7 +129,7 @@ extension FABMenuItem { ...@@ -129,7 +129,7 @@ extension FABMenuItem {
/// Prepares the titleLabel. /// Prepares the titleLabel.
fileprivate func prepareTitleLabel() { fileprivate func prepareTitleLabel() {
titleLabel.font = RobotoFont.regular(with: 14) titleLabel.font = Theme.font.regular(with: 14)
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
titleLabel.backgroundColor = .white titleLabel.backgroundColor = .white
titleLabel.depthPreset = fabButton.depthPreset titleLabel.depthPreset = fabButton.depthPreset
......
...@@ -30,7 +30,28 @@ ...@@ -30,7 +30,28 @@
import UIKit import UIKit
public protocol FontType {} public protocol FontType {
/**
Regular with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static func regular(with size: CGFloat) -> UIFont
/**
Medium with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static func medium(with size: CGFloat) -> UIFont
/**
Bold with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static func bold(with size: CGFloat) -> UIFont
}
public struct Font { public struct Font {
/// Size of font. /// Size of font.
......
...@@ -213,7 +213,7 @@ fileprivate extension SearchBar { ...@@ -213,7 +213,7 @@ fileprivate extension SearchBar {
/// Prepares the textField. /// Prepares the textField.
func prepareTextField() { func prepareTextField() {
textField.contentScaleFactor = Screen.scale textField.contentScaleFactor = Screen.scale
textField.font = RobotoFont.regular(with: 17) textField.font = Theme.font.regular(with: 17)
textField.backgroundColor = Color.clear textField.backgroundColor = Color.clear
textField.clearButtonMode = .whileEditing textField.clearButtonMode = .whileEditing
textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged) textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged)
......
...@@ -104,7 +104,7 @@ open class Snackbar: Bar { ...@@ -104,7 +104,7 @@ open class Snackbar: Bar {
/// Prepares the textLabel. /// Prepares the textLabel.
private func prepareTextLabel() { private func prepareTextLabel() {
textLabel.contentScaleFactor = Screen.scale textLabel.contentScaleFactor = Screen.scale
textLabel.font = RobotoFont.medium(with: 14) textLabel.font = Theme.font.medium(with: 14)
textLabel.textAlignment = .left textLabel.textAlignment = .left
textLabel.textColor = .white textLabel.textColor = .white
textLabel.numberOfLines = 0 textLabel.numberOfLines = 0
......
...@@ -450,7 +450,7 @@ open class TextField: UITextField, Themeable { ...@@ -450,7 +450,7 @@ open class TextField: UITextField, Themeable {
borderStyle = .none borderStyle = .none
backgroundColor = nil backgroundColor = nil
contentScaleFactor = Screen.scale contentScaleFactor = Screen.scale
font = RobotoFont.regular(with: 16) font = Theme.font.regular(with: 16)
textColor = Color.darkText.primary textColor = Color.darkText.primary
prepareDivider() prepareDivider()
...@@ -496,7 +496,7 @@ fileprivate extension TextField { ...@@ -496,7 +496,7 @@ fileprivate extension TextField {
/// Prepares the detailLabel. /// Prepares the detailLabel.
func prepareDetailLabel() { func prepareDetailLabel() {
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = Theme.font.regular(with: 12)
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
detailColor = Color.darkText.others detailColor = Color.darkText.others
addSubview(detailLabel) addSubview(detailLabel)
......
...@@ -283,7 +283,7 @@ open class TextView: UITextView, Themeable { ...@@ -283,7 +283,7 @@ open class TextView: UITextView, Themeable {
contentScaleFactor = Screen.scale contentScaleFactor = Screen.scale
textContainerInset = .zero textContainerInset = .zero
backgroundColor = nil backgroundColor = nil
font = RobotoFont.regular(with: 16) font = Theme.font.regular(with: 16)
textColor = Color.darkText.primary textColor = Color.darkText.primary
prepareNotificationHandlers() prepareNotificationHandlers()
......
...@@ -77,6 +77,9 @@ public struct Theme: Hashable { ...@@ -77,6 +77,9 @@ public struct Theme: Hashable {
/// A boolean indicating if theming is enabled globally. /// A boolean indicating if theming is enabled globally.
public static var isEnabled = true public static var isEnabled = true
/// Global font for app.
public static var font: FontType.Type = RobotoFont.self
/// An initializer. /// An initializer.
public init() { } public init() { }
} }
......
...@@ -184,7 +184,7 @@ private extension Toolbar { ...@@ -184,7 +184,7 @@ private extension Toolbar {
func prepareTitleLabel() { func prepareTitleLabel() {
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
titleLabel.contentScaleFactor = Screen.scale titleLabel.contentScaleFactor = Screen.scale
titleLabel.font = RobotoFont.medium(with: 17) titleLabel.font = Theme.font.medium(with: 17)
titleLabel.textColor = Color.darkText.primary titleLabel.textColor = Color.darkText.primary
titleLabelTextAlignmentObserver = titleLabel.observe(\.textAlignment) { [weak self] titleLabel, _ in titleLabelTextAlignmentObserver = titleLabel.observe(\.textAlignment) { [weak self] titleLabel, _ in
self?.contentViewAlignment = .center == titleLabel.textAlignment ? .center : .full self?.contentViewAlignment = .center == titleLabel.textAlignment ? .center : .full
...@@ -195,7 +195,7 @@ private extension Toolbar { ...@@ -195,7 +195,7 @@ private extension Toolbar {
func prepareDetailLabel() { func prepareDetailLabel() {
detailLabel.textAlignment = .center detailLabel.textAlignment = .center
detailLabel.contentScaleFactor = Screen.scale detailLabel.contentScaleFactor = Screen.scale
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = Theme.font.regular(with: 12)
detailLabel.textColor = Color.darkText.secondary detailLabel.textColor = Color.darkText.secondary
} }
......
...@@ -45,6 +45,7 @@ open class ViewController: UIViewController, Themeable { ...@@ -45,6 +45,7 @@ open class ViewController: UIViewController, Themeable {
*/ */
open func prepare() { open func prepare() {
view.clipsToBounds = true view.clipsToBounds = true
view.backgroundColor = .white
view.contentScaleFactor = Screen.scale view.contentScaleFactor = Screen.scale
applyCurrentTheme() applyCurrentTheme()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment