diff --git a/Mastodon/Scene/Settings/Server Details/AboutInstanceViewController.swift b/Mastodon/Scene/Settings/Server Details/AboutInstanceViewController.swift index 7fc54209f8c..e7d7fb520ea 100644 --- a/Mastodon/Scene/Settings/Server Details/AboutInstanceViewController.swift +++ b/Mastodon/Scene/Settings/Server Details/AboutInstanceViewController.swift @@ -86,12 +86,14 @@ class AboutInstanceViewController: UIViewController { super.viewWillLayoutSubviews() if let tableHeaderView = tableView.tableHeaderView { - tableHeaderView.frame.size = tableHeaderView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) + let size = tableHeaderView.systemLayoutSizeFitting(.init(width: self.tableView.frame.width, height: 10_000)) + tableHeaderView.frame.size = size tableView.tableHeaderView = tableHeaderView } if let tableFooterView = tableView.tableFooterView { - tableFooterView.frame.size = tableFooterView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) + let size = tableFooterView.systemLayoutSizeFitting(.init(width: self.tableView.frame.width, height: 10_000)) + tableFooterView.frame.size = size tableView.tableFooterView = tableFooterView } @@ -119,11 +121,10 @@ class AboutInstanceViewController: UIViewController { DispatchQueue.main.async { self.headerView.updateImage(with: thumbnailUrl) { [weak self] in DispatchQueue.main.async { - if self?.tableView.tableHeaderView == nil { + guard let self else { return } - self?.headerView.setNeedsLayout() - self?.headerView.layoutIfNeeded() - } + self.view.setNeedsLayout() + self.view.layoutIfNeeded() } } } @@ -132,10 +133,9 @@ class AboutInstanceViewController: UIViewController { func updateFooter(with extendedDescription: Mastodon.Entity.ExtendedDescription) { DispatchQueue.main.async { self.footerView.update(with: extendedDescription) - if let tableFooterView = self.tableView.tableFooterView { - tableFooterView.frame.size = tableFooterView.systemLayoutSizeFitting(UIView.layoutFittingExpandedSize) - self.tableView.tableFooterView = tableFooterView - } + + self.view.setNeedsLayout() + self.view.layoutIfNeeded() } } } diff --git a/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableFooterView.swift b/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableFooterView.swift index 52da890094c..642f4971f76 100644 --- a/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableFooterView.swift +++ b/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableFooterView.swift @@ -33,17 +33,17 @@ class AboutInstanceTableFooterView: UIView { private func setupConstraints() { let horizontalMargin = 16.0 + let verticalMargin = 24.0 let constraints = [ - headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: 24), + headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: verticalMargin), headlineLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: horizontalMargin), trailingAnchor.constraint(equalTo: headlineLabel.trailingAnchor, constant: horizontalMargin), contentLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: 8), contentLabel.leadingAnchor.constraint(equalTo: headlineLabel.leadingAnchor), contentLabel.trailingAnchor.constraint(equalTo: headlineLabel.trailingAnchor), -// contentLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 3000), - bottomAnchor.constraint(equalTo: contentLabel.bottomAnchor), + bottomAnchor.constraint(equalTo: contentLabel.bottomAnchor, constant: verticalMargin), ] NSLayoutConstraint.activate(constraints) @@ -51,11 +51,16 @@ class AboutInstanceTableFooterView: UIView { func update(with extendedDescription: Mastodon.Entity.ExtendedDescription) { headlineLabel.text = "A legal notice" - - if let metaContent = try? MastodonMetaContent.convert(document: MastodonContent(content: extendedDescription.content, emojis: [:])) { + + let content = extendedDescription.content + .replacingOccurrences(of: "
", with: "\n") + .replacingOccurrences(of: "\n\n", with: "\n") + + + if let metaContent = try? MastodonMetaContent.convert(document: MastodonContent(content: content, emojis: [:])) { contentLabel.configure(content: metaContent) } else { - let content = PlaintextMetaContent(string: extendedDescription.content) + let content = PlaintextMetaContent(string: content) contentLabel.configure(content: content) } } diff --git a/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableViewHeader.swift b/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableViewHeader.swift index 955a6d813d5..0e8d731f152 100644 --- a/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableViewHeader.swift +++ b/Mastodon/Scene/Settings/Server Details/Table View Components/AboutInstanceTableViewHeader.swift @@ -1,13 +1,15 @@ // Copyright © 2023 Mastodon gGmbH. All rights reserved. import UIKit +import MastodonAsset import AlamofireImage class AboutInstanceTableHeaderView: UIView { let thumbnailImageView: UIImageView init() { - thumbnailImageView = UIImageView() + thumbnailImageView = UIImageView(image: Asset.Settings.aboutInstancePlaceholder.image) + thumbnailImageView.contentMode = .scaleAspectFill thumbnailImageView.translatesAutoresizingMaskIntoConstraints = false super.init(frame: .zero) @@ -24,14 +26,15 @@ class AboutInstanceTableHeaderView: UIView { thumbnailImageView.topAnchor.constraint(equalTo: topAnchor), thumbnailImageView.leadingAnchor.constraint(equalTo: leadingAnchor), trailingAnchor.constraint(equalTo: thumbnailImageView.trailingAnchor), - bottomAnchor.constraint(equalTo: thumbnailImageView.bottomAnchor), - thumbnailImageView.heightAnchor.constraint(equalToConstant: 188), + bottomAnchor.constraint(equalTo: thumbnailImageView.bottomAnchor, constant: 16), ] NSLayoutConstraint.activate(constraints) } func updateImage(with thumbnailURL: URL, completion: (() -> Void)? = nil) { - thumbnailImageView.af.setImage(withURL: thumbnailURL) + thumbnailImageView.af.setImage(withURL: thumbnailURL, placeholderImage: Asset.Settings.aboutInstancePlaceholder.image, completion: { _ in + completion?() + }) } } diff --git a/Mastodon/Scene/Settings/Server Details/Table View Components/ContactAdminTableViewCell.swift b/Mastodon/Scene/Settings/Server Details/Table View Components/ContactAdminTableViewCell.swift index c538a90aaf5..69ffaef8670 100644 --- a/Mastodon/Scene/Settings/Server Details/Table View Components/ContactAdminTableViewCell.swift +++ b/Mastodon/Scene/Settings/Server Details/Table View Components/ContactAdminTableViewCell.swift @@ -15,6 +15,7 @@ class ContactAdminTableViewCell: UITableViewCell { configuration.image = UIImage(systemName: "envelope") configuration.imageProperties.tintColor = Asset.Colors.Brand.blurple.color configuration.text = L10n.Scene.Settings.ServerDetails.AboutInstance.messageAdmin + backgroundColor = .secondarySystemGroupedBackground contentConfiguration = configuration } diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/Contents.json similarity index 73% rename from MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/Contents.json rename to MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/Contents.json index 45265b0c2e1..95dc599198c 100644 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/Contents.json +++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/Contents.json @@ -1,17 +1,15 @@ { "images" : [ { - "filename" : "dark.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "dark@2x.png", + "filename" : "about_instance_placeholder@2x.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "dark@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/about_instance_placeholder@2x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/about_instance_placeholder@2x.png new file mode 100644 index 00000000000..d40e27a1238 Binary files /dev/null and b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/about_instance_placeholder.imageset/about_instance_placeholder@2x.png differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/Contents.json deleted file mode 100644 index 634b1b2490a..00000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "filename" : "automatic.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "automatic@2x.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "automatic@3x.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic.png deleted file mode 100644 index 8a4997026cc..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@2x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@2x.png deleted file mode 100644 index 353f123a52a..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@2x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@3x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@3x.png deleted file mode 100644 index 6a865417a1b..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/automatic.imageset/automatic@3x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark.png deleted file mode 100644 index 5bfe79abf17..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@2x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@2x.png deleted file mode 100644 index 4bbee3622ae..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@2x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@3x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@3x.png deleted file mode 100644 index 4ea316fb2f1..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/dark.imageset/dark@3x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/Contents.json deleted file mode 100644 index c89e6245e1d..00000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "filename" : "light.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "light@2x.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "light@3x.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light.png deleted file mode 100644 index 23efb384ca2..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@2x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@2x.png deleted file mode 100644 index 6bff099c81c..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@2x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@3x.png b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@3x.png deleted file mode 100644 index 94c68eb50b6..00000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Settings/light.imageset/light@3x.png and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift index d23979b9598..be8f204e023 100644 --- a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift +++ b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift @@ -219,9 +219,7 @@ public enum Asset { } } public enum Settings { - public static let automatic = ImageAsset(name: "Settings/automatic") - public static let dark = ImageAsset(name: "Settings/dark") - public static let light = ImageAsset(name: "Settings/light") + public static let aboutInstancePlaceholder = ImageAsset(name: "Settings/about_instance_placeholder") } public enum Theme { public enum System {