This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DetailBackdropView: UICollectionReusableView { | |
| /// Some Code omitted | |
| @IBOutlet weak var playButton: UIButton! | |
| @IBOutlet weak var wishlistButton: UIButton! | |
| private let focusGuide = UIFocusGuide() | |
| override func awakeFromNib() { | |
| super.awakeFromNib() | |
| setupView() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func openPlayer(with asset: AssetModel) { | |
| if let playbackUrl = asset.url.toUrl { | |
| let player = AVPlayer(url: playbackUrl) | |
| let controller = AVPlayerViewController() | |
| controller.player = player | |
| present(controller, animated: true) { | |
| player.play() | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DetailBackdropView: UICollectionReusableView { | |
| @IBOutlet weak var imageView: UIImageView! | |
| @IBOutlet weak var titleLabel: UILabel! | |
| @IBOutlet weak var summaryLabel: UILabel! | |
| typealias ButtonTapClosure = (() -> Void) | |
| public var onPlay: ButtonTapClosure? | |
| public var onWishlist: ButtonTapClosure? | |
| @IBAction func playButtonTapped(_ sender: Any) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension DetailViewController: UICollectionViewDataSource { | |
| func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
| return 1 | |
| } | |
| func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
| let collectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: kRailCellIdentifier, for: indexPath) as? RailCell | |
| guard let cell = collectionCell else { | |
| return UICollectionViewCell() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DetailViewController: UIViewController { | |
| @IBOutlet weak var collectionView: UICollectionView! | |
| var asset: AssetModel! | |
| var rail: RailModel! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| setupView() | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private let kPostViewTag = 1100 | |
| class AssetCell: UICollectionViewCell { | |
| override func prepareForReuse() { | |
| super.prepareForReuse() | |
| if let view = contentView.viewWithTag(kPostViewTag) { | |
| view.removeFromSuperview() | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool { | |
| return true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension RailCell: UICollectionViewDataSource { | |
| func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
| return rail.list.count | |
| } | |
| func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
| let collectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: kAssetCellIdentifier, for: indexPath) as? AssetCell | |
| guard let asset = rail?.list[indexPath.item], let cell = collectionCell else { | |
| return UICollectionViewCell() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RailCell: UICollectionViewCell { | |
| @IBOutlet weak var collectionView: UICollectionView! | |
| private var rail: RailModel! | |
| typealias CellSelectionClosure = ((RailModel, AssetModel) -> Void) | |
| public var onSelect: CellSelectionClosure? | |
| override func awakeFromNib() { | |
| super.awakeFromNib() | |
| setupView() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func loadData(page: PageModel) { | |
| pageModel = page | |
| collectionView.reloadData() | |
| } |