SwiftUI Movable Grids in 5 Mins - Drag & Drop - Xcode 15

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ย. 2024

ความคิดเห็น • 30

  • @eduardstreltsov3961
    @eduardstreltsov3961 ปีที่แล้ว +11

    thank you! please make drag n drop from one list to another, like kanban board

    • @Kavsoft
      @Kavsoft  ปีที่แล้ว +3

      th-cam.com/video/iDnrraNom0o/w-d-xo.html

  • @danvilela
    @danvilela ปีที่แล้ว +1

    Swift UI seems like magic 😍

  • @andrejkling3886
    @andrejkling3886 ปีที่แล้ว +1

    Awesome 👏

  • @thatpolodude
    @thatpolodude 4 หลายเดือนก่อน

    Brilliant

  • @mohd.rajeen4256
    @mohd.rajeen4256 ปีที่แล้ว +1

    Hey, great video!
    I have a doubt that I have searched at multiple places but couldn't find the solution.
    While we are dragging one item from it's place, how can we make the original item disappear from its place and only make the preview visible until it is dropped at some proper location?
    So basically how can we completely detach the item while it is being dragged?
    Thanks

  • @nougatbits.fortnite
    @nougatbits.fortnite ปีที่แล้ว

    Hey Awesome video i would like to give you some video suggestion since its hard to find something like this in the internet it would be creating some small custom browser with swift as macOs desktop app

  • @cakeezz
    @cakeezz 5 หลายเดือนก่อน +1

    the onAppear trick doesnt seem to work. Do you know any other way to do it?

    • @RaduUrsache
      @RaduUrsache 3 หลายเดือนก่อน

      it does.

  • @_sabot
    @_sabot 11 หลายเดือนก่อน +1

    When running this code on macOS (14.0) the trick to find the source view with the onAppear on the draggable preview doesn't work correctly. It's only called after the window lost it's focus. Looks like a SwiftUI bug to me, but do you know some workaround or other method to identify the source view?

    • @Kavsoft
      @Kavsoft  11 หลายเดือนก่อน +2

      I too noticed that on macOS the on-appear is not appearing. I will find a way for that, and if so, I will update this comment!

    • @yuanyewang
      @yuanyewang 8 หลายเดือนก่อน +1

      @@Kavsoft FYI, I have a workaround to add a "onTapGesture" at the RoundedRectangle, before ".graggable(color")
      RoundedRectangle(cornerRadius: 10)
      .fill(color.gradient)
      // start
      .onTapGesture {
      draggingItem = color
      }
      // stop
      .draggable(color) {

  • @alexandardimcevski9136
    @alexandardimcevski9136 ปีที่แล้ว

    It works. Except the animation when you drag. Do you know why?

  • @Drow_choi
    @Drow_choi 8 หลายเดือนก่อน

    Hello, I have a question.
    I have to make two .onDrops in ScrollView called A View within NavigationStack.
    How do I handle .onDrops inside A View and .onDrops delivered outside B View?
    Everything that is delivered by drag and drop is a string

    • @Kavsoft
      @Kavsoft  8 หลายเดือนก่อน

      Check this video!
      th-cam.com/video/iDnrraNom0o/w-d-xo.html

  • @t0p1c85
    @t0p1c85 ปีที่แล้ว

    Thanks for your tutorial, and I have a question.
    How to implement the function of changing the display mode of the grid by clicking the toolbar?
    Thank you!!!

    • @Kavsoft
      @Kavsoft  ปีที่แล้ว

      Do you mean changing layout from Vertical to Horizontal?

    • @t0p1c85
      @t0p1c85 ปีที่แล้ว

      @@Kavsoft
      The demonstration at 00:30 in the video

    • @Kavsoft
      @Kavsoft  ปีที่แล้ว +4

      Oh, simple add a toolbar button and create a state variable called isToggled and update the toggle status inside the button action with animation, then change the grid column from 3 to 2 based on the toggle status, like this
      @State private var isToggled = false
      ///
      let columns = Array(repeating: GridItem(.flexible(), count: isToggled ? 2 : 3)
      ///
      ToolBarItem {
      Button{
      withAnimation{
      isToggled.toggle()
      }
      } label: {
      ///
      }
      }

    • @t0p1c85
      @t0p1c85 ปีที่แล้ว

      @@Kavsoft Thank you so much!🤩

  •  ปีที่แล้ว

    Table Improvements
    OutlineGroup Column Reordering | Column Visibility - this is from, WWDC slide.
    Document Group, and of course Swift❤Data 👏👍👍👍
    EDIT: Done, works on "Mac", but is some bug(?), on second "active" app window, reordering starts working...

  • @arjundureja
    @arjundureja ปีที่แล้ว

    nice thumbnail

  • @Qwertyuuipasdf
    @Qwertyuuipasdf ปีที่แล้ว

    I can't find boucy Animation. is that your custom Animation??

    • @Kavsoft
      @Kavsoft  ปีที่แล้ว

      Bouncy animation is available from iOS 17+

    • @Qwertyuuipasdf
      @Qwertyuuipasdf ปีที่แล้ว

      @@Kavsoft oh thank you😉

  • @joshuarileymagic
    @joshuarileymagic ปีที่แล้ว

    Hello, I'm a paid subscriber, could I contact you for a custom version of this with variable width and heights like cells wrapping multiple columns/rows with drag and drop

  • @FrenchModders
    @FrenchModders ปีที่แล้ว

    Work with iOS 16 ?

    • @Kavsoft
      @Kavsoft  ปีที่แล้ว +3

      Yep!

  • @julkabak9990
    @julkabak9990 ปีที่แล้ว

    Hey! I am using the grid you did here th-cam.com/video/VrwINubmq5g/w-d-xo.html with this variable height for each cards. When I try to make this Drag & Drop work I need to wrap my cards into a geometry reader that destroys the entire layout... How can I for instance keep the height dynamic for each cards? Thanks for your help!

  • @MaximeJunique
    @MaximeJunique ปีที่แล้ว

    Hey! I am using the grid you did here th-cam.com/video/VrwINubmq5g/w-d-xo.html with this variable height for each cards. When I try to make this Drag & Drop work I need to wrap my cards into a geometry reader that destroys the entire layout... How can I for instance keep the height dynamic for each cards? Thanks for your help!