ios – Affirmation dialog doesn’t seem for sure gadgets on iPad… is that this a bug?

Spread the love


I’ve this code:

struct ContentView: View {
  
  non-public var columns: [GridItem] = [
    GridItem(.adaptive(minimum: .infinity, maximum: .infinity), spacing: 0),
    GridItem(.adaptive(minimum: .infinity, maximum: .infinity), spacing: 0),
    GridItem(.adaptive(minimum: .infinity, maximum: .infinity), spacing: 0)]
  
  
  let gadgets:[Int]
  
  init() {
    let strideSequence = stride(from: 0, to: 100, by: 1)
    gadgets = Array(strideSequence)
  }

  var physique: some View {
    ScrollView{
      VStack(alignment: .heart){
        LazyVGrid(
          columns: columns,
          alignment: .heart,
          spacing: 10,
          pinnedViews: []
        ) {
          ForEach(gadgets, id:.self) { merchandise in
            Element(merchandise:String(merchandise))
              .id(merchandise)
          }
        }
      }
    }
  }
}

struct Element: View {
  
  var merchandise:String
  @State non-public var showPopover = false
  
  
  var physique: some View {
    Button(motion: {
      showPopover.toggle()
    }, label: {
      Textual content(merchandise)
        .body(width: 200, peak: 200)
        .background(Colour.black)
        .foregroundColor(.white)
    })
    
    .id(merchandise)
    .confirmationDialog(merchandise, $showPopover)
  }
}



struct ConfirmationDialog: ViewModifier {
  
  non-public var merchandise:String
  @Binding non-public var showPopover:Bool
  
  
  init(_ merchandise:String,
       _ showPopover:Binding<Bool>) {
    self.merchandise = merchandise
    self._showPopover = showPopover
  }
  
  func physique(content material: Content material) -> some View {
    content material
      .confirmationDialog("CONFIRM",
                          isPresented: $showPopover,
                          titleVisibility: .seen) {
        

        Button(motion: {
          
        }, label: {
          Textual content("choice 1")
        })
        
        Button(motion: {
          
        }, label: {
          Textual content("choice 1")
        })
        
        
      }
  message: {
    Textual content("CONFIRM")
    
  }
    
  }
  
}

extension View {
  func confirmationDialog(_ merchandise:String, _ showPopover:Binding<Bool>) -> some View {
    self.modifier(ConfirmationDialog(merchandise, showPopover))
  }
}

This code exhibits a LazyVGrid of numbers enclosed in black squares.

Run this code on an iPad, as a result of it really works nice on iPhone.

Once you faucet an merchandise, a affirmation dialog seems, however only for the primary gadgets.

Attempt to faucet on merchandise 95.

why?

Leave a Reply

Your email address will not be published. Required fields are marked *