diff --git a/Podfile.lock b/Podfile.lock index 12505e8..b5bd883 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -17,4 +17,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 02c21c317ba9be4fdecdfff242f3fa20e9b269bd -COCOAPODS: 1.8.3 +COCOAPODS: 1.8.4 diff --git a/fakestagram.xcodeproj/project.pbxproj b/fakestagram.xcodeproj/project.pbxproj index fd88dc7..c7eafee 100644 --- a/fakestagram.xcodeproj/project.pbxproj +++ b/fakestagram.xcodeproj/project.pbxproj @@ -8,6 +8,18 @@ /* Begin PBXBuildFile section */ 05D8E963168944918FFCC7FF /* Pods_fakestagram.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FFAA8B9133CEE464C903FDF5 /* Pods_fakestagram.framework */; }; + AD065EFE23A0133D00CE9835 /* ComentsAndLikesServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065EFD23A0133D00CE9835 /* ComentsAndLikesServices.swift */; }; + AD065F0423A030F000CE9835 /* FastConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065F0323A030F000CE9835 /* FastConstraints.swift */; }; + AD065F0723A06AF200CE9835 /* CommentsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065F0523A06AF200CE9835 /* CommentsCollectionViewCell.swift */; }; + AD065F0823A06AF200CE9835 /* CommentsCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD065F0623A06AF200CE9835 /* CommentsCollectionViewCell.xib */; }; + AD065F0B23A084F800CE9835 /* ShowPostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065F0923A084F800CE9835 /* ShowPostViewController.swift */; }; + AD065F0C23A084F800CE9835 /* ShowPostViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD065F0A23A084F800CE9835 /* ShowPostViewController.xib */; }; + AD065F1023A0875C00CE9835 /* PreviewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD065F0E23A0875C00CE9835 /* PreviewViewController.xib */; }; + AD065F1223A09C0100CE9835 /* PreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065F1123A09C0100CE9835 /* PreviewViewController.swift */; }; + AD065F1523A0A02200CE9835 /* FiltersCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD065F1323A0A02200CE9835 /* FiltersCollectionViewCell.swift */; }; + AD065F1623A0A02300CE9835 /* FiltersCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD065F1423A0A02200CE9835 /* FiltersCollectionViewCell.xib */; }; + AD23263623A183C800D088EC /* CommentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD23263423A183C800D088EC /* CommentsViewController.swift */; }; + AD23263723A183C800D088EC /* CommentsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD23263523A183C800D088EC /* CommentsViewController.xib */; }; D3D164DC7444072103DE027D /* Pods_fakestagramTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E669E31C92D68155914FC99D /* Pods_fakestagramTests.framework */; }; E023A5542380859200B13B7D /* NotificationKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = E023A5532380859200B13B7D /* NotificationKeys.swift */; }; E038FCED233FC78600E28571 /* PostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E038FCEC233FC78600E28571 /* PostViewController.swift */; }; @@ -33,8 +45,6 @@ E0C93E9923514D8800FD330C /* posts.successful.json in Resources */ = {isa = PBXBuildFile; fileRef = E0C93E9823514D8800FD330C /* posts.successful.json */; }; E0C93E9B23515A0400FD330C /* show_post.successful.json in Resources */ = {isa = PBXBuildFile; fileRef = E0C93E9A23515A0400FD330C /* show_post.successful.json */; }; E0C93E9D23515CEE00FD330C /* CodableSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C93E9C23515CEE00FD330C /* CodableSerializer.swift */; }; - E0C93EA123523B7C00FD330C /* ShowPostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C93E9F23523B7C00FD330C /* ShowPostViewController.swift */; }; - E0C93EA223523B7C00FD330C /* ShowPostViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0C93EA023523B7C00FD330C /* ShowPostViewController.xib */; }; E0C93EA42352452900FD330C /* AuthorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C93EA32352452900FD330C /* AuthorView.swift */; }; E0C93EA62352454E00FD330C /* Author.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C93EA52352454E00FD330C /* Author.swift */; }; E0C93EA82352455C00FD330C /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C93EA72352455C00FD330C /* Comment.swift */; }; @@ -65,6 +75,18 @@ /* Begin PBXFileReference section */ 5E0AE2BFBF9C8D81E583E1BE /* Pods-fakestagramTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fakestagramTests.release.xcconfig"; path = "Target Support Files/Pods-fakestagramTests/Pods-fakestagramTests.release.xcconfig"; sourceTree = ""; }; 66342726A6BCEEEF6289B1AA /* Pods-fakestagramTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fakestagramTests.debug.xcconfig"; path = "Target Support Files/Pods-fakestagramTests/Pods-fakestagramTests.debug.xcconfig"; sourceTree = ""; }; + AD065EFD23A0133D00CE9835 /* ComentsAndLikesServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComentsAndLikesServices.swift; sourceTree = ""; }; + AD065F0323A030F000CE9835 /* FastConstraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FastConstraints.swift; sourceTree = ""; }; + AD065F0523A06AF200CE9835 /* CommentsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentsCollectionViewCell.swift; sourceTree = ""; }; + AD065F0623A06AF200CE9835 /* CommentsCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CommentsCollectionViewCell.xib; sourceTree = ""; }; + AD065F0923A084F800CE9835 /* ShowPostViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowPostViewController.swift; sourceTree = ""; }; + AD065F0A23A084F800CE9835 /* ShowPostViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowPostViewController.xib; sourceTree = ""; }; + AD065F0E23A0875C00CE9835 /* PreviewViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreviewViewController.xib; sourceTree = ""; }; + AD065F1123A09C0100CE9835 /* PreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreviewViewController.swift; sourceTree = ""; }; + AD065F1323A0A02200CE9835 /* FiltersCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FiltersCollectionViewCell.swift; sourceTree = ""; }; + AD065F1423A0A02200CE9835 /* FiltersCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FiltersCollectionViewCell.xib; sourceTree = ""; }; + AD23263423A183C800D088EC /* CommentsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentsViewController.swift; sourceTree = ""; }; + AD23263523A183C800D088EC /* CommentsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CommentsViewController.xib; sourceTree = ""; }; CCC6C6EA9D17CA169951A745 /* Pods-fakestagram.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fakestagram.release.xcconfig"; path = "Target Support Files/Pods-fakestagram/Pods-fakestagram.release.xcconfig"; sourceTree = ""; }; DB68F7FEC717545506064663 /* Pods-fakestagram.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fakestagram.debug.xcconfig"; path = "Target Support Files/Pods-fakestagram/Pods-fakestagram.debug.xcconfig"; sourceTree = ""; }; E023A5532380859200B13B7D /* NotificationKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationKeys.swift; sourceTree = ""; }; @@ -97,8 +119,6 @@ E0C93E9823514D8800FD330C /* posts.successful.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = posts.successful.json; sourceTree = ""; }; E0C93E9A23515A0400FD330C /* show_post.successful.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = show_post.successful.json; sourceTree = ""; }; E0C93E9C23515CEE00FD330C /* CodableSerializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableSerializer.swift; sourceTree = ""; }; - E0C93E9F23523B7C00FD330C /* ShowPostViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowPostViewController.swift; sourceTree = ""; }; - E0C93EA023523B7C00FD330C /* ShowPostViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShowPostViewController.xib; sourceTree = ""; }; E0C93EA32352452900FD330C /* AuthorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorView.swift; sourceTree = ""; }; E0C93EA52352454E00FD330C /* Author.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Author.swift; sourceTree = ""; }; E0C93EA72352455C00FD330C /* Comment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comment.swift; sourceTree = ""; }; @@ -154,6 +174,7 @@ children = ( E045844823762E10006574FA /* CreatePostService.swift */, E0458456237725B9006574FA /* IndexService.swift */, + AD065EFD23A0133D00CE9835 /* ComentsAndLikesServices.swift */, ); path = Services; sourceTree = ""; @@ -228,9 +249,13 @@ E0C185EF237F92C700AD9983 /* PreviewView.swift */, E0A9ED52235A7FF300A0527E /* PostCollectionViewCell.swift */, E0A9ED53235A7FF300A0527E /* PostCollectionViewCell.xib */, - E0C93E9F23523B7C00FD330C /* ShowPostViewController.swift */, - E0C93EA023523B7C00FD330C /* ShowPostViewController.xib */, E0C93EA32352452900FD330C /* AuthorView.swift */, + AD065F0523A06AF200CE9835 /* CommentsCollectionViewCell.swift */, + AD065F0623A06AF200CE9835 /* CommentsCollectionViewCell.xib */, + AD065F0923A084F800CE9835 /* ShowPostViewController.swift */, + AD065F0A23A084F800CE9835 /* ShowPostViewController.xib */, + AD065F1323A0A02200CE9835 /* FiltersCollectionViewCell.swift */, + AD065F1423A0A02200CE9835 /* FiltersCollectionViewCell.xib */, ); path = Views; sourceTree = ""; @@ -241,6 +266,10 @@ E0A9ED50235A782F00A0527E /* PostsViewController.swift */, E038FCEC233FC78600E28571 /* PostViewController.swift */, E0E25462235B675100C55767 /* CameraViewController.swift */, + AD065F1123A09C0100CE9835 /* PreviewViewController.swift */, + AD065F0E23A0875C00CE9835 /* PreviewViewController.xib */, + AD23263423A183C800D088EC /* CommentsViewController.swift */, + AD23263523A183C800D088EC /* CommentsViewController.xib */, ); path = ViewControllers; sourceTree = ""; @@ -252,6 +281,7 @@ E0E2545E235A9F3A00C55767 /* UIDevice+models.swift */, E0E25464235B6C0500C55767 /* UIImage+Base64.swift */, E023A5532380859200B13B7D /* NotificationKeys.swift */, + AD065F0323A030F000CE9835 /* FastConstraints.swift */, ); path = Utils; sourceTree = ""; @@ -286,8 +316,8 @@ E0E8B973234918FF00DA9D1A /* Account.swift */, E0E8B9752349197100DA9D1A /* Post.swift */, E0C93EA52352454E00FD330C /* Author.swift */, - E0C93EA72352455C00FD330C /* Comment.swift */, E0C93EA92352457200FD330C /* Like.swift */, + E0C93EA72352455C00FD330C /* Comment.swift */, ); path = Models; sourceTree = ""; @@ -387,8 +417,12 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - E0C93EA223523B7C00FD330C /* ShowPostViewController.xib in Resources */, + AD065F0823A06AF200CE9835 /* CommentsCollectionViewCell.xib in Resources */, E084FAE6233A8735009AC50D /* LaunchScreen.storyboard in Resources */, + AD23263723A183C800D088EC /* CommentsViewController.xib in Resources */, + AD065F0C23A084F800CE9835 /* ShowPostViewController.xib in Resources */, + AD065F1623A0A02300CE9835 /* FiltersCollectionViewCell.xib in Resources */, + AD065F1023A0875C00CE9835 /* PreviewViewController.xib in Resources */, E084FAE3233A8735009AC50D /* Assets.xcassets in Resources */, E084FAE1233A8734009AC50D /* Main.storyboard in Resources */, E0A9ED55235A7FF300A0527E /* PostCollectionViewCell.xib in Resources */, @@ -496,16 +530,19 @@ E0E2545F235A9F3A00C55767 /* UIDevice+models.swift in Sources */, E0E8B96A23481D5A00DA9D1A /* StatusCode.swift in Sources */, E045845123766203006574FA /* CacheImage.swift in Sources */, + AD065F0723A06AF200CE9835 /* CommentsCollectionViewCell.swift in Sources */, E045844B237652DD006574FA /* StorageType.swift in Sources */, + AD065EFE23A0133D00CE9835 /* ComentsAndLikesServices.swift in Sources */, E023A5542380859200B13B7D /* NotificationKeys.swift in Sources */, E0C185F0237F92C700AD9983 /* PreviewView.swift in Sources */, E0E8B974234918FF00DA9D1A /* Account.swift in Sources */, - E0C93EA123523B7C00FD330C /* ShowPostViewController.swift in Sources */, E0E25463235B675100C55767 /* CameraViewController.swift in Sources */, E0458457237725B9006574FA /* IndexService.swift in Sources */, + AD065F0B23A084F800CE9835 /* ShowPostViewController.swift in Sources */, E038FCED233FC78600E28571 /* PostViewController.swift in Sources */, E0C93EA82352455C00FD330C /* Comment.swift in Sources */, E0C93EAA2352457200FD330C /* Like.swift in Sources */, + AD065F1523A0A02200CE9835 /* FiltersCollectionViewCell.swift in Sources */, E0C93E9D23515CEE00FD330C /* CodableSerializer.swift in Sources */, E0458454237721F5006574FA /* CheckSum.m in Sources */, E0E25465235B6C0500C55767 /* UIImage+Base64.swift in Sources */, @@ -519,10 +556,13 @@ E0A9ED54235A7FF300A0527E /* PostCollectionViewCell.swift in Sources */, E0E8B96C23481E1700DA9D1A /* HttpResponse.swift in Sources */, E045844F23765B0F006574FA /* ImageStore.swift in Sources */, + AD23263623A183C800D088EC /* CommentsViewController.swift in Sources */, E045844D23765677006574FA /* DataContainer.swift in Sources */, E0E8B9652348018200DA9D1A /* Credentials.swift in Sources */, E0E8B971234916D100DA9D1A /* RestClient.swift in Sources */, + AD065F0423A030F000CE9835 /* FastConstraints.swift in Sources */, E084FADC233A8734009AC50D /* SceneDelegate.swift in Sources */, + AD065F1223A09C0100CE9835 /* PreviewViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -689,13 +729,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = D3XL2U7DQC; + DEVELOPMENT_TEAM = 4YDAEX93RK; INFOPLIST_FILE = fakestagram/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram; + PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagramjbkj; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "fakestagram/fakestagram-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -711,13 +751,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = D3XL2U7DQC; + DEVELOPMENT_TEAM = 4YDAEX93RK; INFOPLIST_FILE = fakestagram/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram; + PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagramjbkj; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "fakestagram/fakestagram-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/fakestagram/AppDelegate.swift b/fakestagram/AppDelegate.swift index 2660552..7af9ea0 100644 --- a/fakestagram/AppDelegate.swift +++ b/fakestagram/AppDelegate.swift @@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func loadOrCreateAccount() { if Credentials.apiToken.get() != nil { return } - let account = Account(id: nil, name: "Juan Camaney", deviceNumber: UIDevice.identifier, deviceModel: UIDevice.modelName) + let account = Account(id: nil, name: "Pedro Vázquez", deviceNumber: UIDevice.identifier, deviceModel: UIDevice.modelName) let client = RestClient(client: Client.fakestagram, basePath: "/api/v1/accounts") client.create(account) { account in guard let account = account, let idx = account.id else { return } diff --git a/fakestagram/Assets.xcassets/comments.imageset/Contents.json b/fakestagram/Assets.xcassets/comments.imageset/Contents.json new file mode 100644 index 0000000..faeab1c --- /dev/null +++ b/fakestagram/Assets.xcassets/comments.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "comments.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "comments@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "comments@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/fakestagram/Assets.xcassets/comments.imageset/comments.png b/fakestagram/Assets.xcassets/comments.imageset/comments.png new file mode 100644 index 0000000..c33cabb Binary files /dev/null and b/fakestagram/Assets.xcassets/comments.imageset/comments.png differ diff --git a/fakestagram/Assets.xcassets/comments.imageset/comments@2x.png b/fakestagram/Assets.xcassets/comments.imageset/comments@2x.png new file mode 100644 index 0000000..1e2f8f4 Binary files /dev/null and b/fakestagram/Assets.xcassets/comments.imageset/comments@2x.png differ diff --git a/fakestagram/Assets.xcassets/comments.imageset/comments@3x.png b/fakestagram/Assets.xcassets/comments.imageset/comments@3x.png new file mode 100644 index 0000000..1828886 Binary files /dev/null and b/fakestagram/Assets.xcassets/comments.imageset/comments@3x.png differ diff --git a/fakestagram/Assets.xcassets/like.imageset/Contents.json b/fakestagram/Assets.xcassets/like.imageset/Contents.json new file mode 100644 index 0000000..2481618 --- /dev/null +++ b/fakestagram/Assets.xcassets/like.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "like.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "like@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "like@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/fakestagram/Assets.xcassets/like.imageset/like.png b/fakestagram/Assets.xcassets/like.imageset/like.png new file mode 100644 index 0000000..db137b0 Binary files /dev/null and b/fakestagram/Assets.xcassets/like.imageset/like.png differ diff --git a/fakestagram/Assets.xcassets/like.imageset/like@2x.png b/fakestagram/Assets.xcassets/like.imageset/like@2x.png new file mode 100644 index 0000000..6aeda61 Binary files /dev/null and b/fakestagram/Assets.xcassets/like.imageset/like@2x.png differ diff --git a/fakestagram/Assets.xcassets/like.imageset/like@3x.png b/fakestagram/Assets.xcassets/like.imageset/like@3x.png new file mode 100644 index 0000000..e85a7f5 Binary files /dev/null and b/fakestagram/Assets.xcassets/like.imageset/like@3x.png differ diff --git a/fakestagram/Base.lproj/Main.storyboard b/fakestagram/Base.lproj/Main.storyboard index 469596b..d138f91 100644 --- a/fakestagram/Base.lproj/Main.storyboard +++ b/fakestagram/Base.lproj/Main.storyboard @@ -2,13 +2,13 @@ - + - + @@ -17,7 +17,7 @@ - + @@ -46,16 +46,16 @@ - + - + - + @@ -64,10 +64,10 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fakestagram/ViewControllers/PostViewController.swift b/fakestagram/ViewControllers/PostViewController.swift index f18ad1d..5c19568 100644 --- a/fakestagram/ViewControllers/PostViewController.swift +++ b/fakestagram/ViewControllers/PostViewController.swift @@ -45,7 +45,9 @@ class PostViewController: UIViewController { } */ func loadComments(successful: @escaping ([Comment]) -> Void) { + guard let uwrappedPost = post, let postId = uwrappedPost.id else { return } + let url = URL(string: "https://fakestagram-api.herokuapp.com/api/v1/posts/\(postId)/comments")! var request = URLRequest(url: url) request.setValue("application/json", forHTTPHeaderField: "Accept") @@ -64,6 +66,7 @@ class PostViewController: UIViewController { do { guard let data = data else { print("Empty response"); return } let json = try decoder.decode([Comment].self, from: data) + print(json) successful(json) } catch let err { print("Unable to parse successfull response: \(err.localizedDescription)") diff --git a/fakestagram/ViewControllers/PostsViewController.swift b/fakestagram/ViewControllers/PostsViewController.swift index a49ab76..9baa921 100644 --- a/fakestagram/ViewControllers/PostsViewController.swift +++ b/fakestagram/ViewControllers/PostsViewController.swift @@ -64,6 +64,7 @@ class PostsViewController: UIViewController, UICollectionViewDelegate, UICollect let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PostCollectionViewCell.identifier, for: indexPath) as! PostCollectionViewCell guard let posts = self.posts else { return cell } cell.post = posts[indexPath.row] + cell.delegate = self return cell } diff --git a/fakestagram/ViewControllers/PreviewViewController.swift b/fakestagram/ViewControllers/PreviewViewController.swift new file mode 100644 index 0000000..0ed567b --- /dev/null +++ b/fakestagram/ViewControllers/PreviewViewController.swift @@ -0,0 +1,164 @@ +// +// PreviewViewController.swift +// fakestagram +// +// Created by Pedro Antonio Vazquez Rodriguez on 10/12/19. +// Copyright © 2019 3zcurdia. All rights reserved. +// + +import UIKit +import CoreImage + +class PreviewViewController: UIViewController { + + var image:UIImage! + let service = CreatePostService() + + let filters = ["CIBumpDistortion" + ,"CIGaussianBlur" + ,"CIPixellate" + ,"CISepiaTone","CITwirlDistortion" + ,"CIUnsharpMask" + ,"CIVignette" + ,"CIPhotoEffectMono" + ,"CIPhotoEffectChrome" + ,"CIPhotoEffectFade" + ,"CIPhotoEffectInstant" + ,"CIPhotoEffectNoir" + ,"CIPhotoEffectProcess" + ,"CIPhotoEffectTonal" + ,"CIPhotoEffectTransfer" + ,"CIComicEffect"] + + @IBOutlet weak var postImageView: UIImageView! + + @IBOutlet weak var postTitleTextField: UITextField! + + @IBOutlet weak var filtersCollectionView: UICollectionView! + //stack Views + @IBOutlet weak var intensityStackView: UIStackView! + @IBOutlet weak var radiousStackView: UIStackView! + @IBOutlet weak var scaleStackView: UIStackView! + //sliders + @IBOutlet weak var intensitySlider: UISlider! + @IBOutlet weak var scaleSlider: UISlider! + @IBOutlet weak var radiousSlider: UISlider! + + + var currentImage : UIImage! + var context :CIContext! + var currentFilter: CIFilter! + + + override func viewDidLoad() { + super.viewDidLoad() + context = CIContext() + postImageView.image = image + currentImage = image + // Do any additional setup after loading the view. + intensityStackView.isHidden = true + radiousStackView.isHidden = true + scaleStackView.isHidden = true + + filtersCollectionView.delegate = self + filtersCollectionView.dataSource = self + + filtersCollectionView.register(UINib(nibName: "FiltersCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: FiltersCollectionViewCell.identifier) + let tap = UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing)) + tap.cancelsTouchesInView = false + view.addGestureRecognizer(tap) + } + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + view.endEditing(true) + } + func applyProcessing() { + let inputKeys = currentFilter.inputKeys + if inputKeys.contains(kCIInputIntensityKey){ + intensityStackView.isHidden = false + currentFilter.setValue(intensitySlider.value, forKey: kCIInputIntensityKey) + }else{ + intensityStackView.isHidden = true + } + if inputKeys.contains(kCIInputRadiusKey){ + radiousStackView.isHidden = false + currentFilter.setValue(radiousSlider.value * 300, forKey: kCIInputRadiusKey) + }else{ + radiousStackView.isHidden = true + + } + if inputKeys.contains(kCIInputScaleKey){ + scaleStackView.isHidden = false + currentFilter.setValue(scaleSlider.value * 15, forKey: kCIInputScaleKey) + }else{ + scaleStackView.isHidden = true + } + if inputKeys.contains(kCIInputCenterKey){ + currentFilter.setValue(CIVector(x: currentImage.size.width/2, y: currentImage.size.height/2), forKey: kCIInputCenterKey) + } + + guard let outputImage = currentFilter.outputImage else {return} + + + if let cgImage = context.createCGImage(outputImage, from: outputImage.extent){ + let proceedImage = UIImage(cgImage: cgImage) + postImageView.image = proceedImage + } + } + + @IBAction func scaleChange(_ sender: Any) { + applyProcessing() + } + @IBAction func radiousChange(_ sender: Any) { + applyProcessing() + } + @IBAction func changeIntensity(_ sender: Any) { + applyProcessing() + } + + + @IBAction func post(_ sender: Any) { + guard let img = postImageView.image, let text = postTitleTextField.text else { + return + } + service.call(image: img, title: text) { postId in + print("Successful!") + + print(postId ?? -1) + self.navigationController?.popToRootViewController(animated: true) + } + } + +} + +extension PreviewViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + filters.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = filtersCollectionView.dequeueReusableCell(withReuseIdentifier: FiltersCollectionViewCell.identifier, for: indexPath) as! FiltersCollectionViewCell + cell.filterString = filters[indexPath.item] + cell.image = image + + return cell + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 150, height: self.view.frame.height) + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + intensitySlider.value = 0.5 + radiousSlider.value = 0.5 + scaleSlider.value = 0.5 + currentFilter = CIFilter(name: filters[indexPath.item]) + + + let beginImage = CIImage(image: image) + currentFilter.setValue(beginImage, forKey: kCIInputImageKey) + applyProcessing() + + } + + +} diff --git a/fakestagram/ViewControllers/PreviewViewController.xib b/fakestagram/ViewControllers/PreviewViewController.xib new file mode 100644 index 0000000..6db3456 --- /dev/null +++ b/fakestagram/ViewControllers/PreviewViewController.xib @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fakestagram/Views/CommentsCollectionViewCell.swift b/fakestagram/Views/CommentsCollectionViewCell.swift new file mode 100644 index 0000000..76db2a7 --- /dev/null +++ b/fakestagram/Views/CommentsCollectionViewCell.swift @@ -0,0 +1,25 @@ +// +// CommentsCollectionViewCell.swift +// fakestagram +// +// Created by Pedro Antonio Vazquez Rodriguez on 10/12/19. +// Copyright © 2019 3zcurdia. All rights reserved. +// + +import UIKit + +class CommentsCollectionViewCell: UICollectionViewCell { + + static let identifier: String = "CommentCell" + + @IBOutlet weak var commentsTextView: UITextView! + var post: Post? + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + + } + + +} diff --git a/fakestagram/Views/CommentsCollectionViewCell.xib b/fakestagram/Views/CommentsCollectionViewCell.xib new file mode 100644 index 0000000..9f6c7cd --- /dev/null +++ b/fakestagram/Views/CommentsCollectionViewCell.xib @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fakestagram/Views/FiltersCollectionViewCell.swift b/fakestagram/Views/FiltersCollectionViewCell.swift new file mode 100644 index 0000000..a6c5c31 --- /dev/null +++ b/fakestagram/Views/FiltersCollectionViewCell.swift @@ -0,0 +1,76 @@ +// +// FiltersCollectionViewCell.swift +// fakestagram +// +// Created by Pedro Antonio Vazquez Rodriguez on 10/12/19. +// Copyright © 2019 3zcurdia. All rights reserved. +// + +import UIKit + +class FiltersCollectionViewCell: UICollectionViewCell { + static let identifier: String = "FilterCell" + + @IBOutlet weak var previewImageView: UIImageView! + @IBOutlet weak var titleLabel: UILabel! + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + var currentImage : UIImage! + var context :CIContext! + var currentFilter: CIFilter! + var image: UIImage?{ + didSet{ + guard let img = image else {return} + currentImage = img + previewImageView.image = img + let beginImage = CIImage(image: img) + currentFilter.setValue(beginImage, forKey: kCIInputImageKey) + previewProcessing() + //applyProcessing() + } + } + + var filterString: String?{ + didSet{ + guard let filter = filterString else {return} + context = CIContext() + currentFilter = CIFilter(name: filter) + print(filter) + titleLabel.text = filter +// previewProcessing() + } + + } + + + func previewProcessing() { + let inputKeys = currentFilter.inputKeys + if inputKeys.contains(kCIInputIntensityKey){ + currentFilter.setValue(0.5, forKey: kCIInputIntensityKey) + } + if inputKeys.contains(kCIInputRadiusKey){ + + currentFilter.setValue(0.5 * 300, forKey: kCIInputRadiusKey) + } + if inputKeys.contains(kCIInputScaleKey){ + currentFilter.setValue(0.5 * 15, forKey: kCIInputScaleKey) + } + if inputKeys.contains(kCIInputCenterKey){ + currentFilter.setValue(CIVector(x: currentImage.size.width/2, y: currentImage.size.height/2), forKey: kCIInputCenterKey) + } + + guard let outputImage = currentFilter.outputImage else {return} + + + if let cgImage = context.createCGImage(outputImage, from: outputImage.extent){ + let proceedImage = UIImage(cgImage: cgImage) + previewImageView.image = proceedImage + } + } + +} + + + diff --git a/fakestagram/Views/FiltersCollectionViewCell.xib b/fakestagram/Views/FiltersCollectionViewCell.xib new file mode 100644 index 0000000..eb0221e --- /dev/null +++ b/fakestagram/Views/FiltersCollectionViewCell.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fakestagram/Views/PostCollectionViewCell.swift b/fakestagram/Views/PostCollectionViewCell.swift index 1d5be7b..faa19c3 100644 --- a/fakestagram/Views/PostCollectionViewCell.swift +++ b/fakestagram/Views/PostCollectionViewCell.swift @@ -9,6 +9,8 @@ import UIKit class PostCollectionViewCell: UICollectionViewCell { + + weak var delegate:PostsViewController? static let identifier: String = "PostCell" public var post: Post? { didSet { @@ -21,11 +23,14 @@ class PostCollectionViewCell: UICollectionViewCell { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var likeBttn: UIButton! @IBOutlet weak var commentBttn: UIButton! + @IBOutlet weak var commentCounter: UILabel! + func reset() { self.imageView.image = nil self.likeCounter.text = "" self.titleLabel.text = "" + self.likeBttn.setImage(UIImage.init(systemName: "heart"), for: .normal) } func updateView() { @@ -34,9 +39,40 @@ class PostCollectionViewCell: UICollectionViewCell { self.authorView.author = post.author self.titleLabel.text = post.title self.likeCounter.text = post.likesCountText() + self.commentCounter.text = post.commentsCountText() + print(post.liked) + if post.liked == true{ if post.liked { + self.likeBttn.setImage(UIImage.init(systemName: "heart.fill"), for: .normal) + + } + } post.load { [unowned self] img in self.imageView.image = img } } + + + + + @IBAction func likeAction(_ sender: UIButton) { + + let service = AddLikeService() + service.call(postId: post?.id) { (post) in + print("success") + self.likeBttn.setImage(UIImage.init(systemName: "heart"), for: .normal) + } + + } + + @IBAction func commentAction(_ sender: UIButton) { + guard let id = post?.id else {return} + let comentsCollectionView = CommentsViewController() + comentsCollectionView.postId = id + delegate?.navigationController?.pushViewController(comentsCollectionView, animated: true) + + + } + + } diff --git a/fakestagram/Views/PostCollectionViewCell.xib b/fakestagram/Views/PostCollectionViewCell.xib index afff929..db5a89b 100644 --- a/fakestagram/Views/PostCollectionViewCell.xib +++ b/fakestagram/Views/PostCollectionViewCell.xib @@ -1,8 +1,8 @@ - + - + @@ -31,18 +31,30 @@ - + + -