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

Docs #70

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Docs #70

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6965306
Added models and services for key functions of the app
QS-Coding Sep 3, 2024
d0b6475
Sign Up View Added
wsdalex Sep 3, 2024
379c95e
Added welcome view styling a code
QS-Coding Sep 3, 2024
e0423bd
add create new post view
mqzcn Sep 3, 2024
a9425a0
Update User.swift
QS-Coding Sep 3, 2024
0d9371e
Update Comment.swift
QS-Coding Sep 3, 2024
438c17e
Update Post.swift
QS-Coding Sep 3, 2024
710ef89
Merge pull request #1 from QS-Coding/1.0
mqzcn Sep 3, 2024
a9da30d
Merge pull request #2 from QS-Coding/1.1
QS-Coding Sep 3, 2024
bed8842
Merge pull request #3 from QS-Coding/Login/Signout-View
QS-Coding Sep 3, 2024
eb839c3
Added ds fiel changes
QS-Coding Sep 3, 2024
8470d4c
Added back files to project pbxproj file
QS-Coding Sep 3, 2024
c2bc2e4
Merge pull request #4 from QS-Coding/1.2
QS-Coding Sep 3, 2024
b8d4fc2
Added back CreatePostView to xproj file
QS-Coding Sep 3, 2024
7a00aa5
Merge pull request #5 from QS-Coding/1.3
QS-Coding Sep 3, 2024
72ba3d5
Identifiable switch
QS-Coding Sep 3, 2024
86a4bee
Added date extension
QS-Coding Sep 3, 2024
8a7bbe3
Commented out auth service
QS-Coding Sep 3, 2024
4cee038
Commented out stuff
QS-Coding Sep 3, 2024
9fba400
Added login view
wsdalex Sep 3, 2024
0f7a1c3
Styled Login View
wsdalex Sep 3, 2024
048271b
Added FullPostView and Model as changed post services to async
QS-Coding Sep 3, 2024
e5d2396
Merge pull request #6 from QS-Coding/1.4
QS-Coding Sep 3, 2024
d5ea2f3
Added log out pop up
QS-Coding Sep 4, 2024
3959131
Merge pull request #7 from QS-Coding/1.4
QS-Coding Sep 4, 2024
55102c4
Merge pull request #8 from QS-Coding/LoginView
QS-Coding Sep 4, 2024
1a7b4a9
Add auth service and fixed post and comment services
QS-Coding Sep 4, 2024
c42bbe5
Added service functions to Sign up and Login. Amended auth, post and …
QS-Coding Sep 4, 2024
490bcfd
Sign in and LOgin functioning
QS-Coding Sep 4, 2024
b4596aa
Fixed navigation issues
QS-Coding Sep 4, 2024
dc55f20
Merge pull request #9 from QS-Coding/1.5
QS-Coding Sep 5, 2024
0dd3bb8
Fixed fetch posts
wsdalex Sep 5, 2024
1b3d3b7
Merge pull request #12 from QS-Coding/Wills-Attempt
QS-Coding Sep 5, 2024
e281ab9
Added photo upload and displaying on posts
QS-Coding Sep 5, 2024
6ff911f
Fixed full post view and comments
QS-Coding Sep 5, 2024
0f8e708
Merge pull request #13 from QS-Coding/1.7
QS-Coding Sep 5, 2024
03b19ab
Update README.md
mqzcn Sep 5, 2024
2474842
Update README.md
mqzcn Sep 5, 2024
8f3cfbe
Update README.md
mqzcn Sep 5, 2024
04f0051
Update README.md
mqzcn Sep 5, 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 modified .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions Development.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Development.xcconfig
// MobileAcebook
//
// Created by Sam Quincey on 03/09/2024.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
68 changes: 67 additions & 1 deletion MobileAcebook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
25F17D2D2C870C9F001CEF06 /* SignUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25F17D2C2C870C9F001CEF06 /* SignUpView.swift */; };
25F17D2F2C870CAD001CEF06 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25F17D2E2C870CAD001CEF06 /* LoginView.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 All @@ -19,6 +21,20 @@
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 */; };
F82DA57C2C89BC6800CA8A56 /* PhotoPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82DA57B2C89BC6800CA8A56 /* PhotoPicker.swift */; };
F8304C5D2C888BF000B4BBC9 /* FeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8304C5C2C888BF000B4BBC9 /* FeedView.swift */; };
F8304C5F2C888C0500B4BBC9 /* PostCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8304C5E2C888C0500B4BBC9 /* PostCardView.swift */; };
F83545452C875D9300AB9C9E /* FullPostViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F83545442C875D9300AB9C9E /* FullPostViewModel.swift */; };
F83545472C875DAC00AB9C9E /* FullPostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F83545462C875DAC00AB9C9E /* FullPostView.swift */; };
F844A8AC2C874802007EA48A /* PostService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8A92C874802007EA48A /* PostService.swift */; };
F844A8AD2C874802007EA48A /* CommentService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8AA2C874802007EA48A /* CommentService.swift */; };
F844A8AE2C874802007EA48A /* UserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8AB2C874802007EA48A /* UserService.swift */; };
F844A8B12C87480F007EA48A /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8AF2C87480F007EA48A /* Post.swift */; };
F844A8B22C87480F007EA48A /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8B02C87480F007EA48A /* Comment.swift */; };
F844A8B62C874D56007EA48A /* CreatePostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8B52C874D56007EA48A /* CreatePostView.swift */; };
F844A8B82C875538007EA48A /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F844A8B72C875538007EA48A /* DateExtension.swift */; };
F87BD8272C88AF5E0071F4D3 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87BD8262C88AF5E0071F4D3 /* MainView.swift */; };
F8A25B612C884FF6009AE361 /* LogoutConfirmationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A25B602C884FF6009AE361 /* LogoutConfirmationView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -39,6 +55,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
25F17D2C2C870C9F001CEF06 /* SignUpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpView.swift; sourceTree = "<group>"; };
25F17D2E2C870CAD001CEF06 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.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 All @@ -54,6 +72,20 @@
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>"; };
F82DA57B2C89BC6800CA8A56 /* PhotoPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPicker.swift; sourceTree = "<group>"; };
F8304C5C2C888BF000B4BBC9 /* FeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedView.swift; sourceTree = "<group>"; };
F8304C5E2C888C0500B4BBC9 /* PostCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCardView.swift; sourceTree = "<group>"; };
F83545442C875D9300AB9C9E /* FullPostViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullPostViewModel.swift; sourceTree = "<group>"; };
F83545462C875DAC00AB9C9E /* FullPostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullPostView.swift; sourceTree = "<group>"; };
F844A8A92C874802007EA48A /* PostService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostService.swift; sourceTree = "<group>"; };
F844A8AA2C874802007EA48A /* CommentService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentService.swift; sourceTree = "<group>"; };
F844A8AB2C874802007EA48A /* UserService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserService.swift; sourceTree = "<group>"; };
F844A8AF2C87480F007EA48A /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
F844A8B02C87480F007EA48A /* Comment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Comment.swift; sourceTree = "<group>"; };
F844A8B52C874D56007EA48A /* CreatePostView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreatePostView.swift; sourceTree = "<group>"; };
F844A8B72C875538007EA48A /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
F87BD8262C88AF5E0071F4D3 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
F8A25B602C884FF6009AE361 /* LogoutConfirmationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutConfirmationView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -111,6 +143,16 @@
AE5D85B32AC8A224009680C6 /* Assets.xcassets */,
AE5D85B52AC8A224009680C6 /* Preview Content */,
AE5D85D92AC8A337009680C6 /* WelcomePageView.swift */,
25F17D2C2C870C9F001CEF06 /* SignUpView.swift */,
25F17D2E2C870CAD001CEF06 /* LoginView.swift */,
F844A8B52C874D56007EA48A /* CreatePostView.swift */,
F844A8B72C875538007EA48A /* DateExtension.swift */,
F83545462C875DAC00AB9C9E /* FullPostView.swift */,
F8A25B602C884FF6009AE361 /* LogoutConfirmationView.swift */,
F8304C5C2C888BF000B4BBC9 /* FeedView.swift */,
F8304C5E2C888C0500B4BBC9 /* PostCardView.swift */,
F87BD8262C88AF5E0071F4D3 /* MainView.swift */,
F82DA57B2C89BC6800CA8A56 /* PhotoPicker.swift */,
);
path = MobileAcebook;
sourceTree = "<group>";
Expand Down Expand Up @@ -145,6 +187,9 @@
AE5D85DD2AC9AF72009680C6 /* Services */ = {
isa = PBXGroup;
children = (
F844A8AA2C874802007EA48A /* CommentService.swift */,
F844A8A92C874802007EA48A /* PostService.swift */,
F844A8AB2C874802007EA48A /* UserService.swift */,
AE5D85E02AC9AFA9009680C6 /* AuthenticationService.swift */,
);
path = Services;
Expand All @@ -161,7 +206,10 @@
AE5D85DF2AC9AF83009680C6 /* Models */ = {
isa = PBXGroup;
children = (
F844A8B02C87480F007EA48A /* Comment.swift */,
F844A8AF2C87480F007EA48A /* Post.swift */,
AE5D85E72AC9B29A009680C6 /* User.swift */,
F83545442C875D9300AB9C9E /* FullPostViewModel.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -238,7 +286,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1420;
LastUpgradeCheck = 1540;
TargetAttributes = {
AE5D85AB2AC8A221009680C6 = {
CreatedOnToolsVersion = 14.2;
Expand Down Expand Up @@ -305,9 +353,25 @@
buildActionMask = 2147483647;
files = (
AE5D85E12AC9AFA9009680C6 /* AuthenticationService.swift in Sources */,
F83545472C875DAC00AB9C9E /* FullPostView.swift in Sources */,
F844A8B82C875538007EA48A /* DateExtension.swift in Sources */,
F844A8B12C87480F007EA48A /* Post.swift in Sources */,
F844A8B62C874D56007EA48A /* CreatePostView.swift in Sources */,
F8304C5F2C888C0500B4BBC9 /* PostCardView.swift in Sources */,
25F17D2F2C870CAD001CEF06 /* LoginView.swift in Sources */,
F8A25B612C884FF6009AE361 /* LogoutConfirmationView.swift in Sources */,
AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */,
F844A8AC2C874802007EA48A /* PostService.swift in Sources */,
F844A8AD2C874802007EA48A /* CommentService.swift in Sources */,
F8304C5D2C888BF000B4BBC9 /* FeedView.swift in Sources */,
AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */,
F87BD8272C88AF5E0071F4D3 /* MainView.swift in Sources */,
F82DA57C2C89BC6800CA8A56 /* PhotoPicker.swift in Sources */,
F83545452C875D9300AB9C9E /* FullPostViewModel.swift in Sources */,
F844A8B22C87480F007EA48A /* Comment.swift in Sources */,
F844A8AE2C874802007EA48A /* UserService.swift in Sources */,
AE5D85E82AC9B29A009680C6 /* User.swift in Sources */,
25F17D2D2C870C9F001CEF06 /* SignUpView.swift in Sources */,
AE5D85DA2AC8A337009680C6 /* WelcomePageView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -383,6 +447,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -443,6 +508,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
Binary file added MobileAcebook/.DS_Store
Binary file not shown.
Binary file added MobileAcebook/Assets.xcassets/.DS_Store
Binary file not shown.
128 changes: 128 additions & 0 deletions MobileAcebook/CreatePostView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import SwiftUI
import PhotosUI

struct CreatePostView: View {
@State private var userInput: String = ""
@State private var showAlert: Bool = false
@State private var alertTitle: String = ""
@State private var alertMessage: String = ""
@State private var selectedImage: UIImage? = nil
@State private var showPhotoPicker = false
@State private var isUploadingImage = false
@Environment(\.presentationMode) var presentationMode // Handle modal dismissal

var body: some View {
VStack(alignment: .center) {
HStack {
// Cancel Button to dismiss CreatePostView
Button(action: {
self.presentationMode.wrappedValue.dismiss() // Dismiss the view
}) {
Text("Cancel")
.foregroundColor(.blue)
}
.padding(.leading, 20)
Spacer()
}
.padding(.top, 20)

Spacer()

Text("Make a Post")
.font(.largeTitle)
.bold()
.padding(.bottom, 20)

// Post Text Field - Centered
TextField(
"Post text, lorem ipsum day...",
text: $userInput,
axis: .vertical
)
.textFieldStyle(.roundedBorder)
.lineLimit(10, reservesSpace: true)
.multilineTextAlignment(.leading)
.frame(minWidth: 100, maxWidth: 400, minHeight: 100, maxHeight: 250)
.padding(.horizontal, 20)

// Show selected image preview
if let image = selectedImage {
Image(uiImage: image)
.resizable()
.scaledToFit()
.frame(width: 200, height: 200)
.cornerRadius(10)
}

// Action Buttons - Centered
HStack(alignment: .center, spacing: 20) {
Button("Add Image") {
showPhotoPicker = true // Show the photo picker
}
.frame(width: 120, height: 44)
.background(Color.blue)
.cornerRadius(40)
.foregroundColor(.white)

Button("Create Post") {
Task {
do {
var imageUrl: String? = nil
if let selectedImage = selectedImage {
isUploadingImage = true
// Upload the image to Cloudinary and get the image URL
imageUrl = try await PostService.uploadImageToCloudinary(image: selectedImage)
}

// Create the post with or without an image URL
_ = try await PostService.createPost(message: userInput, image: selectedImage)

// Show success alert
alertTitle = "Post Created"
alertMessage = "Your post has been created successfully."
showAlert = true

} catch {
// Show error alert
alertTitle = "Error"
alertMessage = "Failed to create the post. Please try again."
showAlert = true
}
}
}
.frame(width: 120, height: 44)
.background(Color.blue)
.cornerRadius(40)
.foregroundColor(.white)
.disabled(isUploadingImage) // Disable if image is uploading
}
.padding(.top, 30)

Spacer()

// Alert for showing success or error message
.alert(isPresented: $showAlert) {
Alert(
title: Text(alertTitle),
message: Text(alertMessage),
dismissButton: .default(Text("OK"), action: {
if alertTitle == "Post Created" {
// Dismiss the CreatePostView modal and return to MainView
self.presentationMode.wrappedValue.dismiss()
}
})
)
}
}
.background(Color(red: 0, green: 0.96, blue: 1).ignoresSafeArea()) // Cover entire screen with background color
.navigationBarHidden(true) // Hide default navigation bar
.sheet(isPresented: $showPhotoPicker) {
// Use SwiftUI's photo picker
PhotoPicker(selectedImage: $selectedImage)
}
}
}

#Preview {
CreatePostView()
}
16 changes: 16 additions & 0 deletions MobileAcebook/DateExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// DateExtension.swift
// MobileAcebook
//
// Created by Sam Quincey on 03/09/2024.
//

import Foundation

extension Date {
func iso8601String() -> String {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
return formatter.string(from: self)
}
}
Loading