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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a static presentation mode suitable for embedding in a SwiftUI sheet #164

Open
jaflo opened this issue Jul 14, 2021 · 5 comments
Open

Comments

@jaflo
Copy link

jaflo commented Jul 14, 2021

I am trying to use the SDK with SwiftUI and have taken an approach similar to #44 to present the picker in a sheet. Everything looks good, the only issues are that:

  • there is a gap above the grabber since everything is embedded in the modal, but padding is added by the SDK even when trayHeightMultiplier is set to 1, and
  • when dragging down, the picker becomes smaller, but the containing modal doesn't move, making everything look off.

Is it possible to get an option to make the provided interface appear static? This mode would make it suitable to be embedded in another view that takes care of proper presentation (so no need for the top padding, grabber, or ability to drag down) and dismissal (no swiping down of the view to dismiss).

Gap at top

When dragging down

@cgmaier
Copy link
Contributor

cgmaier commented Aug 4, 2021

hey @jaflo we've been working on a better solution for developers using SwiftUI and hope to share an update soon.

@ALexanderLonsky
Copy link
Collaborator

A new property of GiphyViewController called swiftUIEnabled was added in v2.1.11 to provide a better experience for developers using SwiftUI

@cgmaier cgmaier closed this as completed May 2, 2022
@cgmaier
Copy link
Contributor

cgmaier commented May 2, 2022

closing this, but please reopen if you have ideas for how we can assist here further!

@cerupcat
Copy link

cerupcat commented Jun 15, 2022

@cgmaier @ALexanderLonsky Is there any documentation for swiftUIEnabled? I've enabled it, but it doesn't seem change any behavior from what I can tell. How are we supposed to use/display GiphyViewController with this enabled?

From what I can tell, with swiftUIEnabled it has all the same issues. The background is still white and it's not possible to swipe down to dismiss. The only thing this flag seems to fix is some weird behavior on the search bar.

@cgmaier cgmaier reopened this Dec 8, 2022
@ALexanderLonsky
Copy link
Collaborator

hey @cerupcat, I apologize for the late response.
Hopefully, you will find this code snippet useful:

struct GiphyPicker: UIViewControllerRepresentable {
    func makeUIViewController(context: UIViewControllerRepresentableContext<GiphyPicker>) -> GiphyViewController {
        
        Giphy.configure(apiKey: apiKey)
     
        let giphy = GiphyViewController()
        GiphyViewController.trayHeightMultiplier = 1.0
        giphy.swiftUIEnabled = true
        giphy.shouldLocalizeSearch = true
        giphy.dimBackground = true
        giphy.modalPresentationStyle = .currentContext
        
        
        return giphy
    }
    
    func updateUIViewController(_ uiViewController: GiphyViewController, context: UIViewControllerRepresentableContext<GiphyPicker>) {
    }
}

struct ContentView: View {
    @State private var showingDialog = false
    
    var body: some View {
        Button("Show Giphy Dialog") {
            showingDialog.toggle()
        }
        .padding()
        .sheet(isPresented: $showingDialog, content: {
            GiphyPicker()
        })
        
    }
}

The following is a demonstration:
swiftuienabled

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

No branches or pull requests

4 participants