Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#14] UI 추가 구현 #16

Merged
merged 3 commits into from
Dec 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,22 @@ public class PostRepositoryImpl: PostRepository {
]
return Just(posts).eraseToAnyPublisher()
}

public func getRecentSearchPostData() -> AnyPublisher<[Post], Never> {
let posts: [Post] = [
Post(post_id: "1", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까???", postThumbnailImage: "testImage1"),
Post(post_id: "2", postUIType: .normal, postCategory: .art, postTitle: "그때 그 시절, 무엇을 하며 놀았을까요??", postThumbnailImage: "testImage2"),
Post(post_id: "3", postUIType: .normal, postCategory: .art, postTitle: "그래서 이 아저씨가 누군데?", postThumbnailImage: "testImage7"),
Post(post_id: "4", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage3"),
Post(post_id: "5", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage5"),
Post(post_id: "6", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage4"),
Post(post_id: "7", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage6"),
Post(post_id: "8", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage8"),
Post(post_id: "5", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage5"),
Post(post_id: "6", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage4"),
Post(post_id: "7", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage6"),
Post(post_id: "8", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage8")
]
return Just(posts).eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public class PostRepositoryMockImpl: PostRepository {
)

]

return Just(postData.filter { $0.post_id == postId }.first!).eraseToAnyPublisher()
}

Expand Down Expand Up @@ -228,4 +227,22 @@ public class PostRepositoryMockImpl: PostRepository {
]
return Just(posts).eraseToAnyPublisher()
}

public func getRecentSearchPostData() -> AnyPublisher<[Post], Never> {
let posts: [Post] = [
Post(post_id: "1", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까???", postThumbnailImage: "testImage1"),
Post(post_id: "2", postUIType: .normal, postCategory: .art, postTitle: "그때 그 시절, 무엇을 하며 놀았을까요??", postThumbnailImage: "testImage2"),
Post(post_id: "3", postUIType: .normal, postCategory: .art, postTitle: "그래서 이 아저씨가 누군데?", postThumbnailImage: "testImage7"),
Post(post_id: "4", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage3"),
Post(post_id: "5", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage5"),
Post(post_id: "6", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage4"),
Post(post_id: "7", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage6"),
Post(post_id: "8", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage8"),
Post(post_id: "5", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage5"),
Post(post_id: "6", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage4"),
Post(post_id: "7", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage6"),
Post(post_id: "8", postUIType: .normal, postCategory: .art, postTitle: "흑백 사진은 언제 처음 사용되었을까?", postThumbnailImage: "testImage8")
]
return Just(posts).eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public protocol PostRepository {
func getHomeViewData() -> AnyPublisher<HomePostData, Never>
func getPostOneData(postId: String) -> AnyPublisher<Post, Never>
func getSearchGridPostData() -> AnyPublisher<[Post], Never>
func getRecentSearchPostData() -> AnyPublisher<[Post], Never>
}
16 changes: 12 additions & 4 deletions MyLuxury/Domain/Sources/Domain/UseCase/PostUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import Combine

public protocol PostUseCase {
var postRepository: PostRepository { get }

/// 홈 게시물 조회
func getHomeViewData() -> AnyPublisher<HomePostData, Never>
/// 개별 게시물 조회
func getPostOneData(postId: String) -> AnyPublisher<Post, Never>
/// 검색 탭 그리드 게시물 전체 조회
func getSearchGridPostsData() -> AnyPublisher<[Post], Never>
/// 최근 검색 게시물 조회
func getRecentSearchPostData() -> AnyPublisher<[Post], Never>
}

public class PostUseCaseImpl: PostUseCase {

public var postRepository: PostRepository
private var cancellables = Set<AnyCancellable>()

Expand All @@ -29,7 +32,7 @@ public class PostUseCaseImpl: PostUseCase {
print("PostUseCase deinit")
}

/// 홈 화면 데이터 조회
/// 홈 게시물 조회
public func getHomeViewData() -> AnyPublisher<HomePostData, Never> {
return postRepository.getHomeViewData().eraseToAnyPublisher()
}
Expand All @@ -39,8 +42,13 @@ public class PostUseCaseImpl: PostUseCase {
return postRepository.getPostOneData(postId: postId)
}

/// 검색 화면 그리드 게시물 조회
/// 검색 그리드 게시물 전체 조회
public func getSearchGridPostsData() -> AnyPublisher<[Post], Never> {
return postRepository.getSearchGridPostData()
}

/// 최근 검색 게시물 조회
public func getRecentSearchPostData() -> AnyPublisher<[Post], Never> {
return postRepository.getRecentSearchPostData()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Vector-3.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Vector.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// LibraryCVC.swift
// Presentation
//
// Created by KoSungmin on 11/28/24.
//

import UIKit

final class LibraryCVC: UICollectionViewCell {
static let idenrifier = "LibraryCVC"

private let itemTitleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.pretendard(.bold, size: 20)
label.textColor = .white
return label
}()

private let goToNextImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "chevronRight")
imageView.frame = CGRect(x: 0, y: 0, width: 10, height: 18)
return imageView
}()

var itemTitle: String? {
didSet {
self.itemTitleLabel.text = itemTitle
if itemTitle == "로그아웃" || itemTitle == "회원탈퇴" {
goToNextImageView.isHidden = true
}
}
}

override init(frame: CGRect) {
super.init(frame: frame)
setUpHierarchy()
setUpLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setUpHierarchy() {
self.addSubview(itemTitleLabel)
self.addSubview(goToNextImageView)
}

private func setUpLayout() {
itemTitleLabel.translatesAutoresizingMaskIntoConstraints = false
goToNextImageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
itemTitleLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor),
itemTitleLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 15),
goToNextImageView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
goToNextImageView.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -15)
])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// LibraryHeaderView.swift
// Presentation
//
// Created by KoSungmin on 11/27/24.
//

import UIKit

final class LibraryHeaderView: UIView {
private let libraryTextLabel: UILabel = {
let label = UILabel()
label.font = UIFont.pretendard(.bold, size: 32)
label.textColor = .white
label.text = "마이 페이지"
return label
}()

override init(frame: CGRect) {
super.init(frame: frame)
setUpHierarchy()
setUpLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setUpHierarchy() {
self.addSubview(libraryTextLabel)
}

private func setUpLayout() {
libraryTextLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
self.widthAnchor.constraint(equalToConstant: screenWidth),
self.heightAnchor.constraint(equalToConstant: navigationBarHeight),
libraryTextLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor),
libraryTextLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 15)
])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// LibraryItems.swift
// Presentation
//
// Created by KoSungmin on 11/28/24.
//

import UIKit

enum LibraryItems: String, CaseIterable {
case setCategories = "관심 카테고리 설정"
case recentPosts = "최근 본 지식"
case savedPosts = "저장한 지식"
case serviceTerms = "서비스 이용약관"
case personalInfoGuide = "개인정보 처리방침"
case logout = "로그아웃"
case widthdraw = "회원탈퇴"
}
Loading
Loading