SwiftUI Conditional UINavigationBarAppearance Based on what View.swift

In my AppDelegate.swift I'm trying to get the NavigationView UIColor to change when its not at the parent level (defined as on MainPageView).

i.e. on the MainPageView.swift where the NavigationView is defined- the color is green and when I click through to the next page the color will be "beige". However I'm not sure how to make conditional color changes based on what View.swift I'm in.

Code Block swift
     let condition = false
    let appearance = UINavigationBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = condition ? UIColor( colorLiteral(red: 0.0862745098, green: 0.7803921569, blue: 0.6039215686, alpha: 1)) : UIColor( colorLiteral(red: 0.8549019694, green: 0.250980407, blue: 0.4784313738, alpha: 1))

For example when I was on my MainPageView.swift where the NavigationView is defined I tried using
Code Block swift
if MainPageView() {
condition == false
}
else {
condition == true
}


but obviously you can't make struct's a bool so I'm not sure how to do this.

Could you show more complete code, so that we can understand how the pieces tie together and try to reproduce ?
SwiftUI Conditional UINavigationBarAppearance Based on what View.swift
 
 
Q