Merge pull request #467 from mastodon/fix-ui-appearance

Fix some UI appearance issues
This commit is contained in:
CMK 2022-07-15 04:14:10 +08:00 committed by GitHub
commit 4bebdf7edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 5 deletions

View File

@ -5,6 +5,7 @@
// Created by MainasuK on 2022-1-26.
//
import os.log
import UIKit
import CoreDataStack
import MastodonUI
@ -153,6 +154,8 @@ extension DataSourceFacade {
user: ManagedObjectRecord<MastodonUser>,
previewContext: ImagePreviewContext
) async throws {
let logger = Logger(subsystem: "DataSourceFacade", category: "Media")
let managedObjectContext = dependency.context.managedObjectContext
var _avatarAssetURL: String?
@ -216,13 +219,18 @@ extension DataSourceFacade {
thumbnail: thumbnail
))
case .profileBanner:
return .profileAvatar(.init(
return .profileBanner(.init(
assetURL: _headerAssetURL,
thumbnail: thumbnail
))
}
}()
guard mediaPreviewItem.isAssetURLValid else {
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): discard preview due to assetURL invalid")
return
}
coordinateToMediaPreviewScene(
dependency: dependency,
mediaPreviewItem: mediaPreviewItem,

View File

@ -116,6 +116,19 @@ extension MediaPreviewViewModel {
case profileAvatar(ProfileAvatarPreviewContext)
case profileBanner(ProfileBannerPreviewContext)
// case local(LocalImagePreviewMeta)
var isAssetURLValid: Bool {
switch self {
case .attachment:
return true // default valid
case .profileAvatar:
return true // default valid
case .profileBanner(let item):
guard let assertURL = item.assetURL else { return false }
guard !assertURL.hasSuffix("missing.png") else { return false }
return true
}
}
}
struct AttachmentPreviewContext {

View File

@ -37,6 +37,7 @@ final class ProfileHeaderView: UIView {
weak var delegate: ProfileHeaderViewDelegate?
var disposeBag = Set<AnyCancellable>()
private var _disposeBag = Set<AnyCancellable>()
func prepareForReuse() {
disposeBag.removeAll()
@ -237,7 +238,7 @@ extension ProfileHeaderView {
guard let self = self else { return }
self.backgroundColor = theme.systemBackgroundColor
}
.store(in: &disposeBag)
.store(in: &_disposeBag)
// banner
bannerContainerView.translatesAutoresizingMaskIntoConstraints = false

View File

@ -11,6 +11,7 @@ import Combine
import XLPagerTabStrip
import TabBarPager
import MastodonAsset
import MastodonUI
protocol ProfilePagingViewControllerDelegate: AnyObject {
func profilePagingViewController(_ viewController: ProfilePagingViewController, didScrollToPostCustomScrollViewContainerController customScrollViewContainerController: ScrollViewContainer, atIndex index: Int)
@ -87,6 +88,7 @@ extension ProfilePagingViewController {
.sink { [weak self] theme in
guard let self = self else { return }
self.settings.style.buttonBarBackgroundColor = theme.systemBackgroundColor
self.buttonBarView.backgroundColor = self.settings.style.buttonBarBackgroundColor
self.barButtonLayout?.invalidateLayout()
}
.store(in: &disposeBag)

View File

@ -58,7 +58,12 @@ extension ProfileCardView {
guard let userInterfaceStyle = userInterfaceStyle else { return }
switch userInterfaceStyle {
case .dark:
switch theme.themeName {
case .mastodon:
self.backgroundColor = theme.systemBackgroundColor
case .system:
self.backgroundColor = theme.secondarySystemBackgroundColor
}
case .light, .unspecified:
self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
@unknown default:
@ -99,7 +104,10 @@ extension ProfileCardView.ViewModel {
private func bindHeader(view: ProfileCardView) {
$authorBannerImageURL
.sink { url in
guard let url = url else { return }
guard let url = url, !url.absoluteString.hasSuffix("missing.png") else {
view.bannerImageView.image = .placeholder(color: .systemGray3)
return
}
view.bannerImageView.af.setImage(
withURL: url,
placeholderImage: .placeholder(color: .systemGray3),