Merge pull request #467 from mastodon/fix-ui-appearance
Fix some UI appearance issues
This commit is contained in:
commit
4bebdf7edf
|
@ -5,6 +5,7 @@
|
||||||
// Created by MainasuK on 2022-1-26.
|
// Created by MainasuK on 2022-1-26.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import os.log
|
||||||
import UIKit
|
import UIKit
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import MastodonUI
|
import MastodonUI
|
||||||
|
@ -153,6 +154,8 @@ extension DataSourceFacade {
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
previewContext: ImagePreviewContext
|
previewContext: ImagePreviewContext
|
||||||
) async throws {
|
) async throws {
|
||||||
|
let logger = Logger(subsystem: "DataSourceFacade", category: "Media")
|
||||||
|
|
||||||
let managedObjectContext = dependency.context.managedObjectContext
|
let managedObjectContext = dependency.context.managedObjectContext
|
||||||
|
|
||||||
var _avatarAssetURL: String?
|
var _avatarAssetURL: String?
|
||||||
|
@ -216,13 +219,18 @@ extension DataSourceFacade {
|
||||||
thumbnail: thumbnail
|
thumbnail: thumbnail
|
||||||
))
|
))
|
||||||
case .profileBanner:
|
case .profileBanner:
|
||||||
return .profileAvatar(.init(
|
return .profileBanner(.init(
|
||||||
assetURL: _headerAssetURL,
|
assetURL: _headerAssetURL,
|
||||||
thumbnail: thumbnail
|
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(
|
coordinateToMediaPreviewScene(
|
||||||
dependency: dependency,
|
dependency: dependency,
|
||||||
mediaPreviewItem: mediaPreviewItem,
|
mediaPreviewItem: mediaPreviewItem,
|
||||||
|
|
|
@ -116,6 +116,19 @@ extension MediaPreviewViewModel {
|
||||||
case profileAvatar(ProfileAvatarPreviewContext)
|
case profileAvatar(ProfileAvatarPreviewContext)
|
||||||
case profileBanner(ProfileBannerPreviewContext)
|
case profileBanner(ProfileBannerPreviewContext)
|
||||||
// case local(LocalImagePreviewMeta)
|
// 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 {
|
struct AttachmentPreviewContext {
|
||||||
|
|
|
@ -37,7 +37,8 @@ final class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
weak var delegate: ProfileHeaderViewDelegate?
|
weak var delegate: ProfileHeaderViewDelegate?
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
private var _disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
func prepareForReuse() {
|
func prepareForReuse() {
|
||||||
disposeBag.removeAll()
|
disposeBag.removeAll()
|
||||||
}
|
}
|
||||||
|
@ -237,7 +238,7 @@ extension ProfileHeaderView {
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.backgroundColor = theme.systemBackgroundColor
|
self.backgroundColor = theme.systemBackgroundColor
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &_disposeBag)
|
||||||
|
|
||||||
// banner
|
// banner
|
||||||
bannerContainerView.translatesAutoresizingMaskIntoConstraints = false
|
bannerContainerView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Combine
|
||||||
import XLPagerTabStrip
|
import XLPagerTabStrip
|
||||||
import TabBarPager
|
import TabBarPager
|
||||||
import MastodonAsset
|
import MastodonAsset
|
||||||
|
import MastodonUI
|
||||||
|
|
||||||
protocol ProfilePagingViewControllerDelegate: AnyObject {
|
protocol ProfilePagingViewControllerDelegate: AnyObject {
|
||||||
func profilePagingViewController(_ viewController: ProfilePagingViewController, didScrollToPostCustomScrollViewContainerController customScrollViewContainerController: ScrollViewContainer, atIndex index: Int)
|
func profilePagingViewController(_ viewController: ProfilePagingViewController, didScrollToPostCustomScrollViewContainerController customScrollViewContainerController: ScrollViewContainer, atIndex index: Int)
|
||||||
|
@ -87,6 +88,7 @@ extension ProfilePagingViewController {
|
||||||
.sink { [weak self] theme in
|
.sink { [weak self] theme in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.settings.style.buttonBarBackgroundColor = theme.systemBackgroundColor
|
self.settings.style.buttonBarBackgroundColor = theme.systemBackgroundColor
|
||||||
|
self.buttonBarView.backgroundColor = self.settings.style.buttonBarBackgroundColor
|
||||||
self.barButtonLayout?.invalidateLayout()
|
self.barButtonLayout?.invalidateLayout()
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
|
@ -58,7 +58,12 @@ extension ProfileCardView {
|
||||||
guard let userInterfaceStyle = userInterfaceStyle else { return }
|
guard let userInterfaceStyle = userInterfaceStyle else { return }
|
||||||
switch userInterfaceStyle {
|
switch userInterfaceStyle {
|
||||||
case .dark:
|
case .dark:
|
||||||
self.backgroundColor = theme.systemBackgroundColor
|
switch theme.themeName {
|
||||||
|
case .mastodon:
|
||||||
|
self.backgroundColor = theme.systemBackgroundColor
|
||||||
|
case .system:
|
||||||
|
self.backgroundColor = theme.secondarySystemBackgroundColor
|
||||||
|
}
|
||||||
case .light, .unspecified:
|
case .light, .unspecified:
|
||||||
self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
|
self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
|
||||||
@unknown default:
|
@unknown default:
|
||||||
|
@ -99,7 +104,10 @@ extension ProfileCardView.ViewModel {
|
||||||
private func bindHeader(view: ProfileCardView) {
|
private func bindHeader(view: ProfileCardView) {
|
||||||
$authorBannerImageURL
|
$authorBannerImageURL
|
||||||
.sink { url in
|
.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(
|
view.bannerImageView.af.setImage(
|
||||||
withURL: url,
|
withURL: url,
|
||||||
placeholderImage: .placeholder(color: .systemGray3),
|
placeholderImage: .placeholder(color: .systemGray3),
|
||||||
|
|
Loading…
Reference in New Issue