Skip to content
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
12 changes: 8 additions & 4 deletions fakestagram.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
E0E8B971234916D100DA9D1A /* RestClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E8B970234916D100DA9D1A /* RestClient.swift */; };
E0E8B974234918FF00DA9D1A /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E8B973234918FF00DA9D1A /* Account.swift */; };
E0E8B9762349197100DA9D1A /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E8B9752349197100DA9D1A /* Post.swift */; };
FA55F8582389AF3B007B969D /* CreateLikeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA55F8572389AF3B007B969D /* CreateLikeService.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -115,6 +116,7 @@
E0E8B973234918FF00DA9D1A /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = "<group>"; };
E0E8B9752349197100DA9D1A /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
E669E31C92D68155914FC99D /* Pods_fakestagramTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_fakestagramTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FA55F8572389AF3B007B969D /* CreateLikeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateLikeService.swift; sourceTree = "<group>"; };
FFAA8B9133CEE464C903FDF5 /* Pods_fakestagram.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_fakestagram.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -154,6 +156,7 @@
children = (
E045844823762E10006574FA /* CreatePostService.swift */,
E0458456237725B9006574FA /* IndexService.swift */,
FA55F8572389AF3B007B969D /* CreateLikeService.swift */,
);
path = Services;
sourceTree = "<group>";
Expand Down Expand Up @@ -520,6 +523,7 @@
E0E8B96C23481E1700DA9D1A /* HttpResponse.swift in Sources */,
E045844F23765B0F006574FA /* ImageStore.swift in Sources */,
E045844D23765677006574FA /* DataContainer.swift in Sources */,
FA55F8582389AF3B007B969D /* CreateLikeService.swift in Sources */,
E0E8B9652348018200DA9D1A /* Credentials.swift in Sources */,
E0E8B971234916D100DA9D1A /* RestClient.swift in Sources */,
E084FADC233A8734009AC50D /* SceneDelegate.swift in Sources */,
Expand Down Expand Up @@ -689,13 +693,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = D3XL2U7DQC;
DEVELOPMENT_TEAM = LJRMJUKQ84;
INFOPLIST_FILE = fakestagram/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram;
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagramyfh;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "fakestagram/fakestagram-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -711,13 +715,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = D3XL2U7DQC;
DEVELOPMENT_TEAM = LJRMJUKQ84;
INFOPLIST_FILE = fakestagram/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram;
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagramhfhfj;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "fakestagram/fakestagram-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
27 changes: 27 additions & 0 deletions fakestagram/Services/CreateLikeService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// CreateLikeService.swift
// fakestagram
//
// Created by Alex on 11/23/19.
// Copyright © 2019 3zcurdia. All rights reserved.
//

import Foundation

struct CreateLike: Codable {
let postID: Int?
}

class CreateLikeService {
func call(postID: Int?, success: @escaping (Int?) -> Void) {
let newLike = CreateLike(
postID: postID
)

let client = RestClient<CreateLike>(client: Client.fakestagram, basePath: "/api/v1/posts/\(newLike.postID!)/like")
client.create(newLike) { post in
NotificationCenter.default.post(name: NotificationKeys.didFinishPostCreation.value, object: nil)
success(post?.postID)
}
}
}
13 changes: 13 additions & 0 deletions fakestagram/Views/PostCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,18 @@ class PostCollectionViewCell: UICollectionViewCell {
self.imageView.image = img
}
}

@IBAction
func onTapLike(_ sender: Any) {
let service = CreateLikeService()
guard let post = self.post else { return }
service.call(postID: post.id) { postId in
print("Successful!")
print(postId ?? -1)
}


print(post.id)
}

}
19 changes: 11 additions & 8 deletions fakestagram/Views/PostCollectionViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -24,25 +24,28 @@
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="exclamationmark.icloud" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="bfs-US-mwI">
<rect key="frame" x="0.0" y="91" width="415" height="414.5"/>
<rect key="frame" x="0.0" y="92" width="415" height="415"/>
<constraints>
<constraint firstAttribute="height" constant="418" id="6ca-lE-7T3"/>
<constraint firstAttribute="width" secondItem="bfs-US-mwI" secondAttribute="height" multiplier="415:418" id="t7h-M8-A9g"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="ULx-QV-U8H">
<rect key="frame" x="5" y="516" width="141.5" height="22"/>
<rect key="frame" x="5" y="516" width="141" height="22"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ata-8B-MoQ">
<rect key="frame" x="0.0" y="0.0" width="20.5" height="22"/>
<rect key="frame" x="0.0" y="0.0" width="19.5" height="22"/>
<state key="normal" image="heart" catalog="system"/>
<connections>
<action selector="onTapLike:" destination="gTV-IL-0wX" eventType="touchUpInside" id="GMD-gs-KTC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8XJ-Ma-oEM">
<rect key="frame" x="23.5" y="0.0" width="22.5" height="22"/>
<rect key="frame" x="22.5" y="0.0" width="23" height="22"/>
<state key="normal" image="bubble.left" catalog="system"/>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12345 Likes" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WUZ-ZG-6VV" userLabel="LikesCount">
<rect key="frame" x="49" y="0.0" width="92.5" height="22"/>
<rect key="frame" x="48.5" y="0.0" width="92.5" height="22"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -87,6 +90,6 @@
<resources>
<image name="bubble.left" catalog="system" width="64" height="54"/>
<image name="exclamationmark.icloud" catalog="system" width="64" height="44"/>
<image name="heart" catalog="system" width="64" height="54"/>
<image name="heart" catalog="system" width="64" height="58"/>
</resources>
</document>