Skip to content

Commit

Permalink
- More Dynamic Fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
pablocarmu committed Jan 29, 2019
1 parent 447d6be commit 4e8ca5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ownCloud/Theming/NSObject+ThemeApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ extension NSObject {
case .bigMessage:
label.font = UIFont.systemFont(ofSize: 17)

default: break
default:
break
}

switch itemState {
Expand Down
3 changes: 2 additions & 1 deletion ownCloud/Theming/UI/ThemeButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class ThemeButton : UIButton {

private func styleButton() {
self.layer.cornerRadius = 5
self.titleLabel!.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
self.titleLabel!.font = UIFont.preferredFont(forTextStyle: .headline)
self.titleLabel!.adjustsFontForContentSizeCategory = true
}

override init(frame: CGRect) {
Expand Down
15 changes: 10 additions & 5 deletions ownCloud/Viewer/DisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class DisplayViewController: UIViewController {
// MARK: - Views
private var iconImageView: UIImageView!
private var progressView : UIProgressView?
private var cancelButton : UIButton?
private var cancelButton : ThemeButton?
private var metadataInfoLabel: UILabel?
private var showPreviewButton: UIButton?
private var showPreviewButton: ThemeButton?
private var noNetworkLabel : UILabel?

// MARK: - Delegate
Expand Down Expand Up @@ -119,6 +119,8 @@ class DisplayViewController: UIViewController {
metadataInfoLabel?.isHidden = false
metadataInfoLabel?.text = item.sizeLocalized + " - " + item.lastModifiedLocalized
metadataInfoLabel?.textAlignment = .center
metadataInfoLabel?.adjustsFontForContentSizeCategory = true
metadataInfoLabel?.font = UIFont.preferredFont(forTextStyle: .headline)

view.addSubview(metadataInfoLabel!)

Expand All @@ -130,15 +132,15 @@ class DisplayViewController: UIViewController {

view.addSubview(progressView!)

cancelButton = ThemeButton(type: .system)
cancelButton = ThemeButton(type: .custom)
cancelButton?.translatesAutoresizingMaskIntoConstraints = false
cancelButton?.setTitle("Cancel".localized, for: .normal)
cancelButton?.isHidden = (downloadProgress != nil)
cancelButton?.addTarget(self, action: #selector(cancelDownload(sender:)), for: UIControl.Event.touchUpInside)

view.addSubview(cancelButton!)

showPreviewButton = ThemeButton(type: .system)
showPreviewButton = ThemeButton(type: .custom)
showPreviewButton?.translatesAutoresizingMaskIntoConstraints = false
showPreviewButton?.setTitle("Open file".localized, for: .normal)
showPreviewButton?.isHidden = true
Expand All @@ -148,8 +150,10 @@ class DisplayViewController: UIViewController {
noNetworkLabel = UILabel()
noNetworkLabel?.translatesAutoresizingMaskIntoConstraints = false
noNetworkLabel?.isHidden = true
noNetworkLabel?.adjustsFontForContentSizeCategory = true
noNetworkLabel?.text = "There is no network".localized
noNetworkLabel?.textAlignment = .center
noNetworkLabel?.font = UIFont.preferredFont(forTextStyle: .headline)
view.addSubview(noNetworkLabel!)

NSLayoutConstraint.activate([
Expand All @@ -160,7 +164,8 @@ class DisplayViewController: UIViewController {

metadataInfoLabel!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor),
metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: 10),
metadataInfoLabel!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor),
metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 10),
metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -10),

progressView!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor),
progressView!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor),
Expand Down

0 comments on commit 4e8ca5b

Please sign in to comment.