Skip to content

Commit

Permalink
๐Ÿ”จ[FIX] : #139 ์ถฉ๋Œ ํ•ด๊ฒฐ
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Dec 23, 2021
2 parents e7e2e18 + baa7bf4 commit 665f3d5
Show file tree
Hide file tree
Showing 14 changed files with 963 additions and 225 deletions.
59 changes: 45 additions & 14 deletions ChaRo-iOS/ChaRo-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" 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="18093"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down
5 changes: 3 additions & 2 deletions ChaRo-iOS/ChaRo-iOS/Resource/Xibs/CVC/CommonCVC.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19162" 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="18093"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down
67 changes: 36 additions & 31 deletions ChaRo-iOS/ChaRo-iOS/Source/Models/MyPageDataModel.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//// This file was generated from JSON Schema using quicktype, do not modify it directly.
//// To parse the JSON, add this file to your project and do:
////
//// let myPageDataModel = try? newJSONDecoder().decode(MyPageDataModel.self, from: jsonData)
//
//import Foundation
//
//// MARK: - MyPageDataModel
Expand All @@ -15,13 +10,20 @@
//// MARK: - DataClass
//struct MyPageClass: Codable {
// let userInformation: UserInformation
// let writtnTotal: Int
// let writtenTotal: Int
// let writtenPost: [Post]
// let savedTotal: Int
// let savedPost: [Post]
//}
//
//// MARK: - Post
//// MARK: - UserInformation
//struct UserInformation: Codable {
// let nickname: String
// let profileImage: String
// let following, follower: Int
//}
//
//// MARK: - WrittenPost
//struct Post: Codable {
// let postID: Int
// let title: String
Expand All @@ -35,51 +37,54 @@
// case title, image, tags, favoriteNum, saveNum, year, month, day
// }
//}
//
//// MARK: - UserInformation
//struct UserInformation: Codable {
// let nickname: String
// let profileImage: String
// let following: Int
// let follower: Int
//}


import Foundation

// MARK: - MyPageDataModel
struct MyPageDataModel: Codable {
let success: Bool
let msg: String
let data: MyPageClass
let data: MyPageDataClass
}

