exyte / AnimatedTabBar

A tabbar with a number of preset animations written in pure SwiftUI
https://exyte.com/
MIT License
380 stars 26 forks source link

Variable 'self.views' used before being initialized #15

Closed graygillman closed 3 months ago

graygillman commented 3 months ago

Recently been running into this issue which is breaking my entire App and the only way for me to get it to work is by removing the AnimatedTabBar package. Let me know if you find a fix to this issue.

`public struct AnimatedTabBar: View {

public enum BallTrajectory {
    case parabolic
    case teleport
    case straight
}

@Binding private var selectedIndex: Int
@Binding private var prevSelectedIndex: Int
private let views: [AnyView]

public init<Views>(selectedIndex: Binding<Int>,
                   prevSelectedIndex: Binding<Int>? = nil,
                   @ViewBuilder content: @escaping () -> TupleView<Views>) {
    self._selectedIndex = selectedIndex
    self._prevSelectedIndex = prevSelectedIndex ?? .constant(0)
    self.internalPrevSelectedIndex = selectedIndex.wrappedValue
    self.views = content().getViews
}

public init<Content: View>(selectedIndex: Binding<Int>,
                           prevSelectedIndex: Binding<Int>? = nil,
                           views: [Content]) {
    self._selectedIndex = selectedIndex
    self._prevSelectedIndex = prevSelectedIndex ?? .constant(0)
    self.internalPrevSelectedIndex = selectedIndex.wrappedValue
    self.views = views.map { AnyView($0) }
}public struct AnimatedTabBar: View {

public enum BallTrajectory {
    case parabolic
    case teleport
    case straight
}

@Binding private var selectedIndex: Int
@Binding private var prevSelectedIndex: Int
private let views: [AnyView]

public init<Views>(selectedIndex: Binding<Int>,
                   prevSelectedIndex: Binding<Int>? = nil,
                   @ViewBuilder content: @escaping () -> TupleView<Views>) {
    self._selectedIndex = selectedIndex
    self._prevSelectedIndex = prevSelectedIndex ?? .constant(0)
    self.internalPrevSelectedIndex = selectedIndex.wrappedValue
    self.views = content().getViews
}

public init<Content: View>(selectedIndex: Binding<Int>,
                           prevSelectedIndex: Binding<Int>? = nil,
                           views: [Content]) {
    self._selectedIndex = selectedIndex
    self._prevSelectedIndex = prevSelectedIndex ?? .constant(0)
    self.internalPrevSelectedIndex = selectedIndex.wrappedValue
    self.views = views.map { AnyView($0) }
}'
f3dm76 commented 3 months ago

@graygillman, thanks for the heads up, fixed in version 0.1.4

graygillman commented 3 months ago

Thanks!