'change screens on change of variable

if a user is opening the app for the first time it shows a tutorial screen and after the tutorial screen it shows a login screen and if a user is logged in it shows a normal screen

enum Status: String {
    case firstTime
    case notLoggedIN
    case loggedIn
}

class global {
    static var data = global()
    @AppStorage("Status") var st : Status = .firstTime
}

@main

struct AuthApp: App {

    var body: some Scene {
        WindowGroup {
            switch global.data.st {
            case .firstTime: TutorialScreenView()
            case .notLoggedIN: LogInView()
            case .loggedIn: NormalView()
            }
        }
    }
}

if a user is opening the app for the first time it will show a tutorial screen

struct TutorialScreenView: View {
    var body: some View {
        VStack {
            Text("Tutorial Screen")
            Button(action: {
                global.data.st = .notLoggedIN
            }, label : {
                Text("OK")
            })
        }
    }
}

in LoginView on click of Button 'st' will change to .loggedIn and in NormalView on click of Button 'st' will change to .notLoggedIn but the screens are not changing on the click of the Buttons

after trying various things, This one worked out for me

enum Status: String {
    case firstTime
    case notLoggedIn
    case loggedIn
}

class Global: ObservableObject {
    static var data = Global()
    
    @AppStorage("Status") var firstTime = true
    @Published var st: Status = .notLoggedIn
    private init (){
        if firstTime {
            st = .firstTime
        } else if let _ = Auth.auth().currentUser {
            st = .loggedIn
        } else {
            st = .notLoggedIn
        }
    }
}

@main
struct fireAuthApp: App {
    @ObservedObject var state = Global.data
    
    var body: some Scene {
        WindowGroup {
            switch state.st {
            case .firstTime: TutorialScreenView()
            case .notLoggedIn: LogInView()
            case .loggedIn: Normal()
            }
        }
    }
}

on login or signout, Global.data.st will be changed and the screen will change from normal to login and login to normal science change of Global.data.st will also change the value of state



Solution 1:[1]

Add the loggedIn/notLogged in enum as @Binding in Login and NormalScreens.

    struct LoginView: View {
    @Binding var loginStatus: Status
    var body: some View {
        ///
    //change login status on button click
    }
}

And same in NormalScreen And call them from AuthApp

case .firstTime: TutorialScreenView()
case .notLoggedIN: LogInView(loginStatus: $global.data.st)
case .loggedIn: NormalView(loginStatus: $global.data.st)

Solution 2:[2]

Terraform is expecting that your ssh key is exist. So you need to pass key name in terraform EC2 resources. You can SSH to the server by using existing key.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Neck
Solution 2 Akshay Gopani