Преглед на файлове

same font-style for files and apps inside the app

do not make the subtitles or filesized appear
sometimes italic and at other places regular.

also avoid using `systemFont`, `boldSystemFont` or `italicSystemFont`
which is covered by the following notice by apple:
"Think carefully before using these methods.
In most cases, a font returned by +preferredFontForTextStyle:
will be more appropriate,
and will respect the user's selected content size category."
B. Petersen преди 2 години
родител
ревизия
bdd21cd012
променени са 3 файла, в които са добавени 4 реда и са изтрити 20 реда
  1. 3 3
      deltachat-ios/Chat/Views/FileView.swift
  2. 0 16
      deltachat-ios/Extensions/Extensions.swift
  3. 1 1
      deltachat-ios/View/Cell/DocumentGalleryFileCell.swift

+ 3 - 3
deltachat-ios/Chat/Views/FileView.swift

@@ -121,7 +121,7 @@ public class FileView: UIView {
 
         fileTitle.numberOfLines = 1
         fileTitle.lineBreakMode = .byTruncatingTail
-        fileTitle.font = UIFont.preferredBoldFont(for: .body)
+        fileTitle.font = UIFont.preferredFont(forTextStyle: .headline)
         fileSubtitle.font = UIFont.preferredFont(forTextStyle: .body)
         fileTitle.text = document.isEmpty ? name : "\(document) – \(name)"
         fileSubtitle.text = summary.isEmpty ? String.localized("webxdc_app") : summary
@@ -137,8 +137,8 @@ public class FileView: UIView {
         }
         fileTitle.numberOfLines = 3
         fileTitle.lineBreakMode = .byCharWrapping
-        fileTitle.font = UIFont.preferredItalicFont(for: .body)
-        fileSubtitle.font = UIFont.preferredItalicFont(for: .caption2)
+        fileTitle.font = UIFont.preferredFont(forTextStyle: .headline)
+        fileSubtitle.font = UIFont.preferredFont(forTextStyle: .caption2)
         fileTitle.text = message.filename
         fileSubtitle.text = message.getPrettyFileSize()
     }

+ 0 - 16
deltachat-ios/Extensions/Extensions.swift

@@ -85,22 +85,6 @@ extension UIFont {
         let metrics = UIFontMetrics(forTextStyle: style)
         return metrics.scaledFont(for: font)
     }
-
-    static func preferredItalicFont(for style: TextStyle) -> UIFont {
-        let traits = UITraitCollection(preferredContentSizeCategory: .large)
-        let desc = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style, compatibleWith: traits)
-        let font = UIFont.italicSystemFont(ofSize: desc.pointSize)
-        let metrics = UIFontMetrics(forTextStyle: style)
-        return metrics.scaledFont(for: font)
-    }
-
-    static func preferredBoldFont(for style: TextStyle) -> UIFont {
-        let traits = UITraitCollection(preferredContentSizeCategory: .large)
-        let desc = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style, compatibleWith: traits)
-        let font = UIFont.boldSystemFont(ofSize: desc.pointSize)
-        let metrics = UIFontMetrics(forTextStyle: style)
-        return metrics.scaledFont(for: font)
-    }
 }
 
 extension UINavigationController {

+ 1 - 1
deltachat-ios/View/Cell/DocumentGalleryFileCell.swift

@@ -37,7 +37,7 @@ class DocumentGalleryFileCell: UITableViewCell {
 
     private lazy var subtitle: UILabel = {
         let subtitle = UILabel()
-        subtitle.font = UIFont.preferredItalicFont(for: .subheadline)
+        subtitle.font = UIFont.preferredFont(forTextStyle: .subheadline)
         subtitle.translatesAutoresizingMaskIntoConstraints = false
         return subtitle
     }()