Advertisement
Xaniasty

Untitled

Jun 12th, 2024
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. // ContentView.swift
  2.  
  3. import SwiftUI
  4.  
  5. struct ContentView: View {
  6. @State private var showingLoginSheet = false
  7. @State private var login = ""
  8. @State private var password = ""
  9. @State private var showingPassword = false
  10. @State private var showingLoginFailedAlert = false
  11. @State private var loginFailedMessage = ""
  12. @State private var isUserLoggedIn = false
  13.  
  14. var body: some View {
  15. NavigationView {
  16. if isUserLoggedIn {
  17. UserPhotoGridView(isUserLoggedIn: $isUserLoggedIn)
  18. } else {
  19. VStack {
  20. Spacer()
  21.  
  22. Text("Welcome to X")
  23. .font(.largeTitle)
  24. .padding(.bottom, 10)
  25.  
  26. Text("Choose login method")
  27. .font(.subheadline)
  28. .padding(.bottom, 40)
  29.  
  30. VStack(spacing: 20) {
  31. NavigationLink(destination: PhotoGridView(isUserLoggedIn: $isUserLoggedIn)) {
  32. Text("As Guest")
  33. .font(.headline)
  34. .frame(minWidth: 0, maxWidth: .infinity)
  35. .padding()
  36. .background(Color.blue)
  37. .foregroundColor(.white)
  38. .cornerRadius(10)
  39. }
  40.  
  41. Button(action: {
  42. showingLoginSheet = true
  43. }) {
  44. Text("Login")
  45. .font(.headline)
  46. .frame(minWidth: 0, maxWidth: .infinity)
  47. .padding()
  48. .background(Color.green)
  49. .foregroundColor(.white)
  50. .cornerRadius(10)
  51. }
  52. .sheet(isPresented: $showingLoginSheet) {
  53. LoginView(showingLoginSheet: $showingLoginSheet, login: $login, password: $password, isUserLoggedIn: $isUserLoggedIn, showingLoginFailedAlert: $showingLoginFailedAlert, loginFailedMessage: $loginFailedMessage)
  54. }
  55. }
  56. .padding(.horizontal, 40)
  57.  
  58. Spacer()
  59. }
  60. .navigationBarTitle("Login Screen", displayMode: .inline)
  61. }
  62. }
  63. }
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement