diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 7fa1be84..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 166face2..122b39e3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.xcworkspace/xcuserdata/ DerivedData/ build/ +.DS_Store + diff --git a/MobileAcebook.xcodeproj/project.pbxproj b/MobileAcebook.xcodeproj/project.pbxproj index 5506db3b..9eb5bc3e 100644 --- a/MobileAcebook.xcodeproj/project.pbxproj +++ b/MobileAcebook.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0F81A0C52BCE82C200AED673 /* LoginPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F81A0C42BCE82C200AED673 /* LoginPageView.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 */; }; @@ -39,6 +41,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0F81A0C42BCE82C200AED673 /* LoginPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginPageView.swift; sourceTree = ""; }; + 3D9855852BCE82EF007D584D /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = ""; }; 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 = ""; }; AE5D85B32AC8A224009680C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -111,6 +115,7 @@ AE5D85B32AC8A224009680C6 /* Assets.xcassets */, AE5D85B52AC8A224009680C6 /* Preview Content */, AE5D85D92AC8A337009680C6 /* WelcomePageView.swift */, + 0F81A0C42BCE82C200AED673 /* LoginPageView.swift */, ); path = MobileAcebook; sourceTree = ""; @@ -162,6 +167,7 @@ isa = PBXGroup; children = ( AE5D85E72AC9B29A009680C6 /* User.swift */, + 3D9855852BCE82EF007D584D /* Post.swift */, ); path = Models; sourceTree = ""; @@ -307,8 +313,10 @@ AE5D85E12AC9AFA9009680C6 /* AuthenticationService.swift in Sources */, AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */, AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */, + 3D9855862BCE82EF007D584D /* Post.swift in Sources */, AE5D85E82AC9B29A009680C6 /* User.swift in Sources */, AE5D85DA2AC8A337009680C6 /* WelcomePageView.swift in Sources */, + 0F81A0C52BCE82C200AED673 /* LoginPageView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,5 @@ + + + + + diff --git a/MobileAcebook.xcodeproj/xcshareddata/xcschemes/MobileAcebook.xcscheme b/MobileAcebook.xcodeproj/xcshareddata/xcschemes/MobileAcebook.xcscheme new file mode 100644 index 00000000..f988e3d0 --- /dev/null +++ b/MobileAcebook.xcodeproj/xcshareddata/xcschemes/MobileAcebook.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MobileAcebook/Assets.xcassets/makers-logo.imageset/makers-logo.png b/MobileAcebook/Assets.xcassets/makers-logo.imageset/makers-logo.png deleted file mode 100644 index 8e9844cb..00000000 Binary files a/MobileAcebook/Assets.xcassets/makers-logo.imageset/makers-logo.png and /dev/null differ diff --git a/MobileAcebook/Assets.xcassets/makers-logo.imageset/Contents.json b/MobileAcebook/Assets.xcassets/paw-logo.imageset/Contents.json similarity index 87% rename from MobileAcebook/Assets.xcassets/makers-logo.imageset/Contents.json rename to MobileAcebook/Assets.xcassets/paw-logo.imageset/Contents.json index 216c5e2c..22adbe44 100644 --- a/MobileAcebook/Assets.xcassets/makers-logo.imageset/Contents.json +++ b/MobileAcebook/Assets.xcassets/paw-logo.imageset/Contents.json @@ -1,11 +1,11 @@ { "images" : [ { - "filename" : "makers-logo.png", "idiom" : "universal", "scale" : "1x" }, { + "filename" : "paw (1).png", "idiom" : "universal", "scale" : "2x" }, diff --git a/MobileAcebook/Assets.xcassets/paw-logo.imageset/paw (1).png b/MobileAcebook/Assets.xcassets/paw-logo.imageset/paw (1).png new file mode 100644 index 00000000..d9038482 Binary files /dev/null and b/MobileAcebook/Assets.xcassets/paw-logo.imageset/paw (1).png differ diff --git a/MobileAcebook/LoginPageView.swift b/MobileAcebook/LoginPageView.swift new file mode 100644 index 00000000..7723efb7 --- /dev/null +++ b/MobileAcebook/LoginPageView.swift @@ -0,0 +1,56 @@ +// +// 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 = "" + + var body: some View { + NavigationView { + + VStack { + Spacer() + Text("Log in") + .font(.largeTitle) + .bold() + Spacer() + Text("Username") + TextField("", text: $username) + .frame(width: 220, height: 40) + .textFieldStyle(.roundedBorder) + .multilineTextAlignment(.center) + .accessibilityIdentifier("loginUsername") + Text("Password") + TextField("", text: $password) + .frame(width: 220, height: 40) + .textFieldStyle(.roundedBorder) + .multilineTextAlignment(.center) + .accessibilityIdentifier("loginPassword") + .padding() + Button("Submit") { + guard !username.isEmpty && !password.isEmpty else { return } + } + .frame(width: 220, height: 40) + .background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255)) + .foregroundColor(.white) + .cornerRadius(5) + + Spacer() + Spacer() + } + + } + } +} + +struct LoginPageView_Previews: PreviewProvider { + static var previews: some View { + LoginPageView() + } +} diff --git a/MobileAcebook/Models/Post.swift b/MobileAcebook/Models/Post.swift new file mode 100644 index 00000000..4e404a90 --- /dev/null +++ b/MobileAcebook/Models/Post.swift @@ -0,0 +1,15 @@ +// +// Post.swift +// MobileAcebook +// +// Created by Jess Todd on 16/04/2024. +// + +import Foundation + +public struct Post { + let message: String + let date: String + let user: String + let profilePicture: String +} diff --git a/MobileAcebook/Models/User.swift b/MobileAcebook/Models/User.swift index ea748dd0..1daa5af5 100644 --- a/MobileAcebook/Models/User.swift +++ b/MobileAcebook/Models/User.swift @@ -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 } diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift index 9f7181c3..02b635e9 100644 --- a/MobileAcebook/Services/AuthenticationService.swift +++ b/MobileAcebook/Services/AuthenticationService.swift @@ -4,10 +4,42 @@ // // 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 } + + + + + } + diff --git a/MobileAcebook/WelcomePageView.swift b/MobileAcebook/WelcomePageView.swift index 96006af9..28ba7c8e 100644 --- a/MobileAcebook/WelcomePageView.swift +++ b/MobileAcebook/WelcomePageView.swift @@ -13,26 +13,44 @@ struct WelcomePageView: View { VStack { Spacer() - Text("Welcome to Acebook!") + Text("Welcome to\n Pawbook!") .font(.largeTitle) - .padding(.bottom, 20) + .padding(.bottom, 25) .accessibilityIdentifier("welcomeText") - + .multilineTextAlignment(.center) + .foregroundColor(Color(red: 0.50, green: 0.71, blue: 0.71)) + .bold() Spacer() - - Image("makers-logo") + + Image("paw-logo") .resizable() .scaledToFit() - .frame(width: 200, height: 200) - .accessibilityIdentifier("makers-logo") - + .frame(width: 130, height: 130) + .accessibilityIdentifier("paw-logo") Spacer() - + + Button("Login") { + // TODO: login logic + } + .frame(width: 100) + .controlSize(.large) + .buttonStyle(.bordered) + .background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255)) + .foregroundColor(.white) + .cornerRadius(10) + .accessibilityIdentifier("loginButton") + Button("Sign Up") { // TODO: sign up logic } - .accessibilityIdentifier("signUpButton") - + .frame(width: 100) + .controlSize(.large) + .buttonStyle(.bordered) + .background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255)) + .foregroundColor(.white) + .cornerRadius(10) + .accessibilityIdentifier("signUpButton") + Spacer() } }