Implemented colour picker, TODO: change plan cell colour to selected colours, make CollectionView refresh on colour picked, change selection visualisation in colour picker

This commit is contained in:
Deniz Duezgoeren
2019-07-21 21:14:38 +02:00
parent c041e67064
commit 13b9721c00
22 changed files with 1288 additions and 1224 deletions
+1 -75
View File
@@ -7,9 +7,8 @@
//
import UIKit
import MagazineLayout
class PlanViewCell: MagazineLayoutCollectionViewCell {
class PlanViewCell: GenericViewCell {
@IBOutlet weak var group: UILabel!
@IBOutlet weak var date: UILabel!
@@ -18,77 +17,4 @@ class PlanViewCell: MagazineLayoutCollectionViewCell {
@IBOutlet weak var additional: UILabel!
@IBOutlet weak var room: UILabel!
@IBOutlet weak var tintView: UIView!
private var widthConstraint: NSLayoutConstraint!
public override init(frame: CGRect) {
super.init(frame: frame)
contentView.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
bottomConstraint.priority = .required - 1
NSLayoutConstraint.activate(
[
leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
topAnchor.constraint(equalTo: contentView.topAnchor),
bottomConstraint
]
)
widthConstraint = widthAnchor.constraint(equalToConstant: bounds.width)
widthConstraint.priority = .required - 1
widthConstraint.isActive = true
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override open func awakeFromNib() {
super.awakeFromNib()
contentView.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
bottomConstraint.priority = .required - 1
NSLayoutConstraint.activate(
[
leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
topAnchor.constraint(equalTo: contentView.topAnchor),
bottomConstraint
]
)
widthConstraint = widthAnchor.constraint(equalToConstant: bounds.width)
widthConstraint.priority = .required - 1
widthConstraint.isActive = true
}
override open func preferredLayoutAttributesFitting(
_ layoutAttributes: UICollectionViewLayoutAttributes)
-> UICollectionViewLayoutAttributes
{
guard let attributes = layoutAttributes as? MagazineLayoutCollectionViewLayoutAttributes else {
assertionFailure("`layoutAttributes` must be an instance of `MagazineLayoutCollectionViewLayoutAttributes`")
return super.preferredLayoutAttributesFitting(layoutAttributes)
}
let size: CGSize
if attributes.shouldVerticallySelfSize {
widthConstraint.constant = layoutAttributes.size.width
size = super.preferredLayoutAttributesFitting(layoutAttributes).size
} else {
// No self-sizing is required; respect whatever size the layout determined.
size = layoutAttributes.size
}
layoutAttributes.size = size
return layoutAttributes
}
}