Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminates some UI elements if inside VStacks #19

Open
IZ-Labs opened this issue Jan 30, 2021 · 2 comments
Open

Eliminates some UI elements if inside VStacks #19

IZ-Labs opened this issue Jan 30, 2021 · 2 comments

Comments

@IZ-Labs
Copy link

IZ-Labs commented Jan 30, 2021

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()
}
}
}
`

@AlexFine
Copy link
Collaborator

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

@denizdogan
Copy link

Any news on this matter or alternative library to use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants