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

Post model & Welcome page #40

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -3,3 +3,5 @@
*.xcworkspace/xcuserdata/
DerivedData/
build/
.DS_Store

8 changes: 8 additions & 0 deletions MobileAcebook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -39,6 +41,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0F81A0C42BCE82C200AED673 /* LoginPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginPageView.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>"; };
Expand Down Expand Up @@ -111,6 +115,7 @@
AE5D85B32AC8A224009680C6 /* Assets.xcassets */,
AE5D85B52AC8A224009680C6 /* Preview Content */,
AE5D85D92AC8A337009680C6 /* WelcomePageView.swift */,
0F81A0C42BCE82C200AED673 /* LoginPageView.swift */,
);
path = MobileAcebook;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,6 +167,7 @@
isa = PBXGroup;
children = (
AE5D85E72AC9B29A009680C6 /* User.swift */,
3D9855852BCE82EF007D584D /* Post.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down
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"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions MobileAcebook/LoginPageView.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
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 {
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
Expand Up @@ -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
}
36 changes: 34 additions & 2 deletions MobileAcebook/Services/AuthenticationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}





}

40 changes: 29 additions & 11 deletions MobileAcebook/WelcomePageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down