Automattic / Gravatar-SDK-iOS

Gravatar SDK is a Swift library that allows you to integrate Gravatar features into your own iOS applications.
https://gravatar.com
Mozilla Public License 2.0
36 stars 1 forks source link

Removing `UIScreen.main` due to deprecation warning #231

Closed etoledom closed 4 months ago

etoledom commented 4 months ago

Closes #156

Description

UIScreen.main has a deprecation warning:

@available(iOS, introduced: 2.0, deprecated: 100000, message: "Use a UIScreen instance found through context instead: i.e, view.window.windowScene.screen")
open class var main: UIScreen { get }

The proposed method to access it view.window.windowScene.screen won't work for us since we don't have direct access to a view on this context.

An alternative method to get the screen scale is using UITraitCollection. It will have the correct displayScale as long as we are running in a UIKit app. (This is the method KingFisher uses).

I've also added an alternative ImageProcessingMethod for a custom scale factor, in case the user requested a custom image size independent of screen scale.

With this change, we don't have the build error when building with strict concurrency.

Testing Steps