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
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 02c21c317ba9be4fdecdfff242f3fa20e9b269bd

COCOAPODS: 1.8.3
COCOAPODS: 1.8.4
12 changes: 8 additions & 4 deletions fakestagram.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
05D8E963168944918FFCC7FF /* Pods_fakestagram.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FFAA8B9133CEE464C903FDF5 /* Pods_fakestagram.framework */; };
D3D164DC7444072103DE027D /* Pods_fakestagramTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E669E31C92D68155914FC99D /* Pods_fakestagramTests.framework */; };
D41C4B892389B50800B4FD2E /* CreateLikeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D41C4B882389B50800B4FD2E /* CreateLikeService.swift */; };
E023A5542380859200B13B7D /* NotificationKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = E023A5532380859200B13B7D /* NotificationKeys.swift */; };
E038FCED233FC78600E28571 /* PostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E038FCEC233FC78600E28571 /* PostViewController.swift */; };
E045844923762E10006574FA /* CreatePostService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E045844823762E10006574FA /* CreatePostService.swift */; };
Expand Down Expand Up @@ -66,6 +67,7 @@
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
D41C4B882389B50800B4FD2E /* CreateLikeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateLikeService.swift; sourceTree = "<group>"; };
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 = "<group>"; };
E023A5532380859200B13B7D /* NotificationKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationKeys.swift; sourceTree = "<group>"; };
E038FCEC233FC78600E28571 /* PostViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -154,6 +156,7 @@
children = (
E045844823762E10006574FA /* CreatePostService.swift */,
E0458456237725B9006574FA /* IndexService.swift */,
D41C4B882389B50800B4FD2E /* 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 */,
D41C4B892389B50800B4FD2E /* 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 = UF4G86QXSG;
INFOPLIST_FILE = fakestagram/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram;
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagrampoi;
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 = UF4G86QXSG;
INFOPLIST_FILE = fakestagram/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagram;
PRODUCT_BUNDLE_IDENTIFIER = com.3zcurdia.fakestagrampoi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "fakestagram/fakestagram-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion fakestagram/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Luisito Comunica", deviceNumber: UIDevice.identifier, deviceModel: UIDevice.modelName)
let client = RestClient<Account>(client: Client.fakestagram, basePath: "/api/v1/accounts")
client.create(account) { account in
guard let account = account, let idx = account.id else { return }
Expand Down
40 changes: 40 additions & 0 deletions fakestagram/Services/CreateLikeService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// CreateLikeService.swift
// fakestagram
//
// Created by Luis Alberto Gachuz Morales on 23/11/19.
// Copyright © 2019 3zcurdia. All rights reserved.
//

import Foundation
import UIKit
import CoreLocation

struct CreateLike: Codable {
let id: Int
}

//protocol Geolocable {
// func update(coordinate: CLLocationCoordinate2D?)
//}

class CreateLikeService {

// let client = RestClient<CreateLike>(client: Client.fakestagram, basePath: "/api/v1/like/")

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

let client = RestClient<CreateLike>(client: Client.fakestagram, basePath: "/api/v1/posts/ \(newLike.id)/like")

print("LGMMMMMMMMMMMMMMMM \(newLike.id)")


client.create(newLike) { post in
NotificationCenter.default.post(name: NotificationKeys.didFinishPostCreation.value, object: nil)
success(post?.id)
}
}
}
18 changes: 18 additions & 0 deletions fakestagram/Views/PostCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class PostCollectionViewCell: UICollectionViewCell {
updateView()
}
}

let service = CreateLikeService()


@IBOutlet weak var authorView: AuthorView!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var likeCounter: UILabel!
Expand All @@ -38,5 +42,19 @@ class PostCollectionViewCell: UICollectionViewCell {
self.imageView.image = img
}
}


@IBAction func onTapLike(_ sender: Any) {
print("like")


print(self.post?.id ?? 319)

service.call(id: self.post?.id ?? 359) { postId in
print("Successful!")

print(postId ?? -1)
}
}

}
7 changes: 5 additions & 2 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="15505" 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="15510"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -36,6 +36,9 @@
<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"/>
<state key="normal" image="heart" catalog="system"/>
<connections>
<action selector="onTapLike:" destination="gTV-IL-0wX" eventType="touchUpInside" id="jrD-Q7-hDa"/>
</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"/>
Expand Down