Archived
Changed "done" to "save" in the English translation and made tiny code tweaks
This commit is contained in:
@@ -101,7 +101,7 @@
|
||||
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||
<items>
|
||||
<navigationItem title="Customize" id="9Pf-pB-wLS">
|
||||
<barButtonItem key="rightBarButtonItem" title="Done" id="PWA-cp-z6o">
|
||||
<barButtonItem key="rightBarButtonItem" title="Save" id="PWA-cp-z6o">
|
||||
<connections>
|
||||
<action selector="done:" destination="8XB-jK-YFD" id="7wR-PO-v0i"/>
|
||||
</connections>
|
||||
@@ -216,7 +216,7 @@
|
||||
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||
<items>
|
||||
<navigationItem title="Title" id="HYG-gj-KYl">
|
||||
<barButtonItem key="rightBarButtonItem" title="Done" id="ZI8-Ec-yYU">
|
||||
<barButtonItem key="rightBarButtonItem" title="Save" id="ZI8-Ec-yYU">
|
||||
<connections>
|
||||
<action selector="done:" destination="xQo-mK-Kfi" id="DK7-6I-kUG"/>
|
||||
</connections>
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// GenericViewCell.swift
|
||||
// AvH Plan
|
||||
//
|
||||
// Created by Deniz Duezgoeren on 21.07.19.
|
||||
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MagazineLayout
|
||||
|
||||
class GenericViewCell: MagazineLayoutCollectionViewCell {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,83 +7,8 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MagazineLayout
|
||||
|
||||
class MenuViewCell: MagazineLayoutCollectionViewCell {
|
||||
|
||||
class MenuViewCell: GenericViewCell {
|
||||
|
||||
@IBOutlet weak var content: UILabel!
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user