sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.97k stars 117 forks source link

Fix preserve color space for `Color` type #105

Closed hank121314 closed 2 years ago

hank121314 commented 2 years ago

Summary

Fixes: #97.

By default, ColorBridge will convert Color into UIColor in non-macOS platform. UIColor does not preserve the color space, but Color should store the color space.

Solution

Trying to preserve color space whenever Color.cgColor exists. If SwiftUi.Color has cgColor property, Defaults will serialize and store its colorspace and components, then deserialize it with these properties. If not, Defaults will use NSSecureCodingBridge to do the serialization and deserialization.

Thanks

Thanks for your code review 😄 !

sindresorhus commented 2 years ago

After this PR is merged, do you plan any more changes, or should I do a release?

hank121314 commented 2 years ago

After this PR is merged, do you plan any more changes, or should I do a release?

I have no immediate plan for any more changes. I think we should do a release after this PR gets merged.

Thanks!