// MARK: - DataClass
struct MyPageClass: Codable {
struct MyPageDataClass: Codable {
let userInformation: UserInformation
let writtenTotal: Int
let writtenPost: [Post]
let savedTotal: Int
let savedPost: [Post]
let writtenPost, savedPost: MyPagePost
}

// MARK: - UserInformation
struct UserInformation: Codable {
let nickname: String
let profileImage: String
let following, follower: Int
// MARK: - Post
struct MyPagePost: Codable {
let lastID, lastCount: Int
let drive: [MyPageDrive]

enum CodingKeys: String, CodingKey {
case lastID = "lastId"
case lastCount, drive
}
}

// MARK: - WrittenPost
struct Post: Codable {
// MARK: - Drive
struct MyPageDrive: Codable {
let postID: Int
let title: String
let image: String
let tags: [String]
let favoriteNum, saveNum: Int
let region, theme: String
let warning: String?
let year, month, day: String
let isFavorite: Bool
let favoriteNum, saveNum: Int

enum CodingKeys: String, CodingKey {
case postID = "postId"
case title, image, tags, favoriteNum, saveNum, year, month, day
case title, image, region, theme, warning, year, month, day, isFavorite, favoriteNum, saveNum
}
}

// MARK: - UserInformation
struct UserInformation: Codable {
let nickname: String
let profileImage: String
let following, follower: Int
}
15 changes: 15 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Models/MypageInfinityDataModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse the JSON, add this file to your project and do:
//
// let login = try? newJSONDecoder().decode(Login.self, from: jsonData)

import Foundation

// MARK: - MypageLikeWrite
struct MypageInpinityModel: Codable {
let success: Bool
let msg: String
let data: MyPagePost
}


8 changes: 5 additions & 3 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/Contants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Constants {
// MARK: - BASE URL
static let baseURL = "http://charo-server.o-r.kr"

static let userId = UserDefaults.standard.string(forKey: "userId") ?? "ios"
static let userId = UserDefaults.standard.string(forKey: "userId") ?? "ios@gmail.com"
static let nickName = UserDefaults.standard.string(forKey: "nickname") ?? "์ง€์œผ๋‹ˆ"
static let profileName = UserDefaults.standard.string(forKey: "profileImage") ?? "https://charo-image.s3.ap-northeast-2.amazonaws.com/dummy/jieun.JPG"

Expand All @@ -33,8 +33,10 @@ struct Constants {
static let ThemeNewURL = baseURL + "/preview/new/\(userId)/1?value="
static let likeURL = baseURL + "/post/like"

static let myPageLikeURL = baseURL + "/myPage/like/" + userId
static let myPageNewURL = baseURL + "/myPage/new/" + userId
///myPage
static let myPageURL = baseURL + "/user/myPage/"
static let myPageLikeURL = baseURL + "/user/myPage/like/" + userId
static let myPageNewURL = baseURL + "/user/myPage/new/" + userId


///ํ•„ํ„ฐ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ์กฐํšŒ
Expand Down
62 changes: 62 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Services/MypageInfinityService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//MARK: made by Jack

import Alamofire
import Foundation

struct MypageInfinityService
{
var userId = UserDefaults.standard.string(forKey: "userId") ?? "[email protected]"

static let MyPageInfinityData = MypageInfinityService()
func getRecommendInfo(addURL: String, likeOrNew: String, completion : @escaping (NetworkResult<Any>) -> Void)
{
// completion ํด๋กœ์ €๋ฅผ @escaping closure๋กœ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
var URL = Constants.myPageURL + likeOrNew + userId + addURL;
let header : HTTPHeaders = ["Content-Type": "application/json"]
let dataRequest = AF.request(URL,
method: .get,
encoding: JSONEncoding.default,
headers: header)

dataRequest.responseData { dataResponse in
// dump(dataResponse)
switch dataResponse.result {

case .success:
guard let statusCode = dataResponse.response?.statusCode else {return}
guard let value = dataResponse.value else {return}
let networkResult = self.judgeStatus(by: statusCode, value)
completion(networkResult)


case .failure: completion(.pathErr)
print("์‹คํŒจ ์‚ฌ์œ ")


}
}

}
private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> {
switch statusCode {
case 200: return isValidData(data: data)
case 400: return .pathErr
case 500: return .serverErr
default: return .networkFail
}
}

private func isValidData(data : Data) -> NetworkResult<Any> {

let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(MypageInpinityModel.self, from: data)
else {return .pathErr}
// ์šฐ์„  PersonDataModel ํ˜•ํƒœ๋กœ decode(ํ•ด๋…)์„ ํ•œ๋ฒˆ ๊ฑฐ์นฉ๋‹ˆ๋‹ค. ์‹คํŒจํ•˜๋ฉด pathErr
// ํ•ด๋…์— ์„ฑ๊ณตํ•˜๋ฉด Person data๋ฅผ success์— ๋„ฃ์–ด์ค๋‹ˆ๋‹ค.


return .success(decodedData)

}

}
42 changes: 21 additions & 21 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/Cells/CVC/CommonCVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,25 @@ class CommonCVC: UICollectionViewCell {

extension UIImageView {

func setImageUrl(_ url: String) {

DispatchQueue.global(qos: .background).async {
if let url = URL(string: url) {
URLSession.shared.dataTask(with: url) { (data, res, err) in
if let _ = err {
DispatchQueue.main.async {
self.image = UIImage()
}
return
}
DispatchQueue.main.async {
if let data = data, let image = UIImage(data: data) {
self.image = image
}
}
}.resume()
}
}
print(image)
}
// func setImageUrl(_ url: String) {
//
// DispatchQueue.global(qos: .background).async {
// if let url = URL(string: url) {
// URLSession.shared.dataTask(with: url) { (data, res, err) in
// if let _ = err {
// DispatchQueue.main.async {
// self.image = UIImage()
// }
// return
// }
// DispatchQueue.main.async {
// if let data = data, let image = UIImage(data: data) {
// self.image = image
// }
// }
// }.resume()
// }
// }
// print(image)
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class HomePostDetailCVC: UICollectionViewCell {
delegate?.menuClicked()
// isButtonClicked.toggle()
print("HomePostDetailCVC")
print("๋ฒ„ํŠผ ๋ˆŒ๋ฆผ")

print("๋ฒ„ํŠผ ๋ˆŒ๋ฆผ", selectText)
}

override func awakeFromNib() {
Expand All @@ -53,6 +52,7 @@ class HomePostDetailCVC: UICollectionViewCell {
func setSelectName(name: String){
selectLabel.text = name
selectText = name
print(selectText , "์ด๊ฑฐ๋จ?")
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import UIKit

class MyPagePostCVC: UICollectionViewCell {

static let identifier: String = "MyPagePostCVC"

//titleLable 30์ž๊นŒ์ง€
@IBOutlet weak var postImage: UIImageView!
@IBOutlet weak var postTitle: UILabel!
Expand Down Expand Up @@ -114,13 +117,20 @@ class MyPagePostCVC: UICollectionViewCell {
tagButtonList[index].layer.borderColor = UIColor.clear.cgColor
continue
}
tagButtonList[index].setTitle("โ€#\(tagArr[index])โ€", for: .normal)
tagButtonList[index].titleLabel?.font = UIFont.notoSansRegularFont(ofSize: 10)
tagButtonList[index].setTitleColor(.mainBlue, for: .normal)
tagButtonList[index].layer.cornerRadius = 9
tagButtonList[index].layer.borderWidth = 1
tagButtonList[index].layer.borderColor = UIColor.mainBlue.cgColor
tagButtonList[index].contentEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

if tagArr[index] != "" {
tagButtonList[index].setTitle("โ€#\(tagArr[index])โ€", for: .normal)
tagButtonList[index].titleLabel?.font = UIFont.notoSansRegularFont(ofSize: 10)
tagButtonList[index].setTitleColor(.mainBlue, for: .normal)
tagButtonList[index].layer.cornerRadius = 9
tagButtonList[index].layer.borderWidth = 1
tagButtonList[index].layer.borderColor = UIColor.mainBlue.cgColor
tagButtonList[index].contentEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
else{
tagButtonList[index].setTitle("", for: .normal)
tagButtonList[index].layer.borderColor = UIColor.clear.cgColor
}
}
//ํ•˜ํŠธ ์ˆ˜ ๋ฐ ์ €์žฅ ์ˆ˜
self.heartLabel.text = String(heart)
Expand Down
Loading

0 comments on commit 665f3d5

Please sign in to comment.