Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign up logic #45

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f588bb2
Testing branch creation and pushing via Xcode.
bogdans13 Apr 16, 2024
d5f2c31
First commit - signup function added to AuthenticationService.swift.…
Maria-Basia Apr 16, 2024
0355fb0
login page created
ttyhktup Apr 16, 2024
2c481f3
added post model, aand also changed the welcome page
Jessicacktodd Apr 16, 2024
32e21a9
.DS_Store file added to .gitignore file
Maria-Basia Apr 16, 2024
1f17a2f
deleted .DS_Store file and removed not needed comments
Maria-Basia Apr 16, 2024
787e452
removed DS_Store added DS_Store to gitignore to avoid future pushes
George-Paul-1 Apr 16, 2024
5085729
Merge branch 'main' into services_authentication
Maria-Basia Apr 16, 2024
490ce94
playing around with button sizes
Jessicacktodd Apr 16, 2024
aedc0a1
Merge pull request #2 from bogdans13/services_authentication
ttyhktup Apr 16, 2024
9782224
commit it all
ttyhktup Apr 16, 2024
8cacb5f
DSSTOREREMOVED
ttyhktup Apr 16, 2024
c52738b
deleted DS_Store
Jessicacktodd Apr 16, 2024
3c9935d
Merge pull request #3 from bogdans13/create_login
ttyhktup Apr 16, 2024
1169c1e
got rid of merge conflicts
Jessicacktodd Apr 16, 2024
8cd3aa4
Merge pull request #4 from bogdans13/postModel
Jessicacktodd Apr 16, 2024
e7ed366
let's try
ttyhktup Apr 16, 2024
d66635f
Merge pull request #6 from bogdans13/create_login
ttyhktup Apr 16, 2024
0a2b056
login and signup style
ttyhktup Apr 17, 2024
6eb5044
first logic changes
ohmygois Apr 17, 2024
527317a
Merge branch 'create_login' of https://github.com/bogdans13/swiftui-e…
ohmygois Apr 17, 2024
9219017
signup page final
ttyhktup Apr 17, 2024
ba9a4f9
all pages styles alligned
ttyhktup Apr 17, 2024
336f533
Create Post Service + assign :Encodable to Post [Model]
bogdans13 Apr 17, 2024
1a1db21
changes made
ohmygois Apr 17, 2024
384f8df
changes made
ohmygois Apr 17, 2024
6989292
login function and UserLogin model added
Maria-Basia Apr 17, 2024
4b2054e
Merge pull request #7 from bogdans13/post_route
ohmygois Apr 17, 2024
12d4847
some changes
ttyhktup Apr 18, 2024
0434b60
Merge pull request #9 from bogdans13/create_login
ttyhktup Apr 18, 2024
b58c034
Merge branch 'main' into authentication
ttyhktup Apr 18, 2024
f2881ec
Merge pull request #8 from bogdans13/authentication
ttyhktup Apr 18, 2024
b0486fb
welcome page links added
ttyhktup Apr 18, 2024
b8f988a
Merge pull request #10 from bogdans13/create_login
ttyhktup Apr 18, 2024
fc2b204
autocapitalization removed
ttyhktup Apr 18, 2024
fd0d0e4
Merge pull request #11 from bogdans13/create_login
ttyhktup Apr 18, 2024
95ad1e8
signup working
ttyhktup Apr 18, 2024
bddf4de
Merge pull request #12 from bogdans13/create_login
ttyhktup Apr 18, 2024
83b1f6e
changes made
ohmygois Apr 18, 2024
9e51082
Latest version
ohmygois Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,3 +3,5 @@
*.xcworkspace/xcuserdata/
DerivedData/
build/
.DS_Store

25 changes: 25 additions & 0 deletions MobileAcebook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
0F81A0C52BCE82C200AED673 /* LoginPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F81A0C42BCE82C200AED673 /* LoginPageView.swift */; };
0F81A0C72BCED6FD00AED673 /* SignUpPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F81A0C62BCED6FD00AED673 /* SignUpPageView.swift */; };
3D9855862BCE82EF007D584D /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9855852BCE82EF007D584D /* Post.swift */; };
AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */; };
AE5D85B42AC8A224009680C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B32AC8A224009680C6 /* Assets.xcassets */; };
AE5D85B72AC8A224009680C6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B62AC8A224009680C6 /* Preview Assets.xcassets */; };
@@ -19,6 +22,11 @@
AE5D85E32AC9AFD2009680C6 /* MockAuthenticationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E22AC9AFD2009680C6 /* MockAuthenticationService.swift */; };
AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E52AC9B077009680C6 /* AuthenticationServiceProtocol.swift */; };
AE5D85E82AC9B29A009680C6 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E72AC9B29A009680C6 /* User.swift */; };

