iPages
iPages copied to clipboard
Eliminates some UI elements if inside VStacks
This is a bit of a weird one an potentially not iPages related. I'm curious if you can recreate this issue.
I was using the default apple PageTabViewStyle but saw this library and gave it a shot. My app has buttons that show up based on if statements. This worked fine with PagesTabView, but upon adding iPages, the buttons inside if statements disappear. If I remove the if statement the buttons pop back up.
Not quite sure what the issue is. I've attached my ContentView.swift file below, with most of my code removed for clarity.
` import SwiftUI import HealthKit import HealthKitUI import iPages
class SummaryHolder: ObservableObject { @Published var theSummary: HKActivitySummary = HKActivitySummary(); }
struct ContentView: View { var body: some View { iPages{ ZStack{ LinearGradient(gradient: Gradient(colors: [.black, Color("darkBlue")]), startPoint: .topLeading, endPoint: .bottomTrailing).ignoresSafeArea() VStack { VStack { if movePercent >= 50 { Button(action: /@START_MENU_TOKEN@//@PLACEHOLDER=Action@/{}/@END_MENU_TOKEN@/) { DispenseButton(title: "One Spin", textColor: .blue, backgroundColor: .white) } }
if movePercent >= 75 {
Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
DispenseButton(title: "Two Spins",
textColor: .blue,
backgroundColor: .white)
}
}
if movePercent >= 100 {
Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
DispenseButton(title: "Three Spins",
textColor: .blue,
backgroundColor: .white)
}
}
if movePercent < 50 {
Image(systemName: "exclamationmark.triangle.fill") .renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 180, height: 180, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
Text("Get moving and try again later").font(.system(size: 20, weight: .bold, design: .default))
.foregroundColor(.white)
.padding().multilineTextAlignment(.center)
}
}
Spacer()
}
}
Text("Add Bluetooth Menu here").tabItem {
Image(systemName: (selected == 0 ? "sun.fill" : "sun"))
Text("Home")
}
}.hideDots(false).edgesIgnoringSafeArea(.all)
}
}
struct ContentView_Previews: PreviewProvider { static var previews: some View { Group { ContentView() } } } `
Yeah this is a problem with iPages. This code doesn't work:
struct ContentView: View {
@State var displayButton: Bool = false
var body: some View {
Toggle("Toggle Button", isOn: $displayButton)
iPages {
if displayButton {
Button("Button is Displayed") { }
} else {
Button("Button is not displayed") { }
}
}
}
}
Will dig more into this issue
Any news on this matter or alternative library to use?