danielsaidi / SwiftUIKit

SwiftUIKit is a Swift SDK that adds extra functionality to Swift & SwiftUI.
MIT License
1.42k stars 56 forks source link

Backported ImageRenderer for >=iOS13 in the newest compilators #24

Closed arkus-pm closed 1 year ago

arkus-pm commented 1 year ago
  1. Added runtime check for iOS version
  2. Main init overload mimics ImageRenderer for iOS 16, without size property
  3. Now size is optional, with calculation from content's frame. Frame has to be specified though (via .frame() modificator)

This: ImageRenderer(content: Text("Hello").frame(width: 1080, height: 1080))

Is equivalent to: ImageRenderer(content: Text("Hello"), size: CGSize(width: 1080, height: 1080))

arkus-pm commented 1 year ago

Might be better idea to make size as optional enum: .screenSize and .contentSize. Since it's been pretty handy to have just a content in phone's frame size.

arkus-pm commented 1 year ago

Looks great! But why do we need the @mainactor annotations?

Can't really explain, I've reused this part from the previous version and decided not to change things that work and I am not aware of how

danielsaidi commented 1 year ago

Ok :) In that case, I think I will just deprecate the backport altogether since I don't use it myself and having it in the library will just become messy.

Great job with the backport design, though! I hope you can use it in your own projects with great success.