From 36b7e50f5b75f57ccb3662f4da93ebf31f8013f6 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 20 Dec 2022 18:17:47 -0500 Subject: [PATCH] Delete NotificationAvatarButton.swift --- Mastodon.xcodeproj/project.pbxproj | 12 --- .../Button/NotificationAvatarButton.swift | 86 ------------------- 2 files changed, 98 deletions(-) delete mode 100644 Mastodon/Scene/Notification/Button/NotificationAvatarButton.swift diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 74b7841a5..ce12a4050 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -129,7 +129,6 @@ DB0618032785A7100030EE79 /* RegisterSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0618022785A7100030EE79 /* RegisterSection.swift */; }; DB0618052785A73D0030EE79 /* RegisterItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0618042785A73D0030EE79 /* RegisterItem.swift */; }; DB0A322E280EE9FD001729D2 /* DiscoveryIntroBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0A322D280EE9FD001729D2 /* DiscoveryIntroBannerView.swift */; }; - DB0C947726A7FE840088FB11 /* NotificationAvatarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0C947626A7FE840088FB11 /* NotificationAvatarButton.swift */; }; DB0EF72B26FDB1D200347686 /* SidebarListCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0EF72A26FDB1D200347686 /* SidebarListCollectionViewCell.swift */; }; DB0EF72E26FDB24F00347686 /* SidebarListContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0EF72D26FDB24F00347686 /* SidebarListContentView.swift */; }; DB0F8150264D1E2500F2A12B /* PickServerLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0F814F264D1E2500F2A12B /* PickServerLoaderTableViewCell.swift */; }; @@ -667,7 +666,6 @@ DB0618042785A73D0030EE79 /* RegisterItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterItem.swift; sourceTree = ""; }; DB0618062785A8880030EE79 /* MastodonRegisterViewModel+Diffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MastodonRegisterViewModel+Diffable.swift"; sourceTree = ""; }; DB0A322D280EE9FD001729D2 /* DiscoveryIntroBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryIntroBannerView.swift; sourceTree = ""; }; - DB0C947626A7FE840088FB11 /* NotificationAvatarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationAvatarButton.swift; sourceTree = ""; }; DB0EF72A26FDB1D200347686 /* SidebarListCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarListCollectionViewCell.swift; sourceTree = ""; }; DB0EF72D26FDB24F00347686 /* SidebarListContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarListContentView.swift; sourceTree = ""; }; DB0F814E264CFFD300F2A12B /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -1635,14 +1633,6 @@ path = View; sourceTree = ""; }; - DB0C947826A7FE950088FB11 /* Button */ = { - isa = PBXGroup; - children = ( - DB0C947626A7FE840088FB11 /* NotificationAvatarButton.swift */, - ); - path = Button; - sourceTree = ""; - }; DB0EF72C26FDB1D600347686 /* View */ = { isa = PBXGroup; children = ( @@ -2393,7 +2383,6 @@ isa = PBXGroup; children = ( DB63F765279A5E5600455B82 /* NotificationTimeline */, - DB0C947826A7FE950088FB11 /* Button */, 2D35237F26256F470031AF25 /* Cell */, DB9D6BF725E4F5690051B173 /* NotificationViewController.swift */, 2D607AD726242FC500B70763 /* NotificationViewModel.swift */, @@ -3274,7 +3263,6 @@ DB603113279EBEBA00A935FE /* DataSourceFacade+Block.swift in Sources */, DB63F777279A9A2A00455B82 /* NotificationView+Configuration.swift in Sources */, DB029E95266A20430062874E /* MastodonAuthenticationController.swift in Sources */, - DB0C947726A7FE840088FB11 /* NotificationAvatarButton.swift in Sources */, 5B90C461262599800002E742 /* SettingsLinkTableViewCell.swift in Sources */, DB6180DD263918E30018D199 /* MediaPreviewViewController.swift in Sources */, DBE3CDEC261C6B2900430CC6 /* FavoriteViewController.swift in Sources */, diff --git a/Mastodon/Scene/Notification/Button/NotificationAvatarButton.swift b/Mastodon/Scene/Notification/Button/NotificationAvatarButton.swift deleted file mode 100644 index 26abfbd23..000000000 --- a/Mastodon/Scene/Notification/Button/NotificationAvatarButton.swift +++ /dev/null @@ -1,86 +0,0 @@ -// -// NotificationAvatarButton.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-7-21. -// - -import UIKit -import FLAnimatedImage -import MastodonUI - -final class NotificationAvatarButton: AvatarButton { - - // Size fixed - static let containerSize = CGSize(width: 35, height: 35) - static let badgeImageViewSize = CGSize(width: 24, height: 24) - static let badgeImageMaskSize = CGSize(width: badgeImageViewSize.width + 4, height: badgeImageViewSize.height + 4) - - let badgeImageView: UIImageView = { - let imageView = RoundedImageView() - imageView.contentMode = .center - imageView.isOpaque = true - imageView.layer.shouldRasterize = true - imageView.layer.rasterizationScale = UIScreen.main.scale - return imageView - }() - - override func _init() { - super._init() - - size = CGSize(width: 35, height: 35) - - let path: CGPath = { - let path = CGMutablePath() - path.addRect(CGRect(origin: .zero, size: NotificationAvatarButton.containerSize)) - let x: CGFloat = { - if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft { - return -0.5 * NotificationAvatarButton.badgeImageMaskSize.width - } else { - return NotificationAvatarButton.containerSize.width - 0.5 * NotificationAvatarButton.badgeImageMaskSize.width - } - }() - path.addPath(UIBezierPath( - ovalIn: CGRect( - x: x, - y: NotificationAvatarButton.containerSize.height - 0.5 * NotificationAvatarButton.badgeImageMaskSize.width, - width: NotificationAvatarButton.badgeImageMaskSize.width, - height: NotificationAvatarButton.badgeImageMaskSize.height - ) - ).cgPath) - return path - }() - - let maskShapeLayer = CAShapeLayer() - maskShapeLayer.backgroundColor = UIColor.black.cgColor - maskShapeLayer.fillRule = .evenOdd - maskShapeLayer.path = path - avatarImageView.layer.mask = maskShapeLayer - - badgeImageView.translatesAutoresizingMaskIntoConstraints = false - addSubview(badgeImageView) - NSLayoutConstraint.activate([ - badgeImageView.centerXAnchor.constraint(equalTo: trailingAnchor), - badgeImageView.centerYAnchor.constraint(equalTo: bottomAnchor), - badgeImageView.widthAnchor.constraint(equalToConstant: NotificationAvatarButton.badgeImageViewSize.width).priority(.required - 1), - badgeImageView.heightAnchor.constraint(equalToConstant: NotificationAvatarButton.badgeImageViewSize.height).priority(.required - 1), - ]) - } - - override func updateAppearance() { - super.updateAppearance() - badgeImageView.alpha = primaryActionState.contains(.highlighted) ? 0.6 : 1.0 - } - -} - -final class RoundedImageView: UIImageView { - - override func layoutSubviews() { - super.layoutSubviews() - - layer.masksToBounds = true - layer.cornerRadius = bounds.width / 2 - layer.cornerCurve = .circular - } -}