//
//  LoginView.swift
//  jason
//
//  Created by Jason on 2024/1/19.
//

import SwiftUI

struct LoginView: View {
    @AppStorage("authUsername") private var username: String = ""
    @State private var password: String = ""
    @State private var remember: Bool = false
    @State private var toRegister: Bool = false
    
   
    var body: some View {
        ScrollView {
            
            NavigationLink(destination: RegisterView(), label: {
                Text("去注册")
            })
            
            VStack(alignment: .leading ,spacing: 12) {
//                Button(action: {
//                    dismiss()
//                }, label: {
//                    Image(systemName: "chevron.backward")
//                    Text("返回")
//                })
                
                
                TextField("请输入用户名",text: $username)
                SecureField("请输入密码", text: $password)
                Toggle(isOn: $remember) {
                    Text("记住用户")
                }
                
                HStack {
          
                    Button("注册") {
                        toRegister = true
                    }
                    .padding(.vertical, 12)
                    .padding(.horizontal, 32)
                    .foregroundColor(.white)
         
                    .cornerRadius(6)
                    .fullScreenCover(isPresented: $toRegister, content: {
                        RegisterView()
                    })
                    
                    Spacer()
                    
                    Button("登录") {
                        
                    }
                    .padding(.vertical, 12)
                    .padding(.horizontal, 32)
                    .foregroundColor(.white)
        
                    .cornerRadius(6)
                }
            }
            .padding(.horizontal, 12)
        }
    }
}

#Preview {
    LoginView()
}
