From d716e8a68ee85c46a8c4bb280b3d73531cf72212 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Mon, 8 Feb 2021 18:48:02 -0800 Subject: [PATCH] Refactoring --- Extensions/CollectionItem+Extensions.swift | 4 ++-- Metatext.xcodeproj/project.pbxproj | 4 ++++ .../Table View Cells/AccountTableViewCell.swift | 14 +------------- .../ConversationTableViewCell.swift | 14 +------------- .../LoadMoreTableViewCell.swift | 14 +------------- .../NotificationTableViewCell.swift | 14 +------------- .../SeparatorConfiguredTableViewCell.swift | 17 +++++++++++++++++ .../Table View Cells/TagTableViewCell.swift | 14 +------------- 8 files changed, 28 insertions(+), 67 deletions(-) create mode 100644 Views/UIKit/Table View Cells/SeparatorConfiguredTableViewCell.swift diff --git a/Extensions/CollectionItem+Extensions.swift b/Extensions/CollectionItem+Extensions.swift index c2511af..120dd1c 100644 --- a/Extensions/CollectionItem+Extensions.swift +++ b/Extensions/CollectionItem+Extensions.swift @@ -12,7 +12,7 @@ extension CollectionItem { NotificationTableViewCell.self, ConversationTableViewCell.self, TagTableViewCell.self, - UITableViewCell.self] + SeparatorConfiguredTableViewCell.self] var cellClass: AnyClass { switch self { @@ -29,7 +29,7 @@ extension CollectionItem { case .tag: return TagTableViewCell.self case .moreResults: - return UITableViewCell.self + return SeparatorConfiguredTableViewCell.self } } diff --git a/Metatext.xcodeproj/project.pbxproj b/Metatext.xcodeproj/project.pbxproj index 4476e92..07d7c95 100644 --- a/Metatext.xcodeproj/project.pbxproj +++ b/Metatext.xcodeproj/project.pbxproj @@ -133,6 +133,7 @@ D0BE97A325CF44310057E161 /* CGRect+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97A225CF44310057E161 /* CGRect+Extensions.swift */; }; D0BE97D725D0863E0057E161 /* ImagePastableTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97D625D0863E0057E161 /* ImagePastableTextView.swift */; }; D0BE97E025D086F80057E161 /* ImagePastableTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97D625D0863E0057E161 /* ImagePastableTextView.swift */; }; + D0BE980425D229D50057E161 /* SeparatorConfiguredTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE980325D229D50057E161 /* SeparatorConfiguredTableViewCell.swift */; }; D0BEB1F324F8EE8C001B0F04 /* AttachmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB1F224F8EE8C001B0F04 /* AttachmentView.swift */; }; D0BEB1F724F9A84B001B0F04 /* LoadingTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB1F624F9A84B001B0F04 /* LoadingTableFooterView.swift */; }; D0BEB1FF24F9E5BB001B0F04 /* ListsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB1FE24F9E5BB001B0F04 /* ListsView.swift */; }; @@ -330,6 +331,7 @@ D0BDF66524FD7A6400C7FA1C /* ServiceLayer */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ServiceLayer; sourceTree = ""; }; D0BE97A225CF44310057E161 /* CGRect+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGRect+Extensions.swift"; sourceTree = ""; }; D0BE97D625D0863E0057E161 /* ImagePastableTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePastableTextView.swift; sourceTree = ""; }; + D0BE980325D229D50057E161 /* SeparatorConfiguredTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorConfiguredTableViewCell.swift; sourceTree = ""; }; D0BEB1F224F8EE8C001B0F04 /* AttachmentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentView.swift; sourceTree = ""; }; D0BEB1F624F9A84B001B0F04 /* LoadingTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingTableFooterView.swift; sourceTree = ""; }; D0BEB1FE24F9E5BB001B0F04 /* ListsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListsView.swift; sourceTree = ""; }; @@ -516,6 +518,7 @@ D021A60925C36B32008A0C0D /* IdentityTableViewCell.swift */, D0B8510B25259E56004E0744 /* LoadMoreTableViewCell.swift */, D036AA01254B6101009094DF /* NotificationTableViewCell.swift */, + D0BE980325D229D50057E161 /* SeparatorConfiguredTableViewCell.swift */, D0625E58250F092900502611 /* StatusTableViewCell.swift */, D0D2AC4C25BCD2A9003D5DF2 /* TagTableViewCell.swift */, ); @@ -1087,6 +1090,7 @@ D0030982250C6C8500EACB32 /* URL+Extensions.swift in Sources */, D0BE97A325CF44310057E161 /* CGRect+Extensions.swift in Sources */, D00CB2ED2533ACC00080096B /* StatusView.swift in Sources */, + D0BE980425D229D50057E161 /* SeparatorConfiguredTableViewCell.swift in Sources */, D0A1F4F7252E7D4B004435BF /* TableViewDataSource.swift in Sources */, D025B17E25C500BC001C69A8 /* CapsuleButton.swift in Sources */, D0C7D4C424F7616A001EBDBB /* AppDelegate.swift in Sources */, diff --git a/Views/UIKit/Table View Cells/AccountTableViewCell.swift b/Views/UIKit/Table View Cells/AccountTableViewCell.swift index 0eec342..7ea5594 100644 --- a/Views/UIKit/Table View Cells/AccountTableViewCell.swift +++ b/Views/UIKit/Table View Cells/AccountTableViewCell.swift @@ -3,7 +3,7 @@ import UIKit import ViewModels -final class AccountTableViewCell: UITableViewCell { +final class AccountTableViewCell: SeparatorConfiguredTableViewCell { var viewModel: AccountViewModel? override func updateConfiguration(using state: UICellConfigurationState) { @@ -12,16 +12,4 @@ final class AccountTableViewCell: UITableViewCell { contentConfiguration = AccountContentConfiguration(viewModel: viewModel).updated(for: state) accessibilityElements = [contentView] } - - override func layoutSubviews() { - super.layoutSubviews() - - if UIDevice.current.userInterfaceIdiom == .phone { - separatorInset.left = 0 - separatorInset.right = 0 - } else { - separatorInset.left = layoutMargins.left - separatorInset.right = layoutMargins.right - } - } } diff --git a/Views/UIKit/Table View Cells/ConversationTableViewCell.swift b/Views/UIKit/Table View Cells/ConversationTableViewCell.swift index e0d463d..18dab9e 100644 --- a/Views/UIKit/Table View Cells/ConversationTableViewCell.swift +++ b/Views/UIKit/Table View Cells/ConversationTableViewCell.swift @@ -3,7 +3,7 @@ import UIKit import ViewModels -final class ConversationTableViewCell: UITableViewCell { +final class ConversationTableViewCell: SeparatorConfiguredTableViewCell { var viewModel: ConversationViewModel? override func updateConfiguration(using state: UICellConfigurationState) { @@ -12,16 +12,4 @@ final class ConversationTableViewCell: UITableViewCell { contentConfiguration = ConversationContentConfiguration(viewModel: viewModel).updated(for: state) accessibilityElements = [contentView] } - - override func layoutSubviews() { - super.layoutSubviews() - - if UIDevice.current.userInterfaceIdiom == .phone { - separatorInset.left = 0 - separatorInset.right = 0 - } else { - separatorInset.left = layoutMargins.left - separatorInset.right = layoutMargins.right - } - } } diff --git a/Views/UIKit/Table View Cells/LoadMoreTableViewCell.swift b/Views/UIKit/Table View Cells/LoadMoreTableViewCell.swift index 7325edb..c20038d 100644 --- a/Views/UIKit/Table View Cells/LoadMoreTableViewCell.swift +++ b/Views/UIKit/Table View Cells/LoadMoreTableViewCell.swift @@ -3,7 +3,7 @@ import UIKit import ViewModels -final class LoadMoreTableViewCell: UITableViewCell { +final class LoadMoreTableViewCell: SeparatorConfiguredTableViewCell { var viewModel: LoadMoreViewModel? override func updateConfiguration(using state: UICellConfigurationState) { @@ -12,16 +12,4 @@ final class LoadMoreTableViewCell: UITableViewCell { contentConfiguration = LoadMoreContentConfiguration(viewModel: viewModel) accessibilityElements = [contentView] } - - override func layoutSubviews() { - super.layoutSubviews() - - if UIDevice.current.userInterfaceIdiom == .phone { - separatorInset.left = 0 - separatorInset.right = 0 - } else { - separatorInset.left = layoutMargins.left - separatorInset.right = layoutMargins.right - } - } } diff --git a/Views/UIKit/Table View Cells/NotificationTableViewCell.swift b/Views/UIKit/Table View Cells/NotificationTableViewCell.swift index 2fe37ec..cf39f70 100644 --- a/Views/UIKit/Table View Cells/NotificationTableViewCell.swift +++ b/Views/UIKit/Table View Cells/NotificationTableViewCell.swift @@ -3,7 +3,7 @@ import UIKit import ViewModels -final class NotificationTableViewCell: UITableViewCell { +final class NotificationTableViewCell: SeparatorConfiguredTableViewCell { var viewModel: NotificationViewModel? override func updateConfiguration(using state: UICellConfigurationState) { @@ -12,16 +12,4 @@ final class NotificationTableViewCell: UITableViewCell { contentConfiguration = NotificationContentConfiguration(viewModel: viewModel).updated(for: state) accessibilityElements = [contentView] } - - override func layoutSubviews() { - super.layoutSubviews() - - if UIDevice.current.userInterfaceIdiom == .phone { - separatorInset.left = 0 - separatorInset.right = 0 - } else { - separatorInset.left = layoutMargins.left - separatorInset.right = layoutMargins.right - } - } } diff --git a/Views/UIKit/Table View Cells/SeparatorConfiguredTableViewCell.swift b/Views/UIKit/Table View Cells/SeparatorConfiguredTableViewCell.swift new file mode 100644 index 0000000..febc786 --- /dev/null +++ b/Views/UIKit/Table View Cells/SeparatorConfiguredTableViewCell.swift @@ -0,0 +1,17 @@ +// Copyright © 2021 Metabolist. All rights reserved. + +import UIKit + +class SeparatorConfiguredTableViewCell: UITableViewCell { + override func layoutSubviews() { + super.layoutSubviews() + + if UIDevice.current.userInterfaceIdiom == .phone { + separatorInset.left = 0 + separatorInset.right = 0 + } else { + separatorInset.left = layoutMargins.left + separatorInset.right = layoutMargins.right + } + } +} diff --git a/Views/UIKit/Table View Cells/TagTableViewCell.swift b/Views/UIKit/Table View Cells/TagTableViewCell.swift index 1c6f07c..7d94a7d 100644 --- a/Views/UIKit/Table View Cells/TagTableViewCell.swift +++ b/Views/UIKit/Table View Cells/TagTableViewCell.swift @@ -3,7 +3,7 @@ import UIKit import ViewModels -final class TagTableViewCell: UITableViewCell { +final class TagTableViewCell: SeparatorConfiguredTableViewCell { var viewModel: TagViewModel? override func updateConfiguration(using state: UICellConfigurationState) { @@ -11,16 +11,4 @@ final class TagTableViewCell: UITableViewCell { contentConfiguration = TagContentConfiguration(viewModel: viewModel).updated(for: state) } - - override func layoutSubviews() { - super.layoutSubviews() - - if UIDevice.current.userInterfaceIdiom == .phone { - separatorInset.left = 0 - separatorInset.right = 0 - } else { - separatorInset.left = layoutMargins.left - separatorInset.right = layoutMargins.right - } - } }