Code Monkey home page Code Monkey logo

Comments (8)

 avatar commented on July 17, 2024 2

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.

from splitsheet.

pedrommcarrasco avatar pedrommcarrasco commented on July 17, 2024 1

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

from splitsheet.

 avatar commented on July 17, 2024 1

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

from splitsheet.

 avatar commented on July 17, 2024 1

@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.

from splitsheet.

aheze avatar aheze commented on July 17, 2024

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!

from splitsheet.

aheze avatar aheze commented on July 17, 2024

That's true, thanks!

from splitsheet.

aheze avatar aheze commented on July 17, 2024

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

from splitsheet.

LeoSM-07 avatar LeoSM-07 commented on July 17, 2024

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

from splitsheet.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.