Skip to content

Add FXIOS-14817 [BrowserKit] Centralize the usage of UIScreen.main.value(forKey: _displayCornerRadius) to get device corner radius#34565

Merged
Alex-Bangu merged 6 commits into
mainfrom
abangu/centralize-device-radius
Jul 10, 2026
Merged

Add FXIOS-14817 [BrowserKit] Centralize the usage of UIScreen.main.value(forKey: _displayCornerRadius) to get device corner radius#34565
Alex-Bangu merged 6 commits into
mainfrom
abangu/centralize-device-radius

Conversation

@Alex-Bangu

Copy link
Copy Markdown
Member

📜 Tickets

Jira ticket
Github issue

💡 Description

Added a static variable to DeviceInfo and replaced existing usages of UIScreen.main.value(forKey: _displayCornerRadius) with DeviceInfo.deviceCornerRadius.

📝 Checklist

  • I filled in the ticket numbers and a description of my work
  • I updated the PR name to follow our PR naming guidelines
  • I ensured unit tests pass and wrote tests for new code
  • If working on UI, I checked and implemented accessibility (Dynamic Text and VoiceOver)
  • If adding telemetry, I read the data stewardship requirements and will request a data review
  • If adding or modifying strings, I read the guidelines and will request a string review from l10n
  • If needed, I updated documentation and added comments to complex code

@Alex-Bangu Alex-Bangu requested a review from a team as a code owner July 7, 2026 20:35
@mobiletest-ci-bot

mobiletest-ci-bot commented Jul 7, 2026

Copy link
Copy Markdown
Messages
📖 Project coverage: 44.61%

🧹 Tidy commit

Just 3 file(s) touched. Thanks for keeping it clean and review-friendly!

🙌 Friday high-five

Thanks for pushing us across the finish line this week! 🙌

✅ Code coverage

  • No new files detected so the coverage gate wasn't run.
  • No modified files had significant enough changes for the coverage gate to run.

Client.app: Coverage: 43.51

File Coverage
TabWebViewPreview.swift 50.0% ⚠️

Generated by 🚫 Danger Swift against 3fac2ef

open class DeviceInfo {
@MainActor
public static var deviceCornerRadius: CGFloat? {
return UIScreen.main.value(forKey: "_displayCornerRadius") as? CGFloat

@thatswinnie thatswinnie Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use UICornerConfiguration on iOS 26 instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked online @thatswinnie and i think UICornerConfiguration doesn't support querying the screen corner radius, we should use just the private one i guess

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

During the liquid glass event from Apple in Berlin they recommended using this API as it will match the devices corner radius which makes the UI feel more organic. Yes, it does not give you a number for the corner radius but I think we should still use it and only fall back to querying UIScreen when the new API is not available. For iOS 27 Apple says to avoid using UIScreen as this API is not reliable anymore with resizable shared screens, etc. and there is will an initiative to get rid of all the UIScreen uses in our code before iOS 27 is released. So using the new API here would help us in the long run.

Using the new API would look something like this:
view.cornerConfiguration = UICornerConfiguration.corners(radius: containerConcentric(minimum: 12))
view.cornerConfiguration = UICornerConfiguration.corners(radius: containerConcentric())


@MainActor
@available(iOS 26.0, *)
open class func deviceCornerConfiguration(minimumRadius: CGFloat) -> UICornerConfiguration {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding these. However I don't think we should add methods that are not used at the moment and as they are simple calls to the native API I am not sure we need them at all. What I'd rather like to see is using the new API in the CrossDissolveTransitionAnimator for iOS 26 and the screenCornerRadius for any version below.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes i totally agree @thatswinnie what if we add directly an extension to UIViewExtension inside common something like this:

extension UIView {

func applyScreenCornerRadius(minimumCornerRadius: CGFloat = 0) {
   if #available(iOS 26) {
      view.cornerConfiguration = UICornerConfiguration.
   } else {
      view.layer.cornerRadius = UIScreen.main.value(for: "") ?? minimumCornerRadius
   }

}

}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@FilippoZazzeroni great idea 🎉 Just wondering if we really need the minimumCornerRadius. Seems like we don't have that currently either.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @thatswinnie 🎉 , yes we don't need that, we can just default to 0 for the legacy path

@FilippoZazzeroni FilippoZazzeroni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM @Alex-Bangu just a couple of nits left and we should be good 💪

@MainActor
static let screenCornerRadius: CGFloat = {
return UIScreen.main.value(forKey: "_displayCornerRadius") as? CGFloat ?? 0.0
return DeviceInfo.deviceCornerRadius ?? 0.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't exists anymore we can just apply the screen corner radius directly to the view that needs it

private var layoutWasInvalidated = false
private var screenCornerRadius: CGFloat {
return UIScreen.main.value(forKey: "_displayCornerRadius") as? CGFloat ?? 0.0
return DeviceInfo.deviceCornerRadius ?? 0.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same for this one

/// Sets the corner radius to the devices current corner radius
func applyScreenCornerRadius() {
if #available(iOS 26.0, *) {
self.cornerConfiguration = UICornerConfiguration.corners(radius: .containerConcentric(minimum: 0))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: self can be removed here and in the else branch

@FilippoZazzeroni FilippoZazzeroni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great @Alex-Bangu 🔥

@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@Alex-Bangu Alex-Bangu merged commit b57bb39 into main Jul 10, 2026
12 checks passed
@Alex-Bangu Alex-Bangu deleted the abangu/centralize-device-radius branch July 10, 2026 15:17
@github-actions

Copy link
Copy Markdown
Contributor

🚀 PR merged to main, targeting version: 153.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants