Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ContentView.swift
- import SwiftUI
- struct ContentView: View {
- @State private var showingLoginSheet = false
- @State private var login = ""
- @State private var password = ""
- @State private var showingPassword = false
- @State private var showingLoginFailedAlert = false
- @State private var loginFailedMessage = ""
- @State private var isUserLoggedIn = false
- var body: some View {
- NavigationView {
- if isUserLoggedIn {
- UserPhotoGridView(isUserLoggedIn: $isUserLoggedIn)
- } else {
- VStack {
- Spacer()
- Text("Welcome to X")
- .font(.largeTitle)
- .padding(.bottom, 10)
- Text("Choose login method")
- .font(.subheadline)
- .padding(.bottom, 40)
- VStack(spacing: 20) {
- NavigationLink(destination: PhotoGridView(isUserLoggedIn: $isUserLoggedIn)) {
- Text("As Guest")
- .font(.headline)
- .frame(minWidth: 0, maxWidth: .infinity)
- .padding()
- .background(Color.blue)
- .foregroundColor(.white)
- .cornerRadius(10)
- }
- Button(action: {
- showingLoginSheet = true
- }) {
- Text("Login")
- .font(.headline)
- .frame(minWidth: 0, maxWidth: .infinity)
- .padding()
- .background(Color.green)
- .foregroundColor(.white)
- .cornerRadius(10)
- }
- .sheet(isPresented: $showingLoginSheet) {
- LoginView(showingLoginSheet: $showingLoginSheet, login: $login, password: $password, isUserLoggedIn: $isUserLoggedIn, showingLoginFailedAlert: $showingLoginFailedAlert, loginFailedMessage: $loginFailedMessage)
- }
- }
- .padding(.horizontal, 40)
- Spacer()
- }
- .navigationBarTitle("Login Screen", displayMode: .inline)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement