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

홈 화면 레이아웃 구현 (with CollectionViewFlowLayout) #51

Merged
merged 18 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f92d792
design: 하트, 빈 하트, 드랍다운, 책 생성 버튼 이미지 추가
Kyxxn Nov 11, 2024
e0033cc
refactor: Setting 버튼 이미지 네이밍 수정
Kyxxn Nov 11, 2024
e8b18f8
Merge branch 'develop' into feature/make-main-home-layout
Kyxxn Nov 11, 2024
9e8f170
Merge branch 'develop' into feature/make-main-home-layout
Kyxxn Nov 12, 2024
2ce7cd4
design: 책 상세보기 ... 버튼 이미지 추가
Kyxxn Nov 12, 2024
289036f
feat: HomeViewModel 추가에 따른 SceneDelegate 로직 수정
Kyxxn Nov 12, 2024
c355a5b
refactor: BookCover의 프로퍼티와 MHBook 커스텀 뷰 네이밍 변경
Kyxxn Nov 12, 2024
98824bc
feat: UICollectionView와 FlowLayout 설정
Kyxxn Nov 12, 2024
86681ed
feat: 홈 우측 하단에 추억 만들기 버튼 생성
Kyxxn Nov 12, 2024
89d1cb6
feat: 홈에서 책 표지 만드는 페이지로 이동 로직 구현
Kyxxn Nov 12, 2024
525a950
fix: 홈에서 책 생성 화면 갔다왔을 때 네비게이션 나타나는 문제 수정
Kyxxn Nov 12, 2024
1be5aab
refactor: 코드리뷰 린트 수정
Kyxxn Nov 12, 2024
a93d42f
feat: UIImage resize 메소드 추가
Kyxxn Nov 13, 2024
8ea83b2
fix: 버튼 안에 있는 이미지 사이즈 조절이 안되는 문제 해결
Kyxxn Nov 13, 2024
77aea9c
fix: 컬렉션뷰 레이아웃에 바텀 패딩을 줘서 SafeArea 지키기
Kyxxn Nov 13, 2024
8eafb21
Merge branch 'develop' into feature/make-main-home-layout
Kyxxn Nov 14, 2024
b68088f
chore: 뷰모델 더미 데이터 삭제
Kyxxn Nov 14, 2024
1706479
fix: Xcode Build yml macOS 수정
Kyxxn Nov 14, 2024
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 @@ -13,12 +13,15 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)

let initialViewController = UserDefaults.standard.object(forKey: Constant.houseNameUserDefaultKey) == nil
? RegisterViewController()
: HomeViewController()
let initialViewController: UIViewController
if let houseName = UserDefaults.standard.object(forKey: Constant.houseNameUserDefaultKey) as? String {
let viewModel = HomeViewModel(houseName: houseName)
initialViewController = HomeViewController(viewModel: viewModel)
} else {
initialViewController = RegisterViewController()
}

let navigationController = UINavigationController(rootViewController: initialViewController)
navigationController.navigationBar.isHidden = true
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
Expand Down
12 changes: 6 additions & 6 deletions MemorialHouse/MHDomain/MHDomain/Entity/BookCover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ public struct BookCover {
public let bookIdentifer = UUID()
public let title: String
public let imageURL: String
public let bookType: BookColor
public let bookColor: BookColor
public let category: String
public let favorite: Bool
public let isLike: Bool

public init(
title: String,
imageURL: String,
bookType: BookColor,
bookColor: BookColor,
category: String,
favorite: Bool = false
isLike: Bool = false
) {
self.title = title
self.imageURL = imageURL
self.bookType = bookType
self.bookColor = bookColor
self.category = category
self.favorite = favorite
self.isLike = isLike
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Subject.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "image 19.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "image [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "image [email protected]",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "Vector 17.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Vector [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Vector [email protected]",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "Favorite_duotone.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "Favorite.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Expand Up @@ -64,6 +64,7 @@ final class BookCreationViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

setup()
configureConstraints()
}

Expand All @@ -74,7 +75,12 @@ final class BookCreationViewController: UIViewController {
super.touchesBegan(touches, with: event)
}

// MARK: - Helper
// MARK: - Setup & Configuration
private func setup() {
view.backgroundColor = .baseBackground
navigationController?.navigationBar.isHidden = false
}

private func configureConstraints() {
// 책 미리보기
let bookPreviewViewBackground = bookImageView.embededInDefaultBackground(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit
import MHFoundation
import MHDomain

final class MHBook: UIView {
final class MHBookCover: UIView {
// MARK: - Property
private let bookCoverImageView = UIImageView()
private let titleLabel = UILabel(style: .default)
Expand All @@ -17,7 +17,7 @@ final class MHBook: UIView {

return imageView
}()
private let publisherLabel = UILabel(style: .body2)
private let houseLabel = UILabel(style: .body2)

// MARK: - Initializer
init() {
Expand All @@ -34,24 +34,30 @@ final class MHBook: UIView {
configureConstraints()
}

func resetProperties() {
bookCoverImageView.image = nil
titleLabel.text = nil
targetImageView.image = nil
}

// MARK: - Configuration
func configure(
title: String,
bookCoverImage: UIImage,
targetImage: UIImage,
publisher: String
houseName: String
) {
titleLabel.text = title
bookCoverImageView.image = bookCoverImage
targetImageView.image = targetImage
publisherLabel.text = publisher
houseLabel.text = houseName
}

private func configureAddSubView() {
addSubview(bookCoverImageView)
addSubview(titleLabel)
addSubview(targetImageView)
addSubview(publisherLabel)
addSubview(houseLabel)
}

private func configureConstraints() {
Expand All @@ -60,8 +66,8 @@ final class MHBook: UIView {
titleLabel.setCenterX(view: self, constant: 8)
targetImageView.setTop(anchor: titleLabel.bottomAnchor, constant: 14)
targetImageView.setCenterX(view: self, constant: 8)
targetImageView.setWidthAndHeight(width: 100, height: 100)
publisherLabel.setBottom(anchor: bottomAnchor, constant: 12)
publisherLabel.setTrailing(anchor: trailingAnchor, constant: 12)
targetImageView.setWidthAndHeight(width: 100, height: 110)
houseLabel.setBottom(anchor: bottomAnchor, constant: 12)
houseLabel.setTrailing(anchor: trailingAnchor, constant: 12)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UIKit

extension UIImage {
static func resizedImage(image: UIImage, size: CGSize) -> UIImage {
let renderer = UIGraphicsImageRenderer(size: size)

return renderer.image { _ in
image.draw(in: CGRect(origin: .zero, size: size))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import UIKit

final class BookCollectionViewCell: UICollectionViewCell {
// MARK: - Properties
private let bookCoverView = MHBookCover()
private let likeButton = UIButton(type: .custom)
private let dropDownButton = UIButton(type: .custom)

// MARK: - Initializer
override init(frame: CGRect) {
super.init(frame: frame)

configureAddSubView()
configureAction()
configureConstraints()
}

required init?(coder: NSCoder) {
super.init(coder: coder)

configureAddSubView()
configureAction()
configureConstraints()
}

override func prepareForReuse() {
super.prepareForReuse()

bookCoverView.resetProperties()
likeButton.imageView?.image = nil
}

// MARK: - Configuration
func configure(
title: String,
bookCoverImage: UIImage,
targetImage: UIImage,
isLike: Bool,
// category: String, // TODO: 카테고리 처리 생각해보기

Check warning on line 39 in MemorialHouse/MHPresentation/MHPresentation/Source/Home/BookCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Todo Violation: TODOs should be resolved (카테고리 처리 생각해보기) (todo)

Check warning on line 39 in MemorialHouse/MHPresentation/MHPresentation/Source/Home/BookCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Todo Violation: TODOs should be resolved (카테고리 처리 생각해보기) (todo)
houseName: String
) {
bookCoverView.configure(
title: title,
bookCoverImage: bookCoverImage,
targetImage: targetImage,
houseName: houseName
)

let likeImage = UIImage.resizedImage(
image: isLike ? .likeFill : .likeEmpty,
size: CGSize(width: 28, height: 28)
)
likeButton.setImage(likeImage, for: .normal)
dropDownButton.setImage(.dotHorizontal, for: .normal)
}

private func configureAddSubView() {
contentView.addSubview(bookCoverView)
contentView.addSubview(likeButton)
contentView.addSubview(dropDownButton)
}

private func configureAction() {
likeButton.addAction(UIAction { _ in
// TODO: 좋아요 버튼 로직

Check warning on line 65 in MemorialHouse/MHPresentation/MHPresentation/Source/Home/BookCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Todo Violation: TODOs should be resolved (좋아요 버튼 로직) (todo)

Check warning on line 65 in MemorialHouse/MHPresentation/MHPresentation/Source/Home/BookCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Todo Violation: TODOs should be resolved (좋아요 버튼 로직) (todo)
}, for: .touchUpInside)

dropDownButton.addAction(UIAction { _ in
// TODO: UI Menu 띄우기

Check warning on line 69 in MemorialHouse/MHPresentation/MHPresentation/Source/Home/BookCollectionViewCell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Todo Violation: TODOs should be resolved (UI Menu 띄우기) (todo)
}, for: .touchUpInside)
}

private func configureConstraints() {
bookCoverView.fillSuperview()
likeButton.setAnchor(
top: bookCoverView.bottomAnchor,
trailing: dropDownButton.leadingAnchor, constantTrailing: 10
)
dropDownButton.setAnchor(
trailing: contentView.trailingAnchor, constantTrailing: 4,
width: 24, height: 16
)
dropDownButton.setCenterY(view: likeButton)
}
}
Loading
Loading