Learn Courses My Dashboard

Module 1 - Lesson 10 - Buttons and Module 2 - Lesson 3 - NavigationView and NavigationLink

Hello - My name is Karla Vohra. I am very new to Swift programming. I am in the process of taking iOS Foundations and I finished Module 1 - Lesson 10 - Buttons and Module 2 - Lesson 3 - Lists, Navigation View and Navigation. For additional practice, I created a simple app that has a HomeScreen View and CreateAccount View. On the HomeScreen View, I have a button called Create Account and Sign-In. When I click on either one of them, I want the button to take me to the CreateAccount View or the Sign-In Screen.

Below is the GitHub link to my code

I tired a couple of options:
OPTION #1 - Tried using NavigationView and NavigationLink (HomeScreenNavigationView.swift)
I am using Button, NavigationView and NavigationLink. When I click on the button, it does take me to the CreateAccount screen but it keeps the back button and the text from my HomeScreen on the CreateAccount screen. I tired using .navigationBarBackButtonHidden( true ) modifier but it does not seem to be working.

How do I disable the back button and the Text from my HomeScreen on the CreateAccount Screen?

Option 2 - Presented the CreateAccountView on top of the HomeScreen but you can clearly see that I have added one view on top of another…which is not what I want. (HomeScreenToggleView.swift)

All I want is to click on either the Create Account Button or the Sign-In Button and it takes me to either the CreateAccountView or the SignInView.

Using xCode Version 13.4 (13F17a)

Any help would be greatly appreciated.

Regards,
Karla

Hi Karla,

Your Module 1, Lesson 10 challenge related code is considerably more complex that the challenge that was set. I’m just wondering if perhaps you are getting a little too far ahead in complexity than the point you are currently at in the course.

Chris Ching discusses “Login” and “Create account” screens in the “iOS Database (SwiftUI)” course which is the course that you should do after you complete the “iOS Foundations (SwiftUI)” course. I would recommend that you continue with the “iOS Foundations (SwiftUI)” course which will progressively give you the skills you need to tackle are complex code.

Okay…Thank you. I figured I was getting too far ahead of myself…but I thought I would try it out.

Thank you so much for your help. I will keep going :grinning:

@kvohra

In your GitHub repo for this project, you asked a question in a comment:

//QUESTION - how to use relative sizing instead of hard-coding

Your code was as follows:

Text("Create Account")
    .padding()
    .background(.blue)
    .foregroundColor(.white)
    .cornerRadius(50) //QUESTION - how to use relative sizing instead of hard-coding

What you could do is this instead of using .cornerRadius(value):

Text("Create Account")
    .padding()
    .background(Color.blue)
    .foregroundColor(.white)
    .clipShape(Capsule())

It will adjust the radius of the ends to be effectively the height / 2 of the Text view. By that I mean that if you make the padding a larger value then the Capsule will adjust automatically.

Nice…thank you so much…Really appreciate it.