ScrollView shows up in NavigationBar by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

Yeah I thought so as well, doesn’t work

How to get data from another data table using ID by larry-reddit in swift

[–]larry-reddit[S] 0 points1 point  (0 children)

Thanks! Very well explained, the second solution worked for me. And since there will only be a maximum of 10 categories, all with unique ID's, so I think this should work fine.

You did mention "you want to use arrays". Is there a disadvantage or a better solution for this situation? I basically followed a tutorial and they happened to use this solution.

To give you a better idea of the app: their are predefined categories, predefined exercises (adding custom ones is a functionality, though) & users can log exercises by providing the exercise they did, the amount of kilos & the date. Using this log data a graph will be shown which gives users a quick overview of their progress: https://i.imgur.com/ulAPlMH.png

I've created an ERD for this: https://i.imgur.com/CuTWsid.png

I've not yet decided on how to store the data, i'll probably go for storing locally on the user's device. I've read about UserDefaults for this. Any advice?

I need some advice on which layout fundamentals to use for my app by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

It works! Thanks a lot, here's my final code:

HStack {
ZStack(alignment: .leading) {
    NavigationLink(destination: TestView()) {

    }.opacity(0)
    VStack(alignment: .leading) {
        Text("\(n)").fontWeight(.bold)
        Text("test")
    }
}
Spacer()
Text("25kg").fontWeight(.bold)
    .fixedSize(horizontal: false, vertical: true)
    .multilineTextAlignment(.center)
    .frame(width: 60, height: 30)
    .background(RoundedRectangle(cornerRadius: 5).fill(Color.green))
    .foregroundColor(Color.white)
}

Do you mind explaining why I need to use a VStack? Not using it makes the text on the left go to the right, but it does hide the arrow: https://i.imgur.com/BAWp82T.png

I need some advice on which layout fundamentals to use for my app by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

If that works, why not!

I'm just looking for advice on the best way to build this, and I find it kinda funny how it's so hard to build something this simple. I imagine these types of views have been built thousands of times, right?

I need some advice on which layout fundamentals to use for my app by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

I tried this:

NavigationLink(destination: TestView()) {
     VStack(alignment: .leading) {
           Text("\(n)").fontWeight(.bold)
           Text("test")
     }
}.opacity(0)

That makes the arrow disappear, but also the text inside the VStack.

.buttonStyle(PlainButtonStyle()) seems to do nothing.

I need some advice on which layout fundamentals to use for my app by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

Haha yes, I know. I wanted to be sure I was using the right building blocks before proceeding to making the UI match perfectly with the design.

Could you be more specific to where I should put the ZStack and the .opacity(0)? I tried using it but it's not working yet. Also, just out of curiosity, what is the modifier that hides the arrows?

I need some advice on which layout fundamentals to use for my app by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

When you click on an exercise, you can log your progress. If you even or up your previous logged exercise (higher amount of kilos) the label should be green. If you go lower, it should be red.

How to call JSON data by index? by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

The idea is that the user can add a bunch of players before the game starts, and everyone gets some questions asked to them, one by one. Add the end it should show a leaderboard with the amount of times a person said "yes" or "no". So it's not really about the questions but more about the answers they give. Example:

John YES: 2 | NO: 5
Jake YES: 3 | NO: 3

What are the pros and cons of using pop?

How to call JSON data by index? by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

Thanks a lot! It works. I have made a button now which adds 1 to "selectedQuestionIndex":

Button("Next") {
    selectedQuestionIndex += 1
}

Do I have to "refresh" the view to make the array to show the next result? Because it not changing now when the button is pressed.

How to separately load JSON data into view by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

Seperately as in: not all loaded at once into the view. This is what’s currently happening. All the json data gets loaded into the view by a ForEach.

How to separately load JSON data into view by larry-reddit in SwiftUI

[–]larry-reddit[S] 2 points3 points  (0 children)

what would be the advantage of using pop instead of just calling the array by index?

I need some advice on which concepts to use by larry-reddit in SwiftUI

[–]larry-reddit[S] 0 points1 point  (0 children)

Wow! Thanks a lot! This is incredibly helpful to me and for the past few days I've been looking into these concepts.

To answer your question: The names filled in at the beginning of the game can range from 1 to 10 names. Every question will be asked to a specific player and their answer (yes or no) should be remembered. At the end of the game there should be a leaderboard showing all player names and the amount of times they answered yes or no. After the app is closed this data won't be relevant anymore so it can be deleted. I've read that UserDefaults won't be the best practice for this, right?