Skip to content

Update with iPhone 15 devices #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions Sources/SnapshotTesting/Common/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,75 @@
return .init(safeArea: safeArea, size: size, traits: .iPhone13ProMax(orientation))
}

//https://useyourloaf.com/blog/iphone-15-screen-sizes/
public static let iPhone15 = ViewImageConfig.iPhone15(.portrait)

public static func iPhone15(_ orientation: Orientation) -> ViewImageConfig {
let safeArea: UIEdgeInsets
let size: CGSize
switch orientation {
case .landscape:
safeArea = .init(top: 0, left: 59, bottom: 21, right: 59)
size = .init(width: 852, height: 393)
case .portrait:
safeArea = .init(top: 59, left: 0, bottom: 34, right: 0)
size = .init(width: 393, height: 852)
}

return .init(safeArea: safeArea, size: size, traits: .iPhone15(orientation))
}

public static let iPhone15Plus = ViewImageConfig.iPhone15Plus(.portrait)

public static func iPhone15Plus(_ orientation: Orientation) -> ViewImageConfig {
let safeArea: UIEdgeInsets
let size: CGSize
switch orientation {
case .landscape:
safeArea = .init(top: 0, left: 59, bottom: 21, right: 59)
size = .init(width: 932, height: 430)
case .portrait:
safeArea = .init(top: 59, left: 0, bottom: 34, right: 0)
size = .init(width: 430, height: 932)
}

return .init(safeArea: safeArea, size: size, traits: .iPhone15Plus(orientation))
}

public static let iPhone15Pro = ViewImageConfig.iPhone15Pro(.portrait)

public static func iPhone15Pro(_ orientation: Orientation) -> ViewImageConfig {
let safeArea: UIEdgeInsets
let size: CGSize
switch orientation {
case .landscape:
safeArea = .init(top: 0, left: 59, bottom: 21, right: 59)
size = .init(width: 852, height: 393)
case .portrait:
safeArea = .init(top: 59, left: 0, bottom: 34, right: 0)
size = .init(width: 393, height: 852)
}

return .init(safeArea: safeArea, size: size, traits: .iPhone15Pro(orientation))
}

public static let iPhone15ProMax = ViewImageConfig.iPhone15ProMax(.portrait)

public static func iPhone15ProMax(_ orientation: Orientation) -> ViewImageConfig {
let safeArea: UIEdgeInsets
let size: CGSize
switch orientation {
case .landscape:
safeArea = .init(top: 0, left: 59, bottom: 21, right: 59)
size = .init(width: 932, height: 430)
case .portrait:
safeArea = .init(top: 59, left: 0, bottom: 34, right: 0)
size = .init(width: 430, height: 932)
}

return .init(safeArea: safeArea, size: size, traits: .iPhone15ProMax(orientation))
}

public static let iPadMini = ViewImageConfig.iPadMini(.landscape)

public static func iPadMini(_ orientation: Orientation) -> ViewImageConfig {
Expand Down Expand Up @@ -772,6 +841,106 @@
)
}
}

public static func iPhone15(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone)
]
switch orientation {
case .landscape:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact)
]
)
case .portrait:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular)
]
)
}
}

public static func iPhone15Plus(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
.init(forceTouchCapability: .available),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure these match the actual values, and other places: https://github.com/playbook-ui/playbook-ios/blob/798f686a6d73318185f85d844876274e91f1f3a2/Sources/Playbook/SnapshotSupport/SnapshotDevice.swift#L739

iPhone X series was the last to support force touch afaik

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @luispadron can you approve it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have maintainer access unfortunately

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:( who can approve for merge ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone)
]
switch orientation {
case .landscape:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact)
]
)
case .portrait:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular)
]
)
}
}

public static func iPhone15Pro(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone)
]
switch orientation {
case .landscape:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact)
]
)
case .portrait:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular)
]
)
}
}

public static func iPhone15ProMax(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone)
]
switch orientation {
case .landscape:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact)
]
)
case .portrait:
return .init(
traitsFrom: base + [
.init(horizontalSizeClass: .compact),
.init(verticalSizeClass: .regular)
]
)
}
}

public static let iPadMini = iPad
public static let iPadMini_Compact_SplitView = iPadCompactSplitView
Expand Down