refactor to use custom buttons
MODIFY
Podcast.xcodeproj/project.pbxproj
Podcast.xcodeproj/project.pbxproj
42D7D9AD1D80C557000691A4 /* PodcastUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42D7D9AC1D80C557000691A4 /* PodcastUITests.swift */; };
42F684EB1D80CC7E0035217A /* PlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F684EA1D80CC7E0035217A /* PlayerViewController.swift */; };
42F684ED1D80CC9F0035217A /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F684EC1D80CC9F0035217A /* FeedViewController.swift */; };
+ 42F9942E1EB1B3DB00B78BB2 /* MoreButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F9942D1EB1B3DB00B78BB2 /* MoreButton.swift */; };
+ 42F994301EB1B57600B78BB2 /* BookmarkButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F9942F1EB1B57600B78BB2 /* BookmarkButton.swift */; };
+ 42F994321EB1B5B100B78BB2 /* RecommendButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F994311EB1B5B100B78BB2 /* RecommendButton.swift */; };
+ 42F994341EB1BCE200B78BB2 /* FeedControlButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F994331EB1BCE200B78BB2 /* FeedControlButton.swift */; };
441278C71E69E03C00D5B2AC /* UnderlineTabBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 441278C61E69E03C00D5B2AC /* UnderlineTabBarView.swift */; };
441278C91E69FC0400D5B2AC /* TabbedPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 441278C81E69FC0400D5B2AC /* TabbedPageViewController.swift */; };
441278CB1E6A112B00D5B2AC /* SearchTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 441278CA1E6A112B00D5B2AC /* SearchTableViewController.swift */; };
42D7D9AE1D80C557000691A4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
42F684EA1D80CC7E0035217A /* PlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = "<group>"; };
42F684EC1D80CC9F0035217A /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
+ 42F9942D1EB1B3DB00B78BB2 /* MoreButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoreButton.swift; sourceTree = "<group>"; };
+ 42F9942F1EB1B57600B78BB2 /* BookmarkButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkButton.swift; sourceTree = "<group>"; };
+ 42F994311EB1B5B100B78BB2 /* RecommendButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecommendButton.swift; sourceTree = "<group>"; };
+ 42F994331EB1BCE200B78BB2 /* FeedControlButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedControlButton.swift; sourceTree = "<group>"; };
441278C61E69E03C00D5B2AC /* UnderlineTabBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnderlineTabBarView.swift; sourceTree = "<group>"; };
441278C81E69FC0400D5B2AC /* TabbedPageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabbedPageViewController.swift; sourceTree = "<group>"; };
441278CA1E6A112B00D5B2AC /* SearchTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchTableViewController.swift; sourceTree = "<group>"; };
path = PodcastUITests;
sourceTree = "<group>";
};
+ 42F9942C1EB1B3C500B78BB2 /* Buttons */ = {
+ isa = PBXGroup;
+ children = (
+ 443ED30C1E745C5D001CFFF5 /* PlayButton.swift */,
+ 42F9942D1EB1B3DB00B78BB2 /* MoreButton.swift */,
+ 42F9942F1EB1B57600B78BB2 /* BookmarkButton.swift */,
+ 42F994311EB1B5B100B78BB2 /* RecommendButton.swift */,
+ 42F994331EB1BCE200B78BB2 /* FeedControlButton.swift */,
+ FD295FDC1E636A3D00520526 /* FillButton.swift */,
+ );
+ name = Buttons;
+ sourceTree = "<group>";
+ };
956D85151E51926C00D95F7A /* Networking */ = {
isa = PBXGroup;
children = (
FD9421401DB5306200685E14 /* Views */ = {
isa = PBXGroup;
children = (
+ 42F9942C1EB1B3C500B78BB2 /* Buttons */,
FD9421411DB5307B00685E14 /* ProfileHeaderView.swift */,
FD0159FF1DCBFC80003E7B4E /* ProfileMiniHeader.swift */,
425B393B1E512E8000283CA4 /* Player */,
FD8F7DFD1DDD36D600DCC511 /* ProfileSectionHeaderView.swift */,
447DA8681E5C998E0002BCA0 /* DiscoverTableViewHeaderView.swift */,
FD20F5731E52186500721C46 /* SeriesDetailHeaderView.swift */,
- FD295FDC1E636A3D00520526 /* FillButton.swift */,
441278C61E69E03C00D5B2AC /* UnderlineTabBarView.swift */,
D3738B011E67D793002ECD3F /* TagButtonsView.swift */,
FDE8D6EE1E6FC23000DF7548 /* InternalProfileHeaderView.swift */,
- 443ED30C1E745C5D001CFFF5 /* PlayButton.swift */,
D30D374A1E76082700E9260B /* TagTableViewHeader.swift */,
4225751A1E9E71630071E419 /* CommentsTableViewHeader.swift */,
D34731611EB1136C00E61E56 /* LoginBackgroundGradientView.swift */,
D3B9A05A1E861EB800B634FF /* ListeningHistoryTableViewCell.swift in Sources */,
7F97FBDA1D85A99F0073FC0F /* Constants.swift in Sources */,
D3B41F501E689D9500F68BD6 /* DateFormatter+.swift in Sources */,
+ 42F994301EB1B57600B78BB2 /* BookmarkButton.swift in Sources */,
D3628F721E6F6C5200F96C68 /* Date+.swift in Sources */,
FDE8D6EF1E6FC23000DF7548 /* InternalProfileHeaderView.swift in Sources */,
447DA8621E5C99790002BCA0 /* RecommendedTagsCollectionViewCell.swift in Sources */,
952BD1181E66A2AE006C0370 /* BookmarkViewController.swift in Sources */,
FDE8D6ED1E6FAB2F00DF7548 /* InternalProfileTableViewCell.swift in Sources */,
FD4A9BAF1E70C751001BA0BD /* SettingsViewController.swift in Sources */,
+ 42F994341EB1BCE200B78BB2 /* FeedControlButton.swift in Sources */,
D3E269291E5E7B4200793569 /* EpisodeCard.swift in Sources */,
D35402501E67C5C4008B8A0C /* Session.swift in Sources */,
D3E2692B1E5E7CBF00793569 /* RecommendedCard.swift in Sources */,
D307616C1E8CCA000047EA6F /* CreateUserSubscriptioEndpointRequest.swift in Sources */,
44AA26091E842F2A00C74FAD /* SearchEndpointRequest.swift in Sources */,
422575191E9DF0260071E419 /* CommentsTableViewCell.swift in Sources */,
+ 42F994321EB1B5B100B78BB2 /* RecommendButton.swift in Sources */,
D353AF371E8F5CBF003B3D88 /* GridSeries.swift in Sources */,
D354024E1E67C224008B8A0C /* SearchSeries.swift in Sources */,
447DA85C1E5C996E0002BCA0 /* RecommendedEpisodesOuterTableViewCell.swift in Sources */,
441278C91E69FC0400D5B2AC /* TabbedPageViewController.swift in Sources */,
42D7D98D1D80C557000691A4 /* AppDelegate.swift in Sources */,
D39BEE1D1D8A073200131936 /* Series.swift in Sources */,
+ 42F9942E1EB1B3DB00B78BB2 /* MoreButton.swift in Sources */,
42F684EB1D80CC7E0035217A /* PlayerViewController.swift in Sources */,
D39BEE1F1D8A0B3B00131936 /* User.swift in Sources */,
FDF1D1CF1DAEE2E300697379 /* ExternalProfileViewController.swift in Sources */,

MODIFY
Podcast/BookmarkTableViewCell.swift
Podcast/BookmarkTableViewCell.swift
import UIKit
protocol BookmarkTableViewCellDelegate: class {
-
func bookmarkTableViewCellDidPressPlayPauseButton(bookmarksTableViewCell: BookmarkTableViewCell)
func bookmarkTableViewCellDidPressRecommendButton(bookmarksTableViewCell: BookmarkTableViewCell)
func bookmarkTableViewCellDidPressMoreActionsButton(bookmarksTableViewCell: BookmarkTableViewCell)
@@ -32,8 +31,6 @@ class BookmarkTableViewCell: UITableViewCell {
let dateTimeLabelY: CGFloat = 41.5
let dateTimeLabelHeight: CGFloat = 14.5
- let buttonTitlePadding: CGFloat = 7
-
let playButtonX: CGFloat = 90
let playButtonBottomY: CGFloat = 18
let playButtonHeight: CGFloat = 15
@@ -57,9 +54,9 @@ class BookmarkTableViewCell: UITableViewCell {
var episodeImage: UIImageView!
var episodeNameLabel: UILabel!
var dateTimeLabel: UILabel!
- var recommendedButton: UIButton!
- var moreButton: UIButton!
- var playButton: UIButton!
+ var recommendedButton: RecommendButton!
+ var moreButton: MoreButton!
+ var playButton: PlayButton!
var separator: UIView!
weak var delegate: BookmarkTableViewCellDelegate?
@@ -98,36 +95,16 @@ class BookmarkTableViewCell: UITableViewCell {
dateTimeLabel.numberOfLines = 1
addSubview(dateTimeLabel)
- playButton = UIButton(type: .custom)
- playButton.setTitleColor(.podcastGrayDark, for: .normal)
- playButton.setImage(#imageLiteral(resourceName: "bookmarks_play_small"), for: .normal)
- playButton.setTitle("Play", for: .normal)
- playButton.setTitleColor(.podcastGrayDark, for: .disabled)
- playButton.setImage(#imageLiteral(resourceName: "play_feed_icon_selected"), for: .disabled)
- playButton.setTitle("Playing", for: .disabled)
- playButton.adjustsImageWhenDisabled = false
- playButton.contentHorizontalAlignment = .left
- playButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- playButton.titleLabel?.textColor = .podcastGrayDark
- playButton.titleLabel?.font = .systemFont(ofSize: 12)
- playButton.addTarget(self, action: #selector(didPressPlayButton), for: .touchUpInside)
- addSubview(playButton)
+ playButton = PlayButton(frame: .zero)
+ recommendedButton = RecommendButton(frame: .zero)
+ moreButton = MoreButton(frame: .zero)
- recommendedButton = UIButton(frame: CGRect.zero)
- recommendedButton.setImage(#imageLiteral(resourceName: "bookmarks_recommend_small"), for: .normal)
- recommendedButton.setImage(#imageLiteral(resourceName: "bookmarks_recommend_small_selected"), for: .selected)
- recommendedButton.contentHorizontalAlignment = .left
- recommendedButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- recommendedButton.setTitleColor(.podcastGrayDark, for: .normal)
- recommendedButton.setTitleColor(.cancelButtonRed, for: .selected)
- recommendedButton.setTitle("0", for: .normal)
- recommendedButton.titleLabel?.font = .systemFont(ofSize: 12)
+ playButton.addTarget(self, action: #selector(didPressPlayButton), for: .touchUpInside)
recommendedButton.addTarget(self, action: #selector(didPressRecommendedButton), for: .touchUpInside)
- addSubview(recommendedButton)
-
- moreButton = UIButton(frame: CGRect.zero)
- moreButton.setImage(#imageLiteral(resourceName: "more_icon"), for: .normal)
moreButton.addTarget(self, action: #selector(didPressMoreButton), for: .touchUpInside)
+
+ addSubview(playButton)
+ addSubview(recommendedButton)
addSubview(moreButton)
}

MODIFY
Podcast/CardTableViewCell.swift
Podcast/CardTableViewCell.swift
@@ -75,29 +75,26 @@ class CardTableViewCell: UITableViewCell {
var bottomViewHeight: CGFloat = CardTableViewCell.bottomViewHeight
var mainViewHeight: CGFloat = 195
- let buttonTitlePadding: CGFloat = 7
-
///
/// Mark: Variables
///
var episodeNameLabel: UILabel!
var dateTimeLabel: UILabel!
var descriptionLabel: UILabel!
- var recommendedButton: UIButton!
- var bookmarkButton: UIButton!
- var moreInfoButton: UIButton!
+ var recommendedButton: RecommendButton!
+ var bookmarkButton: BookmarkButton!
var seperator: UIView!
var podcastImageView: UIImageView!
var lineSeperator: UIView!
var topLineSeperator: UIView!
- var moreButton: UIButton!
- var playButton: UIButton!
+ var moreButton: MoreButton!
+ var playButton: PlayButton!
var contextLabel: UILabel!
var contextImages: [UIImageView] = []
var contextView: UIView! //view for upper context bar of feed cell
var mainView: UIView! //main view
var bottomView: UIView! //bottom bar view with buttons
- var feedControlButton: UIButton!
+ var feedControlButton: FeedControlButton!
var tagButtonsView: TagButtonsView!
var cardID: String?
@@ -177,45 +174,22 @@ class CardTableViewCell: UITableViewCell {
podcastImageView = UIImageView(frame: CGRect.zero)
mainView.addSubview(podcastImageView)
- bookmarkButton = UIButton(frame: CGRect.zero)
- bookmarkButton.setImage(#imageLiteral(resourceName: "bookmark_feed_icon_unselected"), for: .normal)
- bookmarkButton.setImage(#imageLiteral(resourceName: "bookmark_feed_icon_selected"), for: .selected)
- bookmarkButton.addTarget(self, action: #selector(didPressBookmarkButton), for: .touchUpInside)
- bottomView.addSubview(bookmarkButton)
+ bookmarkButton = BookmarkButton(frame: .zero)
+ recommendedButton = RecommendButton(frame: .zero)
+ moreButton = MoreButton(frame: .zero)
+ playButton = PlayButton(frame: .zero)
+ feedControlButton = FeedControlButton(frame: .zero)
- recommendedButton = UIButton(frame: CGRect.zero)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon"), for: .normal)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon_selected"), for: .selected)
- recommendedButton.contentHorizontalAlignment = .left
- recommendedButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- recommendedButton.setTitleColor(.podcastGrayDark, for: .normal)
- recommendedButton.setTitleColor(.cancelButtonRed, for: .selected)
- recommendedButton.setTitle("0", for: .normal)
- recommendedButton.titleLabel?.font = .systemFont(ofSize: 12)
+ bookmarkButton.addTarget(self, action: #selector(didPressBookmarkButton), for: .touchUpInside)
recommendedButton.addTarget(self, action: #selector(didPressRecommendedButton), for: .touchUpInside)
- bottomView.addSubview(recommendedButton)
-
- moreButton = UIButton(frame: CGRect.zero)
- moreButton.setImage(#imageLiteral(resourceName: "more_icon"), for: .normal)
moreButton.addTarget(self, action: #selector(didPressMoreButton), for: .touchUpInside)
- bottomView.addSubview(moreButton)
-
- playButton = UIButton(type: .custom)
- playButton.setImage(#imageLiteral(resourceName: "play_feed_icon"), for: .normal)
- playButton.setTitle("Play", for: .normal)
- playButton.setImage(#imageLiteral(resourceName: "play_feed_icon_selected"), for: .disabled)
- playButton.setTitle("Playing", for: .disabled)
- playButton.adjustsImageWhenDisabled = false
playButton.addTarget(self, action: #selector(didPressPlayButton), for: .touchUpInside)
- playButton.setTitleColor(.podcastTealBackground, for: .normal)
- playButton.contentHorizontalAlignment = .left
- playButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- playButton.titleLabel?.font = .systemFont(ofSize: 12)
- bottomView.addSubview(playButton)
-
- feedControlButton = UIButton(frame: CGRect.zero)
- feedControlButton.setImage(#imageLiteral(resourceName: "feed_control_icon"), for: .normal)
feedControlButton.addTarget(self, action: #selector(didPressFeedControlButton), for: .touchUpInside)
+
+ bottomView.addSubview(bookmarkButton)
+ bottomView.addSubview(recommendedButton)
+ bottomView.addSubview(moreButton)
+ bottomView.addSubview(playButton)
contextView.addSubview(feedControlButton)
}

MODIFY
Podcast/DiscoverTableViewCell.swift
Podcast/DiscoverTableViewCell.swift
@@ -39,8 +39,8 @@ class DiscoverTableViewCell: UITableViewCell {
var seriesNameLabel: UILabel!
var episodeDateLabel: UILabel!
var episodeDescriptionLabel: UILabel!
- var likeButton: UIButton!
- var moreButton: UIButton!
+ var likeButton: RecommendButton!
+ var moreButton: MoreButton!
var clickToPlayImageButton: UIButton!
var seperator: UIView!
var isExpanded: Bool!
@@ -113,12 +113,12 @@ class DiscoverTableViewCell: UITableViewCell {
episodeDescriptionLabel.font = .systemFont(ofSize: 11.0)
contentView.addSubview(episodeDescriptionLabel)
- likeButton = UIButton(frame: CGRect.zero)
+ likeButton = RecommendButton(frame: .zero)
likeButton.addTarget(self, action: #selector(likeButtonPress), for: .touchUpInside)
likeButton.setImage(UIImage(named: "heart_icon"), for: UIControlState())
contentView.addSubview(likeButton)
- moreButton = UIButton(frame: CGRect.zero)
+ moreButton = MoreButton(frame: .zero)
moreButton.addTarget(self, action: #selector(moreButtonPress), for: .touchUpInside)
moreButton.setImage(UIImage(named: "more_icon"), for: UIControlState())
contentView.addSubview(moreButton)

MODIFY
Podcast/EpisodeDetailHeaderViewCell.swift
Podcast/EpisodeDetailHeaderViewCell.swift
@@ -23,7 +23,7 @@ class EpisodeDetailHeaderViewCell: UITableViewCell {
var dateLabel: UILabel!
var descriptionLabel: UILabel!
var playButton: PlayButton!
- var recommendedButton: UIButton!
+ var recommendButton: UIButton!
var moreButton: UIButton!
var bookmarkButton: UIButton!
var bottomLineSeparator: UIView!
@@ -54,8 +54,8 @@ class EpisodeDetailHeaderViewCell: UITableViewCell {
let moreButtonRightX: CGFloat = 33
let bookmarkButtonWidth: CGFloat = 18
let bookmarkButtonRightX: CGFloat = 74
- let recommendedButtonWidth: CGFloat = 18
- let recommendedButtonRightX: CGFloat = 110
+ let recommendButtonWidth: CGFloat = 18
+ let recommendButtonRightX: CGFloat = 110
var buttonPadding: CGFloat = 10
let bottomViewInnerPadding: CGFloat = 18
@@ -123,11 +123,11 @@ class EpisodeDetailHeaderViewCell: UITableViewCell {
bookmarkButton.addTarget(self, action: #selector(bookmarkButtonTapped), for: .touchUpInside)
addSubview(bookmarkButton)
- recommendedButton = UIButton(frame: .zero)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon"), for: .normal)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon_selected"), for: .selected)
- recommendedButton.addTarget(self, action: #selector(recommendedButtonTapped), for: .touchUpInside)
- addSubview(recommendedButton)
+ recommendButton = RecommendButton(frame: .zero)
+ recommendButton.setImage(#imageLiteral(resourceName: "heart_icon"), for: .normal)
+ recommendButton.setImage(#imageLiteral(resourceName: "heart_icon_selected"), for: .selected)
+ recommendButton.addTarget(self, action: #selector(recommendButtonTapped), for: .touchUpInside)
+ addSubview(recommendButton)
}
required init?(coder aDecoder: NSCoder) {
@@ -152,7 +152,7 @@ class EpisodeDetailHeaderViewCell: UITableViewCell {
bookmarkButton.frame = CGRect(x: frame.width - bookmarkButtonRightX, y: playButton.frame.origin.y, width: bookmarkButtonWidth, height: bottomSectionHeight)
- recommendedButton.frame = CGRect(x: frame.width - recommendedButtonRightX, y: playButton.frame.origin.y, width: recommendedButtonWidth, height: bottomSectionHeight)
+ recommendButton.frame = CGRect(x: frame.width - recommendButtonRightX, y: playButton.frame.origin.y, width: recommendButtonWidth, height: bottomSectionHeight)
frame.size.height = playButton.frame.maxY
}
@@ -192,9 +192,9 @@ class EpisodeDetailHeaderViewCell: UITableViewCell {
moreButton.isSelected = !moreButton.isSelected
}
- func recommendedButtonTapped() {
+ func recommendButtonTapped() {
delegate?.episodeDetailHeaderDidPressRecommendButton(cell: self)
- recommendedButton.isSelected = !recommendedButton.isSelected
+ recommendButton.isSelected = !recommendButton.isSelected
}
}

MODIFY
Podcast/EpisodeTableViewCell.swift
Podcast/EpisodeTableViewCell.swift
@@ -74,23 +74,20 @@ class EpisodeTableViewCell: UITableViewCell {
var bottomViewHeight: CGFloat = EpisodeTableViewCell.bottomViewHeight
var mainViewHeight: CGFloat = 195
- let buttonTitlePadding: CGFloat = 7
-
///
/// Mark: Variables
///
var episodeNameLabel: UILabel!
var dateTimeLabel: UILabel!
var descriptionLabel: UILabel!
- var recommendedButton: UIButton!
- var bookmarkButton: UIButton!
- var moreInfoButton: UIButton!
+ var recommendedButton: RecommendButton!
+ var bookmarkButton: BookmarkButton!
var seperator: UIView!
var podcastImage: UIImageView!
var lineSeperator: UIView!
var bottomLineSeperator: UIView!
- var moreButton: UIButton!
- var playButton: UIButton!
+ var moreButton: MoreButton!
+ var playButton: PlayButton!
var mainView: UIView! //main view
var bottomView: UIView! //bottom bar view with buttons
var tagButtonsView: TagButtonsView!
@@ -160,41 +157,24 @@ class EpisodeTableViewCell: UITableViewCell {
podcastImage = UIImageView(frame: CGRect.zero)
mainView.addSubview(podcastImage)
- bookmarkButton = UIButton(frame: CGRect.zero)
- bookmarkButton.setImage(#imageLiteral(resourceName: "bookmark_feed_icon_unselected"), for: .normal)
- bookmarkButton.setImage(#imageLiteral(resourceName: "bookmark_feed_icon_selected"), for: .selected)
- bookmarkButton.addTarget(self, action: #selector(didPressBookmarkButton), for: .touchUpInside)
- bottomView.addSubview(bookmarkButton)
+ // buttons
+ bookmarkButton = BookmarkButton(frame: .zero)
+ recommendedButton = RecommendButton(frame: .zero)
+ moreButton = MoreButton(frame: .zero)
+ playButton = PlayButton(frame: .zero)
- recommendedButton = UIButton(frame: CGRect.zero)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon"), for: .normal)
- recommendedButton.setImage(#imageLiteral(resourceName: "heart_icon_selected"), for: .selected)
- recommendedButton.contentHorizontalAlignment = .left
- recommendedButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- recommendedButton.setTitleColor(.podcastGrayDark, for: .normal)
- recommendedButton.setTitleColor(.cancelButtonRed, for: .selected)
- recommendedButton.setTitle("0", for: .normal)
- recommendedButton.titleLabel?.font = .systemFont(ofSize: 12)
+ bookmarkButton.addTarget(self, action: #selector(didPressBookmarkButton), for: .touchUpInside)
recommendedButton.addTarget(self, action: #selector(didPressRecommendedButton), for: .touchUpInside)
- bottomView.addSubview(recommendedButton)
-
- moreButton = UIButton(frame: CGRect.zero)
- moreButton.setImage(#imageLiteral(resourceName: "more_icon"), for: .normal)
moreButton.addTarget(self, action: #selector(didPressMoreButton), for: .touchUpInside)
- bottomView.addSubview(moreButton)
-
- playButton = UIButton(type: .custom)
- playButton.setImage(#imageLiteral(resourceName: "play_feed_icon"), for: .normal)
- playButton.setTitle("Play", for: .normal)
- playButton.setImage(#imageLiteral(resourceName: "play_feed_icon_selected"), for: .disabled)
- playButton.setTitle("Playing", for: .disabled)
- playButton.adjustsImageWhenDisabled = false
playButton.addTarget(self, action: #selector(didPressPlayButton), for: .touchUpInside)
- playButton.setTitleColor(.podcastTealBackground, for: .normal)
- playButton.contentHorizontalAlignment = .left
- playButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
- playButton.titleLabel?.font = .systemFont(ofSize: 12)
+
+ bottomView.addSubview(bookmarkButton)
+ bottomView.addSubview(recommendedButton)
+ bottomView.addSubview(moreButton)
bottomView.addSubview(playButton)
+
+// playButton.setTitle("Play", for: .normal)
+
}
@@ -236,9 +216,7 @@ class EpisodeTableViewCell: UITableViewCell {
}
func setupWithEpisode(episode: Episode) {
-
episodeNameLabel.text = episode.title
-
tagButtonsView.setupTagButtons(tags: episode.tags)
for tagButton in tagButtonsView.tagButtons {
@@ -256,7 +234,6 @@ class EpisodeTableViewCell: UITableViewCell {
podcastImage.image = #imageLiteral(resourceName: "filler_image")
}
-
bookmarkButton.isSelected = episode.isBookmarked
recommendedButton.isSelected = episode.isRecommended
}

MODIFY
Podcast/ListeningHistoryTableViewCell.swift
Podcast/ListeningHistoryTableViewCell.swift
@@ -29,7 +29,7 @@ class ListeningHistoryTableViewCell: UITableViewCell {
var episodeImageView: UIImageView!
var titleLabel: UILabel!
var detailLabel: UILabel!
- var moreButton: UIButton!
+ var moreButton: MoreButton!
var seperator: UIView!
weak var delegate: ListeningHistoryTableViewCellDelegate?
@@ -49,9 +49,8 @@ class ListeningHistoryTableViewCell: UITableViewCell {
detailLabel.textColor = .podcastGrayDark
contentView.addSubview(detailLabel)
- moreButton = UIButton(frame: CGRect.zero)
+ moreButton = MoreButton(frame: CGRect.zero)
moreButton.addTarget(self, action: #selector(didPressMoreButton), for: .touchUpInside)
- moreButton.setImage(#imageLiteral(resourceName: "more_icon"), for: .normal)
contentView.addSubview(moreButton)
seperator = UIView(frame: CGRect.zero)

MODIFY
Podcast/PlayButton.swift
Podcast/PlayButton.swift
import UIKit
class PlayButton: UIButton {
+ let buttonTitlePadding: CGFloat = 7
override init(frame: CGRect) {
super.init(frame: frame)
@@ -20,6 +21,7 @@ class PlayButton: UIButton {
contentHorizontalAlignment = .left
setTitleColor(.podcastBlack, for: .normal)
setTitleColor(.podcastGreenBlue, for: .selected)
+ titleEdgeInsets = UIEdgeInsets(top: 0, left: buttonTitlePadding, bottom: 0, right: 0)
}
required init?(coder aDecoder: NSCoder) {

MODIFY
Podcast/SearchEpisodeTableViewCell.swift
Podcast/SearchEpisodeTableViewCell.swift
@@ -28,7 +28,7 @@ class SearchEpisodeTableViewCell: UITableViewCell {
var episodeImageView: UIImageView!
var titleLabel: UILabel!
var detailLabel: UILabel!
- var playButton: UIButton!
+ var playButton: PlayButton!
var playButtonActivated = false
var index: Int!

refactor to use custom buttons