[SwiftUI] Create Custom Full screen Modal presentation

Updated
Oct 6, 2019 12:37 PM
Created
Oct 6, 2019 12:35 PM
Tags
SwiftUIMemo
Keywords
Date

extension View {
  
  func fullScreenOnCurrentContext<Content>(isPresented: Binding<Bool>, @ViewBuilder content: () -> Content) -> some View where Content : View {
    
    ZStack {
      self
      
      if isPresented.wrappedValue {
        content()
          .transition(AnyTransition.move(edge: .bottom))
          .animation(.spring(response: 0.3, dampingFraction: 1, blendDuration: 0))
      }
    }
    
  }
  
}

.fullScreenOnCurrentContext(isPresented: $confirmsDelete) {
  DeleteEventView(
    onTapDelete: {
      
  }, onTapCancel: {
    withAnimation {
      self.confirmsDelete = false
    }
  })
}