nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
457 stars 19 forks source link

Customize animation parameters for WindowLink #49

Closed PhilipDukhov closed 4 months ago

PhilipDukhov commented 4 months ago

As I can see, right now window is presented with or without animation depending on context isAnimated value, and controlled by transition, but we would like to change animation curve to make it bouncier, do you think it's possible?

https://github.com/nathantannar4/Transmission/blob/6b3e6b46f34d0d18715d27c46e0053f1eda1bcd1/Sources/Transmission/Sources/Extensions/UIWindow%2BExtensions.swift#L10-L32

Sample code:

@State var isWindowPresented = false

var body: some View {
    Button("Show toast") {
         /// transition animation is expected to be customizable, but this parameter is ignored
        withAnimation(.linear(duration: 5)) {
            isWindowPresented.toggle()
        }
    }
    .window(
        transition: .move(edge: .top).combined(with: .opacity),
        isPresented: $isWindowPresented
    ) {
        Text("Toast")
    }
}
nathantannar4 commented 4 months ago

Support for custom animation curves incoming soon!

nathantannar4 commented 4 months ago

Supported in 1.4.0 👍🏻