exyte / FloatingButton

Easily customizable floating button menu created with SwiftUI
MIT License
1.12k stars 75 forks source link

Thread 1: Fatal error: Index out of range #7

Closed benstokoe closed 4 years ago

benstokoe commented 4 years ago

When using this I get the error Thread 1: Fatal error: Index out of range, screenshot below.

Screenshot 2020-10-02 at 20 36 24

I've followed the Example code but getting this issue...

var body: some View {
    let mainButton2 = AnyView(MainButton(imageName: "ellipsis"))

    let textButtons = (0..<MockData.iconAndTextTitles.count).reversed().map { i in
      AnyView(
        IconAndTextButton(
          imageName: MockData.iconAndTextImageNames[i],
          buttonText: MockData.iconAndTextTitles[i]
        )
      )    }

    return VStack {
      Spacer().layoutPriority(10)

      HStack {
        Spacer().layoutPriority(10)

        FloatingButton(mainButtonView: mainButton2, buttons: textButtons)
          .straight()
          .direction(.top)
          .alignment(.right)
          .spacing(10)
          .initialOpacity(0)
      }
    }
  }
ZStack {
  ....view code
  Button()
}
benstokoe commented 4 years ago

And when I do get something to work it looks like this (this is the example code now) Screenshot 2020-10-02 at 21 23 47

iOS14 with XCode 12

f3dm76 commented 4 years ago

@benstokoe Thanks for your report. Fixed the issue. Had to change example's layout a bit cause multiple Spacer().layoutPriority(10) break onPreferencesChanged calls for some reason in the latest swift version, hope Apple fixes this soon. Please check it out in version 0.0.3. Have a marvellous day!