forked from zelo72/mastodon-ios
chore: add translatesAutoresizingMaskIntoConstraints = false to all constrain method
This commit is contained in:
parent
dff874af76
commit
fde5baad2e
|
@ -97,6 +97,7 @@ extension UIView {
|
||||||
|
|
||||||
func pinToBottom(to: UIView, height: CGFloat) {
|
func pinToBottom(to: UIView, height: CGFloat) {
|
||||||
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.width, toView: to),
|
constraint(.width, toView: to),
|
||||||
constraint(toBottom: to, constant: 0.0),
|
constraint(toBottom: to, constant: 0.0),
|
||||||
|
@ -124,6 +125,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainTopCorners(sidePadding: CGFloat, topPadding: CGFloat, topLayoutGuide: UILayoutSupport) {
|
func constrainTopCorners(sidePadding: CGFloat, topPadding: CGFloat, topLayoutGuide: UILayoutSupport) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.leading, toView: view, constant: sidePadding),
|
constraint(.leading, toView: view, constant: sidePadding),
|
||||||
NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: topLayoutGuide, attribute: .bottom, multiplier: 1.0, constant: topPadding),
|
NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: topLayoutGuide, attribute: .bottom, multiplier: 1.0, constant: topPadding),
|
||||||
|
@ -133,6 +135,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainTopCorners(sidePadding: CGFloat, topPadding: CGFloat) {
|
func constrainTopCorners(sidePadding: CGFloat, topPadding: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.leading, toView: view, constant: sidePadding),
|
constraint(.leading, toView: view, constant: sidePadding),
|
||||||
constraint(.top, toView: view, constant: topPadding),
|
constraint(.top, toView: view, constant: topPadding),
|
||||||
|
@ -142,6 +145,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainTopCorners(height: CGFloat) {
|
func constrainTopCorners(height: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.leading, toView: view),
|
constraint(.leading, toView: view),
|
||||||
constraint(.top, toView: view),
|
constraint(.top, toView: view),
|
||||||
|
@ -152,6 +156,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainBottomCorners(sidePadding: CGFloat, bottomPadding: CGFloat) {
|
func constrainBottomCorners(sidePadding: CGFloat, bottomPadding: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.leading, toView: view, constant: sidePadding),
|
constraint(.leading, toView: view, constant: sidePadding),
|
||||||
constraint(.bottom, toView: view, constant: -bottomPadding),
|
constraint(.bottom, toView: view, constant: -bottomPadding),
|
||||||
|
@ -161,6 +166,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainBottomCorners(height: CGFloat) {
|
func constrainBottomCorners(height: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.leading, toView: view),
|
constraint(.leading, toView: view),
|
||||||
constraint(.bottom, toView: view),
|
constraint(.bottom, toView: view),
|
||||||
|
@ -171,6 +177,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainLeadingCorners() {
|
func constrainLeadingCorners() {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.top, toView: view),
|
constraint(.top, toView: view),
|
||||||
constraint(.leading, toView: view),
|
constraint(.leading, toView: view),
|
||||||
|
@ -180,6 +187,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainTrailingCorners() {
|
func constrainTrailingCorners() {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.top, toView: view),
|
constraint(.top, toView: view),
|
||||||
constraint(.trailing, toView: view),
|
constraint(.trailing, toView: view),
|
||||||
|
@ -189,6 +197,7 @@ extension UIView {
|
||||||
|
|
||||||
func constrainToCenter() {
|
func constrainToCenter() {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.centerX, toView: view),
|
constraint(.centerX, toView: view),
|
||||||
constraint(.centerY, toView: view)
|
constraint(.centerY, toView: view)
|
||||||
|
@ -197,6 +206,7 @@ extension UIView {
|
||||||
|
|
||||||
func pinTo(viewAbove: UIView, padding: CGFloat = 0.0, height: CGFloat? = nil) {
|
func pinTo(viewAbove: UIView, padding: CGFloat = 0.0, height: CGFloat? = nil) {
|
||||||
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
constraint(.width, toView: viewAbove),
|
constraint(.width, toView: viewAbove),
|
||||||
constraint(toBottom: viewAbove, constant: padding),
|
constraint(toBottom: viewAbove, constant: padding),
|
||||||
|
@ -207,6 +217,7 @@ extension UIView {
|
||||||
|
|
||||||
func pin(toSize: CGSize) {
|
func pin(toSize: CGSize) {
|
||||||
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
widthAnchor.constraint(equalToConstant: toSize.width),
|
widthAnchor.constraint(equalToConstant: toSize.width),
|
||||||
heightAnchor.constraint(equalToConstant: toSize.height)])
|
heightAnchor.constraint(equalToConstant: toSize.height)])
|
||||||
|
@ -214,6 +225,7 @@ extension UIView {
|
||||||
|
|
||||||
func pinTopLeft(padding: CGFloat) {
|
func pinTopLeft(padding: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding),
|
leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding),
|
||||||
topAnchor.constraint(equalTo: view.topAnchor, constant: padding)])
|
topAnchor.constraint(equalTo: view.topAnchor, constant: padding)])
|
||||||
|
@ -221,6 +233,7 @@ extension UIView {
|
||||||
|
|
||||||
func pinTopRight(padding: CGFloat) {
|
func pinTopRight(padding: CGFloat) {
|
||||||
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard let view = superview else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
view.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding),
|
view.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding),
|
||||||
topAnchor.constraint(equalTo: view.topAnchor, constant: padding)])
|
topAnchor.constraint(equalTo: view.topAnchor, constant: padding)])
|
||||||
|
@ -228,6 +241,7 @@ extension UIView {
|
||||||
|
|
||||||
func pinTopLeft(toView: UIView, topPadding: CGFloat) {
|
func pinTopLeft(toView: UIView, topPadding: CGFloat) {
|
||||||
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
guard superview != nil else { assert(false, "Superview cannot be nil when adding contraints"); return }
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
constrain([
|
constrain([
|
||||||
leadingAnchor.constraint(equalTo: toView.leadingAnchor),
|
leadingAnchor.constraint(equalTo: toView.leadingAnchor),
|
||||||
topAnchor.constraint(equalTo: toView.bottomAnchor, constant: topPadding)])
|
topAnchor.constraint(equalTo: toView.bottomAnchor, constant: topPadding)])
|
||||||
|
|
|
@ -8,26 +8,25 @@
|
||||||
import Combine
|
import Combine
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Follow suggestions
|
|
||||||
///
|
|
||||||
/// Server-generated suggestions on who to follow, based on previous positive interactions.
|
|
||||||
///
|
|
||||||
/// Version history:
|
|
||||||
/// 2.4.3 - added
|
|
||||||
/// # Reference
|
|
||||||
/// [Document](https://docs.joinmastodon.org/methods/accounts/suggestions/)
|
|
||||||
/// - Parameters:
|
|
||||||
/// - session: `URLSession`
|
|
||||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
|
||||||
/// - query: query
|
|
||||||
/// - authorization: User token.
|
|
||||||
/// - Returns: `AnyPublisher` contains `Accounts` nested in the response
|
|
||||||
|
|
||||||
extension Mastodon.API.Suggestions {
|
extension Mastodon.API.Suggestions {
|
||||||
static func suggestionsURL(domain: String) -> URL {
|
static func suggestionsURL(domain: String) -> URL {
|
||||||
Mastodon.API.endpointURL(domain: domain).appendingPathComponent("api/v1/suggestions")
|
Mastodon.API.endpointURL(domain: domain).appendingPathComponent("api/v1/suggestions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Follow suggestions
|
||||||
|
///
|
||||||
|
/// Server-generated suggestions on who to follow, based on previous positive interactions.
|
||||||
|
///
|
||||||
|
/// Version history:
|
||||||
|
/// 2.4.3 - added
|
||||||
|
/// # Reference
|
||||||
|
/// [Document](https://docs.joinmastodon.org/methods/accounts/suggestions/)
|
||||||
|
/// - Parameters:
|
||||||
|
/// - session: `URLSession`
|
||||||
|
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||||
|
/// - query: query
|
||||||
|
/// - authorization: User token.
|
||||||
|
/// - Returns: `AnyPublisher` contains `Accounts` nested in the response
|
||||||
public static func get(
|
public static func get(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
|
|
|
@ -8,26 +8,25 @@
|
||||||
import Combine
|
import Combine
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Trending tags
|
|
||||||
///
|
|
||||||
/// Tags that are being used more frequently within the past week.
|
|
||||||
///
|
|
||||||
/// Version history:
|
|
||||||
/// 3.0.0 - added
|
|
||||||
/// # Reference
|
|
||||||
/// [Document](https://docs.joinmastodon.org/methods/instance/trends/)
|
|
||||||
/// - Parameters:
|
|
||||||
/// - session: `URLSession`
|
|
||||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
|
||||||
/// - query: query
|
|
||||||
/// - authorization: User token.
|
|
||||||
/// - Returns: `AnyPublisher` contains `Hashtags` nested in the response
|
|
||||||
|
|
||||||
extension Mastodon.API.Trends {
|
extension Mastodon.API.Trends {
|
||||||
static func trendsURL(domain: String) -> URL {
|
static func trendsURL(domain: String) -> URL {
|
||||||
Mastodon.API.endpointURL(domain: domain).appendingPathComponent("api/v1/trends")
|
Mastodon.API.endpointURL(domain: domain).appendingPathComponent("api/v1/trends")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Trending tags
|
||||||
|
///
|
||||||
|
/// Tags that are being used more frequently within the past week.
|
||||||
|
///
|
||||||
|
/// Version history:
|
||||||
|
/// 3.0.0 - added
|
||||||
|
/// # Reference
|
||||||
|
/// [Document](https://docs.joinmastodon.org/methods/instance/trends/)
|
||||||
|
/// - Parameters:
|
||||||
|
/// - session: `URLSession`
|
||||||
|
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||||
|
/// - query: query
|
||||||
|
/// - Returns: `AnyPublisher` contains `Hashtags` nested in the response
|
||||||
|
|
||||||
public static func get(
|
public static func get(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
|
|
Loading…
Reference in New Issue