SwiftUI/SwUI/ContentView.swift
2024-03-07 15:29:05 +03:00

138 lines
4.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
struct ContentView: View {
@State private var login: String = ""
@State private var password: String = ""
@State private var isRegistrationVisible: Bool = false
var body: some View {
VStack(alignment: .leading, spacing: 10) {
Text("Добро пожаловать!")
.font(.title)
.padding(.top, 20)
.padding(.leading, 10)
HStack(spacing: -20) {
Button(action: {
// Действие для кнопки "Вход"
isRegistrationVisible = false
}) {
Text("Вход")
.padding()
.frame(minWidth: 0, maxWidth: .infinity)
.background(isRegistrationVisible ? Color.gray.opacity(0.2) : Color.blue)
.foregroundColor(.white)
.cornerRadius(20)
}
Button(action: {
// Действие для кнопки "Регистрация"
isRegistrationVisible = true
}) {
Text("Регистрация")
.padding()
.frame(minWidth: 0, maxWidth: .infinity)
.background(isRegistrationVisible ? Color.blue : Color.gray.opacity(0.2))
.foregroundColor(.white)
.cornerRadius(20)
}
}
.padding(.top, 10)
.padding(.horizontal, 10)
Color.clear
.frame(height: 15)
if isRegistrationVisible {
RegistrationView()
} else {
TextField("Телефон, почта или ник", text: $login)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
TextField("Пароль", text: $password)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
}
Button(action: {
// Действие для кнопки "Забыли пароль?"
}) {
Text("Забыли пароль?")
.foregroundColor(.blue)
.padding(.top, 10)
.padding(.horizontal, 10)
}
Spacer()
Button(action: {
// Действие для кнопки "Продолжить"
}) {
Text("Продолжить")
.padding()
.frame(minWidth: 0, maxWidth: .infinity)
.background(Color.gray.opacity(0.2))
.foregroundColor(.black)
.cornerRadius(20)
}
.padding(.bottom, 20) // Добавляем отступ снизу
}
.padding(.horizontal, 10)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(.bottom, 10) // Добавляем отступ снизу для контейнера
}
}
struct RegistrationView: View {
@State private var name: String = ""
@State private var surname: String = ""
@State private var email: String = ""
@State private var password: String = ""
var body: some View {
VStack(alignment: .leading, spacing: 10) {
TextField("Имя", text: $name)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
TextField("Фамилия", text: $surname)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
TextField("Email", text: $email)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
TextField("Пароль", text: $password)
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal, 10)
.frame(height: 60)
}
.padding(.horizontal, 10)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}