From 6e964ff601104b13e09df1bf651fe4c7ed8f085c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 25 Jan 2022 21:34:21 -0500 Subject: [PATCH] Profile directory can have a little shadow, as a treat --- .../FeaturedProfileCollectionViewCell.swift | 33 ++++++ .../FeaturedProfileCollectionViewCell.xib | 105 ++++++++++-------- .../Explore/ProfileDirectoryFilterView.swift | 2 + .../ProfileDirectoryViewController.swift | 12 +- 4 files changed, 99 insertions(+), 53 deletions(-) diff --git a/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.swift b/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.swift index 8afcf9c2..6e5ae03f 100644 --- a/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.swift +++ b/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.swift @@ -11,6 +11,7 @@ import Pachyderm class FeaturedProfileCollectionViewCell: UICollectionViewCell { + @IBOutlet weak var clippingView: UIView! @IBOutlet weak var headerImageView: UIImageView! @IBOutlet weak var avatarContainerView: UIView! @IBOutlet weak var avatarImageView: UIImageView! @@ -30,6 +31,17 @@ class FeaturedProfileCollectionViewCell: UICollectionViewCell { noteTextView.defaultFont = .systemFont(ofSize: 16) noteTextView.textContainer.lineBreakMode = .byTruncatingTail + noteTextView.textContainerInset = UIEdgeInsets(top: 16, left: 4, bottom: 16, right: 4) + + backgroundColor = .clear + clippingView.layer.cornerRadius = 5 + clippingView.layer.borderWidth = 1 + clippingView.layer.masksToBounds = true + layer.shadowOpacity = 0.2 + layer.shadowRadius = 8 + layer.shadowOffset = .zero + layer.masksToBounds = false + updateLayerColors() NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil) } @@ -75,6 +87,27 @@ class FeaturedProfileCollectionViewCell: UICollectionViewCell { } } + private func updateLayerColors() { + if traitCollection.userInterfaceStyle == .dark { + clippingView.layer.borderColor = UIColor.darkGray.withAlphaComponent(0.5).cgColor + layer.shadowColor = UIColor.darkGray.cgColor + } else { + clippingView.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.5).cgColor + layer.shadowColor = UIColor.black.cgColor + } + } + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + updateLayerColors() + } + + override func layoutSubviews() { + super.layoutSubviews() + + layer.shadowPath = CGPath(roundedRect: bounds, cornerWidth: 5, cornerHeight: 5, transform: nil) + } + @objc private func preferencesChanged() { avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView) avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) diff --git a/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.xib b/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.xib index 1d302d2f..99ec2f5f 100644 --- a/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.xib +++ b/Tusker/Screens/Explore/FeaturedProfileCollectionViewCell.xib @@ -1,8 +1,9 @@ - + - + + @@ -17,67 +18,81 @@ - - - - - - - - - + + - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + - - - - + + + + + + + + + + + + + - - - - Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. - - - - - - - - - - - - - - - - - + + + + + diff --git a/Tusker/Screens/Explore/ProfileDirectoryFilterView.swift b/Tusker/Screens/Explore/ProfileDirectoryFilterView.swift index 3f219a0f..843dde27 100644 --- a/Tusker/Screens/Explore/ProfileDirectoryFilterView.swift +++ b/Tusker/Screens/Explore/ProfileDirectoryFilterView.swift @@ -44,11 +44,13 @@ class ProfileDirectoryFilterView: UICollectionReusableView { fromLabel.translatesAutoresizingMaskIntoConstraints = false fromLabel.text = NSLocalizedString("From", comment: "profile directory scope label") fromLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + fromLabel.textAlignment = .right let sortLabel = UILabel() sortLabel.translatesAutoresizingMaskIntoConstraints = false sortLabel.text = NSLocalizedString("Sort By", comment: "profile directory sort label") sortLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + sortLabel.textAlignment = .right let labelContainer = UIView() labelContainer.addSubview(sortLabel) diff --git a/Tusker/Screens/Explore/ProfileDirectoryViewController.swift b/Tusker/Screens/Explore/ProfileDirectoryViewController.swift index 5d9f648f..2554a78e 100644 --- a/Tusker/Screens/Explore/ProfileDirectoryViewController.swift +++ b/Tusker/Screens/Explore/ProfileDirectoryViewController.swift @@ -45,7 +45,7 @@ class ProfileDirectoryViewController: UIViewController { if case .compact = layoutEnvironment.traitCollection.horizontalSizeClass { itemWidth = .fractionalWidth(1) } else { - itemWidth = .absolute((layoutEnvironment.container.contentSize.width - 12) / 2) + itemWidth = .absolute((layoutEnvironment.container.contentSize.width - 16 - 8 * 2) / 2) } let itemSize = NSCollectionLayoutSize(widthDimension: itemWidth, heightDimension: itemHeight) @@ -54,15 +54,11 @@ class ProfileDirectoryViewController: UIViewController { let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: itemHeight) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item, itemB]) - group.interItemSpacing = .flexible(4) + group.interItemSpacing = .flexible(16) let section = NSCollectionLayoutSection(group: group) - section.interGroupSpacing = 4 - if case .compact = layoutEnvironment.traitCollection.horizontalSizeClass { - section.contentInsets = NSDirectionalEdgeInsets(top: 4, leading: 0, bottom: 4, trailing: 0) - } else { - section.contentInsets = NSDirectionalEdgeInsets(top: 4, leading: 4, bottom: 4, trailing: 4) - } + section.interGroupSpacing = 16 + section.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8) return section }, configuration: configuration)