create a swiftui signup screen for a social media application in swift

Here's an example of how to create a simple signup screen in SwiftUI for a social media app:

main.swift
import SwiftUI

struct SignupView: View {
    @State private var email: String = ""
    @State private var username: String = ""
    @State private var password: String = ""
    @State private var confirmPassword: String = ""
    
    var body: some View {
        NavigationView {
            VStack {
                Text("Create Your Account")
                    .font(.title)
                    .foregroundColor(.blue)
                    .padding(.bottom, 20)
                
                TextField("Email", text: $email)
                    .padding()
                    .background(Color.gray.opacity(0.2))
                    .cornerRadius(10)
                    .padding(.bottom, 20)
                
                TextField("Username", text: $username)
                    .padding()
                    .background(Color.gray.opacity(0.2))
                    .cornerRadius(10)
                    .padding(.bottom, 20)
                
                SecureField("Password", text: $password)
                    .padding()
                    .background(Color.gray.opacity(0.2))
                    .cornerRadius(10)
                    .padding(.bottom, 20)
                
                SecureField("Confirm Password", text: $confirmPassword)
                    .padding()
                    .background(Color.gray.opacity(0.2))
                    .cornerRadius(10)
                    .padding(.bottom, 20)
                
                Button(action: {}) {
                    Text("Sign Up")
                        .foregroundColor(Color.white)
                        .padding()
                }
                .background(Color.blue)
                .cornerRadius(10)
                .padding(.bottom, 30)
                
                Text("Already have an account?")
                    .font(.subheadline)
                    .foregroundColor(.gray)
                
                Button(action: {}) {
                    Text("Log In")
                        .foregroundColor(Color.blue)
                }
            }
            .padding(.horizontal, 30)
        }
    }
}

struct SignupView_Previews: PreviewProvider {
    static var previews: some View {
        SignupView()
    }
}
2242 chars
69 lines

This code creates a form in a VStack with TextFields for the user to input their email, username, password, and confirm password. It also includes a Button to submit the form, as well as a Button to navigate to the login screen if the user already has an account.

Note that this code doesn't include any actual authentication or user creation logic - it just creates the UI for the signup screen. You would need to add additional code to actually create the user account and store the user's information in your app's database.

gistlibby LogSnag