Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI Support #1

Open
pedrommcarrasco opened this issue Jun 9, 2022 · 8 comments
Open

SwiftUI Support #1

pedrommcarrasco opened this issue Jun 9, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@pedrommcarrasco
Copy link

First of all, great work on the framework 馃憤
Are you planning to extend it with a SwiftUI version that uses a Representable? 馃

@pedrommcarrasco pedrommcarrasco changed the title SwiftUI Sugar SwiftUI Support Jun 9, 2022
@aheze
Copy link
Owner

aheze commented Jun 9, 2022

Thanks! Should be pretty simple, when I get the time I'll add support. However at WWDC22 SwiftUI now automatically gets support for half-sheet overlays with presentationDetents - Apple's implementation is probably much more polished than anything I can come up with!

@aheze aheze added the enhancement New feature or request label Jun 9, 2022
@pedrommcarrasco
Copy link
Author

pedrommcarrasco commented Jun 9, 2022

Apple's implementation is probably much more polished than anything I can come up with!

Don't be so pessimistic! The only difference between you and an Apple Engineer is the title - everything is highly subjective and I believe that, under the same conditions, you could perform as good, if not better, than one!

However at WWDC22 SwiftUI now automatically gets support for half-sheet overlays with presentationDetent

I think you might be under-selling your little framework here. SwiftUI's sheets act as modals, as in, they'll be placed on top of an existing view instead of sharing (splitting) the space with other view. I've yet to check the new sheets Apple presented at WWDC22, but assuming I'm right, your framework does a complete different job (both technically and visually) than Apple Sheets - and that's great, because that's exactly what I'm looking for :D

@aheze
Copy link
Owner

aheze commented Jun 9, 2022

That's true, thanks!

@ghost
Copy link

ghost commented Jun 29, 2022

Hey, I'm gonna have a go at porting this to SwiftUI

@aheze
Copy link
Owner

aheze commented Jun 29, 2022

Nice, thanks @FunkyMonkey729! Comment any problems you run into here

@ghost
Copy link

ghost commented Jun 29, 2022

I've got it kind of working, it's all good apart from animations a kinda broken, for example in this view,

struct ContentView: View {
    
    @State var toggleColour = false
    
    var body: some View {
        SplitSheetView(isPresented: $isPresented) {
            ZStack {
                if toggleColour {
                    Color.orange
                } else {
                    Color.green
                }
                Button("Toggle colour") {
                    withAnimation {
                        toggleColour.toggle()
                    }
                }
            }
        } sheet: {
            Color.red
        }
    }
}

it wouldn't animate between green and orange, only cut between them. Also observing the showing property to update isPresented breaks the presenting and dismiss animations. It seems that UIHostingController breaks all animations where the state is outside its root view. I'll try and think of a solution tomorrow, but I'm not sure it's possible without rewriting the whole thing in SwiftUI.

@LeoSM-07
Copy link

LeoSM-07 commented Jul 5, 2022

@FunkyMonkey729 any updates on this? Would love to use something like this in my SwiftUI project.

@ghost
Copy link

ghost commented Jul 5, 2022

@LeoSM-07 I can't find a way of getting the main view to observe if the sheet is showing or not without breaking the presenting and hiding animations. Pretty sure it's impossible as it involves redrawing the SwiftUI views as the presenting animation happens, which breaks the animation. Might try and rewrite it all in SwiftUI if I have time this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants