Skip to content

Commit

Permalink
Merge pull request #8 from idorm/feat/postList/detail
Browse files Browse the repository at this point in the history
[Feat] PostList Detail 작업
  • Loading branch information
eung7 authored Jan 20, 2023
2 parents b6e1625 + bb9dd93 commit c201dad
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 5 deletions.
4 changes: 4 additions & 0 deletions idorm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
E52CD85628BE371F00A262ED /* ManageMyInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E52CD85528BE371F00A262ED /* ManageMyInfoView.swift */; };
E52E96B22915FAB6009E1773 /* MatchingContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E52E96B12915FAB6009E1773 /* MatchingContainerView.swift */; };
E52E96B429160870009E1773 /* TopProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E52E96B329160870009E1773 /* TopProfileView.swift */; };
E52EDAC3297AA75D007CC138 /* TimeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = E52EDAC2297AA75D007CC138 /* TimeManager.swift */; };
E5359117292343A900E28C1C /* (null) in Embed Frameworks */ = {isa = PBXBuildFile; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E53C60B0287B37CB00977909 /* CompleteSignUpVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E53C60AF287B37CB00977909 /* CompleteSignUpVC.swift */; };
E547E3E3291CEF21000D3A47 /* MatchingCardBoolView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E547E3E2291CEF21000D3A47 /* MatchingCardBoolView.swift */; };
Expand Down Expand Up @@ -243,6 +244,7 @@
E52CD85528BE371F00A262ED /* ManageMyInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageMyInfoView.swift; sourceTree = "<group>"; };
E52E96B12915FAB6009E1773 /* MatchingContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingContainerView.swift; sourceTree = "<group>"; };
E52E96B329160870009E1773 /* TopProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopProfileView.swift; sourceTree = "<group>"; };
E52EDAC2297AA75D007CC138 /* TimeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeManager.swift; sourceTree = "<group>"; };
E53C60AF287B37CB00977909 /* CompleteSignUpVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompleteSignUpVC.swift; sourceTree = "<group>"; };
E547E3E2291CEF21000D3A47 /* MatchingCardBoolView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingCardBoolView.swift; sourceTree = "<group>"; };
E547E3E5291CF120000D3A47 /* MatchingCardBoolList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingCardBoolList.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -481,6 +483,7 @@
E55DDAE829179DD900E62ECB /* AppearanceManager.swift */,
E5FD982528EAF8F0005A29E2 /* MailTimerChecker.swift */,
E50F850829587C8B008B7052 /* ModelTransformationManager.swift */,
E52EDAC2297AA75D007CC138 /* TimeManager.swift */,
);
path = Managers;
sourceTree = "<group>";
Expand Down Expand Up @@ -1207,6 +1210,7 @@
E51063C4291E250400FA0EAC /* NoPublicStatePopUp.swift in Sources */,
E50F850529584747008B7052 /* OnboardingEnumerations.swift in Sources */,
E56342232878353100E93D17 /* TabBarVC.swift in Sources */,
E52EDAC3297AA75D007CC138 /* TimeManager.swift in Sources */,
E5226D5E2911F7110065C809 /* OnboardingVC.swift in Sources */,
E55DDAE929179DD900E62ECB /* AppearanceManager.swift in Sources */,
E5E8A3DF2895208500A48A91 /* MyCommentsCollectionVIewCell.swift in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions idorm.xcodeproj/xcshareddata/xcschemes/idorm.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand All @@ -50,6 +51,13 @@
ReferencedContainer = "container:idorm.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "TZ"
value = "Asia/Seoul"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Binary file not shown.
41 changes: 41 additions & 0 deletions idorm/Configuration/Managers/TimeManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// TimeManager.swift
// idorm
//
// Created by 김응철 on 2023/01/20.
//

import Foundation

enum TimeManager {

static func postList(_ string: String) -> String {
let result: String

let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
format.timeZone = .init(abbreviation: "UTC")

let postDate = format.date(from: string)!
let currentDate = format.date(from: Date().ISO8601Format())!

let interval = Int(currentDate.timeIntervalSince(postDate))

switch interval {
case 0..<60:
result = "방금"

case 60..<3600:
result = "\(interval / 60)분 전"

case 3600..<86400:
result = "\(interval / 3600)시간 전"

default:
format.dateFormat = "MM/dd"
result = format.string(from: postDate)
}

return result
}
}
6 changes: 3 additions & 3 deletions idorm/Source/Networks/APIs/CommunityAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ extension CommunityAPI: TargetType {
let anonymousData = MultipartFormData(provider: .data(post.isAnonymous.description.data(using: .utf8)!), name: "isAnonymous")
let dormNumData = MultipartFormData(provider: .data(post.dormNum.rawValue.data(using: .utf8)!), name: "dormNum")

multiFormDatas = [titleData, contentsData, anonymousData, dormNumData]

for i in 0..<post.assets.count {
let image = post.assets[i].getImageFromPHAsset()
let data = image.jpegData(compressionQuality: 0.5)!
let data = image.jpegData(compressionQuality: 0.1)!
let imageData = MultipartFormData(provider: .data(data), name: "files", fileName: "\(i)", mimeType: "image/jpeg")
multiFormDatas.append(imageData)
}

multiFormDatas = [titleData, contentsData, anonymousData, dormNumData]

return .uploadMultipart(multiFormDatas)
}
Expand Down
26 changes: 25 additions & 1 deletion idorm/Source/Networks/Models/CommunityDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,35 @@ struct CommunityDTO: Codable {
let postId: Int
let title: String
let content: String
let nickname: String
let nickname: String?
let commentsCount: Int
let likesCount: Int
let imagesCount: Int
let createdAt: String

init(from decoder: Decoder) throws {
let container: KeyedDecodingContainer<CommunityDTO.Post.CodingKeys> = try decoder.container(keyedBy: CommunityDTO.Post.CodingKeys.self)
self.postId = try container.decode(Int.self, forKey: CommunityDTO.Post.CodingKeys.postId)
self.title = try container.decode(String.self, forKey: CommunityDTO.Post.CodingKeys.title)
self.content = try container.decode(String.self, forKey: CommunityDTO.Post.CodingKeys.content)
self.commentsCount = try container.decode(Int.self, forKey: CommunityDTO.Post.CodingKeys.commentsCount)
self.likesCount = try container.decode(Int.self, forKey: CommunityDTO.Post.CodingKeys.likesCount)
self.imagesCount = try container.decode(Int.self, forKey: CommunityDTO.Post.CodingKeys.imagesCount)
self.createdAt = try container.decode(String.self, forKey: CommunityDTO.Post.CodingKeys.createdAt)

var nickname = try container.decode(String?.self, forKey: CommunityDTO.Post.CodingKeys.nickname)

switch nickname {
case "anonymous":
nickname = "익명"
case nil:
nickname = "탈퇴 사용자"
default:
break
}

self.nickname = nickname
}
}

struct Save {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,19 @@ final class PostingViewController: BaseViewController, View {
.withUnretained(self)
.bind { $0.0.navigationController?.popViewController(animated: true) }
.disposed(by: disposeBag)

// 로딩 인디케이터 제어
reactor.state
.map { $0.isLoading }
.bind(to: indicator.rx.isAnimating)
.disposed(by: disposeBag)

// 화면 인터렉션 제어
reactor.state
.map { !$0.isLoading }
.distinctUntilChanged()
.bind(to: view.rx.isUserInteractionEnabled)
.disposed(by: disposeBag)
}

// MARK: - Helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,14 @@ final class PostCell: UICollectionViewCell {
likeCountLb.text = "\(post.likesCount)"
pictureCountLb.text = "\(post.imagesCount)"
commentsCountLb.text = "\(post.commentsCount)"

timeLb.text = TimeManager.postList(post.createdAt)

if post.imagesCount == 0 {
pictureCountLb.isHidden = true
pictureIv.isHidden = true
} else {
pictureCountLb.isHidden = false
pictureIv.isHidden = false
}
}
}

0 comments on commit c201dad

Please sign in to comment.