From 4e8ca5b4f302b392018d7a136278ab5dbad77514 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Tue, 29 Jan 2019 08:28:57 +0100 Subject: [PATCH] - More Dynamic Fonts --- ownCloud/Theming/NSObject+ThemeApplication.swift | 3 ++- ownCloud/Theming/UI/ThemeButton.swift | 3 ++- ownCloud/Viewer/DisplayViewController.swift | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ownCloud/Theming/NSObject+ThemeApplication.swift b/ownCloud/Theming/NSObject+ThemeApplication.swift index 5a3c0b287..0532d7a38 100644 --- a/ownCloud/Theming/NSObject+ThemeApplication.swift +++ b/ownCloud/Theming/NSObject+ThemeApplication.swift @@ -154,7 +154,8 @@ extension NSObject { case .bigMessage: label.font = UIFont.systemFont(ofSize: 17) - default: break + default: + break } switch itemState { diff --git a/ownCloud/Theming/UI/ThemeButton.swift b/ownCloud/Theming/UI/ThemeButton.swift index dd92b83e0..9bba19174 100644 --- a/ownCloud/Theming/UI/ThemeButton.swift +++ b/ownCloud/Theming/UI/ThemeButton.swift @@ -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) { diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index 9374cfcb8..e55d5f033 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -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 @@ -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!) @@ -130,7 +132,7 @@ 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) @@ -138,7 +140,7 @@ class DisplayViewController: UIViewController { view.addSubview(cancelButton!) - showPreviewButton = ThemeButton(type: .system) + showPreviewButton = ThemeButton(type: .custom) showPreviewButton?.translatesAutoresizingMaskIntoConstraints = false showPreviewButton?.setTitle("Open file".localized, for: .normal) showPreviewButton?.isHidden = true @@ -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([ @@ -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),