init
This commit is contained in:
72
jason/Views/Auth/LoginView.swift
Normal file
72
jason/Views/Auth/LoginView.swift
Normal file
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// 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()
|
||||
}
|
||||
70
jason/Views/Auth/RegisterView.swift
Normal file
70
jason/Views/Auth/RegisterView.swift
Normal file
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// RegisterView.swift
|
||||
// jason
|
||||
//
|
||||
// Created by Jason on 2024/1/19.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RegisterView: View {
|
||||
@State private var username: String = ""
|
||||
@State private var password: String = ""
|
||||
@State private var showNext: Bool = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack (alignment: .leading, spacing: 12) {
|
||||
// Button(action: {
|
||||
// dismiss()
|
||||
// }, label: {
|
||||
// Image(systemName: "chevron.backward")
|
||||
// Text("返回")
|
||||
// })
|
||||
//
|
||||
TextField("请输入用户名",text: $username)
|
||||
.padding(.all, 12)
|
||||
.cornerRadius(6)
|
||||
.border(Color.gray)
|
||||
|
||||
SecureField("请输入密码", text: $password)
|
||||
.padding(.all, 12)
|
||||
.cornerRadius(6)
|
||||
.border(Color.gray)
|
||||
|
||||
HStack {
|
||||
Button("注册") {
|
||||
showNext = true
|
||||
}
|
||||
.padding(.vertical, 12)
|
||||
.padding(.horizontal, 32)
|
||||
.foregroundColor(.white)
|
||||
|
||||
.cornerRadius(6)
|
||||
.fullScreenCover(isPresented: $showNext, content: {
|
||||
RegisterView()
|
||||
})
|
||||
|
||||
Spacer()
|
||||
|
||||
Button("登录") {
|
||||
|
||||
}
|
||||
.padding(.vertical, 12)
|
||||
.padding(.horizontal, 32)
|
||||
.foregroundColor(.white)
|
||||
|
||||
.cornerRadius(6)
|
||||
}
|
||||
}
|
||||
.padding(.all, 12)
|
||||
.navigationTitle("注册")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
RegisterView()
|
||||
}
|
||||
Reference in New Issue
Block a user