D6070C072BD005F5003EFBE5 /* UserLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6070C062BD005F5003EFBE5 /* UserLogin.swift */; };

C1615B992BCFEF2800A7AB81 /* PostService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1615B982BCFEF2800A7AB81 /* PostService.swift */; };

/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
@@ -39,6 +47,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0F81A0C42BCE82C200AED673 /* LoginPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginPageView.swift; sourceTree = "<group>"; };
0F81A0C62BCED6FD00AED673 /* SignUpPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpPageView.swift; sourceTree = "<group>"; };
3D9855852BCE82EF007D584D /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
AE5D85AC2AC8A221009680C6 /* MobileAcebook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileAcebook.app; sourceTree = BUILT_PRODUCTS_DIR; };
AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileAcebookApp.swift; sourceTree = "<group>"; };
AE5D85B32AC8A224009680C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -54,6 +65,10 @@
AE5D85E22AC9AFD2009680C6 /* MockAuthenticationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAuthenticationService.swift; sourceTree = "<group>"; };
AE5D85E52AC9B077009680C6 /* AuthenticationServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationServiceProtocol.swift; sourceTree = "<group>"; };
AE5D85E72AC9B29A009680C6 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };

D6070C062BD005F5003EFBE5 /* UserLogin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserLogin.swift; sourceTree = "<group>"; };
C1615B982BCFEF2800A7AB81 /* PostService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostService.swift; sourceTree = "<group>"; };

/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -111,6 +126,8 @@
AE5D85B32AC8A224009680C6 /* Assets.xcassets */,
AE5D85B52AC8A224009680C6 /* Preview Content */,
AE5D85D92AC8A337009680C6 /* WelcomePageView.swift */,
0F81A0C42BCE82C200AED673 /* LoginPageView.swift */,
0F81A0C62BCED6FD00AED673 /* SignUpPageView.swift */,
);
path = MobileAcebook;
sourceTree = "<group>";
@@ -146,6 +163,7 @@
isa = PBXGroup;
children = (
AE5D85E02AC9AFA9009680C6 /* AuthenticationService.swift */,
C1615B982BCFEF2800A7AB81 /* PostService.swift */,
);
path = Services;
sourceTree = "<group>";
@@ -162,6 +180,8 @@
isa = PBXGroup;
children = (
AE5D85E72AC9B29A009680C6 /* User.swift */,
3D9855852BCE82EF007D584D /* Post.swift */,
D6070C062BD005F5003EFBE5 /* UserLogin.swift */,
);
path = Models;
sourceTree = "<group>";
@@ -306,9 +326,14 @@
files = (
AE5D85E12AC9AFA9009680C6 /* AuthenticationService.swift in Sources */,
AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */,
D6070C072BD005F5003EFBE5 /* UserLogin.swift in Sources */,
AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */,
3D9855862BCE82EF007D584D /* Post.swift in Sources */,
AE5D85E82AC9B29A009680C6 /* User.swift in Sources */,
0F81A0C72BCED6FD00AED673 /* SignUpPageView.swift in Sources */,
AE5D85DA2AC8A337009680C6 /* WelcomePageView.swift in Sources */,
C1615B992BCFEF2800A7AB81 /* PostService.swift in Sources */,
0F81A0C52BCE82C200AED673 /* LoginPageView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
102 changes: 102 additions & 0 deletions MobileAcebook.xcodeproj/xcshareddata/xcschemes/MobileAcebook.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE5D85AB2AC8A221009680C6"
BuildableName = "MobileAcebook.app"
BlueprintName = "MobileAcebook"
ReferencedContainer = "container:MobileAcebook.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE5D85BB2AC8A224009680C6"
BuildableName = "MobileAcebookTests.xctest"
BlueprintName = "MobileAcebookTests"
ReferencedContainer = "container:MobileAcebook.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE5D85C52AC8A224009680C6"
BuildableName = "MobileAcebookUITests.xctest"
BlueprintName = "MobileAcebookUITests"
ReferencedContainer = "container:MobileAcebook.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE5D85AB2AC8A221009680C6"
BuildableName = "MobileAcebook.app"
BlueprintName = "MobileAcebook"
ReferencedContainer = "container:MobileAcebook.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE5D85AB2AC8A221009680C6"
BuildableName = "MobileAcebook.app"
BlueprintName = "MobileAcebook"
ReferencedContainer = "container:MobileAcebook.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"images" : [
{
"filename" : "makers-logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "paw (1).png",
"idiom" : "universal",
"scale" : "2x"
},
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions MobileAcebook/LoginPageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// WelcomePageView.swift
// MobileAcebook
//
// Created by Josué Estévez Fernández on 30/09/2023.
//

import SwiftUI

struct LoginPageView: View {
@State private var username = ""
@State private var password = ""
@State var isShowingPassword: Bool = false

var body: some View {
NavigationView {

VStack {
Spacer()
Text("Log in")
.font(.largeTitle)
.bold()
Spacer()
VStack {
Text("Username") .frame(maxWidth: 250, alignment: .topLeading)

TextField("", text: $username)
.frame(width: 250, height: 40)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray)
)
.multilineTextAlignment(.center)
.autocapitalization(. none)
.accessibilityIdentifier("loginUsername")
}.padding()
VStack {
Text("Password")
.frame(maxWidth: 250, alignment: .topLeading)
Group {
if isShowingPassword {
TextField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}else {
SecureField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}
}
.disableAutocorrection(true)
.autocapitalization(.none)

Button {
isShowingPassword.toggle()
} label: {
if isShowingPassword {
Text("Hide password")
} else {
Text("Show password")
}
}.padding()
}


Button("Submit") {
guard !username.isEmpty && !password.isEmpty else { return }
}
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.padding()

Spacer()
Spacer()
Spacer()
HStack(spacing:3){
Text("Don't have an account?")
NavigationLink(destination: SignUpPageView()){
Text("Sign up here")
.fontWeight(.bold)
}

//add navigation to login
}
.padding()
}

}
}
}

struct LoginPageView_Previews: PreviewProvider {
static var previews: some View {
LoginPageView()
}
}
15 changes: 15 additions & 0 deletions MobileAcebook/Models/Post.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Post.swift
// MobileAcebook
//
// Created by Jess Todd on 16/04/2024.
//

import Foundation

public struct Post: Encodable {
let message: String
let date: String
let user: String
let profilePicture: String
}
8 changes: 6 additions & 2 deletions MobileAcebook/Models/User.swift
Original file line number Diff line number Diff line change
@@ -5,7 +5,11 @@
// Created by Josué Estévez Fernández on 01/10/2023.
//

public struct User {
let username: String


public struct User: Encodable {
let imgUrl: String
let email: String
let password: String
let username: String
}
13 changes: 13 additions & 0 deletions MobileAcebook/Models/UserLogin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// UserLogin.swift
// MobileAcebook
//
// Created by Maria Basia on 17/04/2024.
//

import Foundation

struct UserLogin: Encodable {
let email: String
let password: String
}
58 changes: 56 additions & 2 deletions MobileAcebook/Services/AuthenticationService.swift
Original file line number Diff line number Diff line change
@@ -4,10 +4,64 @@
//
// Created by Josué Estévez Fernández on 01/10/2023.
//
import Foundation



class AuthenticationService: AuthenticationServiceProtocol {
struct Response: Codable {
let message : String
}

func signUp(user: User) -> Bool {
// Logic to call the backend API for signing up
return true // placeholder
guard let url = URL(string: "http://localhost:3000/users") else {return false}

var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body = user
urlRequest.httpBody = try? JSONEncoder().encode(user)
let task = URLSession.shared.dataTask(with : urlRequest) {data, response, error in
guard let data = data else {return}
do {
let response = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
print(response)
print("User created successfully")
}
catch {
print(error)
}
}
task.resume()
return true
}

func login(userLogin: UserLogin) -> Bool {
guard let url = URL(string: "http://localhost:3000/tokens") else {return false}

var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body = userLogin
urlRequest.httpBody = try? JSONEncoder().encode(userLogin)
let task = URLSession.shared.dataTask(with : urlRequest) {data, response, error in
guard let data = data else {return}
do {
let response = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
print("Valid user")
print(response)
}
catch {
print(error)
}
}
task.resume()
return true
}



}

58 changes: 58 additions & 0 deletions MobileAcebook/Services/PostService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// PostService.swift
// MobileAcebook
//
// Created by Bogdan Stăiculescu on 17/04/2024.
//

import Foundation

class postService {

// response returned on succesful /POST request
struct Response: Codable {
// let message : String
let token: String
}


func createPost(post: Post, token: String, completion: @escaping ((String) -> Void)) -> Bool {
// defining URL to which we make the POST on the Backend
guard let url = URL(string: "http://localhost:3000/posts") else
{return false}

// var that contains the URL request and content
var urlRequest = URLRequest(url: url)
// method of the createPost
urlRequest.httpMethod = "POST"
// value of the URL request that's being sent to backend [application/json]
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
// also passing along Bearer and Token to show authorization
urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")

// defining the body of the HTTP request
let body = post

urlRequest.httpBody = try? JSONEncoder().encode(body)

// defining what we do with the response of our request
let task = URLSession.shared.dataTask(with: urlRequest) {data, response, error in
// ensures there is data that returns after making the request ELSE print error
guard let data = data else {return}
// if there is data
do {
let response = try JSONDecoder().decode(Response.self, from: data)
//print(response.token)
DispatchQueue.main.async {
completion(response.token)
}
print("Post Created")
}
catch {
print(error)
}
}
task.resume()
return true
}
}
143 changes: 143 additions & 0 deletions MobileAcebook/SignUpPageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//
// SignUpPageView.swift
// MobileAcebook
//
// Created by Venera Zhargakova on 16/04/2024.
//

import Foundation

import SwiftUI

struct SignUpError: Identifiable {
let id = UUID()
let message: String
}

let authService = AuthenticationService()


struct SignUpPageView: View {
@State private var email = ""
@State private var imgUrl = ""
@State private var username = ""
@State private var password = ""
@State var isShowingPassword: Bool = false
@State private var signUpError: String? = nil
@State private var showAlert = false
@State private var isSignUpComplete = false


//errors:
@State private var emailError = ""
let authService = AuthenticationService()
var body: some View {
NavigationView {
VStack(spacing: 30) {
Spacer()
Spacer()
Text("Sign Up")
.font(.largeTitle)
.fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
VStack(spacing:0) {
Text("Email Address")
.frame(maxWidth: 250, alignment: .topLeading)
.padding()
TextField("", text: $email)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray)
)
.autocapitalization(. none)
.accessibilityIdentifier("email")
Text("Full Name")
.frame(maxWidth: 250, alignment: .topLeading)
.padding()
TextField("", text: $username)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray)
)
.autocapitalization(. none)
.accessibilityIdentifier("Full Name")
Text("Password")
.frame(maxWidth: 250, alignment: .topLeading)
.padding()
VStack {
Group {
if isShowingPassword {
TextField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}else {
SecureField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}
}
.disableAutocorrection(true)
.autocapitalization(.none)

Button {
isShowingPassword.toggle()
} label: {
if isShowingPassword {
Text("Hide password")
} else {
Text("Show password")
}
}.padding()
}

VStack{
Button("Sign Up"){

let newUser = User(imgUrl: imgUrl, email: email, password: password, username: username)
let success = authService.signUp(user: newUser)
if success {
// Clear fields if signup successful
email = ""
username = ""
password = ""
isSignUpComplete = true


// Show success message
signUpError = "Account created successfully"
} else {
// Show error message
signUpError = "Error creating account"
}

}
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
}
}
.padding(.top, 40)
Spacer()
HStack(spacing:3){
Text("Already have an account?")
NavigationLink(destination: LoginPageView(), isActive: $isSignUpComplete, label: {Text("Login here")
.fontWeight(.bold)})
}
}

}
}
}
#Preview {
SignUpPageView()
}


93 changes: 67 additions & 26 deletions MobileAcebook/WelcomePageView.swift
Original file line number Diff line number Diff line change
@@ -9,34 +9,75 @@ import SwiftUI

struct WelcomePageView: View {
var body: some View {
ZStack {
VStack {
Spacer()

Text("Welcome to Acebook!")
.font(.largeTitle)
.padding(.bottom, 20)
.accessibilityIdentifier("welcomeText")

Spacer()

Image("makers-logo")
.resizable()
.scaledToFit()
.frame(width: 200, height: 200)
.accessibilityIdentifier("makers-logo")

Spacer()

Button("Sign Up") {
// TODO: sign up logic
<<<<<<< HEAD
NavigationView{
=======
NavigationView {
>>>>>>> bddf4de293ba456171c3682d257fba2a9996240b
ZStack {
VStack {
Spacer()

Text("Welcome to\n Pawbook!")
.font(.largeTitle)
.padding(.bottom, 25)
.accessibilityIdentifier("welcomeText")
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.50, green: 0.71, blue: 0.71))
.bold()
Spacer()

Image("paw-logo")
.resizable()
.scaledToFit()
.frame(width: 130, height: 130)
.accessibilityIdentifier("paw-logo")
Spacer()

<<<<<<< HEAD
NavigationLink(destination: LoginPageView()) {
Button("Login") {
// TODO: login logic
}
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.accessibilityIdentifier("loginButton")}

NavigationLink(destination: SignUpPageView()) {
Button(action: {
}) {
Text("Sign Up")
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.accessibilityIdentifier("signUpButton")
}
=======
NavigationLink(destination: LoginPageView()){
Text("Login")
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.accessibilityIdentifier("loginButton")
}
NavigationLink(destination: SignUpPageView()){
Text("Sign Up")
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.accessibilityIdentifier("signUpButton")
>>>>>>> bddf4de293ba456171c3682d257fba2a9996240b
}

Spacer()
}
.accessibilityIdentifier("signUpButton")

Spacer()
}
}
}
}}
}

struct WelcomePageView_Previews: PreviewProvider {