SwiftUIBackports icon indicating copy to clipboard operation
SwiftUIBackports copied to clipboard

Work in progress

Open shaps80 opened this issue 2 years ago • 14 comments

In order to keep everyone up-to-date with what I'm working on and to avoid duplication, here's a list of the currently planned additions/backports. Some just require documentation and cleanup (since they were developed some time ago), others are not yet in development. If you need a feature and want to know if you should start on it yourself, please check with me first to ensure we reach a similar solution.

WIP

  • [ ] scrollBounceBehaviour

Up next

Version 2.0.0

  • [x] FocusState
  • [x] onSubmit
  • [x] submitLabel
  • [x] presentationBackgroundInteraction
  • [x] presentationContentInteraction
  • [x] presentationCornerRadius
  • [x] TextEditor

Version `1.13.0

  • [x] UniformTypeIdentifiers

Version 1.12.0

  • [x] PhotosPicker

Version 1.11.0

  • [x] Toolbar (limited)

Version 1.10.0

Version 1.9.0

  • [x] ImageRenderer
  • [x] ShareLink

Version 1.5.0

  • [x] Table Hosting

Version 1.5.0

  • [x] LabelledContent
  • [x] quickLookPreview

Version 1.4.0

  • [x] ScrollDismissesKeyboard
  • [x] ScrollIndicators
  • [x] ScrollEnabled

Version 1.3.1

  • [x] List Pull-to-Refresh

Version 1.2.0

  • [x] Dismiss (environment)
  • [x] DynamicTypeSize
  • [x] AppStore Review
  • [x] OpenURL modifier

shaps80 avatar Jul 04 '22 08:07 shaps80

Hi @shaps80, great work! Are there any plans to backport the iOS 16 PhotosPicker?

schiewe avatar Aug 31 '22 13:08 schiewe

Potentially, I've done a similar thing in the past, including property wrappers that make fetching way easier and thus far simpler to build custom UI rapidly. Feel free to check it out: https://github.com/SwiftUI-Plus/Media

shaps80 avatar Aug 31 '22 15:08 shaps80

Hi @shaps80, thanks a lot for your work! This is really helpful!

I'm curious, do you think it would be possible to backport the @AccessibilityFocusState wrapper? I honestly have not clue if it's even possible.

Thanks in advance! 🙏

pblondin avatar Sep 19 '22 14:09 pblondin

To be honest, I have no clue, and I don't have the time at the moment to investigate. Feel free to look into it yourself and comment here with more details and then I can have a deeper discussion about it. I just don't have the time myself at the moment, sorry

shaps80 avatar Sep 19 '22 15:09 shaps80

Hi @shaps80, thanks for putting in all the work on this. I have a question regarding the new ShareLink. I currently use ActivitiyView, but I noticed in my fork there's a message at the top with the following:

This backport is now available as Backport.ShareLink, in a single Backports library, with a LOT more additions. This should simply my efforts and allow me and others to contribute more backports in the near future. SwiftUI Backports

But when I added the back ports library ShareLink wasn't there, when will this be there? Also, will you be adding extra functionality like ActivityView has where there's an onComplete. I need this because I update my CoreData Store when the share is complete.

tazmancoder avatar Sep 28 '22 14:09 tazmancoder

Hey! Thanks for reaching out. Yeah sorry about the left in comment. I had to pull that because it didn't work close enough to expectation. I had planned to revisit the implementation but hadn't found the time atm.

Regarding additional features I've only done this in a few key areas where the API was relevant. This would be a little more difficult to define given it's not supposed to be used in that way (at least currently).

That being said when I revisit this I'll have a think about those things. Tbh it'd be nice to support custom activity's etc too.

But perhaps my SwiftUI+ lib would be better suited for this. Let me see what I can come up with 👍

shaps80 avatar Sep 28 '22 17:09 shaps80

Hey,

Thanks for the reply I appreciate it. I will just have to continue using ActivityView since it does give me that functionality. I hope that ActivityView will be sticking around?

ShareLink, being new to us, maybe next year we’ll get that functionality. Of course if they don’t, I’ll have to come up with another way to know that something was shared.

Thanks again,

-Mark/*

Mark Perryman Apple (MAC) Enthusiast (435) 882-1008

On Sep 28, 2022, at 11:02 AM, Shaps @.***> wrote:

 Hey! Thanks for reaching out. Yeah sorry about the left in comment. I had to pull that because it didn't work close enough to expectation. I had planned to revisit the implementation but hadn't found the time atm.

Regarding additional features I've only done this in a few key areas where the API was relevant. This would be a little more difficult to define given it's not supposed to be used in that way (at least currently).

That being said when I revisit this I'll have a think about those things. Tbh it'd be nice to support custom activity's etc too.

But perhaps my SwiftUI+ lib would be better suited for this. Let me see what I can come up with 👍

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

tazmancoder avatar Sep 28 '22 19:09 tazmancoder

Yep ActivityView is def sticking around since its super useful. I’ll take another crack at ShareLink at some point, will keep this Issue open a little longer so I can reply to you if I manage something earlier 👍

shaps80 avatar Sep 28 '22 19:09 shaps80

@tazmancoder great news, I found the old branch and realised I'd gone a lot further than I'd expected. I've filled in the blanks and it's pretty close now. Including iOS and macOS support.

I had to include something like Transferable but its obviously not a complete backport.

However there's a new API in the CoreTransferable that allows you to get progress and feedback when an NSItemProvider has finished loading some resource. I'm thinking this could be a nice approach for knowing when 'sharing' has completed, that's not directly connected to ShareLink which is a UI element.

This would likely suit your needs as well, since updating your model should occur once the resource has actually been shared, not when some UI has been dismissed.

Will keep you updated, but should have a branch, including this ShareLink implementation, by tomorrow 👍

Side note, in order to support arbitrary view's for preview's etc I also back ported the new ImageRenderer so that'll be included in the backports as well 👍

shaps80 avatar Sep 29 '22 11:09 shaps80

That’s awesome, let me know when I can start to use it. If you could show me an example, I am a visual learner, its hard for me to dig through documentation, although I am getting better at that, but still prefer an example with a little explanation of what’s going on.

Thanks,

-Mark/*

Mark J Perryman Apple Product Enthusiast (435) 882-1008

On Sep 29, 2022, at 5:58 AM, Shaps @.***> wrote:

@tazmancoder https://github.com/tazmancoder great news, I found the old branch and realised I'd gone a lot further than I'd expected. I've filled in the blanks and it's pretty close now. Including iOS and macOS support.

I had to include something like Transferable but its obviously not a complete backport.

However there's a new API in the CoreTransferable that allows you to get progress and feedback when an NSItemProvider has finished loading some resource. I'm thinking this could be a nice approach for knowing when 'sharing' has completed, that's not directly connected to ShareLink which is a UI element.

This would likely suit your needs as well, since updating your model should occur once the resource has actually been shared, not when some UI has been dismissed.

Will keep you updated, but should have a branch, including this ShareLink implementation, by tomorrow 👍

— Reply to this email directly, view it on GitHub https://github.com/shaps80/SwiftUIBackports/issues/9#issuecomment-1262174322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6AQV4VIRZQN4TGANBRU73WAV74VANCNFSM52SLBCKQ. You are receiving this because you were mentioned.

tazmancoder avatar Sep 29 '22 12:09 tazmancoder

FYI I’ve fallen sick today, will get to this very soon, just need a couple days 👍🏻

shaps80 avatar Sep 30 '22 17:09 shaps80

@tazmancoder ok so if you point to main you can try out the initial ShareLink implementation. It currently support String, URL, Image and UI/NS Image types.

In order to support custom previews and things like import/export including knowledge about transfers, I plan to also backport Tranferable. More specifically this will bring support for arbitrary Data and Codable types, making it far more useful without having to do the copying to file (for example) manually.

This will take a while longer but the current implementation is pretty usable for the most use-cases.

main also now includes a full implementation of ImageRenderer however its currently only for iOS (macOS support coming soon)

For a rough example, these all work perfectly.

VStack(spacing: 40) {
    Backport.ShareLink(item: "Hello, world!") {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text("Hello, world!")
        }
    }
    .buttonStyle(.plain)

    Backport.ShareLink(item: "Some text to share")
    Backport.ShareLink("Benkau", item: URL(string: "https://benkau.com")!)
}

Even a few hidden extras 'just work' – like the right Label style is used in toolbar buttons so you don't see the text for example. And also the title support localization keys, etc. as expected too.


Final note

The share sheet implementation here is far better than ActivityView, since it makes use of the newer APIs and ensures the sheet presents as quickly as possible regardless of the content. Its also macOS supported!

If you don't find what you're looking for in ShareLink and want to use that directly, you can just copy/paste the new implementation I wrote for this for presenting the sheet itself.

It's called ShareSheet and it uses ActivityItem to control presentation. I will not be providing those types publicly here since they're not 'backports' but you can absolutely copy/paste them for now if you want a more performant implementation that feels more familiar to the previous library.

I will later update ActivityView to use this new approach, will take a while longer though and it'll be a 2.0 for that lib, deprecating the existing APIs in favour of the new one.

shaps80 avatar Oct 03 '22 14:10 shaps80

Good morning,

I have a question, I am using ActivityView in one of my Apps. I have noticed that if you bring up the activity view and choose to email or text or anything else. If you cancel the email or text the activity view doesn’t dismiss. I can’t seem to figure out why this is not dismissing. Any help or advice would be appreciated….

Thanks,

-Mark/*

Mark J Perryman Apple Product Enthusiast (435) 882-1008

tazmancoder avatar Nov 15 '22 14:11 tazmancoder

@tazmancoder as mentioned above, this package does not use that implementation so I hope you don't think I'm ignoring the question but I don't want to flood this ticket which was honestly just for my own tracking of work in progress, in a transparent way.

Thanks.

shaps80 avatar Feb 06 '23 09:02 shaps80