forked from tvidenov/appstore-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLargeCategoryCell.swift
39 lines (31 loc) · 1.52 KB
/
LargeCategoryCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// LargeCategoryCell.swift
// AppStore
//
// Created by Tihomir Videnov on 11/12/16.
// Copyright © 2016 Tihomir Videnov. All rights reserved.
//
import UIKit
class LargeCategoryCell: CategoryCell {
private let largeCellId = "LargeCellId"
override func setupViews() {
super.setupViews()
appsCollectionView.register(LargeAppCell.self, forCellWithReuseIdentifier: largeCellId)
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: largeCellId, for: indexPath) as! LargeAppCell
cell.app = appCategory?.apps?[indexPath.row]
return cell
}
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 200, height: frame.height - 32)
}
fileprivate class LargeAppCell: AppCell {
fileprivate override func setupViews() {
imageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(imageView)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": imageView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-2-[v0]-14-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": imageView]))
}
}
}