From ba88b2ffa3af0dd71bb01d5a57eb43def3528039 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Tue, 29 Aug 2023 15:43:02 +0900 Subject: [PATCH 01/50] =?UTF-8?q?=ED=83=AD=20=EB=B0=94=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20View=EC=9D=98=20?= =?UTF-8?q?=EB=B0=B0=EA=B2=BD=EC=83=89=EC=83=81=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/DetailDiaryViewController.swift | 1 + DiaryApp/Controllers/DiaryCalenderViewController.swift | 1 + DiaryApp/Controllers/DiaryListViewController.swift | 1 + DiaryApp/Controllers/DiaryProgressViewController.swift | 1 + DiaryApp/Controllers/EditDiaryViewController.swift | 1 + DiaryApp/Controllers/HomeViewController.swift | 1 + DiaryApp/Controllers/NewDiaryViewController.swift | 1 + DiaryApp/Controllers/ProfileViewController.swift | 1 + DiaryApp/Controllers/ProgressListViewController.swift | 1 + DiaryApp/Resources/SceneDelegate.swift | 2 +- 10 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DiaryApp/Controllers/DetailDiaryViewController.swift b/DiaryApp/Controllers/DetailDiaryViewController.swift index 860de8f..ef0f52f 100644 --- a/DiaryApp/Controllers/DetailDiaryViewController.swift +++ b/DiaryApp/Controllers/DetailDiaryViewController.swift @@ -10,5 +10,6 @@ import UIKit class DetailDiaryViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/DiaryCalenderViewController.swift b/DiaryApp/Controllers/DiaryCalenderViewController.swift index f7a70a2..41e69b3 100644 --- a/DiaryApp/Controllers/DiaryCalenderViewController.swift +++ b/DiaryApp/Controllers/DiaryCalenderViewController.swift @@ -10,5 +10,6 @@ import UIKit class DiaryCalenderViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index ab85548..6dc2824 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -10,5 +10,6 @@ import UIKit class DiaryListViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index c52ed74..d9d7542 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -10,5 +10,6 @@ import UIKit class DiaryProgressViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/EditDiaryViewController.swift b/DiaryApp/Controllers/EditDiaryViewController.swift index 119f0bc..1378a6a 100644 --- a/DiaryApp/Controllers/EditDiaryViewController.swift +++ b/DiaryApp/Controllers/EditDiaryViewController.swift @@ -10,5 +10,6 @@ import UIKit class EditDiaryViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 06a56c7..87a4139 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -10,5 +10,6 @@ import UIKit class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index a22f69d..d0092ba 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -10,5 +10,6 @@ import UIKit class NewDiaryViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/ProfileViewController.swift b/DiaryApp/Controllers/ProfileViewController.swift index 103969e..1add78a 100644 --- a/DiaryApp/Controllers/ProfileViewController.swift +++ b/DiaryApp/Controllers/ProfileViewController.swift @@ -10,5 +10,6 @@ import UIKit class ProfileViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index dec3de7..0e1653a 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -10,5 +10,6 @@ import UIKit class ProgressListViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .systemBackground } } diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index a775bd1..5b21290 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { let tabs: [(root: UIViewController, icon: String)] = [ (HomeViewController(), "house"), (DiaryListViewController(), "list.bullet"), - (DiaryCalenderViewController(), "plus.square"), + (NewDiaryViewController(), "plus.square"), (DiaryProgressViewController(), "tag.fill"), (ProfileViewController(), "person.fill"), ] From 82002248375902d6b60fbd7362eb801f96b3ad2e Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Tue, 29 Aug 2023 16:08:40 +0900 Subject: [PATCH 02/50] =?UTF-8?q?Git=20Convention=20=20=EB=82=B4=EC=9A=A9?= =?UTF-8?q?=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e6a088..d2f8682 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,17 @@ - develop : 개발용 default 브랜치로, 이 브랜치를 기준으로 feature 브랜치를 따고, 각 feature를 합치는 브랜치 - feature: 단위 기능 개발용 브랜치 -> feature/작업할페이지컨트롤러명 -### 참고 -1. 커밋은 기능 단위로!! -> 한 번에 모아서 올리면, 무슨 기능인지 분간이 안됨. -2. 맡은 작업 페이지 외에 다른 작업은 건드리지 말 것!! +### Git Conventions +Commit Message는 아래와 같은 규칙을 따릅니다. +- [FEAT]: 새로운 기능을 추가 +[FIX]: 잔잔바리 수정 +- [DESIGN]: UI 디자인 변경 +- [STYLE]: 코드 포맷 변경, 세미 콜론 누락, 코드 수정이 없는 경우 +- [DOCS]: 문서 수정, 필요한 주석 추가 및 변경 +- [RENAME]: 파일 혹은 폴더명을 수정하거나 옮기는 작업만인 경우 +- [REMOVE]: 파일을 삭제하는 작업만 수행한 경우 +- [MERGE] : 병합 +- [CONFLICT]: 병합 시 충돌 해결 +- [COMPLETION]: 작업을 완료하고 마지막 커밋을 작성하는 경우 +Pull Requests는 Commit Message와 동일하게 써서 올립니다. From f716405a945541e75f1ebc2ddd47cfdd46d5e3b0 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Tue, 29 Aug 2023 19:30:55 +0900 Subject: [PATCH 03/50] =?UTF-8?q?[FEAT]:=20feature/DiaryList-Page=20?= =?UTF-8?q?=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/DiaryListViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 6dc2824..7abe9f3 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -13,3 +13,4 @@ class DiaryListViewController: UIViewController { view.backgroundColor = .systemBackground } } + From 6e8bbbc97374ce41b31e58445e2e3bf85256174a Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Tue, 29 Aug 2023 19:39:07 +0900 Subject: [PATCH 04/50] =?UTF-8?q?[FEAT]:=20=20feature/home-Page=20?= =?UTF-8?q?=EB=B8=8C=EB=9F=B0=EC=B9=98=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 12 +++ DiaryApp/Controllers/HomeViewController.swift | 93 +++++++++++++++++++ DiaryApp/Resources/SceneDelegate.swift | 2 +- DiaryApp/Views/CustomCollectionView.swift | 20 ++++ DiaryApp/Views/CustomImageView.swift | 21 +++++ DiaryApp/Views/HomeFeedCell.swift | 45 +++++++++ 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 DiaryApp/Views/CustomCollectionView.swift create mode 100644 DiaryApp/Views/CustomImageView.swift create mode 100644 DiaryApp/Views/HomeFeedCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 1631a8b..63f0209 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -23,6 +23,9 @@ 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */; }; 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B72A9CAD27003052D3 /* User.swift */; }; 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B92A9CAD60003052D3 /* Weather.swift */; }; + 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */; }; + 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */; }; + 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -44,6 +47,9 @@ 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; 4E98A3B72A9CAD27003052D3 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 4E98A3B92A9CAD60003052D3 /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; + 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCollectionView.swift; sourceTree = ""; }; + 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; + 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomImageView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -115,6 +121,9 @@ isa = PBXGroup; children = ( 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, + 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, + 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, + 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, ); path = Views; sourceTree = ""; @@ -199,6 +208,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */, 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */, 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, @@ -208,10 +218,12 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, + 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, 4E98A3B02A9CA762003052D3 /* DiaryProgressViewController.swift in Sources */, 4E98A3A62A9CA6A6003052D3 /* NewDiaryViewController.swift in Sources */, + 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */, 4E98A3AA2A9CA6F6003052D3 /* ProgressListViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 87a4139..3d2b6e2 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -7,9 +7,102 @@ import UIKit +private enum Const { + static let itemSize = CGSize(width: 300, height: 550) + static let itemSpacing = 46.0 + + static var insetX: CGFloat { + (UIScreen.main.bounds.width - Self.itemSize.width) / 2.0 + } + + static var collectionViewContentInset: UIEdgeInsets { + UIEdgeInsets(top: 40, left: Self.insetX, bottom: 10, right: Self.insetX) + } +} + class HomeViewController: UIViewController { + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground + configureCollectionView() + configureLayout() + addSearchBar() + } + + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + layout.itemSize = Const.itemSize + layout.minimumLineSpacing = Const.itemSpacing + layout.minimumInteritemSpacing = 0 + return layout + }() + + private func configureCollectionView() { + collectionView.register(HomeFeedCell.self, forCellWithReuseIdentifier: HomeFeedCell.identifier) + collectionView.delegate = self + collectionView.dataSource = self + + collectionView.isScrollEnabled = true + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.register(HomeFeedCell.self, forCellWithReuseIdentifier: HomeFeedCell.identifier) + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = Const.collectionViewContentInset + collectionView.decelerationRate = .fast + + collectionView.collectionViewLayout = collectionViewFlowLayout + } + + private func configureLayout() { + view.addSubview(collectionView) + + NSLayoutConstraint.activate([ + collectionView.topAnchor.constraint(equalTo: view.topAnchor), + collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), + collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + ]) + } + + private func addSearchBar() { + let searchController = UISearchController(searchResultsController: nil) + searchController.hidesNavigationBarDuringPresentation = false + searchController.searchBar.placeholder = "Search" + searchController.navigationItem.hidesSearchBarWhenScrolling = true + navigationItem.searchController = searchController + } +} + +extension HomeViewController: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 3 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeFeedCell.identifier, for: indexPath) as? HomeFeedCell else { return UICollectionViewCell() } + cell.backgroundColor = .systemOrange + cell.layer.cornerRadius = 20 + return cell + } +} + +extension HomeViewController: UICollectionViewDelegate {} + +extension HomeViewController: UICollectionViewDelegateFlowLayout { + func scrollViewWillEndDragging( + _ scrollView: UIScrollView, + withVelocity velocity: CGPoint, + targetContentOffset: UnsafeMutablePointer + ) { + let scrolledOffsetX = targetContentOffset.pointee.x + scrollView.contentInset.left + let cellWidth = Const.itemSize.width + Const.itemSpacing + let index = round(scrolledOffsetX / cellWidth) + targetContentOffset.pointee = CGPoint(x: index * cellWidth - scrollView.contentInset.left, y: scrollView.contentInset.top) } } diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index 5b21290..e0f906e 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -24,7 +24,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { (DiaryProgressViewController(), "tag.fill"), (ProfileViewController(), "person.fill"), ] - + tabBarController.setViewControllers(tabs.map { root, icon in let navigationController = UINavigationController(rootViewController: root) let tabBarItem = UITabBarItem(title: nil, image: .init(systemName: icon), selectedImage: .init(systemName: "\(icon).fill")) diff --git a/DiaryApp/Views/CustomCollectionView.swift b/DiaryApp/Views/CustomCollectionView.swift new file mode 100644 index 0000000..b74407e --- /dev/null +++ b/DiaryApp/Views/CustomCollectionView.swift @@ -0,0 +1,20 @@ +// +// CustomCollectionView.swift +// CollectionWithoutSB +// +// Created by (^ㅗ^)7 iMac on 2023/08/23. +// + +import UIKit + +final class CustomCollectionView: UICollectionView { + override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { + super.init(frame: frame, collectionViewLayout: layout) + self.translatesAutoresizingMaskIntoConstraints = false + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/DiaryApp/Views/CustomImageView.swift b/DiaryApp/Views/CustomImageView.swift new file mode 100644 index 0000000..6a0f6c3 --- /dev/null +++ b/DiaryApp/Views/CustomImageView.swift @@ -0,0 +1,21 @@ +// +// CustomImageView.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/28. +// + +import UIKit + +final class CustomImageView: UIImageView { + override init(frame: CGRect) { + super.init(frame: frame) + self.image = nil + self.translatesAutoresizingMaskIntoConstraints = false + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/DiaryApp/Views/HomeFeedCell.swift b/DiaryApp/Views/HomeFeedCell.swift new file mode 100644 index 0000000..0b2bdc4 --- /dev/null +++ b/DiaryApp/Views/HomeFeedCell.swift @@ -0,0 +1,45 @@ +// +// HomeFeedCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/28. +// + +import UIKit + +final class HomeFeedCell: UICollectionViewCell { + static let identifier = "HomeFeedCell" + + private let myView = CustomImageView(frame: .zero) + private let weatherImage = CustomImageView(frame: .zero) + + let sizeWidth = 70.0 + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override init(frame: CGRect) { + super.init(frame: frame) + + self.contentView.addSubview(self.myView) + + self.weatherImage.backgroundColor = .systemBlue + self.weatherImage.layer.cornerRadius = CGFloat(self.sizeWidth / 2) + + self.myView.addSubview(self.weatherImage) + + NSLayoutConstraint.activate([ + self.myView.leftAnchor.constraint(equalTo: self.contentView.leftAnchor), + self.myView.rightAnchor.constraint(equalTo: self.contentView.rightAnchor), + self.myView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor), + self.myView.topAnchor.constraint(equalTo: self.contentView.topAnchor), + + self.weatherImage.trailingAnchor.constraint(equalTo: self.myView.trailingAnchor, constant: -30), + self.weatherImage.bottomAnchor.constraint(equalTo: self.myView.bottomAnchor, constant: -30), + self.weatherImage.heightAnchor.constraint(equalToConstant: self.sizeWidth), + self.weatherImage.widthAnchor.constraint(equalToConstant: self.sizeWidth), + ]) + } +} From 86bb7de352828c35587fe180226c6e13af10711f Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Tue, 29 Aug 2023 20:14:13 +0900 Subject: [PATCH 05/50] =?UTF-8?q?[STYLE]:=20=EC=BD=9C=EB=A0=89=EC=85=98?= =?UTF-8?q?=EB=B7=B0=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 + .../Controllers/DiaryListViewController.swift | 75 +++++++++++++++++++ DiaryApp/Controllers/HomeViewController.swift | 8 +- DiaryApp/Views/DiaryListCell.swift | 20 +++++ 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 DiaryApp/Views/DiaryListCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 63f0209..da88814 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -29,6 +30,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -122,6 +124,7 @@ children = ( 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, + 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, ); @@ -215,6 +218,7 @@ 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, + 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 7abe9f3..7a7d613 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -8,9 +8,84 @@ import UIKit class DiaryListViewController: UIViewController { + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground + configureCollectionView() + configureLayout() + } + + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.itemSize = Const.itemSize + layout.minimumLineSpacing = Const.itemSpacing + layout.minimumInteritemSpacing = 0 + return layout + }() + + private func configureCollectionView() { + collectionView.register(DiaryListCell.self, forCellWithReuseIdentifier: DiaryListCell.identifier) + collectionView.delegate = self + collectionView.dataSource = self + + collectionView.isScrollEnabled = true + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = Const.collectionViewContentInset + collectionView.decelerationRate = .fast + + collectionView.collectionViewLayout = collectionViewFlowLayout + } + + private func configureLayout() { + view.addSubview(collectionView) + + NSLayoutConstraint.activate([ + collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), + collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), + ]) } } +extension DiaryListViewController: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DiaryListCell.identifier, for: indexPath) as? DiaryListCell else { return UICollectionViewCell() } + cell.backgroundColor = .systemPink + cell.layer.cornerRadius = 20 + return cell + } +} + +extension DiaryListViewController: UICollectionViewDelegate {} + +extension DiaryListViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let interItemSpacing: CGFloat = 10 + let padding: CGFloat = 10 + let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) + print("### \(width)") + let height = width / 3 + return CGSize(width: width, height: height) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 10 + } +} diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 3d2b6e2..a54be2d 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -7,7 +7,7 @@ import UIKit -private enum Const { +enum Const { static let itemSize = CGSize(width: 300, height: 550) static let itemSpacing = 46.0 @@ -16,7 +16,7 @@ private enum Const { } static var collectionViewContentInset: UIEdgeInsets { - UIEdgeInsets(top: 40, left: Self.insetX, bottom: 10, right: Self.insetX) + UIEdgeInsets(top: 0, left: Self.insetX, bottom: 0, right: Self.insetX) } } @@ -63,10 +63,10 @@ class HomeViewController: UIViewController { view.addSubview(collectionView) NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.topAnchor), + collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -20), ]) } diff --git a/DiaryApp/Views/DiaryListCell.swift b/DiaryApp/Views/DiaryListCell.swift new file mode 100644 index 0000000..949a951 --- /dev/null +++ b/DiaryApp/Views/DiaryListCell.swift @@ -0,0 +1,20 @@ +// +// DiaryListCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/29. +// + +import UIKit + +final class DiaryListCell: UICollectionViewCell { + static let identifier = "DiaryListCell" + + override init(frame: CGRect) { + super.init(frame: frame) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 91697bba5cb1ae51a55b6cf4dea683adee3ddd07 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 12:29:00 +0900 Subject: [PATCH 06/50] =?UTF-8?q?[STYLE]:=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=97=86=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 20 +++++++++-- DiaryApp/Views/Cells/DiaryListCell.swift | 35 +++++++++++++++++++ DiaryApp/Views/{ => Cells}/HomeFeedCell.swift | 0 ...{DiaryListCell.swift => CustomLabel.swift} | 13 +++---- DiaryApp/Views/CustomStackView.swift | 20 +++++++++++ 5 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 DiaryApp/Views/Cells/DiaryListCell.swift rename DiaryApp/Views/{ => Cells}/HomeFeedCell.swift (100%) rename DiaryApp/Views/{DiaryListCell.swift => CustomLabel.swift} (55%) create mode 100644 DiaryApp/Views/CustomStackView.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index da88814..78ae35d 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; + 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; + 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -31,6 +33,8 @@ /* Begin PBXFileReference section */ 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; + 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; + 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -65,6 +69,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 4E1550852A9E0BBB00C8A500 /* Cells */ = { + isa = PBXGroup; + children = ( + 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, + 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, + ); + path = Cells; + sourceTree = ""; + }; 4E98A3822A9CA57B003052D3 = { isa = PBXGroup; children = ( @@ -124,9 +137,10 @@ children = ( 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, - 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, - 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, + 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, + 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, + 4E1550852A9E0BBB00C8A500 /* Cells */, ); path = Views; sourceTree = ""; @@ -222,6 +236,8 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, + 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, + 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, diff --git a/DiaryApp/Views/Cells/DiaryListCell.swift b/DiaryApp/Views/Cells/DiaryListCell.swift new file mode 100644 index 0000000..b5f4822 --- /dev/null +++ b/DiaryApp/Views/Cells/DiaryListCell.swift @@ -0,0 +1,35 @@ +// +// DiaryListCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/29. +// + +import UIKit + +final class DiaryListCell: UICollectionViewCell { + static let identifier = "DiaryListCell" + + let stackView = CustomStackView(frame: .zero) + + override init(frame: CGRect) { + super.init(frame: frame) + setupUI() + setupLayout() + } + + func setupUI() { + stackView.axis = .vertical + } + + func setupLayout() { + contentView.addSubview(stackView) + NSLayoutConstraint.activate([ + ]) + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/DiaryApp/Views/HomeFeedCell.swift b/DiaryApp/Views/Cells/HomeFeedCell.swift similarity index 100% rename from DiaryApp/Views/HomeFeedCell.swift rename to DiaryApp/Views/Cells/HomeFeedCell.swift diff --git a/DiaryApp/Views/DiaryListCell.swift b/DiaryApp/Views/CustomLabel.swift similarity index 55% rename from DiaryApp/Views/DiaryListCell.swift rename to DiaryApp/Views/CustomLabel.swift index 949a951..326414e 100644 --- a/DiaryApp/Views/DiaryListCell.swift +++ b/DiaryApp/Views/CustomLabel.swift @@ -1,19 +1,20 @@ // -// DiaryListCell.swift +// CustomLabel.swift // DiaryApp // // Created by (^ㅗ^)7 iMac on 2023/08/29. // -import UIKit - -final class DiaryListCell: UICollectionViewCell { - static let identifier = "DiaryListCell" +import Foundation +final class CustomLabel: UILabel { override init(frame: CGRect) { super.init(frame: frame) + self.textColor = .black + self.translatesAutoresizingMaskIntoConstraints = false } - + + @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/DiaryApp/Views/CustomStackView.swift b/DiaryApp/Views/CustomStackView.swift new file mode 100644 index 0000000..b68a694 --- /dev/null +++ b/DiaryApp/Views/CustomStackView.swift @@ -0,0 +1,20 @@ +// +// CustomStackView.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/29. +// + +import UIKit + +final class CustomStackView: UIStackView { + override init(frame: CGRect) { + super.init(frame: frame) + self.translatesAutoresizingMaskIntoConstraints = false + } + + @available(*, unavailable) + required init(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 5765151635ddd738ad0794504dee559d7a1e1a5e Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 12:32:03 +0900 Subject: [PATCH 07/50] =?UTF-8?q?[FEAT]:=20Snapkit=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 27 +++++++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 14 ++++++++++ 2 files changed, 41 insertions(+) create mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 1631a8b..7fb802b 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -51,6 +52,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -145,6 +147,9 @@ dependencies = ( ); name = DiaryApp; + packageProductDependencies = ( + 4E6138AF2A9EEF50003A2B37 /* SnapKit */, + ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; productType = "com.apple.product-type.application"; @@ -173,6 +178,9 @@ Base, ); mainGroup = 4E98A3822A9CA57B003052D3; + packageReferences = ( + 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, + ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -422,6 +430,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4E6138AF2A9EEF50003A2B37 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 4E98A3832A9CA57B003052D3 /* Project object */; } diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..009c162 --- /dev/null +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + } + ], + "version" : 2 +} From c36bda326d496d9b05c6f22bcd6dfb7495932789 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 12:38:33 +0900 Subject: [PATCH 08/50] =?UTF-8?q?[CONFLICT]:=20=EB=B3=91=ED=95=A9=20?= =?UTF-8?q?=EC=8B=9C=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 78ae35d..dc7ebc7 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,9 +7,13 @@ objects = { /* Begin PBXBuildFile section */ +<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; +======= + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; +>>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -63,6 +67,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -171,6 +176,9 @@ dependencies = ( ); name = DiaryApp; + packageProductDependencies = ( + 4E6138AF2A9EEF50003A2B37 /* SnapKit */, + ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; productType = "com.apple.product-type.application"; @@ -199,6 +207,9 @@ Base, ); mainGroup = 4E98A3822A9CA57B003052D3; + packageReferences = ( + 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, + ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -454,6 +465,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4E6138AF2A9EEF50003A2B37 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 4E98A3832A9CA57B003052D3 /* Project object */; } From 29e09f6a8d28790ba0fe0eeeec502fcc3e5d8582 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 15:28:46 +0900 Subject: [PATCH 09/50] =?UTF-8?q?[STYLE]:=20=EC=BD=94=EB=93=9C=20=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=95=84=EC=9B=83=20Snapkit=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 3 --- .../xcshareddata/swiftpm/Package.resolved | 14 ++++++++++++++ .../Controllers/DiaryListViewController.swift | 16 ++++++++++------ DiaryApp/Views/CustomLabel.swift | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index dc7ebc7..5ea7647 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,13 +7,10 @@ objects = { /* Begin PBXBuildFile section */ -<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; -======= 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; ->>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..009c162 --- /dev/null +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + } + ], + "version" : 2 +} diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 7a7d613..fb70692 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -5,6 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import SnapKit import UIKit class DiaryListViewController: UIViewController { @@ -47,12 +48,15 @@ class DiaryListViewController: UIViewController { private func configureLayout() { view.addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), - collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), - ]) + collectionView.snp.makeConstraints { make in + make.top.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide) + } +// NSLayoutConstraint.activate([ +// collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), +// collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), +// collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), +// collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), +// ]) } } diff --git a/DiaryApp/Views/CustomLabel.swift b/DiaryApp/Views/CustomLabel.swift index 326414e..7c09492 100644 --- a/DiaryApp/Views/CustomLabel.swift +++ b/DiaryApp/Views/CustomLabel.swift @@ -5,7 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/29. // -import Foundation +import UIKit final class CustomLabel: UILabel { override init(frame: CGRect) { From 42e224869a93d21ea8388028fda748cab1b9df8a Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 18:07:22 +0900 Subject: [PATCH 10/50] =?UTF-8?q?[FEAT]:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=EB=B0=94=20&=20=EC=BD=9C=EB=A0=89=EC=85=98?= =?UTF-8?q?=EB=B7=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 + .../Controllers/DiaryListViewController.swift | 12 +- DiaryApp/Views/Cells/DiaryListCell.swift | 130 +++++++++++++++++- .../Views/Cells/DiaryListThumbnailCell.swift | 34 +++++ 4 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 DiaryApp/Views/Cells/DiaryListThumbnailCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 5ea7647..65a3e57 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; + 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -36,6 +37,7 @@ 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; + 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -75,6 +77,7 @@ isa = PBXGroup; children = ( 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, + 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */, 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, ); path = Cells; @@ -239,6 +242,7 @@ 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, + 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index fb70692..4a98878 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -51,12 +51,6 @@ class DiaryListViewController: UIViewController { collectionView.snp.makeConstraints { make in make.top.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide) } -// NSLayoutConstraint.activate([ -// collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), -// collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), -// collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), -// collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), -// ]) } } @@ -67,7 +61,13 @@ extension DiaryListViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DiaryListCell.identifier, for: indexPath) as? DiaryListCell else { return UICollectionViewCell() } + cell.diaryTitleLabel.text = "Hello World" + cell.startDayLabel.text = "2023.08.30" + cell.endDayLabel.text = "2023.09.30" + cell.backgroundColor = .systemPink + cell.collectionView.backgroundColor = .systemBlue + cell.collectionView.layer.cornerRadius = 10 cell.layer.cornerRadius = 20 return cell } diff --git a/DiaryApp/Views/Cells/DiaryListCell.swift b/DiaryApp/Views/Cells/DiaryListCell.swift index b5f4822..d12400e 100644 --- a/DiaryApp/Views/Cells/DiaryListCell.swift +++ b/DiaryApp/Views/Cells/DiaryListCell.swift @@ -5,27 +5,121 @@ // Created by (^ㅗ^)7 iMac on 2023/08/29. // +import SnapKit import UIKit -final class DiaryListCell: UICollectionViewCell { +class DiaryListCell: UICollectionViewCell { static let identifier = "DiaryListCell" - let stackView = CustomStackView(frame: .zero) + let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewLayout()) + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + layout.itemSize = CGSize(width: 40, height: 40) + layout.minimumLineSpacing = 5 + layout.minimumInteritemSpacing = 2 + layout.estimatedItemSize = .zero + return layout + }() + + private let stackView = CustomStackView(frame: .zero) + private let labelStackView = CustomStackView(frame: .zero) + + lazy var diaryTitleLabel = CustomLabel(frame: .zero) + lazy var startDayLabel = CustomLabel(frame: .zero) + lazy var endDayLabel = CustomLabel(frame: .zero) + private let spaceLabel = CustomLabel(frame: .zero) + + lazy var progressView: UIProgressView = { + let view = UIProgressView() + view.translatesAutoresizingMaskIntoConstraints = false + /// progress 배경 색상 + view.trackTintColor = .lightGray + /// progress 진행 색상 + view.progressTintColor = .systemBlue + view.progress = 0.5 + return view + }() override init(frame: CGRect) { super.init(frame: frame) setupUI() setupLayout() + configureCollectionView() } - func setupUI() { + private func setupUI() { stackView.axis = .vertical + stackView.backgroundColor = .systemOrange + stackView.distribution = .fillProportionally + stackView.spacing = 0 + + labelStackView.axis = .horizontal + labelStackView.backgroundColor = .systemBlue + labelStackView.distribution = .fillProportionally + + diaryTitleLabel.font = .systemFont(ofSize: 20, weight: .bold) + + startDayLabel.adjustsFontSizeToFitWidth = true + + spaceLabel.text = " ~ " + + endDayLabel.adjustsFontSizeToFitWidth = true + endDayLabel.textAlignment = .center + + collectionView.backgroundColor = .systemRed } - func setupLayout() { + private func setupLayout() { + contentView.addSubview(collectionView) + + collectionView.snp.makeConstraints { make in + make.top.equalTo(contentView.safeAreaLayoutGuide).inset(12) + make.bottom.equalTo(contentView.safeAreaLayoutGuide).inset(10) + make.leading.equalTo(contentView.safeAreaLayoutGuide).inset(25) + make.trailing.equalTo(contentView.safeAreaLayoutGuide).inset(210) + make.width.height.equalTo(50) + } + contentView.addSubview(stackView) - NSLayoutConstraint.activate([ - ]) + stackView.snp.makeConstraints { make in + make.top.trailing.bottom.equalTo(contentView.safeAreaLayoutGuide).inset(20) + make.leading.equalTo(collectionView.snp.trailing).offset(10) + } + + [diaryTitleLabel, progressView, labelStackView].forEach { + stackView.addArrangedSubview($0) + } + + progressView.snp.makeConstraints { make in + make.bottom.equalTo(labelStackView.snp.top).offset(-5) + make.height.equalTo(15) + } + + labelStackView.snp.makeConstraints { make in + make.height.equalTo(20) + } + + [startDayLabel, spaceLabel, endDayLabel].forEach { + labelStackView.addArrangedSubview($0) + } + } + + private func configureCollectionView() { + collectionView.register(DiaryListThumbnailCell.self, forCellWithReuseIdentifier: DiaryListThumbnailCell.identifier) + collectionView.dataSource = self + + collectionView.isScrollEnabled = false + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 5) + collectionView.decelerationRate = .fast + + collectionView.collectionViewLayout = collectionViewFlowLayout } @available(*, unavailable) @@ -33,3 +127,27 @@ final class DiaryListCell: UICollectionViewCell { fatalError("init(coder:) has not been implemented") } } + +extension DiaryListCell: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 4 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DiaryListThumbnailCell.identifier, for: indexPath) as? DiaryListThumbnailCell else { return UICollectionViewCell() } + cell.backgroundColor = .systemGreen + cell.layer.cornerRadius = 5 + cell.thumbNailImage.image = UIImage(systemName: "bell") + return cell + } +} + +extension DiaryListCell: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let interItemSpacing: CGFloat = 10 + let padding: CGFloat = 10 + let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) / 3 + let height = width + return CGSize(width: width, height: height) + } +} diff --git a/DiaryApp/Views/Cells/DiaryListThumbnailCell.swift b/DiaryApp/Views/Cells/DiaryListThumbnailCell.swift new file mode 100644 index 0000000..1a4c00f --- /dev/null +++ b/DiaryApp/Views/Cells/DiaryListThumbnailCell.swift @@ -0,0 +1,34 @@ +// +// DiaryListThumbnailCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/30. +// + +import SnapKit +import UIKit + +class DiaryListThumbnailCell: UICollectionViewCell { + static let identifier = "DiaryListThumbnailCell" + + lazy var thumbNailImage = CustomImageView(frame: .zero) + + override init(frame: CGRect) { + super.init(frame: frame) + configure() + } + + private func configure() { + thumbNailImage.contentMode = .scaleToFill + + contentView.addSubview(thumbNailImage) + thumbNailImage.snp.makeConstraints { make in + make.top.leading.trailing.bottom.equalTo(contentView) + } + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 46195f1deee59c397ffb438bd3cc3062cfcfa5c5 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 18:14:12 +0900 Subject: [PATCH 11/50] =?UTF-8?q?[FEAT]:=20Diary-Progress-Page=20=EB=B8=8C?= =?UTF-8?q?=EB=9F=B0=EC=B9=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/DiaryProgressViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index d9d7542..9808beb 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -11,5 +11,6 @@ class DiaryProgressViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground + } } From 52e45b55d817827e1eb2136f5a59295b2a9b85ae Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 19:18:09 +0900 Subject: [PATCH 12/50] =?UTF-8?q?[FEAT]:=20DiaryProgressCell=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ++++ .../Controllers/DiaryProgressViewController.swift | 13 ++++++++++++- DiaryApp/Resources/SceneDelegate.swift | 2 +- DiaryApp/Views/Cells/DiaryProgressCell.swift | 10 ++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 DiaryApp/Views/Cells/DiaryProgressCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 65a3e57..f413b2a 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; + 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -38,6 +39,7 @@ 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; + 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryProgressCell.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -78,6 +80,7 @@ children = ( 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */, + 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */, 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, ); path = Cells; @@ -248,6 +251,7 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, + 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 9808beb..19021ad 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -8,9 +8,20 @@ import UIKit class DiaryProgressViewController: UIViewController { + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground - + } +} + +extension DiaryProgressViewController: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return UICollectionViewCell() } } diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index e0f906e..5b21290 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -24,7 +24,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { (DiaryProgressViewController(), "tag.fill"), (ProfileViewController(), "person.fill"), ] - + tabBarController.setViewControllers(tabs.map { root, icon in let navigationController = UINavigationController(rootViewController: root) let tabBarItem = UITabBarItem(title: nil, image: .init(systemName: icon), selectedImage: .init(systemName: "\(icon).fill")) diff --git a/DiaryApp/Views/Cells/DiaryProgressCell.swift b/DiaryApp/Views/Cells/DiaryProgressCell.swift new file mode 100644 index 0000000..f95e0eb --- /dev/null +++ b/DiaryApp/Views/Cells/DiaryProgressCell.swift @@ -0,0 +1,10 @@ +// +// DiaryProgressCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/30. +// + +import Cocoa + +final class DiaryProgressCell: UICollectionViewCell {} From 681413b1b1b6ca7486db62431066b5da575368a0 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 22:45:23 +0900 Subject: [PATCH 13/50] =?UTF-8?q?[STYLE]:=20=EC=9E=91=EC=97=85=20=EB=82=B4?= =?UTF-8?q?=EC=97=AD=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ++ .../DiaryProgressViewController.swift | 67 ++++++++++++++++++- DiaryApp/Views/Cells/DiaryProgressCell.swift | 33 ++++++++- DiaryApp/Views/CircleProgressBar.swift | 61 +++++++++++++++++ 4 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 DiaryApp/Views/CircleProgressBar.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index f413b2a..34dac76 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; + 4E6138B62A9F56E0003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -40,6 +41,7 @@ 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryProgressCell.swift; sourceTree = ""; }; + 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressBar.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -148,6 +150,7 @@ 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, + 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */, 4E1550852A9E0BBB00C8A500 /* Cells */, ); path = Views; @@ -243,6 +246,7 @@ 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */, 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, + 4E6138B62A9F56E0003A2B37 /* CircleProgressBar.swift in Sources */, 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */, diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 19021ad..17a33e4 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -5,23 +5,86 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import SnapKit import UIKit class DiaryProgressViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) +// private let collectionViewFlowLayout: UICollectionViewFlowLayout = { +// let layout = UICollectionViewFlowLayout() +// layout.scrollDirection = .vertical +// layout.itemSize = Const.itemSize +// layout.minimumLineSpacing = Const.itemSpacing +// layout.minimumInteritemSpacing = 0 +// return layout +// }() + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground + setupUI() + configureCollectionView() + } + + private func setupUI() { + view.addSubview(collectionView) + + collectionView.snp.makeConstraints { make in + make.top.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide) + } + } + + private func configureCollectionView() { + collectionView.register(DiaryProgressCell.self, forCellWithReuseIdentifier: DiaryProgressCell.identifier) + collectionView.dataSource = self + collectionView.delegate = self + + collectionView.isScrollEnabled = true + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = Const.collectionViewContentInset + collectionView.decelerationRate = .fast + + if let flowlayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { + flowlayout.estimatedItemSize = .zero + } +// collectionView.collectionViewLayout = collectionViewFlowLayout } } extension DiaryProgressViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 10 + return 15 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - return UICollectionViewCell() + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DiaryProgressCell.identifier, for: indexPath) as? DiaryProgressCell else { return UICollectionViewCell() } + + cell.backgroundColor = .systemPink + return cell + } +} + +extension DiaryProgressViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let interItemSpacing: CGFloat = 10 + let padding: CGFloat = 16 + let width = (collectionView.bounds.width - interItemSpacing * 2 - padding * 2) / 2 + print("### \(width)") + let height = width + return CGSize(width: width, height: height) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 10 } } diff --git a/DiaryApp/Views/Cells/DiaryProgressCell.swift b/DiaryApp/Views/Cells/DiaryProgressCell.swift index f95e0eb..6b7af22 100644 --- a/DiaryApp/Views/Cells/DiaryProgressCell.swift +++ b/DiaryApp/Views/Cells/DiaryProgressCell.swift @@ -5,6 +5,35 @@ // Created by (^ㅗ^)7 iMac on 2023/08/30. // -import Cocoa +import SnapKit +import UIKit -final class DiaryProgressCell: UICollectionViewCell {} +final class DiaryProgressCell: UICollectionViewCell { + static let identifier = "DiaryProgressCell" + + lazy var circularProgressBarView = CircleProgressBar(frame: .zero) + lazy var percentLabel = CustomLabel(frame: .zero) + + override init(frame: CGRect) { + super.init(frame: frame) + setUpCircularProgressBarView() + } + + func setUpCircularProgressBarView() { + circularProgressBarView.translatesAutoresizingMaskIntoConstraints = false + + circularProgressBarView.center = contentView.center + circularProgressBarView.progressAnimation(duration: 30) + percentLabel.text = "100%" + + contentView.addSubview(circularProgressBarView) + circularProgressBarView.snp.makeConstraints { make in + make.centerX.centerY.equalTo(contentView) + } + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/DiaryApp/Views/CircleProgressBar.swift b/DiaryApp/Views/CircleProgressBar.swift new file mode 100644 index 0000000..4be6935 --- /dev/null +++ b/DiaryApp/Views/CircleProgressBar.swift @@ -0,0 +1,61 @@ +// +// CircleProgressBar.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/30. +// + +import SnapKit +import UIKit + +final class CircleProgressBar: UIView { + private var circleLayer = CAShapeLayer() + private var progressLayer = CAShapeLayer() + private var startPoint = CGFloat(-Double.pi / 2) + private var endPoint = CGFloat(3 * Double.pi / 2) + + override init(frame: CGRect) { + super.init(frame: frame) + createCircularPath() + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func createCircularPath() { + let circularPath = UIBezierPath(arcCenter: CGPoint(x: frame.size.width / 2.0, y: frame.size.height / 2.0), radius: 80, startAngle: startPoint, endAngle: endPoint, clockwise: true) + // circleLayer path defined to circularPath + circleLayer.path = circularPath.cgPath + // ui edits + circleLayer.fillColor = UIColor.clear.cgColor + circleLayer.lineCap = .round + circleLayer.lineWidth = 20.0 + circleLayer.strokeEnd = 1.0 + circleLayer.strokeColor = UIColor.systemGray6.cgColor + // added circleLayer to layer + layer.addSublayer(circleLayer) + // progressLayer path defined to circularPath + progressLayer.path = circularPath.cgPath + // ui edits + progressLayer.fillColor = UIColor.clear.cgColor + progressLayer.lineCap = .round + progressLayer.lineWidth = 10.0 + progressLayer.strokeEnd = 0 + progressLayer.strokeColor = UIColor.systemOrange.cgColor + // added progressLayer to layer + layer.addSublayer(progressLayer) + } + + func progressAnimation(duration: TimeInterval) { + // created circularProgressAnimation with keyPath + let circularProgressAnimation = CABasicAnimation(keyPath: "strokeEnd") + // set the end time + circularProgressAnimation.duration = 30 + circularProgressAnimation.toValue = 10.0 + circularProgressAnimation.fillMode = .forwards + circularProgressAnimation.isRemovedOnCompletion = false + progressLayer.add(circularProgressAnimation, forKey: "progressAnim") + } +} From 70454b6b7f9a761a087118c0e97384a1cea17d6b Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:12:31 +0900 Subject: [PATCH 14/50] =?UTF-8?q?FEAT]:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=EB=B0=94=20UI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiaryProgressViewController.swift | 11 ++++--- DiaryApp/Views/Cells/DiaryProgressCell.swift | 7 +++- DiaryApp/Views/CircleProgressBar.swift | 33 ++++++++++--------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 17a33e4..2f00330 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -47,7 +47,7 @@ class DiaryProgressViewController: UIViewController { collectionView.clipsToBounds = true collectionView.isPagingEnabled = false collectionView.contentInsetAdjustmentBehavior = .never - collectionView.contentInset = Const.collectionViewContentInset + collectionView.contentInset = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5) collectionView.decelerationRate = .fast if let flowlayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { @@ -59,13 +59,14 @@ class DiaryProgressViewController: UIViewController { extension DiaryProgressViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 15 + return 7 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DiaryProgressCell.identifier, for: indexPath) as? DiaryProgressCell else { return UICollectionViewCell() } - - cell.backgroundColor = .systemPink + cell.backgroundColor = .clear + cell.circularProgressBarView.createCircularPath(0.3) + cell.percentLabel.text = "\(30)%" return cell } } @@ -73,7 +74,7 @@ extension DiaryProgressViewController: UICollectionViewDataSource { extension DiaryProgressViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let interItemSpacing: CGFloat = 10 - let padding: CGFloat = 16 + let padding: CGFloat = 10 let width = (collectionView.bounds.width - interItemSpacing * 2 - padding * 2) / 2 print("### \(width)") let height = width diff --git a/DiaryApp/Views/Cells/DiaryProgressCell.swift b/DiaryApp/Views/Cells/DiaryProgressCell.swift index 6b7af22..e0ac2fc 100644 --- a/DiaryApp/Views/Cells/DiaryProgressCell.swift +++ b/DiaryApp/Views/Cells/DiaryProgressCell.swift @@ -23,13 +23,18 @@ final class DiaryProgressCell: UICollectionViewCell { circularProgressBarView.translatesAutoresizingMaskIntoConstraints = false circularProgressBarView.center = contentView.center - circularProgressBarView.progressAnimation(duration: 30) +// circularProgressBarView.progressAnimation(duration: 30) percentLabel.text = "100%" contentView.addSubview(circularProgressBarView) circularProgressBarView.snp.makeConstraints { make in make.centerX.centerY.equalTo(contentView) } + + circularProgressBarView.addSubview(percentLabel) + percentLabel.snp.makeConstraints { make in + make.centerX.centerY.equalTo(circularProgressBarView) + } } @available(*, unavailable) diff --git a/DiaryApp/Views/CircleProgressBar.swift b/DiaryApp/Views/CircleProgressBar.swift index 4be6935..92043e5 100644 --- a/DiaryApp/Views/CircleProgressBar.swift +++ b/DiaryApp/Views/CircleProgressBar.swift @@ -13,10 +13,11 @@ final class CircleProgressBar: UIView { private var progressLayer = CAShapeLayer() private var startPoint = CGFloat(-Double.pi / 2) private var endPoint = CGFloat(3 * Double.pi / 2) + var dayCount: Double? override init(frame: CGRect) { super.init(frame: frame) - createCircularPath() + createCircularPath(dayCount ?? 0) } @available(*, unavailable) @@ -24,8 +25,8 @@ final class CircleProgressBar: UIView { fatalError("init(coder:) has not been implemented") } - func createCircularPath() { - let circularPath = UIBezierPath(arcCenter: CGPoint(x: frame.size.width / 2.0, y: frame.size.height / 2.0), radius: 80, startAngle: startPoint, endAngle: endPoint, clockwise: true) + func createCircularPath(_ strokeEnd: Double) { + let circularPath = UIBezierPath(arcCenter: CGPoint(x: frame.size.width / 2.0, y: frame.size.height / 2.0), radius: 65, startAngle: startPoint, endAngle: endPoint, clockwise: true) // circleLayer path defined to circularPath circleLayer.path = circularPath.cgPath // ui edits @@ -41,21 +42,21 @@ final class CircleProgressBar: UIView { // ui edits progressLayer.fillColor = UIColor.clear.cgColor progressLayer.lineCap = .round - progressLayer.lineWidth = 10.0 - progressLayer.strokeEnd = 0 - progressLayer.strokeColor = UIColor.systemOrange.cgColor + progressLayer.lineWidth = 20.0 + progressLayer.strokeEnd = strokeEnd + progressLayer.strokeColor = UIColor.systemBlue.cgColor // added progressLayer to layer layer.addSublayer(progressLayer) } - func progressAnimation(duration: TimeInterval) { - // created circularProgressAnimation with keyPath - let circularProgressAnimation = CABasicAnimation(keyPath: "strokeEnd") - // set the end time - circularProgressAnimation.duration = 30 - circularProgressAnimation.toValue = 10.0 - circularProgressAnimation.fillMode = .forwards - circularProgressAnimation.isRemovedOnCompletion = false - progressLayer.add(circularProgressAnimation, forKey: "progressAnim") - } +// func progressAnimation(duration: TimeInterval) { +// // created circularProgressAnimation with keyPath +// let circularProgressAnimation = CABasicAnimation(keyPath: "strokeEnd") +// // set the end time +// circularProgressAnimation.duration = 30 +// circularProgressAnimation.toValue = 3 +// circularProgressAnimation.fillMode = .forwards +// circularProgressAnimation.isRemovedOnCompletion = false +// progressLayer.add(circularProgressAnimation, forKey: "progressAnim") +// } } From 2a6ba115932c62550871b94723c0a5377a8a75ec Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:28:42 +0900 Subject: [PATCH 15/50] =?UTF-8?q?[STYLE]:=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=9D=B4=20=EC=97=86=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/DiaryListViewController.swift | 3 ++- DiaryApp/Controllers/HomeViewController.swift | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 4a98878..16dcca9 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -49,7 +49,8 @@ class DiaryListViewController: UIViewController { view.addSubview(collectionView) collectionView.snp.makeConstraints { make in - make.top.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide) + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-10) } } } diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index a54be2d..b86b144 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -25,7 +25,7 @@ class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemBackground + view.backgroundColor = .systemGray6 configureCollectionView() configureLayout() addSearchBar() From a7964007579da625d0384a3e8785f0dca839ce5b Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:43:31 +0900 Subject: [PATCH 16/50] =?UTF-8?q?[MERGE]=20:=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ++++ .../xcshareddata/swiftpm/Package.resolved | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 34dac76..3201e58 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ +<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; @@ -14,6 +15,9 @@ 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; 4E6138B62A9F56E0003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */; }; +======= + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; +>>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 009c162..0000000 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "snapkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/SnapKit/SnapKit.git", - "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" - } - } - ], - "version" : 2 -} From 1472db483b5b22f30c24b2ae536a8ce485be8723 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:46:41 +0900 Subject: [PATCH 17/50] =?UTF-8?q?[MERGE]=20:=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 3201e58..1985749 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,17 +7,11 @@ objects = { /* Begin PBXBuildFile section */ -<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; - 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; - 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; - 4E6138B62A9F56E0003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */; }; -======= - 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; ->>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) +>>>>>>> 29e09f6 ([STYLE]: 코드 레이아웃 Snapkit으로 변경) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -43,9 +37,6 @@ 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; - 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; - 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryProgressCell.swift; sourceTree = ""; }; - 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressBar.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -85,8 +76,6 @@ isa = PBXGroup; children = ( 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, - 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */, - 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */, 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, ); path = Cells; @@ -154,7 +143,6 @@ 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, - 4E6138B52A9F56E0003A2B37 /* CircleProgressBar.swift */, 4E1550852A9E0BBB00C8A500 /* Cells */, ); path = Views; @@ -250,10 +238,8 @@ 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */, 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, - 4E6138B62A9F56E0003A2B37 /* CircleProgressBar.swift in Sources */, 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, - 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, From dcef2d0522f9230e76709fcc66a7d5f0bfc0f386 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:48:14 +0900 Subject: [PATCH 18/50] =?UTF-8?q?[MERGE]=20:=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 1985749..eca51c5 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -11,7 +11,8 @@ 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; ->>>>>>> 29e09f6 ([STYLE]: 코드 레이아웃 Snapkit으로 변경) + 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; + 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; From 1431699e0bf0b207499a79986212825137b0f597 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:30:14 +0900 Subject: [PATCH 19/50] =?UTF-8?q?[STYLE]:=20=ED=83=AD=EB=B0=94=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=95=84=EC=9D=B4=EC=BD=98?= =?UTF-8?q?=ED=91=9C=ED=98=84=20=EC=BD=94=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Resources/SceneDelegate.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index 5b21290..28a72e8 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -21,8 +21,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { (HomeViewController(), "house"), (DiaryListViewController(), "list.bullet"), (NewDiaryViewController(), "plus.square"), - (DiaryProgressViewController(), "tag.fill"), - (ProfileViewController(), "person.fill"), + (DiaryProgressViewController(), "tag"), + (ProfileViewController(), "person"), ] tabBarController.setViewControllers(tabs.map { root, icon in From 510df131d7b7c039cfb0486dd5986ef0dc62fe64 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:50:43 +0900 Subject: [PATCH 20/50] =?UTF-8?q?[MERGE]=20:=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 8 ++++ DiaryApp/Controllers/HomeViewController.swift | 4 +- DiaryApp/Resources/SceneDelegate.swift | 2 +- DiaryApp/Views/HomeFeedCell.swift | 45 +++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 DiaryApp/Views/HomeFeedCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index eca51c5..a00dec0 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -141,10 +141,15 @@ children = ( 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, +<<<<<<< HEAD 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, 4E1550852A9E0BBB00C8A500 /* Cells */, +======= + 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, + 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, +>>>>>>> d8ba701 ([FEAT]: feature/home-Page 브런치 병합) ); path = Views; sourceTree = ""; @@ -246,9 +251,12 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, +<<<<<<< HEAD 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, +======= +>>>>>>> d8ba701 ([FEAT]: feature/home-Page 브런치 병합) 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index b86b144..46df91f 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -7,7 +7,7 @@ import UIKit -enum Const { +private enum Const { static let itemSize = CGSize(width: 300, height: 550) static let itemSpacing = 46.0 @@ -25,7 +25,7 @@ class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemGray6 + view.backgroundColor = .systemBackground configureCollectionView() configureLayout() addSearchBar() diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index 28a72e8..298ead0 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -24,7 +24,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { (DiaryProgressViewController(), "tag"), (ProfileViewController(), "person"), ] - + tabBarController.setViewControllers(tabs.map { root, icon in let navigationController = UINavigationController(rootViewController: root) let tabBarItem = UITabBarItem(title: nil, image: .init(systemName: icon), selectedImage: .init(systemName: "\(icon).fill")) diff --git a/DiaryApp/Views/HomeFeedCell.swift b/DiaryApp/Views/HomeFeedCell.swift new file mode 100644 index 0000000..0b2bdc4 --- /dev/null +++ b/DiaryApp/Views/HomeFeedCell.swift @@ -0,0 +1,45 @@ +// +// HomeFeedCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/28. +// + +import UIKit + +final class HomeFeedCell: UICollectionViewCell { + static let identifier = "HomeFeedCell" + + private let myView = CustomImageView(frame: .zero) + private let weatherImage = CustomImageView(frame: .zero) + + let sizeWidth = 70.0 + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override init(frame: CGRect) { + super.init(frame: frame) + + self.contentView.addSubview(self.myView) + + self.weatherImage.backgroundColor = .systemBlue + self.weatherImage.layer.cornerRadius = CGFloat(self.sizeWidth / 2) + + self.myView.addSubview(self.weatherImage) + + NSLayoutConstraint.activate([ + self.myView.leftAnchor.constraint(equalTo: self.contentView.leftAnchor), + self.myView.rightAnchor.constraint(equalTo: self.contentView.rightAnchor), + self.myView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor), + self.myView.topAnchor.constraint(equalTo: self.contentView.topAnchor), + + self.weatherImage.trailingAnchor.constraint(equalTo: self.myView.trailingAnchor, constant: -30), + self.weatherImage.bottomAnchor.constraint(equalTo: self.myView.bottomAnchor, constant: -30), + self.weatherImage.heightAnchor.constraint(equalToConstant: self.sizeWidth), + self.weatherImage.widthAnchor.constraint(equalToConstant: self.sizeWidth), + ]) + } +} From c4faefaaae13345bbcd18fb5ca26693af44703c1 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 23:28:42 +0900 Subject: [PATCH 21/50] =?UTF-8?q?[STYLE]:=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=9D=B4=20=EC=97=86=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/HomeViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 46df91f..928a1dc 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -25,7 +25,7 @@ class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemBackground + view.backgroundColor = .systemGray6 configureCollectionView() configureLayout() addSearchBar() From bdf3c91de821e4314ab1c34293990d8bc3dd10c5 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 00:01:40 +0900 Subject: [PATCH 22/50] =?UTF-8?q?[FIX]=20=EB=B3=91=ED=95=A9=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/HomeViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 928a1dc..46df91f 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -25,7 +25,7 @@ class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemGray6 + view.backgroundColor = .systemBackground configureCollectionView() configureLayout() addSearchBar() From 5225cacd8de4cf1e78db1cbe0b5ff22199c3160e Mon Sep 17 00:00:00 2001 From: MOMO <89556301+jakkujakku@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:31:37 +0900 Subject: [PATCH 23/50] Update project.pbxproj MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [FIX] : Conflict 해결 중 --- DiaryApp.xcodeproj/project.pbxproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index a00dec0..be4e761 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -141,15 +141,12 @@ children = ( 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, -<<<<<<< HEAD 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, 4E1550852A9E0BBB00C8A500 /* Cells */, -======= 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, ->>>>>>> d8ba701 ([FEAT]: feature/home-Page 브런치 병합) ); path = Views; sourceTree = ""; @@ -251,12 +248,9 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, -<<<<<<< HEAD 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, -======= ->>>>>>> d8ba701 ([FEAT]: feature/home-Page 브런치 병합) 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, From 40a991b28aece414fe9acc0283567005b96dd986 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 01:11:31 +0900 Subject: [PATCH 24/50] =?UTF-8?q?[FIX]=20:=20Git=20Pull=20Merge=20Conflict?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 50 +++++++++---------- .../contents.xcworkspacedata | 2 +- .../xcshareddata/swiftpm/Package.resolved | 14 ++++++ DiaryApp/Controllers/HomeViewController.swift | 2 +- .../LaunchScreen.storyboard | 0 DiaryApp/Views/HomeFeedCell.swift | 45 ----------------- 6 files changed, 41 insertions(+), 72 deletions(-) create mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved rename DiaryApp/{Views/Base.lproj => Resources}/LaunchScreen.storyboard (100%) delete mode 100644 DiaryApp/Views/HomeFeedCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index be4e761..cf9a89a 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -11,13 +11,16 @@ 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; - 4E6138B22A9F2664003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B12A9F2664003A2B37 /* DiaryListThumbnailCell.swift */; }; - 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138B32A9F4E87003A2B37 /* DiaryProgressCell.swift */; }; + 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */; }; + 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */; }; + 4E6138C22A9F9E8B003A2B37 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */; }; + 4E6138C42A9F9FBA003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */; }; + 4E6138C62A9F9FDE003A2B37 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */; }; + 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; 4E98A3982A9CA57E003052D3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4E98A3972A9CA57E003052D3 /* Assets.xcassets */; }; - 4E98A39B2A9CA57E003052D3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */; }; 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3A22A9CA634003052D3 /* HomeViewController.swift */; }; 4E98A3A62A9CA6A6003052D3 /* NewDiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3A52A9CA6A6003052D3 /* NewDiaryViewController.swift */; }; 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3A72A9CA6B6003052D3 /* EditDiaryViewController.swift */; }; @@ -30,7 +33,6 @@ 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B72A9CAD27003052D3 /* User.swift */; }; 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B92A9CAD60003052D3 /* Weather.swift */; }; 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */; }; - 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */; }; 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */; }; /* End PBXBuildFile section */ @@ -38,12 +40,17 @@ 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; + 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; + 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryProgressCell.swift; sourceTree = ""; }; + 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; + 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleProgressBar.swift; sourceTree = ""; }; + 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; + 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 4E98A3922A9CA57B003052D3 /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; 4E98A3972A9CA57E003052D3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 4E98A39A2A9CA57E003052D3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4E98A39C2A9CA57E003052D3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4E98A3A22A9CA634003052D3 /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; 4E98A3A52A9CA6A6003052D3 /* NewDiaryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewDiaryViewController.swift; sourceTree = ""; }; @@ -57,7 +64,6 @@ 4E98A3B72A9CAD27003052D3 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 4E98A3B92A9CAD60003052D3 /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCollectionView.swift; sourceTree = ""; }; - 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomImageView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -77,7 +83,10 @@ isa = PBXGroup; children = ( 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, - 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, + 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */, + 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */, + 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */, + 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */, ); path = Cells; sourceTree = ""; @@ -139,14 +148,12 @@ 4E98A3B42A9CA7AD003052D3 /* Views */ = { isa = PBXGroup; children = ( - 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */, 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */, - 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */, 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */, - 4E1550852A9E0BBB00C8A500 /* Cells */, - 4E98A3BE2A9CBA1B003052D3 /* HomeFeedCell.swift */, + 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */, 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */, + 4E1550852A9E0BBB00C8A500 /* Cells */, ); path = Views; sourceTree = ""; @@ -157,6 +164,7 @@ 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */, 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */, 4E98A3972A9CA57E003052D3 /* Assets.xcassets */, + 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */, ); path = Resources; sourceTree = ""; @@ -225,8 +233,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4E98A39B2A9CA57E003052D3 /* LaunchScreen.storyboard in Resources */, 4E98A3982A9CA57E003052D3 /* Assets.xcassets in Resources */, + 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -237,6 +245,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4E6138C62A9F9FDE003A2B37 /* HomeFeedCell.swift in Sources */, 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */, 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */, 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, @@ -245,16 +254,18 @@ 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, + 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, + 4E6138C22A9F9E8B003A2B37 /* HomeFeedCell.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, + 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, - 4E6138B42A9F4E87003A2B37 /* DiaryProgressCell.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, - 4E98A3BF2A9CBA1B003052D3 /* HomeFeedCell.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, 4E98A3B02A9CA762003052D3 /* DiaryProgressViewController.swift in Sources */, + 4E6138C42A9F9FBA003A2B37 /* CircleProgressBar.swift in Sources */, 4E98A3A62A9CA6A6003052D3 /* NewDiaryViewController.swift in Sources */, 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */, 4E98A3AA2A9CA6F6003052D3 /* ProgressListViewController.swift in Sources */, @@ -263,17 +274,6 @@ }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXVariantGroup section */ - 4E98A3992A9CA57E003052D3 /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 4E98A39A2A9CA57E003052D3 /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ 4E98A39D2A9CA57E003052D3 /* Debug */ = { isa = XCBuildConfiguration; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 919434a..1bd1958 100644 --- a/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:../DiaryApp/Views"> diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..009c162 --- /dev/null +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + } + ], + "version" : 2 +} diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 46df91f..a54be2d 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -7,7 +7,7 @@ import UIKit -private enum Const { +enum Const { static let itemSize = CGSize(width: 300, height: 550) static let itemSpacing = 46.0 diff --git a/DiaryApp/Views/Base.lproj/LaunchScreen.storyboard b/DiaryApp/Resources/LaunchScreen.storyboard similarity index 100% rename from DiaryApp/Views/Base.lproj/LaunchScreen.storyboard rename to DiaryApp/Resources/LaunchScreen.storyboard diff --git a/DiaryApp/Views/HomeFeedCell.swift b/DiaryApp/Views/HomeFeedCell.swift deleted file mode 100644 index 0b2bdc4..0000000 --- a/DiaryApp/Views/HomeFeedCell.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// HomeFeedCell.swift -// DiaryApp -// -// Created by (^ㅗ^)7 iMac on 2023/08/28. -// - -import UIKit - -final class HomeFeedCell: UICollectionViewCell { - static let identifier = "HomeFeedCell" - - private let myView = CustomImageView(frame: .zero) - private let weatherImage = CustomImageView(frame: .zero) - - let sizeWidth = 70.0 - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override init(frame: CGRect) { - super.init(frame: frame) - - self.contentView.addSubview(self.myView) - - self.weatherImage.backgroundColor = .systemBlue - self.weatherImage.layer.cornerRadius = CGFloat(self.sizeWidth / 2) - - self.myView.addSubview(self.weatherImage) - - NSLayoutConstraint.activate([ - self.myView.leftAnchor.constraint(equalTo: self.contentView.leftAnchor), - self.myView.rightAnchor.constraint(equalTo: self.contentView.rightAnchor), - self.myView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor), - self.myView.topAnchor.constraint(equalTo: self.contentView.topAnchor), - - self.weatherImage.trailingAnchor.constraint(equalTo: self.myView.trailingAnchor, constant: -30), - self.weatherImage.bottomAnchor.constraint(equalTo: self.myView.bottomAnchor, constant: -30), - self.weatherImage.heightAnchor.constraint(equalToConstant: self.sizeWidth), - self.weatherImage.widthAnchor.constraint(equalToConstant: self.sizeWidth), - ]) - } -} From 89306790615b3bd37cdfc5385e53e0d8ce9a7e05 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 19:43:54 +0900 Subject: [PATCH 25/50] =?UTF-8?q?[FEAT]=20:=20feature/Progress-List-Page?= =?UTF-8?q?=20=EB=B8=8C=EB=9F=B0=EC=B9=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1bd1958..919434a 100644 --- a/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/DiaryApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> From a06054b6386835d868a456ae4d5f426402bf750b Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 19:54:42 +0900 Subject: [PATCH 26/50] =?UTF-8?q?[FEAT]=20:=20DiaryListViewController=20->?= =?UTF-8?q?=20ProgressListViewController=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/DiaryListViewController.swift | 7 ++++++- DiaryApp/Controllers/ProgressListViewController.swift | 2 ++ DiaryApp/Views/Cells/DiaryListCell.swift | 10 ---------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 16dcca9..92bcb12 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -74,7 +74,12 @@ extension DiaryListViewController: UICollectionViewDataSource { } } -extension DiaryListViewController: UICollectionViewDelegate {} +extension DiaryListViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let vc = ProgressListViewController() + navigationController?.pushViewController(vc, animated: true) + } +} extension DiaryListViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index 0e1653a..1d0fdd4 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -8,6 +8,8 @@ import UIKit class ProgressListViewController: UIViewController { + static let identifier = "ProgressListViewController" + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground diff --git a/DiaryApp/Views/Cells/DiaryListCell.swift b/DiaryApp/Views/Cells/DiaryListCell.swift index d12400e..81fbbd4 100644 --- a/DiaryApp/Views/Cells/DiaryListCell.swift +++ b/DiaryApp/Views/Cells/DiaryListCell.swift @@ -141,13 +141,3 @@ extension DiaryListCell: UICollectionViewDataSource { return cell } } - -extension DiaryListCell: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let interItemSpacing: CGFloat = 10 - let padding: CGFloat = 10 - let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) / 3 - let height = width - return CGSize(width: width, height: height) - } -} From cd6d5b986a128fcb0b96c2667ebac13db597b436 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 20:09:04 +0900 Subject: [PATCH 27/50] =?UTF-8?q?[FEAT]:=20ProgressListCell=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 + .../ProgressListViewController.swift | 73 ++++++++++++++++++- DiaryApp/Views/Cells/ProgressListCell.swift | 12 +++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 DiaryApp/Views/Cells/ProgressListCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index cf9a89a..3426ad1 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 4E6138C42A9F9FBA003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */; }; 4E6138C62A9F9FDE003A2B37 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */; }; 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */; }; + 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -46,6 +47,7 @@ 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleProgressBar.swift; sourceTree = ""; }; 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; + 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressListCell.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -87,6 +89,7 @@ 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */, 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */, 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */, + 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */, ); path = Cells; sourceTree = ""; @@ -258,6 +261,7 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, 4E6138C22A9F9E8B003A2B37 /* HomeFeedCell.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, + 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */, 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index 1d0fdd4..f0e97c5 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -6,12 +6,83 @@ // import UIKit +import SnapKit class ProgressListViewController: UIViewController { - static let identifier = "ProgressListViewController" + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground + configureCollectionView() + configureLayout() + } + + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.itemSize = Const.itemSize + layout.minimumLineSpacing = Const.itemSpacing + layout.minimumInteritemSpacing = 0 + return layout + }() + + private func configureCollectionView() { + collectionView.register(ProgressListCell.self, forCellWithReuseIdentifier: ProgressListCell.identifier) + collectionView.dataSource = self + collectionView.delegate = self + + collectionView.isScrollEnabled = true + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = Const.collectionViewContentInset + collectionView.decelerationRate = .fast + + collectionView.collectionViewLayout = collectionViewFlowLayout + } + + private func configureLayout() { + view.addSubview(collectionView) + + collectionView.snp.makeConstraints { make in + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-10) + } + } +} + +extension ProgressListViewController: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 7 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ProgressListCell.identifier, for: indexPath) as? ProgressListCell else { return UICollectionViewCell() } + cell.backgroundColor = .systemRed + cell.layer.cornerRadius = 20 + return cell + } +} + +extension ProgressListViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let interItemSpacing: CGFloat = 10 + let padding: CGFloat = 10 + let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) + print("### \(width)") + let height = width / 3 + return CGSize(width: width, height: height) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 10 } } diff --git a/DiaryApp/Views/Cells/ProgressListCell.swift b/DiaryApp/Views/Cells/ProgressListCell.swift new file mode 100644 index 0000000..2a6cee0 --- /dev/null +++ b/DiaryApp/Views/Cells/ProgressListCell.swift @@ -0,0 +1,12 @@ +// +// ProgressListCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/31. +// + +import UIKit + +class ProgressListCell: UICollectionViewCell { + static let identifier = "ProgressListCell" +} From 59834cdc34236212bbc755f5375c7fadfa98ff12 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 21:56:08 +0900 Subject: [PATCH 28/50] =?UTF-8?q?[FEAT]:=20ProgressTageCell=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20&=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 16 +-- .../ProgressListViewController.swift | 8 +- DiaryApp/Views/Cells/DiaryProgressCell.swift | 3 +- DiaryApp/Views/Cells/ProgressListCell.swift | 107 ++++++++++++++++++ DiaryApp/Views/Cells/ProgressTagCell.swift | 39 +++++++ 5 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 DiaryApp/Views/Cells/ProgressTagCell.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 3426ad1..4dc13df 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -13,11 +13,11 @@ 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */; }; 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */; }; - 4E6138C22A9F9E8B003A2B37 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */; }; 4E6138C42A9F9FBA003A2B37 /* CircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */; }; - 4E6138C62A9F9FDE003A2B37 /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */; }; 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */; }; 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */; }; + 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */; }; + 4E7A150A2AA0C11E005FCD9C /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -43,11 +43,11 @@ 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryListThumbnailCell.swift; sourceTree = ""; }; 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryProgressCell.swift; sourceTree = ""; }; - 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; 4E6138C32A9F9FBA003A2B37 /* CircleProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleProgressBar.swift; sourceTree = ""; }; - 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; 4E6138C82A9FA164003A2B37 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressListCell.swift; sourceTree = ""; }; + 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressTagCell.swift; sourceTree = ""; }; + 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -86,10 +86,10 @@ children = ( 4E1550832A9E049100C8A500 /* DiaryListCell.swift */, 4E6138BD2A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift */, + 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */, 4E6138BE2A9F9E8B003A2B37 /* DiaryProgressCell.swift */, - 4E6138C52A9F9FDE003A2B37 /* HomeFeedCell.swift */, - 4E6138BF2A9F9E8B003A2B37 /* HomeFeedCell.swift */, 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */, + 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */, ); path = Cells; sourceTree = ""; @@ -248,7 +248,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4E6138C62A9F9FDE003A2B37 /* HomeFeedCell.swift in Sources */, + 4E7A150A2AA0C11E005FCD9C /* HomeFeedCell.swift in Sources */, 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */, 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */, 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, @@ -259,8 +259,8 @@ 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, - 4E6138C22A9F9E8B003A2B37 /* HomeFeedCell.swift in Sources */, 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */, + 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */, 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */, 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index f0e97c5..fbf6fb3 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -5,8 +5,8 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // -import UIKit import SnapKit +import UIKit class ProgressListViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) @@ -31,7 +31,7 @@ class ProgressListViewController: UIViewController { collectionView.register(ProgressListCell.self, forCellWithReuseIdentifier: ProgressListCell.identifier) collectionView.dataSource = self collectionView.delegate = self - + collectionView.isScrollEnabled = true collectionView.showsHorizontalScrollIndicator = false collectionView.showsVerticalScrollIndicator = true @@ -62,6 +62,10 @@ extension ProgressListViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ProgressListCell.identifier, for: indexPath) as? ProgressListCell else { return UICollectionViewCell() } + cell.imageView.image = UIImage(systemName: "bell") + cell.weatherImageView.image = UIImage(systemName: "sun.max") + cell.descriptionLabel.text = "오늘 하루 운동을 했는데 어쩌구 저쩌구 닭가슴살을 먹었는데 어쩌구 저쩌구 헬스장을 다녀왔는데 어쩌구 저꺼구" + cell.backgroundColor = .systemRed cell.layer.cornerRadius = 20 return cell diff --git a/DiaryApp/Views/Cells/DiaryProgressCell.swift b/DiaryApp/Views/Cells/DiaryProgressCell.swift index e0ac2fc..21f2699 100644 --- a/DiaryApp/Views/Cells/DiaryProgressCell.swift +++ b/DiaryApp/Views/Cells/DiaryProgressCell.swift @@ -23,14 +23,13 @@ final class DiaryProgressCell: UICollectionViewCell { circularProgressBarView.translatesAutoresizingMaskIntoConstraints = false circularProgressBarView.center = contentView.center -// circularProgressBarView.progressAnimation(duration: 30) percentLabel.text = "100%" contentView.addSubview(circularProgressBarView) circularProgressBarView.snp.makeConstraints { make in make.centerX.centerY.equalTo(contentView) } - + circularProgressBarView.addSubview(percentLabel) percentLabel.snp.makeConstraints { make in make.centerX.centerY.equalTo(circularProgressBarView) diff --git a/DiaryApp/Views/Cells/ProgressListCell.swift b/DiaryApp/Views/Cells/ProgressListCell.swift index 2a6cee0..e95c440 100644 --- a/DiaryApp/Views/Cells/ProgressListCell.swift +++ b/DiaryApp/Views/Cells/ProgressListCell.swift @@ -5,8 +5,115 @@ // Created by (^ㅗ^)7 iMac on 2023/08/31. // +import SnapKit import UIKit class ProgressListCell: UICollectionViewCell { static let identifier = "ProgressListCell" + + lazy var imageView = CustomImageView(frame: .zero) + lazy var weatherImageView = CustomImageView(frame: .zero) + lazy var descriptionLabel = CustomLabel(frame: .zero) + + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + layout.itemSize = CGSize(width: 50, height: 20) + layout.minimumLineSpacing = 5 + layout.minimumInteritemSpacing = 2 + layout.estimatedItemSize = .zero + return layout + }() + + override init(frame: CGRect) { + super.init(frame: frame) + configureCell() + setupLayout() + configureCollectionView() + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func configureCell() { + imageView.contentMode = .scaleAspectFit + imageView.layer.cornerRadius = 20 + imageView.backgroundColor = .systemBrown + + descriptionLabel.backgroundColor = .white + descriptionLabel.font = .systemFont(ofSize: 15, weight: .regular) + descriptionLabel.numberOfLines = 3 + descriptionLabel.textAlignment = .left + descriptionLabel.adjustsFontSizeToFitWidth = false + + weatherImageView.contentMode = .scaleAspectFit + weatherImageView.layer.cornerRadius = weatherImageView.bounds.size.width / 2 + weatherImageView.backgroundColor = .purple + } + + private func setupLayout() { + contentView.addSubview(imageView) + imageView.snp.makeConstraints { make in + make.top.leading.bottom.equalTo(contentView) + make.width.equalTo(imageView.snp.height) + } + + contentView.addSubview(weatherImageView) + weatherImageView.snp.makeConstraints { make in + make.leading.equalTo(imageView.snp.trailing).offset(10) + make.top.equalTo(contentView).inset(5) + make.width.height.equalTo(30) + } + + contentView.addSubview(descriptionLabel) + descriptionLabel.snp.makeConstraints { make in + make.leading.equalTo(imageView.snp.trailing).offset(10) + make.trailing.equalTo(contentView).inset(10) + make.top.equalTo(weatherImageView.snp.bottom).offset(5) + make.bottom.equalTo(contentView).inset(10) + } + + contentView.addSubview(collectionView) + collectionView.snp.makeConstraints { make in + make.top.equalTo(contentView).inset(5) + make.trailing.equalTo(contentView).inset(10) + make.bottom.equalTo(descriptionLabel.snp.top).offset(5) + make.leading.equalTo(weatherImageView.snp.trailing).offset(5) + } + } + + private func configureCollectionView() { + collectionView.register(ProgressTagCell.self, forCellWithReuseIdentifier: ProgressTagCell.identifier) + collectionView.dataSource = self + + collectionView.isScrollEnabled = false + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = true + collectionView.backgroundColor = .clear + collectionView.clipsToBounds = true + collectionView.isPagingEnabled = false + collectionView.contentInsetAdjustmentBehavior = .never + collectionView.contentInset = UIEdgeInsets(top: 5, left: 5, bottom: 15, right: 5) + collectionView.decelerationRate = .fast + + collectionView.collectionViewLayout = collectionViewFlowLayout + } +} + +extension ProgressListCell: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 3 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ProgressTagCell.identifier, for: indexPath) as? ProgressTagCell else { return UICollectionViewCell() } + cell.tagTitleLabel.text = "Hi" + cell.backgroundColor = .systemYellow + cell.layer.cornerRadius = 5 + return cell + } } diff --git a/DiaryApp/Views/Cells/ProgressTagCell.swift b/DiaryApp/Views/Cells/ProgressTagCell.swift new file mode 100644 index 0000000..c8893bc --- /dev/null +++ b/DiaryApp/Views/Cells/ProgressTagCell.swift @@ -0,0 +1,39 @@ +// +// ProgressTagCell.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/31. +// + +import SnapKit +import UIKit + +final class ProgressTagCell: UICollectionViewCell { + static let identifier = "ProgressTagCell" + + lazy var tagTitleLabel = CustomLabel(frame: .zero) + + override init(frame: CGRect) { + super.init(frame: frame) + setupUI() + setupLayout() + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setupUI() { + tagTitleLabel.numberOfLines = 1 + tagTitleLabel.font = .systemFont(ofSize: 15) + tagTitleLabel.textAlignment = .center + } + + func setupLayout() { + contentView.addSubview(tagTitleLabel) + tagTitleLabel.snp.makeConstraints { make in + make.top.bottom.leading.trailing.equalTo(contentView).inset(-10) + } + } +} From 4e1582cb6617ac4b52f09ffa4852370f732f98c9 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 22:01:34 +0900 Subject: [PATCH 29/50] =?UTF-8?q?[FEAT]:=20DiaryProgressViewController=20-?= =?UTF-8?q?>=20ProgressListViewController=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiaryProgressViewController.swift | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 2f00330..35e523c 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -11,15 +11,6 @@ import UIKit class DiaryProgressViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) -// private let collectionViewFlowLayout: UICollectionViewFlowLayout = { -// let layout = UICollectionViewFlowLayout() -// layout.scrollDirection = .vertical -// layout.itemSize = Const.itemSize -// layout.minimumLineSpacing = Const.itemSpacing -// layout.minimumInteritemSpacing = 0 -// return layout -// }() - override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground @@ -53,7 +44,6 @@ class DiaryProgressViewController: UIViewController { if let flowlayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { flowlayout.estimatedItemSize = .zero } -// collectionView.collectionViewLayout = collectionViewFlowLayout } } @@ -71,6 +61,13 @@ extension DiaryProgressViewController: UICollectionViewDataSource { } } +extension DiaryProgressViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let vc = ProgressListViewController() + navigationController?.pushViewController(vc, animated: true) + } +} + extension DiaryProgressViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let interItemSpacing: CGFloat = 10 From e09690ad309dbbbc81abc1e8734416c23a2f3c45 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Wed, 30 Aug 2023 12:32:03 +0900 Subject: [PATCH 30/50] =?UTF-8?q?[FEAT]:=20Snapkit=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ++++ .../xcshareddata/swiftpm/Package.resolved | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 4dc13df..71e028f 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ +<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; @@ -18,6 +19,9 @@ 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */; }; 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */; }; 4E7A150A2AA0C11E005FCD9C /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */; }; +======= + 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; +>>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 009c162..0000000 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "snapkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/SnapKit/SnapKit.git", - "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" - } - } - ], - "version" : 2 -} From 7666d255661d6a34f3688c8074dbafafc8afac9a Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 22:24:24 +0900 Subject: [PATCH 31/50] =?UTF-8?q?[MERGE]:=20Develop=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 71e028f..4dc13df 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ -<<<<<<< HEAD 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; @@ -19,9 +18,6 @@ 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */; }; 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */; }; 4E7A150A2AA0C11E005FCD9C /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */; }; -======= - 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4E6138AF2A9EEF50003A2B37 /* SnapKit */; }; ->>>>>>> 5765151 ([FEAT]: Snapkit 패키지 추가가) 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; From 2fce643865c32fa00e5755bc314a376035b1ea47 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Thu, 31 Aug 2023 22:27:53 +0900 Subject: [PATCH 32/50] =?UTF-8?q?[MERGE]:=20Develop=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/swiftpm/Package.resolved | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..009c162 --- /dev/null +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + } + ], + "version" : 2 +} From 63972b7a5049b99c7154fa81915408061c5d76d0 Mon Sep 17 00:00:00 2001 From: p2glet Date: Thu, 31 Aug 2023 22:42:59 +0900 Subject: [PATCH 33/50] =?UTF-8?q?[MERGE]=20feature/DiaryCalendar=20?= =?UTF-8?q?=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 8 +- .../DiaryCalendarViewController.swift | 488 ++++++++++++++++++ .../DiaryCalenderViewController.swift | 15 - 3 files changed, 492 insertions(+), 19 deletions(-) create mode 100644 DiaryApp/Controllers/DiaryCalendarViewController.swift delete mode 100644 DiaryApp/Controllers/DiaryCalenderViewController.swift diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 4dc13df..9e34023 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -29,12 +29,12 @@ 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3AB2A9CA70B003052D3 /* DiaryListViewController.swift */; }; 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3AD2A9CA748003052D3 /* DetailDiaryViewController.swift */; }; 4E98A3B02A9CA762003052D3 /* DiaryProgressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3AF2A9CA762003052D3 /* DiaryProgressViewController.swift */; }; - 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B12A9CA781003052D3 /* DiaryCalenderViewController.swift */; }; 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */; }; 4E98A3B82A9CAD27003052D3 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B72A9CAD27003052D3 /* User.swift */; }; 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B92A9CAD60003052D3 /* Weather.swift */; }; 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */; }; 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */; }; + FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -61,12 +61,12 @@ 4E98A3AB2A9CA70B003052D3 /* DiaryListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListViewController.swift; sourceTree = ""; }; 4E98A3AD2A9CA748003052D3 /* DetailDiaryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailDiaryViewController.swift; sourceTree = ""; }; 4E98A3AF2A9CA762003052D3 /* DiaryProgressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryProgressViewController.swift; sourceTree = ""; }; - 4E98A3B12A9CA781003052D3 /* DiaryCalenderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryCalenderViewController.swift; sourceTree = ""; }; 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; 4E98A3B72A9CAD27003052D3 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 4E98A3B92A9CAD60003052D3 /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCollectionView.swift; sourceTree = ""; }; 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomImageView.swift; sourceTree = ""; }; + FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCalendarViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -129,11 +129,11 @@ 4E98A3A22A9CA634003052D3 /* HomeViewController.swift */, 4E98A3A52A9CA6A6003052D3 /* NewDiaryViewController.swift */, 4E98A3A72A9CA6B6003052D3 /* EditDiaryViewController.swift */, + FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */, 4E98A3A92A9CA6F6003052D3 /* ProgressListViewController.swift */, 4E98A3AB2A9CA70B003052D3 /* DiaryListViewController.swift */, 4E98A3AD2A9CA748003052D3 /* DetailDiaryViewController.swift */, 4E98A3AF2A9CA762003052D3 /* DiaryProgressViewController.swift */, - 4E98A3B12A9CA781003052D3 /* DiaryCalenderViewController.swift */, 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */, ); path = Controllers; @@ -254,7 +254,6 @@ 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */, 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, - 4E98A3B22A9CA781003052D3 /* DiaryCalenderViewController.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */, @@ -272,6 +271,7 @@ 4E6138C42A9F9FBA003A2B37 /* CircleProgressBar.swift in Sources */, 4E98A3A62A9CA6A6003052D3 /* NewDiaryViewController.swift in Sources */, 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */, + FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */, 4E98A3AA2A9CA6F6003052D3 /* ProgressListViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/DiaryApp/Controllers/DiaryCalendarViewController.swift b/DiaryApp/Controllers/DiaryCalendarViewController.swift new file mode 100644 index 0000000..581e77c --- /dev/null +++ b/DiaryApp/Controllers/DiaryCalendarViewController.swift @@ -0,0 +1,488 @@ +// +// BottomSheetViewController.swift +// DiaryApp +// +// Created by t2023-m0056 on 2023/08/31. +// + +import UIKit +import SnapKit + +@available(iOS 16.0, *) +class DiaryCalendarViewController: UIViewController { + + // MARK: - BottomSheet + // 바텀 시트 높이 + var bottomHeight: CGFloat = 620 + + // bottomSheet가 view의 상단에서 떨어진 거리 + private var bottomSheetViewTopConstraint: NSLayoutConstraint! + + // 기존 화면을 흐려지게 만들기 위한 뷰 + private let dimmedBackView: UIView = { + let view = UIView() + view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5) + return view + }() + + // 바텀 시트 뷰 + private let bottomSheetView: UIView = { + let view = UIView() + view.backgroundColor = .white + + view.layer.cornerRadius = 27 + view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + view.clipsToBounds = true + + return view + }() + + // MARK: - Callendar + + lazy var dateView: UICalendarView = { + var view = UICalendarView() + view.wantsDateDecorations = true + return view + }() + + var selectedDate: DateComponents? = nil + + // MARK: - Properties + + var purposeTextField: UITextField = { + var textField = UITextField() + let centeredParagraphStyle = NSMutableParagraphStyle() + centeredParagraphStyle.alignment = .center + textField.attributedPlaceholder = NSAttributedString(string: "목표", attributes:[NSAttributedString.Key.foregroundColor : UIColor.black, NSAttributedString.Key.paragraphStyle: centeredParagraphStyle]) + textField.layer.cornerRadius = 10 + textField.layer.borderWidth = 1 + return textField + }() + + var everyDayBtn = UIButton(), threeDaysBtn = UIButton(), fiveDaysBtn = UIButton(), everyWeekBtn = UIButton() + + var checkedEverDay = false, checkedThreeDays = false, checkedFiveDays = false, checkedEverWeek = false + + var sundayBtn = UIButton() ,mondayBtn = UIButton(), tuesdayBtn = UIButton(), wednesdayBtn = UIButton(), thursdayBtn = UIButton(), fridayBtn = UIButton(), saturdayBtn = UIButton() + + var checkedSunday = false, checkedMonday = false, checkedTuesday = false, checkedWednesday = false, checkedThursday = false, checkedFridaay = false, checkedSaturday = false + + var saveBtn: UIButton = { + var btn = UIButton() + btn.setTitle("저장", for: .normal) + btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 20) + btn.setTitleColor(.black, for: .normal) + btn.layer.cornerRadius = 10 + btn.layer.borderWidth = 1 + return btn + }() + + // dismiss Indicator View UI 구성 부분 + private let dismissIndicatorView: UIView = { + let view = UIView() + view.backgroundColor = .systemGray + view.layer.cornerRadius = 3 + return view + }() + + // MARK: - StackView + + var totalStackView = { + var view = UIStackView() + view.axis = .vertical + view.spacing = 10 + view.snp.makeConstraints{ + $0.height.equalTo(120) + } + return view + }() + + lazy var intervalStackView = { + var view = UIStackView(arrangedSubviews: [self.everyDayBtn, self.threeDaysBtn, self.fiveDaysBtn, self.everyWeekBtn]) + view.axis = .horizontal + view.distribution = .equalSpacing + view.snp.makeConstraints{ + $0.height.equalTo(50) + } + return view + }() + + lazy var dayStackView = { + let view = UIStackView(arrangedSubviews: [self.sundayBtn,self.mondayBtn,self.tuesdayBtn,self.wednesdayBtn,self.thursdayBtn,self.fridayBtn,self.saturdayBtn]) + view.axis = .horizontal + view.distribution = .equalSpacing + view.isHidden = true + view.snp.makeConstraints{ + $0.height.equalTo(40) + } + return view + }() + + // MARK: - View Life Cycle + override func viewDidLoad() { + super.viewDidLoad() + + dateView.delegate = self + let dateSelection = UICalendarSelectionSingleDate(delegate: self) + dateView.selectionBehavior = dateSelection + + configurationView() + setupGestureRecognizer() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + showBottomSheet() + } + + // MARK: - @Functions + func configurationView() { + setupUI() + setupLayout() + setDateView() + setPurposeTitle() + setTotalStackView() + + setEveryDayBtn() + setThreeDaysBtn() + setFiveDaysBtn() + setEveryWeekBtn() + + setSundayBtn() + setMondayBtn() + setTuesdayBtn() + setWednesdayBtn() + setThursdayBtn() + setFridayBtn() + setSaturdayBtn() + + setSaveBtn() + } + + // UI 세팅 작업 + private func setupUI() { + view.addSubview(dimmedBackView) + view.addSubview(bottomSheetView) + view.addSubview(dismissIndicatorView) + dimmedBackView.alpha = 0.0 + } + + // GestureRecognizer 세팅 작업 + private func setupGestureRecognizer() { + // 흐린 부분 탭할 때, 바텀시트를 내리는 TapGesture + let dimmedTap = UITapGestureRecognizer(target: self, action: #selector(dimmedViewTapped(_:))) + dimmedBackView.addGestureRecognizer(dimmedTap) + dimmedBackView.isUserInteractionEnabled = true + + // 스와이프 했을 때, 바텀시트를 내리는 swipeGesture + let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(panGesture)) + swipeGesture.direction = .down + view.addGestureRecognizer(swipeGesture) + } + + // 레이아웃 세팅 + private func setupLayout() { + dimmedBackView.snp.makeConstraints{ + $0.top.equalTo(view.safeAreaLayoutGuide.snp.top) + $0.leading.equalTo(view.safeAreaLayoutGuide.snp.leading) + $0.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing) + $0.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom) + } + + bottomSheetView.translatesAutoresizingMaskIntoConstraints = false + let topConstant = view.safeAreaInsets.bottom + view.safeAreaLayoutGuide.layoutFrame.height + bottomSheetViewTopConstraint = bottomSheetView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: topConstant) + bottomSheetView.snp.makeConstraints{ + $0.leading.equalTo(view.safeAreaLayoutGuide.snp.leading) + $0.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing) + $0.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom) + } + bottomSheetViewTopConstraint.isActive = true + + dismissIndicatorView.snp.makeConstraints{ + $0.width.equalTo(102) + $0.height.equalTo(7) + $0.top.equalTo(bottomSheetView.snp.top).inset(12) + $0.centerX.equalTo(bottomSheetView.snp.centerX) + } + } + + func setDateView() { + bottomSheetView.addSubview(dateView) + dateView.snp.makeConstraints{ + $0.top.equalToSuperview().inset(10) + $0.leading.equalToSuperview().inset(10) + $0.trailing.equalToSuperview().inset(10) + } + } + + func reloadDateView(date: Date?) { + if date == nil { return } + let calendar = Calendar.current + dateView.reloadDecorations(forDateComponents: [calendar.dateComponents([.day, .month, .year], from: date!)], animated: true) + } + + func setPurposeTitle() { + bottomSheetView.addSubview(purposeTextField) + purposeTextField.snp.makeConstraints { + $0.top.equalTo(dateView.snp.bottom).inset(-10) + $0.leading.equalToSuperview().inset(10) + $0.trailing.equalToSuperview().inset(10) + $0.height.equalTo(50) + } + } + + func setTotalStackView() { + bottomSheetView.addSubview(totalStackView) + totalStackView.addArrangedSubview(intervalStackView) + totalStackView.addArrangedSubview(dayStackView) + totalStackView.snp.makeConstraints { + $0.top.equalTo(purposeTextField.snp.bottom).inset(-10) + $0.leading.equalToSuperview().inset(10) + $0.trailing.equalToSuperview().inset(10) + } + } + + // MARK: - IntervalBtn + func setEveryDayBtn() { + self.setIntervalBtn("매일", everyDayBtn) + everyDayBtn.addTarget(self, action: #selector(clickedEveryDay), for: .touchUpInside) + } + + func setThreeDaysBtn() { + self.setIntervalBtn("3일", threeDaysBtn) + threeDaysBtn.addTarget(self, action: #selector(clickedThreeDays), for: .touchUpInside) + } + + func setFiveDaysBtn() { + self.setIntervalBtn("5일", fiveDaysBtn) + fiveDaysBtn.addTarget(self, action: #selector(clickedFiveDays), for: .touchUpInside) + } + + func setEveryWeekBtn() { + self.setIntervalBtn("매주", everyWeekBtn) + everyWeekBtn.addTarget(self, action: #selector(clickedEveryWeek), for: .touchUpInside) + } + + // MARK: - DaysBtn + func setSundayBtn() { + self.setDayBtn("일", self.sundayBtn) + sundayBtn.layer.borderColor = UIColor.red.cgColor + sundayBtn.setTitleColor(.red, for: .normal) + sundayBtn.addTarget(self, action: #selector(clickedSunday), for: .touchUpInside) + } + + func setMondayBtn() { + self.setDayBtn("월", self.mondayBtn) + mondayBtn.addTarget(self, action: #selector(clickedMonday), for: .touchUpInside) + } + + func setTuesdayBtn() { + self.setDayBtn("화", self.tuesdayBtn) + tuesdayBtn.addTarget(self, action: #selector(clickedTuesday), for: .touchUpInside) + } + + func setWednesdayBtn() { + self.setDayBtn("수", self.wednesdayBtn) + wednesdayBtn.addTarget(self, action: #selector(clickedWednesday), for: .touchUpInside) + } + + func setThursdayBtn() { + self.setDayBtn("목", self.thursdayBtn) + thursdayBtn.addTarget(self, action: #selector(clickedThursday), for: .touchUpInside) + } + + func setFridayBtn() { + self.setDayBtn("금", self.fridayBtn) + fridayBtn.addTarget(self, action: #selector(clickedFriday), for: .touchUpInside) + } + + func setSaturdayBtn() { + self.setDayBtn("토", self.saturdayBtn) + saturdayBtn.layer.borderColor = UIColor.blue.cgColor + saturdayBtn.setTitleColor(.blue, for: .normal) + saturdayBtn.addTarget(self, action: #selector(clickedSaturday), for: .touchUpInside) + } + + func setSaveBtn() { + bottomSheetView.addSubview(saveBtn) + saveBtn.snp.makeConstraints { + $0.top.equalTo(totalStackView.snp.bottom).inset(-10) + $0.leading.equalToSuperview().inset(10) + $0.trailing.equalToSuperview().inset(10) + $0.bottom.equalToSuperview() + $0.height.equalTo(50) + } + saveBtn.addTarget(self, action: #selector(clickedSaveBtn), for: .touchUpInside) + } + + func setIntervalBtn(_ title: String, _ btn: UIButton) { + btn.setTitle(title, for: .normal) + btn.setTitleColor(.black, for: .normal) + btn.layer.cornerRadius = 10 + btn.layer.borderWidth = 1 + btn.snp.makeConstraints{ + $0.width.equalTo(80) + } + } + + func setDayBtn(_ title: String, _ btn: UIButton) { + btn.setTitle(title, for: .normal) + btn.setTitleColor(.black, for: .normal) + btn.layer.cornerRadius = 10 + btn.layer.borderWidth = 1 + btn.snp.makeConstraints{ + $0.width.equalTo(40) + } + } + + // 바텀 시트 표출 애니메이션 + private func showBottomSheet() { + let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height + let bottomPadding: CGFloat = view.safeAreaInsets.bottom + + bottomSheetViewTopConstraint.constant = (safeAreaHeight + bottomPadding) - bottomHeight + + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { + self.dimmedBackView.alpha = 0.5 + self.view.layoutIfNeeded() + }, completion: nil) + } + + // 바텀 시트 사라지는 애니메이션 + private func hideBottomSheetAndGoBack() { + let safeAreaHeight = view.safeAreaLayoutGuide.layoutFrame.height + let bottomPadding = view.safeAreaInsets.bottom + bottomSheetViewTopConstraint.constant = safeAreaHeight + bottomPadding + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { + self.dimmedBackView.alpha = 0.0 + self.view.layoutIfNeeded() + }) { _ in + if self.presentingViewController != nil { + self.dismiss(animated: false, completion: nil) + } + } + } + + // MARK: - @objc + @objc func clickedEveryDay() { + everyDayBtn.backgroundColor = checkedEverDay ? .white : .black + everyDayBtn.setTitleColor(checkedEverDay ? .black : .white, for: .normal) + checkedEverDay = !checkedEverDay + } + + @objc func clickedThreeDays() { + threeDaysBtn.backgroundColor = checkedThreeDays ? .white : .black + threeDaysBtn.setTitleColor(checkedThreeDays ? .black : .white, for: .normal) + checkedThreeDays = !checkedThreeDays + } + + @objc func clickedFiveDays() { + fiveDaysBtn.backgroundColor = checkedFiveDays ? .white : .black + fiveDaysBtn.setTitleColor(checkedFiveDays ? .black : .white, for: .normal) + checkedFiveDays = !checkedFiveDays + } + + @objc func clickedEveryWeek() { + everyWeekBtn.backgroundColor = checkedEverWeek ? .white : .black + everyWeekBtn.setTitleColor(checkedEverWeek ? .black : .white, for: .normal) + checkedEverWeek = !checkedEverWeek + + dayStackView.isHidden = !dayStackView.isHidden + bottomHeight = (dayStackView.isHidden == false) ? 660 : 620 + showBottomSheet() + } + + @objc func clickedSunday() { + sundayBtn.backgroundColor = checkedSunday ? .white : .red + sundayBtn.setTitleColor(checkedSunday ? .red : .white, for: .normal) + checkedSunday = !checkedSunday + } + + @objc func clickedMonday() { + mondayBtn.backgroundColor = checkedMonday ? .white : .black + mondayBtn.setTitleColor(checkedMonday ? .black : .white, for: .normal) + checkedMonday = !checkedMonday + } + + @objc func clickedTuesday() { + tuesdayBtn.backgroundColor = checkedTuesday ? .white : .black + tuesdayBtn.setTitleColor(checkedTuesday ? .black : .white, for: .normal) + checkedTuesday = !checkedTuesday + } + + @objc func clickedWednesday() { + wednesdayBtn.backgroundColor = checkedWednesday ? .white : .black + wednesdayBtn.setTitleColor(checkedWednesday ? .black : .white, for: .normal) + checkedWednesday = !checkedWednesday + } + + @objc func clickedThursday() { + thursdayBtn.backgroundColor = checkedThursday ? .white : .black + thursdayBtn.setTitleColor(checkedThursday ? .black : .white, for: .normal) + checkedThursday = !checkedThursday + } + + @objc func clickedFriday() { + fridayBtn.backgroundColor = checkedFridaay ? .white : .black + fridayBtn.setTitleColor(checkedFridaay ? .black : .white, for: .normal) + checkedFridaay = !checkedFridaay + } + + @objc func clickedSaturday() { + saturdayBtn.backgroundColor = checkedSaturday ? .white : .blue + saturdayBtn.setTitleColor(checkedSaturday ? .blue : .white, for: .normal) + checkedSaturday = !checkedSaturday + } + + @objc func clickedSaveBtn() { + //save + } + + // UITapGestureRecognizer 연결 함수 부분 + @objc private func dimmedViewTapped(_ tapRecognizer: UITapGestureRecognizer) { + hideBottomSheetAndGoBack() + } + + // UISwipeGestureRecognizer 연결 함수 부분 + @objc func panGesture(_ recognizer: UISwipeGestureRecognizer) { + if recognizer.state == .ended { + switch recognizer.direction { + case .down: + hideBottomSheetAndGoBack() + default: + break + } + } + } +} + +@available(iOS 16.0, *) +extension DiaryCalendarViewController: UICalendarViewDelegate, UICalendarSelectionSingleDateDelegate { + // UICalendarView + func calendarView(_ calendarView: UICalendarView, decorationFor dateComponents: DateComponents) -> UICalendarView.Decoration? { + if let selectedDate = selectedDate, selectedDate == dateComponents { + return .customView { + let label = UILabel() +// label.text = "🐶" + label.textAlignment = .center + return label + } + } + return nil + } + + // 달력에서 날짜 선택했을 경우 + func dateSelection(_ selection: UICalendarSelectionSingleDate, didSelectDate dateComponents: DateComponents?) { + selection.setSelected(dateComponents, animated: true) + selectedDate = dateComponents + reloadDateView(date: Calendar.current.date(from: dateComponents!)) + } +} + +//// btn.addTarget(self, action: #selector(pushCallendar), for: .touchUpInside) +// @objc func pushCallendar() { +// let vc = DiaryCalendarViewController() +// vc.modalPresentationStyle = .overFullScreen +// self.present(vc, animated: false, completion: nil) +// } diff --git a/DiaryApp/Controllers/DiaryCalenderViewController.swift b/DiaryApp/Controllers/DiaryCalenderViewController.swift deleted file mode 100644 index 41e69b3..0000000 --- a/DiaryApp/Controllers/DiaryCalenderViewController.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// DiaryCalenderViewController.swift -// DiaryApp -// -// Created by (^ㅗ^)7 iMac on 2023/08/28. -// - -import UIKit - -class DiaryCalenderViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = .systemBackground - } -} From f60182777749ff646e176374a92e18ea347c4711 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 15:53:39 +0900 Subject: [PATCH 34/50] =?UTF-8?q?[FEAT]:=20*.pbxproj=20Avoid=20Merge=20Con?= =?UTF-8?q?flict=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..36bbda7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.pbxproj binary merge=union + From 1da1b003b836933bc28079aadd43f39e753436c8 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 16:30:24 +0900 Subject: [PATCH 35/50] =?UTF-8?q?[STYLE]:=20Nslayout=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20->=20Snapkit=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/HomeViewController.swift | 11 +++++----- DiaryApp/Views/Cells/HomeFeedCell.swift | 21 ++++++++----------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index a54be2d..76ba51e 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -5,6 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import SnapKit import UIKit enum Const { @@ -62,12 +63,10 @@ class HomeViewController: UIViewController { private func configureLayout() { view.addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), - collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -20), - ]) + collectionView.snp.makeConstraints { make in + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-20) + } } private func addSearchBar() { diff --git a/DiaryApp/Views/Cells/HomeFeedCell.swift b/DiaryApp/Views/Cells/HomeFeedCell.swift index 0b2bdc4..248bd37 100644 --- a/DiaryApp/Views/Cells/HomeFeedCell.swift +++ b/DiaryApp/Views/Cells/HomeFeedCell.swift @@ -5,6 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import SnapKit import UIKit final class HomeFeedCell: UICollectionViewCell { @@ -29,17 +30,13 @@ final class HomeFeedCell: UICollectionViewCell { self.weatherImage.layer.cornerRadius = CGFloat(self.sizeWidth / 2) self.myView.addSubview(self.weatherImage) - - NSLayoutConstraint.activate([ - self.myView.leftAnchor.constraint(equalTo: self.contentView.leftAnchor), - self.myView.rightAnchor.constraint(equalTo: self.contentView.rightAnchor), - self.myView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor), - self.myView.topAnchor.constraint(equalTo: self.contentView.topAnchor), - - self.weatherImage.trailingAnchor.constraint(equalTo: self.myView.trailingAnchor, constant: -30), - self.weatherImage.bottomAnchor.constraint(equalTo: self.myView.bottomAnchor, constant: -30), - self.weatherImage.heightAnchor.constraint(equalToConstant: self.sizeWidth), - self.weatherImage.widthAnchor.constraint(equalToConstant: self.sizeWidth), - ]) + self.myView.snp.makeConstraints { make in + make.top.bottom.leading.trailing.equalTo(contentView) + } + + self.weatherImage.snp.makeConstraints { make in + make.trailing.bottom.equalTo(self.myView).offset(-30) + make.height.width.equalTo(self.sizeWidth) + } } } From a873dd0f2a20d1896491e288042be21573f5b4cb Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 17:11:41 +0900 Subject: [PATCH 36/50] =?UTF-8?q?[FEAT]:=20=ED=8C=8C=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=EB=B2=A0=EC=9D=B4=EC=8A=A4=20=EC=9E=84=ED=8F=AC=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 41 +++++++ .../xcshareddata/swiftpm/Package.resolved | 108 ++++++++++++++++++ DiaryApp/Resources/AppDelegate.swift | 1 + 3 files changed, 150 insertions(+) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 9e34023..2df2414 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -34,6 +34,10 @@ 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3B92A9CAD60003052D3 /* Weather.swift */; }; 4E98A3BD2A9CB918003052D3 /* CustomCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */; }; 4E98A3C12A9CCFB8003052D3 /* CustomImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */; }; + 4EA8081E2AA1D41100A4D465 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA8081D2AA1D41100A4D465 /* FirebaseAuth */; }; + 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA8081F2AA1D41100A4D465 /* FirebaseDatabase */; }; + 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808212AA1D41100A4D465 /* FirebaseFirestore */; }; + 4EA808242AA1D41100A4D465 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808232AA1D41100A4D465 /* FirebaseStorage */; }; FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; /* End PBXBuildFile section */ @@ -74,7 +78,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */, + 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */, 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, + 4EA808242AA1D41100A4D465 /* FirebaseStorage in Frameworks */, + 4EA8081E2AA1D41100A4D465 /* FirebaseAuth in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -190,6 +198,10 @@ name = DiaryApp; packageProductDependencies = ( 4E6138AF2A9EEF50003A2B37 /* SnapKit */, + 4EA8081D2AA1D41100A4D465 /* FirebaseAuth */, + 4EA8081F2AA1D41100A4D465 /* FirebaseDatabase */, + 4EA808212AA1D41100A4D465 /* FirebaseFirestore */, + 4EA808232AA1D41100A4D465 /* FirebaseStorage */, ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; @@ -221,6 +233,7 @@ mainGroup = 4E98A3822A9CA57B003052D3; packageReferences = ( 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, + 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; @@ -481,6 +494,14 @@ minimumVersion = 5.0.0; }; }; + 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 10.0.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -489,6 +510,26 @@ package = 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */; productName = SnapKit; }; + 4EA8081D2AA1D41100A4D465 /* FirebaseAuth */ = { + isa = XCSwiftPackageProductDependency; + package = 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseAuth; + }; + 4EA8081F2AA1D41100A4D465 /* FirebaseDatabase */ = { + isa = XCSwiftPackageProductDependency; + package = 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseDatabase; + }; + 4EA808212AA1D41100A4D465 /* FirebaseFirestore */ = { + isa = XCSwiftPackageProductDependency; + package = 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseFirestore; + }; + 4EA808232AA1D41100A4D465 /* FirebaseStorage */ = { + isa = XCSwiftPackageProductDependency; + package = 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseStorage; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 4E98A3832A9CA57B003052D3 /* Project object */; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 009c162..49740e1 100644 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,104 @@ { "pins" : [ + { + "identity" : "abseil-cpp-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/abseil-cpp-binary.git", + "state" : { + "revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c", + "version" : "1.2022062300.0" + } + }, + { + "identity" : "firebase-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/firebase-ios-sdk.git", + "state" : { + "revision" : "2bfe6abe1014aafe5cf28401708f7d39f9926a76", + "version" : "10.14.0" + } + }, + { + "identity" : "googleappmeasurement", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleAppMeasurement.git", + "state" : { + "revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b", + "version" : "10.13.0" + } + }, + { + "identity" : "googledatatransport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleDataTransport.git", + "state" : { + "revision" : "aae45a320fd0d11811820335b1eabc8753902a40", + "version" : "9.2.5" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "c38ce365d77b04a9a300c31061c5227589e5597b", + "version" : "7.11.5" + } + }, + { + "identity" : "grpc-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/grpc-binary.git", + "state" : { + "revision" : "f1b366129d1125be7db83247e003fc333104b569", + "version" : "1.50.2" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd", + "version" : "3.1.1" + } + }, + { + "identity" : "interop-ios-for-google-sdks", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/interop-ios-for-google-sdks.git", + "state" : { + "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", + "version" : "100.0.0" + } + }, + { + "identity" : "leveldb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/leveldb.git", + "state" : { + "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", + "version" : "1.22.2" + } + }, + { + "identity" : "nanopb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/nanopb.git", + "state" : { + "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", + "version" : "2.30909.0" + } + }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", + "version" : "2.3.1" + } + }, { "identity" : "snapkit", "kind" : "remoteSourceControl", @@ -8,6 +107,15 @@ "revision" : "f222cbdf325885926566172f6f5f06af95473158", "version" : "5.6.0" } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d", + "version" : "1.23.0" + } } ], "version" : 2 diff --git a/DiaryApp/Resources/AppDelegate.swift b/DiaryApp/Resources/AppDelegate.swift index 580f229..4ebf13a 100644 --- a/DiaryApp/Resources/AppDelegate.swift +++ b/DiaryApp/Resources/AppDelegate.swift @@ -7,6 +7,7 @@ import UIKit + @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { From 116ea1b736372ac20c58332d502f39e7a034b346 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 17:16:47 +0900 Subject: [PATCH 37/50] =?UTF-8?q?[FEAT]:=20=ED=8C=8C=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=EB=B2=A0=EC=9D=B4=EC=8A=A4=20=EC=97=B0=EB=8F=99=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 4 ++++ DiaryApp/GoogleService-Info.plist | 34 ++++++++++++++++++++++++++++ DiaryApp/Resources/AppDelegate.swift | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 DiaryApp/GoogleService-Info.plist diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 2df2414..bfae310 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA8081F2AA1D41100A4D465 /* FirebaseDatabase */; }; 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808212AA1D41100A4D465 /* FirebaseFirestore */; }; 4EA808242AA1D41100A4D465 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808232AA1D41100A4D465 /* FirebaseStorage */; }; + 4EA808262AA1D46800A4D465 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */; }; FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; /* End PBXBuildFile section */ @@ -70,6 +71,7 @@ 4E98A3B92A9CAD60003052D3 /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCollectionView.swift; sourceTree = ""; }; 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomImageView.swift; sourceTree = ""; }; + 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCalendarViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -126,6 +128,7 @@ 4E98A3B42A9CA7AD003052D3 /* Views */, 4E98A3A42A9CA638003052D3 /* Controllers */, 4E98A39C2A9CA57E003052D3 /* Info.plist */, + 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */, ); path = DiaryApp; sourceTree = ""; @@ -251,6 +254,7 @@ files = ( 4E98A3982A9CA57E003052D3 /* Assets.xcassets in Resources */, 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */, + 4EA808262AA1D46800A4D465 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/DiaryApp/GoogleService-Info.plist b/DiaryApp/GoogleService-Info.plist new file mode 100644 index 0000000..128a083 --- /dev/null +++ b/DiaryApp/GoogleService-Info.plist @@ -0,0 +1,34 @@ + + + + + CLIENT_ID + 362176913792-tda207b6l1e87ifhcll7sm23qt1f1v7c.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.362176913792-tda207b6l1e87ifhcll7sm23qt1f1v7c + API_KEY + AIzaSyBCu5uLGUJ_eru0wsQOJNulDzFskaFLHOM + GCM_SENDER_ID + 362176913792 + PLIST_VERSION + 1 + BUNDLE_ID + com.Junwoo.Momo8282.DiaryApp + PROJECT_ID + diaryapp-90713 + STORAGE_BUCKET + diaryapp-90713.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:362176913792:ios:523d7a190b449e2d006165 + + \ No newline at end of file diff --git a/DiaryApp/Resources/AppDelegate.swift b/DiaryApp/Resources/AppDelegate.swift index 4ebf13a..f86fe25 100644 --- a/DiaryApp/Resources/AppDelegate.swift +++ b/DiaryApp/Resources/AppDelegate.swift @@ -5,12 +5,13 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import FirebaseCore import UIKit - @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + FirebaseApp.configure() return true } From 99fc0d17ccf15e5d4030755ac284e386555ed0c5 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 17:38:43 +0900 Subject: [PATCH 38/50] =?UTF-8?q?[MERGE]:=20Feature/NewDiaryVC=20=EB=B3=91?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiaryCalenderViewController.swift | 15 ++ .../DiaryProgressViewController.swift | 1 + DiaryApp/Controllers/HomeViewController.swift | 20 +- .../Controllers/NewDiaryViewController.swift | 175 +++++++++++++++++- DiaryApp/Resources/SceneDelegate.swift | 21 ++- 5 files changed, 212 insertions(+), 20 deletions(-) create mode 100644 DiaryApp/Controllers/DiaryCalenderViewController.swift diff --git a/DiaryApp/Controllers/DiaryCalenderViewController.swift b/DiaryApp/Controllers/DiaryCalenderViewController.swift new file mode 100644 index 0000000..41e69b3 --- /dev/null +++ b/DiaryApp/Controllers/DiaryCalenderViewController.swift @@ -0,0 +1,15 @@ +// +// DiaryCalenderViewController.swift +// DiaryApp +// +// Created by (^ㅗ^)7 iMac on 2023/08/28. +// + +import UIKit + +class DiaryCalenderViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .systemBackground + } +} diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 35e523c..502d4e9 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -84,5 +84,6 @@ extension DiaryProgressViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { return 10 + } } diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 76ba51e..1d1bd2f 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -11,11 +11,11 @@ import UIKit enum Const { static let itemSize = CGSize(width: 300, height: 550) static let itemSpacing = 46.0 - + static var insetX: CGFloat { (UIScreen.main.bounds.width - Self.itemSize.width) / 2.0 } - + static var collectionViewContentInset: UIEdgeInsets { UIEdgeInsets(top: 0, left: Self.insetX, bottom: 0, right: Self.insetX) } @@ -23,7 +23,7 @@ enum Const { class HomeViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground @@ -31,7 +31,7 @@ class HomeViewController: UIViewController { configureLayout() addSearchBar() } - + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal @@ -40,12 +40,12 @@ class HomeViewController: UIViewController { layout.minimumInteritemSpacing = 0 return layout }() - + private func configureCollectionView() { collectionView.register(HomeFeedCell.self, forCellWithReuseIdentifier: HomeFeedCell.identifier) collectionView.delegate = self collectionView.dataSource = self - + collectionView.isScrollEnabled = true collectionView.showsHorizontalScrollIndicator = false collectionView.showsVerticalScrollIndicator = true @@ -56,10 +56,10 @@ class HomeViewController: UIViewController { collectionView.contentInsetAdjustmentBehavior = .never collectionView.contentInset = Const.collectionViewContentInset collectionView.decelerationRate = .fast - + collectionView.collectionViewLayout = collectionViewFlowLayout } - + private func configureLayout() { view.addSubview(collectionView) @@ -68,7 +68,7 @@ class HomeViewController: UIViewController { make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-20) } } - + private func addSearchBar() { let searchController = UISearchController(searchResultsController: nil) searchController.hidesNavigationBarDuringPresentation = false @@ -82,7 +82,7 @@ extension HomeViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 3 } - + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeFeedCell.identifier, for: indexPath) as? HomeFeedCell else { return UICollectionViewCell() } cell.backgroundColor = .systemOrange diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index d0092ba..b20b82f 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -5,11 +5,184 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import SnapKit import UIKit class NewDiaryViewController: UIViewController { + let options = ["운동", "식단", "헬스", "크로스핏", "양배추", "닭가슴살", "닭안심살"] + var selectedButton: UIButton? + lazy var pickerView: UIPickerView = { + let pickerView = UIPickerView() + pickerView.delegate = self + pickerView.dataSource = self + return pickerView + }() + + lazy var pickImageButton: UIButton = { + let button = UIButton(type: .system) + button.setImage(UIImage(systemName: "camera"), for: .normal) + button.addTarget(self, action: #selector(pickImage), for: .touchUpInside) + return button + }() + + lazy var textView: UITextView = { + let textView = UITextView() + textView.text = "입력하시요" + textView.layer.borderWidth = 1.0 + textView.layer.borderColor = UIColor.lightGray.cgColor + textView.layer.cornerRadius = 5.0 + return textView + }() + + lazy var button1: UIButton = { + let button = UIButton(type: .system) + button.setTitle("Button 1", for: .normal) + button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + return button + }() + + lazy var button2: UIButton = { + let button = UIButton(type: .system) + button.setTitle("운동", for: .normal) + button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + return button + }() + + lazy var button3: UIButton = { + let button = UIButton(type: .system) + button.setTitle("건강", for: .normal) + button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + return button + }() + + lazy var button4: UIButton = { + let button = UIButton(type: .system) + button.setTitle("식단", for: .normal) + button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + return button + }() + override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemBackground + view.backgroundColor = .white + view.addSubview(pickImageButton) + view.addSubview(textView) + view.addSubview(button1) + view.addSubview(button2) + view.addSubview(button3) + view.addSubview(button4) + pickImageButton.snp.makeConstraints { make in + make.centerX.equalToSuperview() + // make.centerY.equalToSuperview() + } + textView.snp.makeConstraints { make in + make.top.equalTo(pickImageButton.snp.bottom).offset(100) + make.leading.trailing.equalToSuperview().inset(20) + make.bottom.equalTo(view.safeAreaLayoutGuide).inset(200) + make.height.equalTo(button1).offset(100) + } + button1.snp.makeConstraints { make in + make.bottom.equalTo(textView.snp.bottom).offset(20) + make.trailing.equalTo(textView).inset(20) + make.top.equalTo(textView).offset(150) + } + button2.snp.makeConstraints { make in + make.top.equalTo(button1.snp.bottom).offset(20) + make.leading.equalTo(button1) + } + button3.snp.makeConstraints { make in + make.top.equalTo(button1.snp.bottom).offset(20) + make.leading.equalTo(button2.snp.leading).offset(-100) + } + button4.snp.makeConstraints { make in + make.top.equalTo(button1.snp.bottom).offset(20) + make.leading.equalTo(button2.snp.leading).offset(-200) + } + } + + @objc func button1Tapped() { + presentAlertWithPicker(for: button1) + } + + @objc func button2Tapped() { + presentAlertWithPicker(for: button2) + } + + @objc func button3Tapped() { + presentAlertWithPicker(for: button3) + } + + @objc func button4Tapped() { + presentAlertWithPicker(for: button4) + } + + func presentAlertWithPicker(for button: UIButton) { + selectedButton = button + let alertController = UIAlertController(title: "Select", message: nil, preferredStyle: .alert) + alertController.addTextField { textField in + textField.inputView = self.pickerView + } + let confirmAction = UIAlertAction(title: "수정", style: .default) { [weak self] _ in + guard let self = self else { return } + let textField = alertController.textFields?.first + if textField?.inputView == self.pickerView { + let selectedRow = self.pickerView.selectedRow(inComponent: 0) + let selectedOption = self.options[selectedRow] + button.setTitle(selectedOption, for: .normal) + } else { + // Handle custom input from text field + if let customInput = textField?.text, !customInput.isEmpty { + button.setTitle(customInput, for: .normal) + } + } + self.selectedButton = nil + } + let cancelAction = UIAlertAction(title: "취소", style: .cancel) { _ in + self.selectedButton = nil + } + alertController.addAction(confirmAction) + alertController.addAction(cancelAction) + present(alertController, animated: true, completion: nil) + } +} + +extension NewDiaryViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + @objc func pickImage() { + showImagePicker() + } + + func showImagePicker() { + let imagePicker = UIImagePickerController() + imagePicker.delegate = self + imagePicker.sourceType = .photoLibrary + present(imagePicker, animated: true, completion: nil) + } + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) { + picker.dismiss(animated: true, completion: nil) + if let selectedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { + let imageView = UIImageView(image: selectedImage) + imageView.contentMode = .scaleAspectFit + view.addSubview(imageView) + imageView.snp.makeConstraints { make in + make.centerX.equalTo(pickImageButton) + make.centerY.equalTo(pickImageButton) + make.width.height.equalTo(300) + } + } + } +} + +extension NewDiaryViewController: UIPickerViewDelegate, UIPickerViewDataSource { + func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 1 + } + + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return options.count + } + + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return options[row] } } diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index 298ead0..e86883f 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -9,41 +9,44 @@ import UIKit class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } window = UIWindow(windowScene: windowScene) window?.makeKeyAndVisible() - + let tabBarController = TabBarController() - + let tabs: [(root: UIViewController, icon: String)] = [ (HomeViewController(), "house"), (DiaryListViewController(), "list.bullet"), (NewDiaryViewController(), "plus.square"), (DiaryProgressViewController(), "tag"), (ProfileViewController(), "person"), + (DiaryProgressViewController(), "tag"), + (ProfileViewController(), "person"), ] + tabBarController.setViewControllers(tabs.map { root, icon in let navigationController = UINavigationController(rootViewController: root) let tabBarItem = UITabBarItem(title: nil, image: .init(systemName: icon), selectedImage: .init(systemName: "\(icon).fill")) navigationController.tabBarItem = tabBarItem return navigationController }, animated: false) - + tabBarController.tabBar.tintColor = .label tabBarController.tabBar.backgroundColor = .systemBackground window?.rootViewController = tabBarController } - + func sceneDidDisconnect(_ scene: UIScene) {} - + func sceneDidBecomeActive(_ scene: UIScene) {} - + func sceneWillResignActive(_ scene: UIScene) {} - + func sceneWillEnterForeground(_ scene: UIScene) {} - + func sceneDidEnterBackground(_ scene: UIScene) {} } From 616ba0c69417580203d54c9470b96569a16bb260 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Fri, 1 Sep 2023 17:41:06 +0900 Subject: [PATCH 39/50] =?UTF-8?q?[REMOVE]:=20DirayCalenderViewController?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DiaryCalenderViewController.swift | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 DiaryApp/Controllers/DiaryCalenderViewController.swift diff --git a/DiaryApp/Controllers/DiaryCalenderViewController.swift b/DiaryApp/Controllers/DiaryCalenderViewController.swift deleted file mode 100644 index 41e69b3..0000000 --- a/DiaryApp/Controllers/DiaryCalenderViewController.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// DiaryCalenderViewController.swift -// DiaryApp -// -// Created by (^ㅗ^)7 iMac on 2023/08/28. -// - -import UIKit - -class DiaryCalenderViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = .systemBackground - } -} From 5ca72895c245b3761db905e9d458ca1c404eb50a Mon Sep 17 00:00:00 2001 From: p2glet Date: Fri, 1 Sep 2023 21:52:23 +0900 Subject: [PATCH 40/50] [FEAT] : created FirestoreManager --- DiaryApp/Models/Post.swift | 28 ++++++++++ DiaryApp/Network/FirestoreManager.swift | 71 +++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 DiaryApp/Models/Post.swift create mode 100644 DiaryApp/Network/FirestoreManager.swift diff --git a/DiaryApp/Models/Post.swift b/DiaryApp/Models/Post.swift new file mode 100644 index 0000000..4d9720c --- /dev/null +++ b/DiaryApp/Models/Post.swift @@ -0,0 +1,28 @@ +// +// Post.swift +// DiaryApp +// +// Created by t2023-m0056 on 2023/09/01. +// + +import Foundation + +struct Post: Codable { + var content: String? + var goal: String? + var image: String? + var tag: Array + var temperature: String + var weather: String + var weatherIcon: String + + enum CodingKeys: String, CodingKey { + case content + case goal + case image + case tag + case temperature + case weather + case weatherIcon + } +} diff --git a/DiaryApp/Network/FirestoreManager.swift b/DiaryApp/Network/FirestoreManager.swift new file mode 100644 index 0000000..5e6060e --- /dev/null +++ b/DiaryApp/Network/FirestoreManager.swift @@ -0,0 +1,71 @@ +// +// FirestoreManager.swift +// DiaryApp +// +// Created by t2023-m0056 on 2023/09/01. +// + +import Foundation +import FirebaseFirestore + +final class FirestoreService { + let db = Firestore.firestore() + + func getPostData(completion: @escaping ([Post]?) -> Void) { + var names: [[String:Any]] = [[:]] + var post: [Post]? + + db.collection("Post").getDocuments { (querySnapshot, error) in + if let error = error { + print("Error getting documents: \(error)") + completion(post) // 호출하는 쪽에 빈 배열 전달 + return + } + for document in querySnapshot!.documents { + names.append(document.data()) + } + names.remove(at: 0) + post = self.dictionaryToObject(objectType: Post.self, dictionary: names) + completion(post) // 성공 시 이름 배열 전달 + } + } + + func addPostDocument(content: String, goal: String, image: String, tag: Array, temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { + // Add a new document with a generated ID + db.collection("Info").document(goal).setData([ + "content": content, + "goal": goal, + "image": image, + "tag": tag, + "temperature": temperature, + "weather": weather, + "weatherIcon": weatherIcon, + ]) { err in + if let err = err { + print("Error adding document: \(err)") + } else { + completion("Post Document added") + } + } + } +} + +extension FirestoreService { + func dictionaryToObject(objectType:T.Type,dictionary:[[String:Any]]) -> [T]? { + + guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } + let decoder = JSONDecoder() + decoder.keyDecodingStrategy = .convertFromSnakeCase + guard let objects = try? decoder.decode([T].self, from: dictionaries) else { return nil } + return objects + } + + func dicToObject(objectType:T.Type,dictionary:[String:Any]) -> T? { + + guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } + let decoder = JSONDecoder() + decoder.keyDecodingStrategy = .convertFromSnakeCase + guard let objects = try? decoder.decode(T.self, from: dictionaries) else { return nil } + return objects + } +} From df2518c15cf686a594769fc54d3e10bb510b2431 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Sun, 3 Sep 2023 22:14:58 +0900 Subject: [PATCH 41/50] =?UTF-8?q?[MERGE]:=20feature/firebase-operation=20?= =?UTF-8?q?=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 34 ++++ .../xcshareddata/swiftpm/Package.resolved | 9 + .../DiaryCalendarViewController.swift | 79 ++++---- .../Controllers/DiaryListViewController.swift | 5 +- DiaryApp/Controllers/HomeViewController.swift | 40 +++- .../Controllers/NewDiaryViewController.swift | 181 ++++++++++-------- .../ProgressListViewController.swift | 32 +++- DiaryApp/Network/FirestoreManager.swift | 38 ++++ DiaryApp/Views/Cells/DiaryListCell.swift | 9 +- DiaryApp/Views/Cells/HomeFeedCell.swift | 11 +- DiaryApp/Views/Cells/ProgressListCell.swift | 10 +- 11 files changed, 309 insertions(+), 139 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index bfae310..85852d5 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -18,6 +18,9 @@ 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */; }; 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */; }; 4E7A150A2AA0C11E005FCD9C /* HomeFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */; }; + 4E97E6C72AA37FDD00DD4C1F /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E97E6C62AA37FDC00DD4C1F /* Post.swift */; }; + 4E97E6CA2AA390A600DD4C1F /* FirestoreManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E97E6C92AA390A600DD4C1F /* FirestoreManager.swift */; }; + 4E97E6CD2AA39F7600DD4C1F /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */; }; 4E98A38F2A9CA57B003052D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */; }; 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */; }; 4E98A3932A9CA57B003052D3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E98A3922A9CA57B003052D3 /* TabBarController.swift */; }; @@ -53,6 +56,8 @@ 4E7A15032AA0A9C8005FCD9C /* ProgressListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressListCell.swift; sourceTree = ""; }; 4E7A15052AA0BFA1005FCD9C /* ProgressTagCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressTagCell.swift; sourceTree = ""; }; 4E7A15092AA0C11E005FCD9C /* HomeFeedCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeFeedCell.swift; sourceTree = ""; }; + 4E97E6C62AA37FDC00DD4C1F /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = ""; }; + 4E97E6C92AA390A600DD4C1F /* FirestoreManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirestoreManager.swift; sourceTree = ""; }; 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiaryApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E98A38E2A9CA57B003052D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4E98A3902A9CA57B003052D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -80,6 +85,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4E97E6CD2AA39F7600DD4C1F /* Kingfisher in Frameworks */, 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */, 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */, 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, @@ -104,6 +110,15 @@ path = Cells; sourceTree = ""; }; + 4E97E6C82AA390A600DD4C1F /* Network */ = { + isa = PBXGroup; + children = ( + 4E97E6C92AA390A600DD4C1F /* FirestoreManager.swift */, + ); + name = Network; + path = DiaryApp/Network; + sourceTree = SOURCE_ROOT; + }; 4E98A3822A9CA57B003052D3 = { isa = PBXGroup; children = ( @@ -127,6 +142,7 @@ 4E98A3B32A9CA795003052D3 /* Models */, 4E98A3B42A9CA7AD003052D3 /* Views */, 4E98A3A42A9CA638003052D3 /* Controllers */, + 4E97E6C82AA390A600DD4C1F /* Network */, 4E98A39C2A9CA57E003052D3 /* Info.plist */, 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */, ); @@ -153,6 +169,7 @@ 4E98A3B32A9CA795003052D3 /* Models */ = { isa = PBXGroup; children = ( + 4E97E6C62AA37FDC00DD4C1F /* Post.swift */, 4E98A3B72A9CAD27003052D3 /* User.swift */, 4E98A3B92A9CAD60003052D3 /* Weather.swift */, ); @@ -205,6 +222,7 @@ 4EA8081F2AA1D41100A4D465 /* FirebaseDatabase */, 4EA808212AA1D41100A4D465 /* FirebaseFirestore */, 4EA808232AA1D41100A4D465 /* FirebaseStorage */, + 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */, ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; @@ -237,6 +255,7 @@ packageReferences = ( 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, + 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */, ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; @@ -281,7 +300,9 @@ 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, + 4E97E6CA2AA390A600DD4C1F /* FirestoreManager.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, + 4E97E6C72AA37FDD00DD4C1F /* Post.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, 4E98A3B02A9CA762003052D3 /* DiaryProgressViewController.swift in Sources */, @@ -498,6 +519,14 @@ minimumVersion = 5.0.0; }; }; + 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/onevcat/Kingfisher.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 7.0.0; + }; + }; 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git"; @@ -514,6 +543,11 @@ package = 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */; productName = SnapKit; }; + 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */ = { + isa = XCSwiftPackageProductDependency; + package = 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */; + productName = Kingfisher; + }; 4EA8081D2AA1D41100A4D465 /* FirebaseAuth */ = { isa = XCSwiftPackageProductDependency; package = 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 49740e1..529c120 100644 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -72,6 +72,15 @@ "version" : "100.0.0" } }, + { + "identity" : "kingfisher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/onevcat/Kingfisher.git", + "state" : { + "revision" : "b6f62758f21a8c03cd64f4009c037cfa580a256e", + "version" : "7.9.1" + } + }, { "identity" : "leveldb", "kind" : "remoteSourceControl", diff --git a/DiaryApp/Controllers/DiaryCalendarViewController.swift b/DiaryApp/Controllers/DiaryCalendarViewController.swift index 581e77c..b2820b5 100644 --- a/DiaryApp/Controllers/DiaryCalendarViewController.swift +++ b/DiaryApp/Controllers/DiaryCalendarViewController.swift @@ -5,15 +5,15 @@ // Created by t2023-m0056 on 2023/08/31. // -import UIKit import SnapKit +import UIKit @available(iOS 16.0, *) class DiaryCalendarViewController: UIViewController { - // MARK: - BottomSheet + // 바텀 시트 높이 - var bottomHeight: CGFloat = 620 + var bottomHeight: CGFloat = 650 // bottomSheet가 view의 상단에서 떨어진 거리 private var bottomSheetViewTopConstraint: NSLayoutConstraint! @@ -21,7 +21,7 @@ class DiaryCalendarViewController: UIViewController { // 기존 화면을 흐려지게 만들기 위한 뷰 private let dimmedBackView: UIView = { let view = UIView() - view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5) + view.backgroundColor = .clear return view }() @@ -52,8 +52,8 @@ class DiaryCalendarViewController: UIViewController { var purposeTextField: UITextField = { var textField = UITextField() let centeredParagraphStyle = NSMutableParagraphStyle() - centeredParagraphStyle.alignment = .center - textField.attributedPlaceholder = NSAttributedString(string: "목표", attributes:[NSAttributedString.Key.foregroundColor : UIColor.black, NSAttributedString.Key.paragraphStyle: centeredParagraphStyle]) + centeredParagraphStyle.alignment = .center + textField.attributedPlaceholder = NSAttributedString(string: "목표", attributes: [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.paragraphStyle: centeredParagraphStyle]) textField.layer.cornerRadius = 10 textField.layer.borderWidth = 1 return textField @@ -63,7 +63,7 @@ class DiaryCalendarViewController: UIViewController { var checkedEverDay = false, checkedThreeDays = false, checkedFiveDays = false, checkedEverWeek = false - var sundayBtn = UIButton() ,mondayBtn = UIButton(), tuesdayBtn = UIButton(), wednesdayBtn = UIButton(), thursdayBtn = UIButton(), fridayBtn = UIButton(), saturdayBtn = UIButton() + var sundayBtn = UIButton(), mondayBtn = UIButton(), tuesdayBtn = UIButton(), wednesdayBtn = UIButton(), thursdayBtn = UIButton(), fridayBtn = UIButton(), saturdayBtn = UIButton() var checkedSunday = false, checkedMonday = false, checkedTuesday = false, checkedWednesday = false, checkedThursday = false, checkedFridaay = false, checkedSaturday = false @@ -91,7 +91,7 @@ class DiaryCalendarViewController: UIViewController { var view = UIStackView() view.axis = .vertical view.spacing = 10 - view.snp.makeConstraints{ + view.snp.makeConstraints { $0.height.equalTo(120) } return view @@ -101,24 +101,25 @@ class DiaryCalendarViewController: UIViewController { var view = UIStackView(arrangedSubviews: [self.everyDayBtn, self.threeDaysBtn, self.fiveDaysBtn, self.everyWeekBtn]) view.axis = .horizontal view.distribution = .equalSpacing - view.snp.makeConstraints{ + view.snp.makeConstraints { $0.height.equalTo(50) } return view }() lazy var dayStackView = { - let view = UIStackView(arrangedSubviews: [self.sundayBtn,self.mondayBtn,self.tuesdayBtn,self.wednesdayBtn,self.thursdayBtn,self.fridayBtn,self.saturdayBtn]) + let view = UIStackView(arrangedSubviews: [self.sundayBtn, self.mondayBtn, self.tuesdayBtn, self.wednesdayBtn, self.thursdayBtn, self.fridayBtn, self.saturdayBtn]) view.axis = .horizontal view.distribution = .equalSpacing view.isHidden = true - view.snp.makeConstraints{ + view.snp.makeConstraints { $0.height.equalTo(40) } return view }() - + // MARK: - View Life Cycle + override func viewDidLoad() { super.viewDidLoad() @@ -136,6 +137,7 @@ class DiaryCalendarViewController: UIViewController { } // MARK: - @Functions + func configurationView() { setupUI() setupLayout() @@ -182,7 +184,7 @@ class DiaryCalendarViewController: UIViewController { // 레이아웃 세팅 private func setupLayout() { - dimmedBackView.snp.makeConstraints{ + dimmedBackView.snp.makeConstraints { $0.top.equalTo(view.safeAreaLayoutGuide.snp.top) $0.leading.equalTo(view.safeAreaLayoutGuide.snp.leading) $0.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing) @@ -192,14 +194,14 @@ class DiaryCalendarViewController: UIViewController { bottomSheetView.translatesAutoresizingMaskIntoConstraints = false let topConstant = view.safeAreaInsets.bottom + view.safeAreaLayoutGuide.layoutFrame.height bottomSheetViewTopConstraint = bottomSheetView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: topConstant) - bottomSheetView.snp.makeConstraints{ + bottomSheetView.snp.makeConstraints { $0.leading.equalTo(view.safeAreaLayoutGuide.snp.leading) $0.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing) - $0.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom) + $0.bottom.equalTo(view) } bottomSheetViewTopConstraint.isActive = true - dismissIndicatorView.snp.makeConstraints{ + dismissIndicatorView.snp.makeConstraints { $0.width.equalTo(102) $0.height.equalTo(7) $0.top.equalTo(bottomSheetView.snp.top).inset(12) @@ -209,7 +211,7 @@ class DiaryCalendarViewController: UIViewController { func setDateView() { bottomSheetView.addSubview(dateView) - dateView.snp.makeConstraints{ + dateView.snp.makeConstraints { $0.top.equalToSuperview().inset(10) $0.leading.equalToSuperview().inset(10) $0.trailing.equalToSuperview().inset(10) @@ -217,10 +219,10 @@ class DiaryCalendarViewController: UIViewController { } func reloadDateView(date: Date?) { - if date == nil { return } - let calendar = Calendar.current - dateView.reloadDecorations(forDateComponents: [calendar.dateComponents([.day, .month, .year], from: date!)], animated: true) - } + if date == nil { return } + let calendar = Calendar.current + dateView.reloadDecorations(forDateComponents: [calendar.dateComponents([.day, .month, .year], from: date!)], animated: true) + } func setPurposeTitle() { bottomSheetView.addSubview(purposeTextField) @@ -244,61 +246,63 @@ class DiaryCalendarViewController: UIViewController { } // MARK: - IntervalBtn + func setEveryDayBtn() { - self.setIntervalBtn("매일", everyDayBtn) + setIntervalBtn("매일", everyDayBtn) everyDayBtn.addTarget(self, action: #selector(clickedEveryDay), for: .touchUpInside) } func setThreeDaysBtn() { - self.setIntervalBtn("3일", threeDaysBtn) + setIntervalBtn("3일", threeDaysBtn) threeDaysBtn.addTarget(self, action: #selector(clickedThreeDays), for: .touchUpInside) } func setFiveDaysBtn() { - self.setIntervalBtn("5일", fiveDaysBtn) + setIntervalBtn("5일", fiveDaysBtn) fiveDaysBtn.addTarget(self, action: #selector(clickedFiveDays), for: .touchUpInside) } func setEveryWeekBtn() { - self.setIntervalBtn("매주", everyWeekBtn) + setIntervalBtn("매주", everyWeekBtn) everyWeekBtn.addTarget(self, action: #selector(clickedEveryWeek), for: .touchUpInside) } // MARK: - DaysBtn + func setSundayBtn() { - self.setDayBtn("일", self.sundayBtn) + setDayBtn("일", sundayBtn) sundayBtn.layer.borderColor = UIColor.red.cgColor sundayBtn.setTitleColor(.red, for: .normal) sundayBtn.addTarget(self, action: #selector(clickedSunday), for: .touchUpInside) } func setMondayBtn() { - self.setDayBtn("월", self.mondayBtn) + setDayBtn("월", mondayBtn) mondayBtn.addTarget(self, action: #selector(clickedMonday), for: .touchUpInside) } func setTuesdayBtn() { - self.setDayBtn("화", self.tuesdayBtn) + setDayBtn("화", tuesdayBtn) tuesdayBtn.addTarget(self, action: #selector(clickedTuesday), for: .touchUpInside) } func setWednesdayBtn() { - self.setDayBtn("수", self.wednesdayBtn) + setDayBtn("수", wednesdayBtn) wednesdayBtn.addTarget(self, action: #selector(clickedWednesday), for: .touchUpInside) } func setThursdayBtn() { - self.setDayBtn("목", self.thursdayBtn) + setDayBtn("목", thursdayBtn) thursdayBtn.addTarget(self, action: #selector(clickedThursday), for: .touchUpInside) } func setFridayBtn() { - self.setDayBtn("금", self.fridayBtn) + setDayBtn("금", fridayBtn) fridayBtn.addTarget(self, action: #selector(clickedFriday), for: .touchUpInside) } func setSaturdayBtn() { - self.setDayBtn("토", self.saturdayBtn) + setDayBtn("토", saturdayBtn) saturdayBtn.layer.borderColor = UIColor.blue.cgColor saturdayBtn.setTitleColor(.blue, for: .normal) saturdayBtn.addTarget(self, action: #selector(clickedSaturday), for: .touchUpInside) @@ -310,7 +314,7 @@ class DiaryCalendarViewController: UIViewController { $0.top.equalTo(totalStackView.snp.bottom).inset(-10) $0.leading.equalToSuperview().inset(10) $0.trailing.equalToSuperview().inset(10) - $0.bottom.equalToSuperview() + $0.bottom.equalToSuperview().inset(50) $0.height.equalTo(50) } saveBtn.addTarget(self, action: #selector(clickedSaveBtn), for: .touchUpInside) @@ -321,7 +325,7 @@ class DiaryCalendarViewController: UIViewController { btn.setTitleColor(.black, for: .normal) btn.layer.cornerRadius = 10 btn.layer.borderWidth = 1 - btn.snp.makeConstraints{ + btn.snp.makeConstraints { $0.width.equalTo(80) } } @@ -331,7 +335,7 @@ class DiaryCalendarViewController: UIViewController { btn.setTitleColor(.black, for: .normal) btn.layer.cornerRadius = 10 btn.layer.borderWidth = 1 - btn.snp.makeConstraints{ + btn.snp.makeConstraints { $0.width.equalTo(40) } } @@ -365,6 +369,7 @@ class DiaryCalendarViewController: UIViewController { } // MARK: - @objc + @objc func clickedEveryDay() { everyDayBtn.backgroundColor = checkedEverDay ? .white : .black everyDayBtn.setTitleColor(checkedEverDay ? .black : .white, for: .normal) @@ -389,7 +394,7 @@ class DiaryCalendarViewController: UIViewController { checkedEverWeek = !checkedEverWeek dayStackView.isHidden = !dayStackView.isHidden - bottomHeight = (dayStackView.isHidden == false) ? 660 : 620 + bottomHeight = (dayStackView.isHidden == false) ? 700 : 650 showBottomSheet() } @@ -436,7 +441,7 @@ class DiaryCalendarViewController: UIViewController { } @objc func clickedSaveBtn() { - //save + // save } // UITapGestureRecognizer 연결 함수 부분 diff --git a/DiaryApp/Controllers/DiaryListViewController.swift b/DiaryApp/Controllers/DiaryListViewController.swift index 92bcb12..b5bb80a 100644 --- a/DiaryApp/Controllers/DiaryListViewController.swift +++ b/DiaryApp/Controllers/DiaryListViewController.swift @@ -66,8 +66,8 @@ extension DiaryListViewController: UICollectionViewDataSource { cell.startDayLabel.text = "2023.08.30" cell.endDayLabel.text = "2023.09.30" - cell.backgroundColor = .systemPink - cell.collectionView.backgroundColor = .systemBlue + cell.layer.borderWidth = 1 + cell.layer.borderColor = UIColor.black.cgColor cell.collectionView.layer.cornerRadius = 10 cell.layer.cornerRadius = 20 return cell @@ -86,7 +86,6 @@ extension DiaryListViewController: UICollectionViewDelegateFlowLayout { let interItemSpacing: CGFloat = 10 let padding: CGFloat = 10 let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) - print("### \(width)") let height = width / 3 return CGSize(width: width, height: height) } diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 1d1bd2f..670c287 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -5,6 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import Kingfisher import SnapKit import UIKit @@ -13,17 +14,19 @@ enum Const { static let itemSpacing = 46.0 static var insetX: CGFloat { - (UIScreen.main.bounds.width - Self.itemSize.width) / 2.0 + (UIScreen.main.bounds.width - itemSize.width) / 2.0 } static var collectionViewContentInset: UIEdgeInsets { - UIEdgeInsets(top: 0, left: Self.insetX, bottom: 0, right: Self.insetX) + UIEdgeInsets(top: 0, left: insetX, bottom: 0, right: insetX) } } class HomeViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + var postList = [Post]() + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground @@ -32,6 +35,10 @@ class HomeViewController: UIViewController { addSearchBar() } + override func viewWillAppear(_ animated: Bool) { + firebaseOperation() + } + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal @@ -41,11 +48,24 @@ class HomeViewController: UIViewController { return layout }() + private func firebaseOperation() { + FirestoreService().getPostData { post in + post?.forEach { _ in + guard let post = post else { return } + self.postList = post + + DispatchQueue.main.async { + self.collectionView.reloadData() + } + } + } + } + private func configureCollectionView() { collectionView.register(HomeFeedCell.self, forCellWithReuseIdentifier: HomeFeedCell.identifier) collectionView.delegate = self collectionView.dataSource = self - + collectionView.isScrollEnabled = true collectionView.showsHorizontalScrollIndicator = false collectionView.showsVerticalScrollIndicator = true @@ -59,7 +79,7 @@ class HomeViewController: UIViewController { collectionView.collectionViewLayout = collectionViewFlowLayout } - + private func configureLayout() { view.addSubview(collectionView) @@ -80,12 +100,20 @@ class HomeViewController: UIViewController { extension HomeViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 3 + return postList.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let item = postList[indexPath.row] guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeFeedCell.identifier, for: indexPath) as? HomeFeedCell else { return UICollectionViewCell() } - cell.backgroundColor = .systemOrange + if let image = item.image { + cell.myView.kf.setImage(with: URL(string: image)) + } + cell.weatherImage.image = UIImage(systemName: item.weatherIcon) + + + cell.layer.borderColor = UIColor.black.cgColor + cell.layer.borderWidth = 1 cell.layer.cornerRadius = 20 return cell } diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index b20b82f..ccf0a20 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -8,141 +8,166 @@ import SnapKit import UIKit -class NewDiaryViewController: UIViewController { - let options = ["운동", "식단", "헬스", "크로스핏", "양배추", "닭가슴살", "닭안심살"] +enum Options: String { + case exercise = "운동" + case food = "식단" + case healthy = "헬스" + case crossFit = "크로스핏" +} + +final class NewDiaryViewController: UIViewController { + let options: [Options] = [.exercise, .food, .healthy, .crossFit] + + var postList: [Post] = [] var selectedButton: UIButton? + lazy var pickerView: UIPickerView = { let pickerView = UIPickerView() pickerView.delegate = self pickerView.dataSource = self + return pickerView }() - lazy var pickImageButton: UIButton = { + private let pickImageButton: UIButton = { let button = UIButton(type: .system) button.setImage(UIImage(systemName: "camera"), for: .normal) button.addTarget(self, action: #selector(pickImage), for: .touchUpInside) + button.layer.cornerRadius = 20 + button.layer.borderWidth = 2 + button.layer.borderColor = UIColor.lightGray.cgColor return button }() lazy var textView: UITextView = { let textView = UITextView() - textView.text = "입력하시요" + textView.text = "내용을 입력하세요" textView.layer.borderWidth = 1.0 textView.layer.borderColor = UIColor.lightGray.cgColor - textView.layer.cornerRadius = 5.0 + textView.layer.cornerRadius = 10 + textView.contentInset = UIEdgeInsets(top: 5, left: 5, bottom: 0, right: 0) return textView }() - lazy var button1: UIButton = { + private let goalButton: UIButton = { let button = UIButton(type: .system) - button.setTitle("Button 1", for: .normal) - button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + button.setTitle("목표", for: .normal) + button.layer.borderWidth = 1 + button.layer.borderColor = UIColor.black.cgColor + button.layer.masksToBounds = true + button.layer.cornerRadius = 15 + button.translatesAutoresizingMaskIntoConstraints = false + button.addTarget(self, action: #selector(tappedGoalButton), for: .touchUpInside) return button }() - lazy var button2: UIButton = { + private let exercisButton: UIButton = { let button = UIButton(type: .system) + button.layer.borderWidth = 1 + button.layer.borderColor = UIColor.black.cgColor + button.layer.masksToBounds = true + button.layer.cornerRadius = 15 + button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("운동", for: .normal) - button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + button.addTarget(self, action: #selector(tappedHealthyButton), for: .touchUpInside) return button }() - lazy var button3: UIButton = { + private let healthyButton: UIButton = { let button = UIButton(type: .system) + button.layer.borderWidth = 1 + button.layer.borderColor = UIColor.black.cgColor + button.layer.masksToBounds = true + button.layer.cornerRadius = 15 + button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("건강", for: .normal) - button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + button.addTarget(self, action: #selector(tappedHealthyButton), for: .touchUpInside) return button }() - lazy var button4: UIButton = { + private let foodButton: UIButton = { let button = UIButton(type: .system) + button.layer.borderWidth = 1 + button.layer.borderColor = UIColor.black.cgColor + button.layer.masksToBounds = true + button.layer.cornerRadius = 15 + button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("식단", for: .normal) - button.addTarget(self, action: #selector(button1Tapped), for: .touchUpInside) + button.addTarget(self, action: #selector(tappedFoodButton), for: .touchUpInside) return button }() - override func viewDidLoad() { - super.viewDidLoad() + private func setupLayout() { view.backgroundColor = .white view.addSubview(pickImageButton) view.addSubview(textView) - view.addSubview(button1) - view.addSubview(button2) - view.addSubview(button3) - view.addSubview(button4) + view.addSubview(goalButton) + view.addSubview(exercisButton) + view.addSubview(healthyButton) + view.addSubview(foodButton) + pickImageButton.snp.makeConstraints { make in - make.centerX.equalToSuperview() - // make.centerY.equalToSuperview() + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(20) + make.bottom.equalTo(textView.snp.top).offset(-15) + make.height.equalTo(pickImageButton.snp.width) } + textView.snp.makeConstraints { make in make.top.equalTo(pickImageButton.snp.bottom).offset(100) make.leading.trailing.equalToSuperview().inset(20) - make.bottom.equalTo(view.safeAreaLayoutGuide).inset(200) - make.height.equalTo(button1).offset(100) + make.bottom.equalTo(view.safeAreaLayoutGuide).inset(100) } - button1.snp.makeConstraints { make in - make.bottom.equalTo(textView.snp.bottom).offset(20) - make.trailing.equalTo(textView).inset(20) - make.top.equalTo(textView).offset(150) + + goalButton.snp.makeConstraints { make in + make.trailing.equalTo(textView) + make.top.equalTo(textView.snp.bottom).offset(12) + make.width.equalTo(150) + make.height.equalTo(30) } - button2.snp.makeConstraints { make in - make.top.equalTo(button1.snp.bottom).offset(20) - make.leading.equalTo(button1) + + foodButton.snp.makeConstraints { make in + make.top.equalTo(goalButton.snp.bottom).offset(12) + make.leading.equalTo(textView.snp.leading) + make.width.equalTo(100) } - button3.snp.makeConstraints { make in - make.top.equalTo(button1.snp.bottom).offset(20) - make.leading.equalTo(button2.snp.leading).offset(-100) + + healthyButton.snp.makeConstraints { make in + make.top.equalTo(goalButton.snp.bottom).offset(12) + make.centerX.equalToSuperview() + make.width.equalTo(100) } - button4.snp.makeConstraints { make in - make.top.equalTo(button1.snp.bottom).offset(20) - make.leading.equalTo(button2.snp.leading).offset(-200) + + exercisButton.snp.makeConstraints { make in + make.top.equalTo(goalButton.snp.bottom).offset(12) + make.trailing.equalTo(textView.snp.trailing) + make.width.equalTo(100) } } - @objc func button1Tapped() { - presentAlertWithPicker(for: button1) + override func viewDidLoad() { + super.viewDidLoad() + setupLayout() } - @objc func button2Tapped() { - presentAlertWithPicker(for: button2) + @objc func tappedGoalButton() { + print("### \(#function)") + if #available(iOS 16.0, *) { + let vc = DiaryCalendarViewController() + vc.modalPresentationStyle = .automatic + self.present(vc, animated: true) + } } - @objc func button3Tapped() { - presentAlertWithPicker(for: button3) + @objc func tappedExerciseButton() { + print("### \(#function)") } - @objc func button4Tapped() { - presentAlertWithPicker(for: button4) + @objc func tappedHealthyButton() { + print("### \(#function)") } - func presentAlertWithPicker(for button: UIButton) { - selectedButton = button - let alertController = UIAlertController(title: "Select", message: nil, preferredStyle: .alert) - alertController.addTextField { textField in - textField.inputView = self.pickerView - } - let confirmAction = UIAlertAction(title: "수정", style: .default) { [weak self] _ in - guard let self = self else { return } - let textField = alertController.textFields?.first - if textField?.inputView == self.pickerView { - let selectedRow = self.pickerView.selectedRow(inComponent: 0) - let selectedOption = self.options[selectedRow] - button.setTitle(selectedOption, for: .normal) - } else { - // Handle custom input from text field - if let customInput = textField?.text, !customInput.isEmpty { - button.setTitle(customInput, for: .normal) - } - } - self.selectedButton = nil - } - let cancelAction = UIAlertAction(title: "취소", style: .cancel) { _ in - self.selectedButton = nil - } - alertController.addAction(confirmAction) - alertController.addAction(cancelAction) - present(alertController, animated: true, completion: nil) + @objc func tappedFoodButton() { + print("### \(#function)") } } @@ -162,12 +187,14 @@ extension NewDiaryViewController: UIImagePickerControllerDelegate, UINavigationC picker.dismiss(animated: true, completion: nil) if let selectedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { let imageView = UIImageView(image: selectedImage) - imageView.contentMode = .scaleAspectFit + imageView.layer.cornerRadius = 20 + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleToFill + imageView.layer.borderWidth = 1 + imageView.layer.borderColor = UIColor.lightGray.cgColor view.addSubview(imageView) imageView.snp.makeConstraints { make in - make.centerX.equalTo(pickImageButton) - make.centerY.equalTo(pickImageButton) - make.width.height.equalTo(300) + make.top.bottom.leading.trailing.equalTo(pickImageButton) } } } @@ -183,6 +210,6 @@ extension NewDiaryViewController: UIPickerViewDelegate, UIPickerViewDataSource { } func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return options[row] + return options[row].rawValue } } diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index fbf6fb3..3b48356 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -5,12 +5,15 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import Kingfisher import SnapKit import UIKit class ProgressListViewController: UIViewController { private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + var postList = [Post]() + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground @@ -18,6 +21,10 @@ class ProgressListViewController: UIViewController { configureLayout() } + override func viewWillAppear(_ animated: Bool) { + firebaseOperation() + } + private let collectionViewFlowLayout: UICollectionViewFlowLayout = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical @@ -27,6 +34,19 @@ class ProgressListViewController: UIViewController { return layout }() + private func firebaseOperation() { + FirestoreService().getPostData { post in + post?.forEach { _ in + guard let post = post else { return } + self.postList = post + + DispatchQueue.main.async { + self.collectionView.reloadData() + } + } + } + } + private func configureCollectionView() { collectionView.register(ProgressListCell.self, forCellWithReuseIdentifier: ProgressListCell.identifier) collectionView.dataSource = self @@ -57,15 +77,18 @@ class ProgressListViewController: UIViewController { extension ProgressListViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 7 + return postList.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let item = postList[indexPath.row] guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ProgressListCell.identifier, for: indexPath) as? ProgressListCell else { return UICollectionViewCell() } - cell.imageView.image = UIImage(systemName: "bell") + if let image = item.image { + cell.imageView.kf.setImage(with: URL(string: image)) + } cell.weatherImageView.image = UIImage(systemName: "sun.max") - cell.descriptionLabel.text = "오늘 하루 운동을 했는데 어쩌구 저쩌구 닭가슴살을 먹었는데 어쩌구 저쩌구 헬스장을 다녀왔는데 어쩌구 저꺼구" - + cell.descriptionLabel.text = item.content + cell.tagValue = [item.tag] cell.backgroundColor = .systemRed cell.layer.cornerRadius = 20 return cell @@ -77,7 +100,6 @@ extension ProgressListViewController: UICollectionViewDelegateFlowLayout { let interItemSpacing: CGFloat = 10 let padding: CGFloat = 10 let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) - print("### \(width)") let height = width / 3 return CGSize(width: width, height: height) } diff --git a/DiaryApp/Network/FirestoreManager.swift b/DiaryApp/Network/FirestoreManager.swift index 5e6060e..023e186 100644 --- a/DiaryApp/Network/FirestoreManager.swift +++ b/DiaryApp/Network/FirestoreManager.swift @@ -5,6 +5,7 @@ // Created by t2023-m0056 on 2023/09/01. // +<<<<<<< HEAD import Foundation import FirebaseFirestore @@ -16,6 +17,20 @@ final class FirestoreService { var post: [Post]? db.collection("Post").getDocuments { (querySnapshot, error) in +======= +import FirebaseFirestore +import Foundation + +final class FirestoreService { +// let db = Firestore.firestore() + static let db = Firestore.firestore() + + func getPostData(completion: @escaping ([Post]?) -> Void) { + var names: [[String: Any]] = [[:]] + var post: [Post]? + + FirestoreService.db.collection("Post").getDocuments { querySnapshot, error in +>>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) if let error = error { print("Error getting documents: \(error)") completion(post) // 호출하는 쪽에 빈 배열 전달 @@ -29,10 +44,17 @@ final class FirestoreService { completion(post) // 성공 시 이름 배열 전달 } } +<<<<<<< HEAD func addPostDocument(content: String, goal: String, image: String, tag: Array, temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { // Add a new document with a generated ID db.collection("Info").document(goal).setData([ +======= + + func addPostDocument(content: String, goal: String, image: String, tag: [String], temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { + // Add a new document with a generated ID + FirestoreService.db.collection("Post").document(goal).setData([ +>>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) "content": content, "goal": goal, "image": image, @@ -42,26 +64,42 @@ final class FirestoreService { "weatherIcon": weatherIcon, ]) { err in if let err = err { +<<<<<<< HEAD print("Error adding document: \(err)") } else { completion("Post Document added") +======= + print("### Error adding document: \(err)") + } else { + completion("#### Post Document added") + print("### 현재 Firebase 에 저장된 데이터들 : \(FirestoreService.db.collection("Info").document(goal))") +>>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) } } } } extension FirestoreService { +<<<<<<< HEAD func dictionaryToObject(objectType:T.Type,dictionary:[[String:Any]]) -> [T]? { +======= + func dictionaryToObject(objectType: T.Type, dictionary: [[String: Any]]) -> [T]? { +>>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase guard let objects = try? decoder.decode([T].self, from: dictionaries) else { return nil } return objects } +<<<<<<< HEAD func dicToObject(objectType:T.Type,dictionary:[String:Any]) -> T? { +======= + + func dicToObject(objectType: T.Type, dictionary: [String: Any]) -> T? { +>>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase diff --git a/DiaryApp/Views/Cells/DiaryListCell.swift b/DiaryApp/Views/Cells/DiaryListCell.swift index 81fbbd4..1dc4c14 100644 --- a/DiaryApp/Views/Cells/DiaryListCell.swift +++ b/DiaryApp/Views/Cells/DiaryListCell.swift @@ -50,12 +50,10 @@ class DiaryListCell: UICollectionViewCell { private func setupUI() { stackView.axis = .vertical - stackView.backgroundColor = .systemOrange stackView.distribution = .fillProportionally stackView.spacing = 0 labelStackView.axis = .horizontal - labelStackView.backgroundColor = .systemBlue labelStackView.distribution = .fillProportionally diaryTitleLabel.font = .systemFont(ofSize: 20, weight: .bold) @@ -67,7 +65,8 @@ class DiaryListCell: UICollectionViewCell { endDayLabel.adjustsFontSizeToFitWidth = true endDayLabel.textAlignment = .center - collectionView.backgroundColor = .systemRed + collectionView.layer.borderColor = UIColor.black.cgColor + collectionView.layer.borderWidth = 1 } private func setupLayout() { @@ -76,8 +75,8 @@ class DiaryListCell: UICollectionViewCell { collectionView.snp.makeConstraints { make in make.top.equalTo(contentView.safeAreaLayoutGuide).inset(12) make.bottom.equalTo(contentView.safeAreaLayoutGuide).inset(10) - make.leading.equalTo(contentView.safeAreaLayoutGuide).inset(25) - make.trailing.equalTo(contentView.safeAreaLayoutGuide).inset(210) + make.leading.equalTo(contentView.safeAreaLayoutGuide).inset(12) + make.trailing.equalTo(contentView.safeAreaLayoutGuide).inset(225) make.width.height.equalTo(50) } diff --git a/DiaryApp/Views/Cells/HomeFeedCell.swift b/DiaryApp/Views/Cells/HomeFeedCell.swift index 248bd37..90bbdb0 100644 --- a/DiaryApp/Views/Cells/HomeFeedCell.swift +++ b/DiaryApp/Views/Cells/HomeFeedCell.swift @@ -11,10 +11,10 @@ import UIKit final class HomeFeedCell: UICollectionViewCell { static let identifier = "HomeFeedCell" - private let myView = CustomImageView(frame: .zero) - private let weatherImage = CustomImageView(frame: .zero) + lazy var myView = CustomImageView(frame: .zero) + lazy var weatherImage = CustomImageView(frame: .zero) - let sizeWidth = 70.0 + let sizeWidth = 50 @available(*, unavailable) required init?(coder: NSCoder) { @@ -26,7 +26,12 @@ final class HomeFeedCell: UICollectionViewCell { self.contentView.addSubview(self.myView) + self.myView.layer.masksToBounds = true + self.myView.layer.cornerRadius = 20 + self.weatherImage.backgroundColor = .systemBlue + self.weatherImage.contentMode = .center + self.weatherImage.tintColor = .white self.weatherImage.layer.cornerRadius = CGFloat(self.sizeWidth / 2) self.myView.addSubview(self.weatherImage) diff --git a/DiaryApp/Views/Cells/ProgressListCell.swift b/DiaryApp/Views/Cells/ProgressListCell.swift index e95c440..d8c204d 100644 --- a/DiaryApp/Views/Cells/ProgressListCell.swift +++ b/DiaryApp/Views/Cells/ProgressListCell.swift @@ -15,6 +15,8 @@ class ProgressListCell: UICollectionViewCell { lazy var weatherImageView = CustomImageView(frame: .zero) lazy var descriptionLabel = CustomLabel(frame: .zero) + var tagValue: [[String]] = [] + private let collectionView = CustomCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) private let collectionViewFlowLayout: UICollectionViewFlowLayout = { @@ -40,7 +42,8 @@ class ProgressListCell: UICollectionViewCell { } private func configureCell() { - imageView.contentMode = .scaleAspectFit + imageView.contentMode = .scaleToFill + imageView.layer.masksToBounds = true imageView.layer.cornerRadius = 20 imageView.backgroundColor = .systemBrown @@ -106,12 +109,13 @@ class ProgressListCell: UICollectionViewCell { extension ProgressListCell: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 3 + return tagValue[section].count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ProgressTagCell.identifier, for: indexPath) as? ProgressTagCell else { return UICollectionViewCell() } - cell.tagTitleLabel.text = "Hi" + let item = tagValue[indexPath.section][indexPath.item] + cell.tagTitleLabel.text = item cell.backgroundColor = .systemYellow cell.layer.cornerRadius = 5 return cell From f0fce3f310f45ed73e82038020f8fbabee1736ec Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Sun, 3 Sep 2023 22:16:11 +0900 Subject: [PATCH 42/50] =?UTF-8?q?[MERGE]:=20feature/firebase-operation=20?= =?UTF-8?q?=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Network/FirestoreManager.swift | 38 ------------------------- 1 file changed, 38 deletions(-) diff --git a/DiaryApp/Network/FirestoreManager.swift b/DiaryApp/Network/FirestoreManager.swift index 023e186..4d0eaa4 100644 --- a/DiaryApp/Network/FirestoreManager.swift +++ b/DiaryApp/Network/FirestoreManager.swift @@ -5,19 +5,6 @@ // Created by t2023-m0056 on 2023/09/01. // -<<<<<<< HEAD -import Foundation -import FirebaseFirestore - -final class FirestoreService { - let db = Firestore.firestore() - - func getPostData(completion: @escaping ([Post]?) -> Void) { - var names: [[String:Any]] = [[:]] - var post: [Post]? - - db.collection("Post").getDocuments { (querySnapshot, error) in -======= import FirebaseFirestore import Foundation @@ -30,7 +17,6 @@ final class FirestoreService { var post: [Post]? FirestoreService.db.collection("Post").getDocuments { querySnapshot, error in ->>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) if let error = error { print("Error getting documents: \(error)") completion(post) // 호출하는 쪽에 빈 배열 전달 @@ -44,17 +30,10 @@ final class FirestoreService { completion(post) // 성공 시 이름 배열 전달 } } -<<<<<<< HEAD - - func addPostDocument(content: String, goal: String, image: String, tag: Array, temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { - // Add a new document with a generated ID - db.collection("Info").document(goal).setData([ -======= func addPostDocument(content: String, goal: String, image: String, tag: [String], temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { // Add a new document with a generated ID FirestoreService.db.collection("Post").document(goal).setData([ ->>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) "content": content, "goal": goal, "image": image, @@ -64,42 +43,25 @@ final class FirestoreService { "weatherIcon": weatherIcon, ]) { err in if let err = err { -<<<<<<< HEAD - print("Error adding document: \(err)") - } else { - completion("Post Document added") -======= print("### Error adding document: \(err)") } else { completion("#### Post Document added") print("### 현재 Firebase 에 저장된 데이터들 : \(FirestoreService.db.collection("Info").document(goal))") ->>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) } } } } extension FirestoreService { -<<<<<<< HEAD - func dictionaryToObject(objectType:T.Type,dictionary:[[String:Any]]) -> [T]? { - -======= func dictionaryToObject(objectType: T.Type, dictionary: [[String: Any]]) -> [T]? { ->>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase guard let objects = try? decoder.decode([T].self, from: dictionaries) else { return nil } return objects } -<<<<<<< HEAD - - func dicToObject(objectType:T.Type,dictionary:[String:Any]) -> T? { - -======= func dicToObject(objectType: T.Type, dictionary: [String: Any]) -> T? { ->>>>>>> 3efe6a1 ([MERGE]: feature/firebase-operation) guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase From 7ad9dba9721c54c80fc40a688e6183cc89769d6d Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Mon, 4 Sep 2023 00:51:54 +0900 Subject: [PATCH 43/50] =?UTF-8?q?[STYLE]:=20=EB=B3=80=EA=B2=BD=20=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=97=86=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp/Controllers/HomeViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index 670c287..fa4b416 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -111,7 +111,6 @@ extension HomeViewController: UICollectionViewDataSource { } cell.weatherImage.image = UIImage(systemName: item.weatherIcon) - cell.layer.borderColor = UIColor.black.cgColor cell.layer.borderWidth = 1 cell.layer.cornerRadius = 20 From 6aa606250a25f8aa45863e65b9d43c110241a4f1 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Mon, 4 Sep 2023 01:30:33 +0900 Subject: [PATCH 44/50] =?UTF-8?q?[FEAT]:=20Alamofire=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 17 +++++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 85852d5..0a1e011 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */; }; 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; @@ -86,6 +87,7 @@ buildActionMask = 2147483647; files = ( 4E97E6CD2AA39F7600DD4C1F /* Kingfisher in Frameworks */, + 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */, 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */, 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */, 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, @@ -223,6 +225,7 @@ 4EA808212AA1D41100A4D465 /* FirebaseFirestore */, 4EA808232AA1D41100A4D465 /* FirebaseStorage */, 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */, + 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */, ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; @@ -256,6 +259,7 @@ 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */, + 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */, ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; @@ -511,6 +515,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SnapKit/SnapKit.git"; @@ -538,6 +550,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; 4E6138AF2A9EEF50003A2B37 /* SnapKit */ = { isa = XCSwiftPackageProductDependency; package = 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 529c120..38dbcdf 100644 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,15 @@ "version" : "1.2022062300.0" } }, + { + "identity" : "alamofire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Alamofire/Alamofire", + "state" : { + "revision" : "b2fa556e4e48cbf06cf8c63def138c98f4b811fa", + "version" : "5.8.0" + } + }, { "identity" : "firebase-ios-sdk", "kind" : "remoteSourceControl", From 5b47ec80c61fee9ee5a0c0810c10835a09694c3e Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Mon, 4 Sep 2023 02:12:51 +0900 Subject: [PATCH 45/50] =?UTF-8?q?[MERGE]:=20Feature/NewDiaryVC=20=EB=B3=91?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 28 ++++ .../xcshareddata/swiftpm/Package.resolved | 140 ------------------ .../DiaryProgressViewController.swift | 1 - .../Controllers/NewDiaryViewController.swift | 44 ++++++ .../Controllers/Weather/WeatherManager.swift | 61 ++++++++ .../Controllers/Weather/WeatherResponse.swift | 24 +++ DiaryApp/Controllers/weatherAPI.plist | 8 + DiaryApp/Resources/SceneDelegate.swift | 2 - 8 files changed, 165 insertions(+), 143 deletions(-) delete mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 DiaryApp/Controllers/Weather/WeatherManager.swift create mode 100644 DiaryApp/Controllers/Weather/WeatherResponse.swift create mode 100644 DiaryApp/Controllers/weatherAPI.plist diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 0a1e011..f1f559d 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 4E0EBBA32AA4F11100CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBBA22AA4F11100CD64DE /* Alamofire */; }; + 4E1112492AA45E7A00D4E550 /* weatherAPI.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4E1112482AA45E7A00D4E550 /* weatherAPI.plist */; }; 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */; }; 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; @@ -43,10 +45,13 @@ 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808212AA1D41100A4D465 /* FirebaseFirestore */; }; 4EA808242AA1D41100A4D465 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA808232AA1D41100A4D465 /* FirebaseStorage */; }; 4EA808262AA1D46800A4D465 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */; }; + 4ED3122E2AA46BA700677EE0 /* WeatherManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED3122D2AA46BA700677EE0 /* WeatherManager.swift */; }; + 4ED312302AA48BFB00677EE0 /* WeatherResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */; }; FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4E1112482AA45E7A00D4E550 /* weatherAPI.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = weatherAPI.plist; sourceTree = ""; }; 4E1550832A9E049100C8A500 /* DiaryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryListCell.swift; sourceTree = ""; }; 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStackView.swift; sourceTree = ""; }; 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLabel.swift; sourceTree = ""; }; @@ -78,6 +83,8 @@ 4E98A3BC2A9CB918003052D3 /* CustomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCollectionView.swift; sourceTree = ""; }; 4E98A3C02A9CCFB8003052D3 /* CustomImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomImageView.swift; sourceTree = ""; }; 4EA808252AA1D46800A4D465 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + 4ED3122D2AA46BA700677EE0 /* WeatherManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherManager.swift; sourceTree = ""; }; + 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherResponse.swift; sourceTree = ""; }; FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCalendarViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -87,6 +94,7 @@ buildActionMask = 2147483647; files = ( 4E97E6CD2AA39F7600DD4C1F /* Kingfisher in Frameworks */, + 4E0EBBA32AA4F11100CD64DE /* Alamofire in Frameworks */, 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */, 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */, 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */, @@ -162,8 +170,10 @@ 4E98A3A92A9CA6F6003052D3 /* ProgressListViewController.swift */, 4E98A3AB2A9CA70B003052D3 /* DiaryListViewController.swift */, 4E98A3AD2A9CA748003052D3 /* DetailDiaryViewController.swift */, + 4ED312312AA48CFA00677EE0 /* Weather */, 4E98A3AF2A9CA762003052D3 /* DiaryProgressViewController.swift */, 4E98A3B52A9CAA16003052D3 /* ProfileViewController.swift */, + 4E1112482AA45E7A00D4E550 /* weatherAPI.plist */, ); path = Controllers; sourceTree = ""; @@ -202,6 +212,15 @@ path = Resources; sourceTree = ""; }; + 4ED312312AA48CFA00677EE0 /* Weather */ = { + isa = PBXGroup; + children = ( + 4ED3122D2AA46BA700677EE0 /* WeatherManager.swift */, + 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */, + ); + path = Weather; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -225,6 +244,7 @@ 4EA808212AA1D41100A4D465 /* FirebaseFirestore */, 4EA808232AA1D41100A4D465 /* FirebaseStorage */, 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */, + 4E0EBBA22AA4F11100CD64DE /* Alamofire */, 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */, ); productName = DiaryApp; @@ -259,6 +279,7 @@ 4E6138AE2A9EEF50003A2B37 /* XCRemoteSwiftPackageReference "SnapKit" */, 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */, + 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */, 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */, ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; @@ -275,6 +296,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4E1112492AA45E7A00D4E550 /* weatherAPI.plist in Resources */, 4E98A3982A9CA57E003052D3 /* Assets.xcassets in Resources */, 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */, 4EA808262AA1D46800A4D465 /* GoogleService-Info.plist in Resources */, @@ -295,6 +317,7 @@ 4E98A3912A9CA57B003052D3 /* SceneDelegate.swift in Sources */, 4E98A3A32A9CA634003052D3 /* HomeViewController.swift in Sources */, 4E98A3A82A9CA6B6003052D3 /* EditDiaryViewController.swift in Sources */, + 4ED312302AA48BFB00677EE0 /* WeatherResponse.swift in Sources */, 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */, 4E6138C02A9F9E8B003A2B37 /* DiaryListThumbnailCell.swift in Sources */, 4E98A3BA2A9CAD60003052D3 /* Weather.swift in Sources */, @@ -302,6 +325,7 @@ 4E7A15062AA0BFA1005FCD9C /* ProgressTagCell.swift in Sources */, 4E7A15042AA0A9C8005FCD9C /* ProgressListCell.swift in Sources */, 4E6138C12A9F9E8B003A2B37 /* DiaryProgressCell.swift in Sources */, + 4ED3122E2AA46BA700677EE0 /* WeatherManager.swift in Sources */, 4E98A3B62A9CAA16003052D3 /* ProfileViewController.swift in Sources */, 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */, 4E97E6CA2AA390A600DD4C1F /* FirestoreManager.swift in Sources */, @@ -515,6 +539,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */ = { 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Alamofire/Alamofire"; @@ -550,6 +575,9 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 4E0EBBA22AA4F11100CD64DE /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */; 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */ = { isa = XCSwiftPackageProductDependency; package = 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */; diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 38dbcdf..0000000 --- a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,140 +0,0 @@ -{ - "pins" : [ - { - "identity" : "abseil-cpp-binary", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/abseil-cpp-binary.git", - "state" : { - "revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c", - "version" : "1.2022062300.0" - } - }, - { - "identity" : "alamofire", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire", - "state" : { - "revision" : "b2fa556e4e48cbf06cf8c63def138c98f4b811fa", - "version" : "5.8.0" - } - }, - { - "identity" : "firebase-ios-sdk", - "kind" : "remoteSourceControl", - "location" : "https://github.com/firebase/firebase-ios-sdk.git", - "state" : { - "revision" : "2bfe6abe1014aafe5cf28401708f7d39f9926a76", - "version" : "10.14.0" - } - }, - { - "identity" : "googleappmeasurement", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/GoogleAppMeasurement.git", - "state" : { - "revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b", - "version" : "10.13.0" - } - }, - { - "identity" : "googledatatransport", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/GoogleDataTransport.git", - "state" : { - "revision" : "aae45a320fd0d11811820335b1eabc8753902a40", - "version" : "9.2.5" - } - }, - { - "identity" : "googleutilities", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/GoogleUtilities.git", - "state" : { - "revision" : "c38ce365d77b04a9a300c31061c5227589e5597b", - "version" : "7.11.5" - } - }, - { - "identity" : "grpc-binary", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/grpc-binary.git", - "state" : { - "revision" : "f1b366129d1125be7db83247e003fc333104b569", - "version" : "1.50.2" - } - }, - { - "identity" : "gtm-session-fetcher", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/gtm-session-fetcher.git", - "state" : { - "revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd", - "version" : "3.1.1" - } - }, - { - "identity" : "interop-ios-for-google-sdks", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/interop-ios-for-google-sdks.git", - "state" : { - "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", - "version" : "100.0.0" - } - }, - { - "identity" : "kingfisher", - "kind" : "remoteSourceControl", - "location" : "https://github.com/onevcat/Kingfisher.git", - "state" : { - "revision" : "b6f62758f21a8c03cd64f4009c037cfa580a256e", - "version" : "7.9.1" - } - }, - { - "identity" : "leveldb", - "kind" : "remoteSourceControl", - "location" : "https://github.com/firebase/leveldb.git", - "state" : { - "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", - "version" : "1.22.2" - } - }, - { - "identity" : "nanopb", - "kind" : "remoteSourceControl", - "location" : "https://github.com/firebase/nanopb.git", - "state" : { - "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", - "version" : "2.30909.0" - } - }, - { - "identity" : "promises", - "kind" : "remoteSourceControl", - "location" : "https://github.com/google/promises.git", - "state" : { - "revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", - "version" : "2.3.1" - } - }, - { - "identity" : "snapkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/SnapKit/SnapKit.git", - "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" - } - }, - { - "identity" : "swift-protobuf", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-protobuf.git", - "state" : { - "revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d", - "version" : "1.23.0" - } - } - ], - "version" : 2 -} diff --git a/DiaryApp/Controllers/DiaryProgressViewController.swift b/DiaryApp/Controllers/DiaryProgressViewController.swift index 502d4e9..35e523c 100644 --- a/DiaryApp/Controllers/DiaryProgressViewController.swift +++ b/DiaryApp/Controllers/DiaryProgressViewController.swift @@ -84,6 +84,5 @@ extension DiaryProgressViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { return 10 - } } diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index ccf0a20..ce79931 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -5,6 +5,7 @@ // Created by (^ㅗ^)7 iMac on 2023/08/28. // +import Alamofire import SnapKit import UIKit @@ -105,6 +106,7 @@ final class NewDiaryViewController: UIViewController { view.addSubview(exercisButton) view.addSubview(healthyButton) view.addSubview(foodButton) + view.addSubview(weatherDescriptionLabel) pickImageButton.snp.makeConstraints { make in make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(20) @@ -142,11 +144,18 @@ final class NewDiaryViewController: UIViewController { make.trailing.equalTo(textView.snp.trailing) make.width.equalTo(100) } + + weatherDescriptionLabel.snp.makeConstraints { make in + print("### \(weatherDescriptionLabel.bounds.height)") + make.centerX.equalToSuperview() + make.top.equalTo(exercisButton.snp.bottom).offset(-50) + } } override func viewDidLoad() { super.viewDidLoad() setupLayout() + fetchAndDisplayWeather() } @objc func tappedGoalButton() { @@ -169,6 +178,41 @@ final class NewDiaryViewController: UIViewController { @objc func tappedFoodButton() { print("### \(#function)") } + + func fetchAndDisplayWeather() { + let city = "Busan" + WeatherManager.shared.fetchWeather(for: city) { result in + switch result { + case .success(let weatherData): + // 날씨 정보를 받아와 UI에 표시 + DispatchQueue.main.async { + self.weatherDescriptionLabel.text = weatherData.description + let celsiusTemp = round(weatherData.temperature - 273.15) + + self.temperatureLabel.text = "\(celsiusTemp) °C" + + // 아이콘 이미지를 표시 + if let iconUrl = URL(string: weatherData.iconUrl) { + DispatchQueue.global().async { + if let imageData = try? Data(contentsOf: iconUrl), + let iconImage = UIImage(data: imageData) + { + DispatchQueue.main.async { + print("###이미지 다운로드 완ㄹ") + + self.weatherIconImageView.image = iconImage + } + } else { + print("이미지 다운로드 변환 실패 ###") + } + } + } + } + case .failure(let error): + print("###날씨 정보 가져오기 실패: \(error)") + } + } + } } extension NewDiaryViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { diff --git a/DiaryApp/Controllers/Weather/WeatherManager.swift b/DiaryApp/Controllers/Weather/WeatherManager.swift new file mode 100644 index 0000000..71e05e4 --- /dev/null +++ b/DiaryApp/Controllers/Weather/WeatherManager.swift @@ -0,0 +1,61 @@ +// +// WeatherManager.swift +// DiaryApp +// +// Created by 김기현 on 2023/09/03. +// + +import Foundation +import Alamofire + +class WeatherManager { + static let shared = WeatherManager() + + private init() {} + + private let apiKey = "e8aeafe9abc4ec56d53a28782b1991f8" + private let baseUrl = "https://api.openweathermap.org/data/2.5/weather" // HTTPS 사용 + + func fetchWeather(for city: String, completion: @escaping (Result) -> Void) { + let parameters: [String: Any] = [ + "q": city, + "APPID": apiKey + ] + + // Alamofire를 사용하여 GET 요청을 보냅니다. + AF.request(baseUrl, method: .get, parameters: parameters) + .validate() + .responseJSON { response in + switch response.result { + case .success(let value): + if let weatherResponse = WeatherResponse(json: value) { + // 이미지 데이터 가져오기 + self.fetchWeatherIcon(for: weatherResponse.iconUrl) { imageData in + var weatherResponseWithIcon = weatherResponse + weatherResponseWithIcon.iconImageData = imageData + completion(.success(weatherResponseWithIcon)) + } + } else { + print("###날씨 데이터 파싱 실패ㅜㅜ") + } + case .failure(let error): + completion(.failure(error)) + } + } + } + + private func fetchWeatherIcon(for iconUrl: String, completion: @escaping (Data?) -> Void) { + if let url = URL(string: iconUrl) { + AF.request(url).responseData { response in + switch response.result { + case .success(let data): + completion(data) + case .failure(_): + completion(nil) + } + } + } else { + completion(nil) + } + } +} diff --git a/DiaryApp/Controllers/Weather/WeatherResponse.swift b/DiaryApp/Controllers/Weather/WeatherResponse.swift new file mode 100644 index 0000000..fc62465 --- /dev/null +++ b/DiaryApp/Controllers/Weather/WeatherResponse.swift @@ -0,0 +1,24 @@ +import Foundation + +struct WeatherResponse { + let description: String + let temperature: Double + let iconUrl: String + var iconImageData: Data? // 이미지 데이터 추가 + + init?(json: Any) { + guard let jsonDict = json as? [String: Any], + let weatherArray = jsonDict["weather"] as? [[String: Any]], + let mainDict = jsonDict["main"] as? [String: Any], + let description = weatherArray.first?["description"] as? String, + let icon = weatherArray.first?["icon"] as? String, + let temperature = mainDict["temp"] as? Double + else { + return nil + } + + self.description = description + self.temperature = temperature + self.iconUrl = "https://openweathermap.org/img/wn/\(icon)@2x.png" + } +} diff --git a/DiaryApp/Controllers/weatherAPI.plist b/DiaryApp/Controllers/weatherAPI.plist new file mode 100644 index 0000000..7ae8c99 --- /dev/null +++ b/DiaryApp/Controllers/weatherAPI.plist @@ -0,0 +1,8 @@ + + + + + OpenWeather + e8aeafe9abc4ec56d53a28782b1991f8 + + diff --git a/DiaryApp/Resources/SceneDelegate.swift b/DiaryApp/Resources/SceneDelegate.swift index e86883f..0150a7f 100644 --- a/DiaryApp/Resources/SceneDelegate.swift +++ b/DiaryApp/Resources/SceneDelegate.swift @@ -23,8 +23,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { (NewDiaryViewController(), "plus.square"), (DiaryProgressViewController(), "tag"), (ProfileViewController(), "person"), - (DiaryProgressViewController(), "tag"), - (ProfileViewController(), "person"), ] From 87a31ab6a86b6b427c6c10c56894a79f6678ee84 Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Mon, 4 Sep 2023 02:17:41 +0900 Subject: [PATCH 46/50] =?UTF-8?q?[FIX]:=20MERGE=20Conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiaryApp.xcodeproj/project.pbxproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index f1f559d..93bbdb2 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -245,7 +245,6 @@ 4EA808232AA1D41100A4D465 /* FirebaseStorage */, 4E97E6CC2AA39F7600DD4C1F /* Kingfisher */, 4E0EBBA22AA4F11100CD64DE /* Alamofire */, - 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */, ); productName = DiaryApp; productReference = 4E98A38B2A9CA57B003052D3 /* DiaryApp.app */; @@ -280,7 +279,6 @@ 4EA8081C2AA1D41100A4D465 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, 4E97E6CB2AA39F7600DD4C1F /* XCRemoteSwiftPackageReference "Kingfisher" */, 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */, - 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */, ); productRefGroup = 4E98A38C2A9CA57B003052D3 /* Products */; projectDirPath = ""; @@ -540,7 +538,6 @@ /* Begin XCRemoteSwiftPackageReference section */ 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */ = { - 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Alamofire/Alamofire"; requirement = { @@ -578,9 +575,6 @@ 4E0EBBA22AA4F11100CD64DE /* Alamofire */ = { isa = XCSwiftPackageProductDependency; package = 4E0EBBA12AA4F11100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */; - 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */ = { - isa = XCSwiftPackageProductDependency; - package = 4E0EBB9E2AA4EC1100CD64DE /* XCRemoteSwiftPackageReference "Alamofire" */; productName = Alamofire; }; 4E6138AF2A9EEF50003A2B37 /* SnapKit */ = { From 8c5cc14dfef5a6f5a8ab4e87935280899c61a5be Mon Sep 17 00:00:00 2001 From: jakkujakku Date: Mon, 4 Sep 2023 02:20:57 +0900 Subject: [PATCH 47/50] =?UTF-8?q?[FIX]:=20MERGE=20Conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/swiftpm/Package.resolved | 140 ++++++++++++++++++ .../Controllers/NewDiaryViewController.swift | 16 ++ 2 files changed, 156 insertions(+) create mode 100644 DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..38dbcdf --- /dev/null +++ b/DiaryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,140 @@ +{ + "pins" : [ + { + "identity" : "abseil-cpp-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/abseil-cpp-binary.git", + "state" : { + "revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c", + "version" : "1.2022062300.0" + } + }, + { + "identity" : "alamofire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Alamofire/Alamofire", + "state" : { + "revision" : "b2fa556e4e48cbf06cf8c63def138c98f4b811fa", + "version" : "5.8.0" + } + }, + { + "identity" : "firebase-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/firebase-ios-sdk.git", + "state" : { + "revision" : "2bfe6abe1014aafe5cf28401708f7d39f9926a76", + "version" : "10.14.0" + } + }, + { + "identity" : "googleappmeasurement", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleAppMeasurement.git", + "state" : { + "revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b", + "version" : "10.13.0" + } + }, + { + "identity" : "googledatatransport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleDataTransport.git", + "state" : { + "revision" : "aae45a320fd0d11811820335b1eabc8753902a40", + "version" : "9.2.5" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "c38ce365d77b04a9a300c31061c5227589e5597b", + "version" : "7.11.5" + } + }, + { + "identity" : "grpc-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/grpc-binary.git", + "state" : { + "revision" : "f1b366129d1125be7db83247e003fc333104b569", + "version" : "1.50.2" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd", + "version" : "3.1.1" + } + }, + { + "identity" : "interop-ios-for-google-sdks", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/interop-ios-for-google-sdks.git", + "state" : { + "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", + "version" : "100.0.0" + } + }, + { + "identity" : "kingfisher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/onevcat/Kingfisher.git", + "state" : { + "revision" : "b6f62758f21a8c03cd64f4009c037cfa580a256e", + "version" : "7.9.1" + } + }, + { + "identity" : "leveldb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/leveldb.git", + "state" : { + "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", + "version" : "1.22.2" + } + }, + { + "identity" : "nanopb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/nanopb.git", + "state" : { + "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", + "version" : "2.30909.0" + } + }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", + "version" : "2.3.1" + } + }, + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d", + "version" : "1.23.0" + } + } + ], + "version" : 2 +} diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index ce79931..eecf427 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -98,6 +98,22 @@ final class NewDiaryViewController: UIViewController { return button }() + let weatherIconImageView: UIImageView = { + let imageView = UIImageView() + + return imageView + }() + + let weatherDescriptionLabel: UILabel = { + let label = UILabel() + return label + }() + + let temperatureLabel: UILabel = { + let label = UILabel() + return label + }() + private func setupLayout() { view.backgroundColor = .white view.addSubview(pickImageButton) From 27dea009d30d1b5c56be869e6b824d4e4c4c1491 Mon Sep 17 00:00:00 2001 From: p2glet Date: Fri, 1 Sep 2023 22:04:29 +0900 Subject: [PATCH 48/50] [MERGE] : merge firestoremanager to develop --- DiaryApp.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 93bbdb2..567d4b8 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 4ED3122E2AA46BA700677EE0 /* WeatherManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED3122D2AA46BA700677EE0 /* WeatherManager.swift */; }; 4ED312302AA48BFB00677EE0 /* WeatherResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */; }; FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; + FF0F82582AA218A3005CFB57 /* Network in Resources */ = {isa = PBXBuildFile; fileRef = FF0F82572AA218A3005CFB57 /* Network */; }; + FF0F825A2AA218AC005CFB57 /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82592AA218AC005CFB57 /* Post.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -86,6 +88,8 @@ 4ED3122D2AA46BA700677EE0 /* WeatherManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherManager.swift; sourceTree = ""; }; 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherResponse.swift; sourceTree = ""; }; FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCalendarViewController.swift; sourceTree = ""; }; + FF0F82572AA218A3005CFB57 /* Network */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Network; sourceTree = ""; }; + FF0F82592AA218AC005CFB57 /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -148,6 +152,7 @@ 4E98A38D2A9CA57B003052D3 /* DiaryApp */ = { isa = PBXGroup; children = ( + FF0F82572AA218A3005CFB57 /* Network */, 4E98A3BB2A9CAD89003052D3 /* Resources */, 4E98A3B32A9CA795003052D3 /* Models */, 4E98A3B42A9CA7AD003052D3 /* Views */, @@ -182,6 +187,7 @@ isa = PBXGroup; children = ( 4E97E6C62AA37FDC00DD4C1F /* Post.swift */, + FF0F82592AA218AC005CFB57 /* Post.swift */, 4E98A3B72A9CAD27003052D3 /* User.swift */, 4E98A3B92A9CAD60003052D3 /* Weather.swift */, ); @@ -296,6 +302,7 @@ files = ( 4E1112492AA45E7A00D4E550 /* weatherAPI.plist in Resources */, 4E98A3982A9CA57E003052D3 /* Assets.xcassets in Resources */, + FF0F82582AA218A3005CFB57 /* Network in Resources */, 4E6138C92A9FA164003A2B37 /* LaunchScreen.storyboard in Resources */, 4EA808262AA1D46800A4D465 /* GoogleService-Info.plist in Resources */, ); @@ -329,6 +336,7 @@ 4E97E6CA2AA390A600DD4C1F /* FirestoreManager.swift in Sources */, 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */, 4E97E6C72AA37FDD00DD4C1F /* Post.swift in Sources */, + FF0F825A2AA218AC005CFB57 /* Post.swift in Sources */, 4E98A3AE2A9CA748003052D3 /* DetailDiaryViewController.swift in Sources */, 4E98A3AC2A9CA70B003052D3 /* DiaryListViewController.swift in Sources */, 4E98A3B02A9CA762003052D3 /* DiaryProgressViewController.swift in Sources */, From 11defa410e7bc754ee3cb499c2de6f78fe090ab4 Mon Sep 17 00:00:00 2001 From: p2glet Date: Mon, 4 Sep 2023 19:39:15 +0900 Subject: [PATCH 49/50] [MERGE] : UploadFirebase to develop --- DiaryApp.xcodeproj/project.pbxproj | 6 +- .../DiaryCalendarViewController.swift | 12 ++- DiaryApp/Controllers/HomeViewController.swift | 2 +- .../Controllers/NewDiaryViewController.swift | 91 +++++++++++++++++-- .../ProgressListViewController.swift | 2 +- DiaryApp/Models/Post.swift | 2 + DiaryApp/Network/FirestoreManager.swift | 13 +-- 7 files changed, 107 insertions(+), 21 deletions(-) diff --git a/DiaryApp.xcodeproj/project.pbxproj b/DiaryApp.xcodeproj/project.pbxproj index 567d4b8..6bbd729 100644 --- a/DiaryApp.xcodeproj/project.pbxproj +++ b/DiaryApp.xcodeproj/project.pbxproj @@ -10,6 +10,9 @@ 4E0EBBA32AA4F11100CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBBA22AA4F11100CD64DE /* Alamofire */; }; 4E1112492AA45E7A00D4E550 /* weatherAPI.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4E1112482AA45E7A00D4E550 /* weatherAPI.plist */; }; 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBB9F2AA4EC1200CD64DE /* Alamofire */; }; + 4E0EBBA02AA4EC1200CD64DE /* (null) in Frameworks */ = {isa = PBXBuildFile; }; + 4E0EBBA32AA4F11100CD64DE /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 4E0EBBA22AA4F11100CD64DE /* Alamofire */; }; + 4E1112492AA45E7A00D4E550 /* weatherAPI.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4E1112482AA45E7A00D4E550 /* weatherAPI.plist */; }; 4E1550842A9E049100C8A500 /* DiaryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550832A9E049100C8A500 /* DiaryListCell.swift */; }; 4E1550892A9E0C6500C8A500 /* CustomStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E1550882A9E0C6500C8A500 /* CustomStackView.swift */; }; 4E15508B2A9E0DF500C8A500 /* CustomLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E15508A2A9E0DF500C8A500 /* CustomLabel.swift */; }; @@ -49,7 +52,6 @@ 4ED312302AA48BFB00677EE0 /* WeatherResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */; }; FF0F824A2AA0D01C005CFB57 /* DiaryCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */; }; FF0F82582AA218A3005CFB57 /* Network in Resources */ = {isa = PBXBuildFile; fileRef = FF0F82572AA218A3005CFB57 /* Network */; }; - FF0F825A2AA218AC005CFB57 /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0F82592AA218AC005CFB57 /* Post.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -89,7 +91,6 @@ 4ED3122F2AA48BFB00677EE0 /* WeatherResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherResponse.swift; sourceTree = ""; }; FF0F82492AA0D01C005CFB57 /* DiaryCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCalendarViewController.swift; sourceTree = ""; }; FF0F82572AA218A3005CFB57 /* Network */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Network; sourceTree = ""; }; - FF0F82592AA218AC005CFB57 /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -100,6 +101,7 @@ 4E97E6CD2AA39F7600DD4C1F /* Kingfisher in Frameworks */, 4E0EBBA32AA4F11100CD64DE /* Alamofire in Frameworks */, 4E0EBBA02AA4EC1200CD64DE /* Alamofire in Frameworks */, + 4E0EBBA02AA4EC1200CD64DE /* (null) in Frameworks */, 4EA808202AA1D41100A4D465 /* FirebaseDatabase in Frameworks */, 4EA808222AA1D41100A4D465 /* FirebaseFirestore in Frameworks */, 4E6138B02A9EEF50003A2B37 /* SnapKit in Frameworks */, diff --git a/DiaryApp/Controllers/DiaryCalendarViewController.swift b/DiaryApp/Controllers/DiaryCalendarViewController.swift index b2820b5..1ac2222 100644 --- a/DiaryApp/Controllers/DiaryCalendarViewController.swift +++ b/DiaryApp/Controllers/DiaryCalendarViewController.swift @@ -18,6 +18,9 @@ class DiaryCalendarViewController: UIViewController { // bottomSheet가 view의 상단에서 떨어진 거리 private var bottomSheetViewTopConstraint: NSLayoutConstraint! + // 전달받을 클로저 + var dataSendClosure: ((_ data: (String?, Date?)) -> Void)? + // 기존 화면을 흐려지게 만들기 위한 뷰 private let dimmedBackView: UIView = { let view = UIView() @@ -46,6 +49,7 @@ class DiaryCalendarViewController: UIViewController { }() var selectedDate: DateComponents? = nil + var selectedTitle: String? = nil // MARK: - Properties @@ -232,6 +236,7 @@ class DiaryCalendarViewController: UIViewController { $0.trailing.equalToSuperview().inset(10) $0.height.equalTo(50) } + purposeTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged) } func setTotalStackView() { @@ -441,7 +446,8 @@ class DiaryCalendarViewController: UIViewController { } @objc func clickedSaveBtn() { - // save + self.dataSendClosure?((selectedTitle, selectedDate?.date)) + self.dismiss(animated: true, completion: nil) } // UITapGestureRecognizer 연결 함수 부분 @@ -460,6 +466,10 @@ class DiaryCalendarViewController: UIViewController { } } } + + @objc func textFieldDidChange() { + self.selectedTitle = self.purposeTextField.text! + } } @available(iOS 16.0, *) diff --git a/DiaryApp/Controllers/HomeViewController.swift b/DiaryApp/Controllers/HomeViewController.swift index fa4b416..abd5d85 100644 --- a/DiaryApp/Controllers/HomeViewController.swift +++ b/DiaryApp/Controllers/HomeViewController.swift @@ -49,7 +49,7 @@ class HomeViewController: UIViewController { }() private func firebaseOperation() { - FirestoreService().getPostData { post in + FirestoreManager().getPostData { post in post?.forEach { _ in guard let post = post else { return } self.postList = post diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index eecf427..17dd4fb 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -21,7 +21,12 @@ final class NewDiaryViewController: UIViewController { var postList: [Post] = [] var selectedButton: UIButton? - + + var selectedTitle: String? + var selectedDate: Date? + + var selectedTag = [String]() + lazy var pickerView: UIPickerView = { let pickerView = UIPickerView() pickerView.delegate = self @@ -70,10 +75,12 @@ final class NewDiaryViewController: UIViewController { button.layer.cornerRadius = 15 button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("운동", for: .normal) - button.addTarget(self, action: #selector(tappedHealthyButton), for: .touchUpInside) + button.addTarget(self, action: #selector(tappedExerciseButton), for: .touchUpInside) return button }() - + + var checkedExercise = false + private let healthyButton: UIButton = { let button = UIButton(type: .system) button.layer.borderWidth = 1 @@ -85,7 +92,9 @@ final class NewDiaryViewController: UIViewController { button.addTarget(self, action: #selector(tappedHealthyButton), for: .touchUpInside) return button }() - + + var checkedHealthy = false + private let foodButton: UIButton = { let button = UIButton(type: .system) button.layer.borderWidth = 1 @@ -103,7 +112,22 @@ final class NewDiaryViewController: UIViewController { return imageView }() - + + + var checkedFood = false + + let completeButton: UIButton = { + let button = UIButton(type: .system) + button.layer.borderWidth = 1 + button.layer.borderColor = UIColor.black.cgColor + button.layer.masksToBounds = true + button.layer.cornerRadius = 15 + button.translatesAutoresizingMaskIntoConstraints = false + button.setTitle("완료", for: .normal) + button.addTarget(self, action: #selector(tappedCompleteButton), for: .touchUpInside) + return button + }() + let weatherDescriptionLabel: UILabel = { let label = UILabel() return label @@ -123,7 +147,8 @@ final class NewDiaryViewController: UIViewController { view.addSubview(healthyButton) view.addSubview(foodButton) view.addSubview(weatherDescriptionLabel) - + view.addSubview(completeButton) + pickImageButton.snp.makeConstraints { make in make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(20) make.bottom.equalTo(textView.snp.top).offset(-15) @@ -133,12 +158,14 @@ final class NewDiaryViewController: UIViewController { textView.snp.makeConstraints { make in make.top.equalTo(pickImageButton.snp.bottom).offset(100) make.leading.trailing.equalToSuperview().inset(20) - make.bottom.equalTo(view.safeAreaLayoutGuide).inset(100) + // make.bottom.equalTo(view.safeAreaLayoutGuide).inset(100) + make.bottom.equalTo(goalButton.snp.top).inset(-12) + make.height.equalTo(150) } goalButton.snp.makeConstraints { make in make.trailing.equalTo(textView) - make.top.equalTo(textView.snp.bottom).offset(12) + // make.top.equalTo(textView.snp.bottom).offset(12) make.width.equalTo(150) make.height.equalTo(30) } @@ -165,9 +192,36 @@ final class NewDiaryViewController: UIViewController { print("### \(weatherDescriptionLabel.bounds.height)") make.centerX.equalToSuperview() make.top.equalTo(exercisButton.snp.bottom).offset(-50) + + completeButton.snp.makeConstraints { make in + make.top.equalTo(foodButton.snp.bottom).offset(12) + make.leading.equalTo(view.safeAreaLayoutGuide.snp.leading).offset(20) + make.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing).offset(-20) + make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-12) + } } } - + + func checkedTag() { + if checkedExercise { + selectedTag.append("운동") + } + + if checkedHealthy { + selectedTag.append("건강") + } + + if checkedFood { + selectedTag.append("음식") + + weatherDescriptionLabel.snp.makeConstraints { make in + print("### \(weatherDescriptionLabel.bounds.height)") + make.centerX.equalToSuperview() + make.top.equalTo(exercisButton.snp.bottom).offset(-50) + } + } + } + override func viewDidLoad() { super.viewDidLoad() setupLayout() @@ -179,22 +233,39 @@ final class NewDiaryViewController: UIViewController { if #available(iOS 16.0, *) { let vc = DiaryCalendarViewController() vc.modalPresentationStyle = .automatic + vc.dataSendClosure = { data in + self.selectedTitle = data.0 + self.selectedDate = data.1 + } + self.present(vc, animated: true) } } @objc func tappedExerciseButton() { print("### \(#function)") + checkedExercise = !checkedExercise + exercisButton.backgroundColor = (checkedExercise == false) ? .white : .systemGray } @objc func tappedHealthyButton() { print("### \(#function)") + checkedHealthy = !checkedHealthy + healthyButton.backgroundColor = (checkedHealthy == false) ? .white : .systemGray } @objc func tappedFoodButton() { print("### \(#function)") + checkedFood = !checkedFood + foodButton.backgroundColor = (checkedFood == false) ? .white : .systemGray } - + + @objc func tappedCompleteButton() { + checkedTag() + FirestoreManager().addPostDocument(content: textView.text, goal: selectedTitle!, date: selectedDate!, image: "이미지", tag: selectedTag, temperature: "온도", weather: "날씨", weatherIcon: "아이콘") { _ in + } + } + func fetchAndDisplayWeather() { let city = "Busan" WeatherManager.shared.fetchWeather(for: city) { result in diff --git a/DiaryApp/Controllers/ProgressListViewController.swift b/DiaryApp/Controllers/ProgressListViewController.swift index 3b48356..776086a 100644 --- a/DiaryApp/Controllers/ProgressListViewController.swift +++ b/DiaryApp/Controllers/ProgressListViewController.swift @@ -35,7 +35,7 @@ class ProgressListViewController: UIViewController { }() private func firebaseOperation() { - FirestoreService().getPostData { post in + FirestoreManager().getPostData { post in post?.forEach { _ in guard let post = post else { return } self.postList = post diff --git a/DiaryApp/Models/Post.swift b/DiaryApp/Models/Post.swift index 4d9720c..9f2e08d 100644 --- a/DiaryApp/Models/Post.swift +++ b/DiaryApp/Models/Post.swift @@ -8,6 +8,7 @@ import Foundation struct Post: Codable { + var date: Date? var content: String? var goal: String? var image: String? @@ -17,6 +18,7 @@ struct Post: Codable { var weatherIcon: String enum CodingKeys: String, CodingKey { + case date case content case goal case image diff --git a/DiaryApp/Network/FirestoreManager.swift b/DiaryApp/Network/FirestoreManager.swift index 4d0eaa4..9c09a80 100644 --- a/DiaryApp/Network/FirestoreManager.swift +++ b/DiaryApp/Network/FirestoreManager.swift @@ -8,7 +8,7 @@ import FirebaseFirestore import Foundation -final class FirestoreService { +final class FirestoreManager { // let db = Firestore.firestore() static let db = Firestore.firestore() @@ -16,7 +16,7 @@ final class FirestoreService { var names: [[String: Any]] = [[:]] var post: [Post]? - FirestoreService.db.collection("Post").getDocuments { querySnapshot, error in + FirestoreManager.db.collection("Post").getDocuments { querySnapshot, error in if let error = error { print("Error getting documents: \(error)") completion(post) // 호출하는 쪽에 빈 배열 전달 @@ -31,11 +31,12 @@ final class FirestoreService { } } - func addPostDocument(content: String, goal: String, image: String, tag: [String], temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { + func addPostDocument(content: String, goal: String, date:Date, image: String, tag: [String], temperature: String, weather: String, weatherIcon: String, completion: @escaping (String) -> Void) { // Add a new document with a generated ID - FirestoreService.db.collection("Post").document(goal).setData([ + FirestoreManager.db.collection("Post").document(goal).setData([ "content": content, "goal": goal, + "date": date.timeIntervalSince1970, "image": image, "tag": tag, "temperature": temperature, @@ -46,13 +47,13 @@ final class FirestoreService { print("### Error adding document: \(err)") } else { completion("#### Post Document added") - print("### 현재 Firebase 에 저장된 데이터들 : \(FirestoreService.db.collection("Info").document(goal))") + print("### 현재 Firebase 에 저장된 데이터들 : \(FirestoreManager.db.collection("Post").document(goal))") } } } } -extension FirestoreService { +extension FirestoreManager { func dictionaryToObject(objectType: T.Type, dictionary: [[String: Any]]) -> [T]? { guard let dictionaries = try? JSONSerialization.data(withJSONObject: dictionary) else { return nil } let decoder = JSONDecoder() From 003cca40e00c69799b7a8987e864033f3537a1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=B5=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=AB?= Date: Mon, 4 Sep 2023 21:17:31 +0900 Subject: [PATCH 50/50] =?UTF-8?q?[FIX]NewDiaryVC=20=EB=82=A0=EC=94=A8=20ui?= =?UTF-8?q?=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/NewDiaryViewController.swift | 222 +++++++++--------- 1 file changed, 114 insertions(+), 108 deletions(-) diff --git a/DiaryApp/Controllers/NewDiaryViewController.swift b/DiaryApp/Controllers/NewDiaryViewController.swift index 17dd4fb..38cc814 100644 --- a/DiaryApp/Controllers/NewDiaryViewController.swift +++ b/DiaryApp/Controllers/NewDiaryViewController.swift @@ -18,7 +18,7 @@ enum Options: String { final class NewDiaryViewController: UIViewController { let options: [Options] = [.exercise, .food, .healthy, .crossFit] - + var postList: [Post] = [] var selectedButton: UIButton? @@ -31,10 +31,10 @@ final class NewDiaryViewController: UIViewController { let pickerView = UIPickerView() pickerView.delegate = self pickerView.dataSource = self - + return pickerView }() - + private let pickImageButton: UIButton = { let button = UIButton(type: .system) button.setImage(UIImage(systemName: "camera"), for: .normal) @@ -44,7 +44,7 @@ final class NewDiaryViewController: UIViewController { button.layer.borderColor = UIColor.lightGray.cgColor return button }() - + lazy var textView: UITextView = { let textView = UITextView() textView.text = "내용을 입력하세요" @@ -54,7 +54,7 @@ final class NewDiaryViewController: UIViewController { textView.contentInset = UIEdgeInsets(top: 5, left: 5, bottom: 0, right: 0) return textView }() - + private let goalButton: UIButton = { let button = UIButton(type: .system) button.setTitle("목표", for: .normal) @@ -66,7 +66,7 @@ final class NewDiaryViewController: UIViewController { button.addTarget(self, action: #selector(tappedGoalButton), for: .touchUpInside) return button }() - + private let exercisButton: UIButton = { let button = UIButton(type: .system) button.layer.borderWidth = 1 @@ -106,10 +106,10 @@ final class NewDiaryViewController: UIViewController { button.addTarget(self, action: #selector(tappedFoodButton), for: .touchUpInside) return button }() - + let weatherIconImageView: UIImageView = { let imageView = UIImageView() - + return imageView }() @@ -132,12 +132,12 @@ final class NewDiaryViewController: UIViewController { let label = UILabel() return label }() - + let temperatureLabel: UILabel = { let label = UILabel() return label }() - + private func setupLayout() { view.backgroundColor = .white view.addSubview(pickImageButton) @@ -148,172 +148,178 @@ final class NewDiaryViewController: UIViewController { view.addSubview(foodButton) view.addSubview(weatherDescriptionLabel) view.addSubview(completeButton) + view.addSubview(temperatureLabel) + view.addSubview(weatherIconImageView) pickImageButton.snp.makeConstraints { make in make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(20) make.bottom.equalTo(textView.snp.top).offset(-15) make.height.equalTo(pickImageButton.snp.width) } - + textView.snp.makeConstraints { make in make.top.equalTo(pickImageButton.snp.bottom).offset(100) make.leading.trailing.equalToSuperview().inset(20) // make.bottom.equalTo(view.safeAreaLayoutGuide).inset(100) make.bottom.equalTo(goalButton.snp.top).inset(-12) - make.height.equalTo(150) + make.height.equalTo(100) } - + goalButton.snp.makeConstraints { make in make.trailing.equalTo(textView) // make.top.equalTo(textView.snp.bottom).offset(12) make.width.equalTo(150) make.height.equalTo(30) } - + foodButton.snp.makeConstraints { make in make.top.equalTo(goalButton.snp.bottom).offset(12) make.leading.equalTo(textView.snp.leading) make.width.equalTo(100) + make.height.equalTo(goalButton) } - + healthyButton.snp.makeConstraints { make in make.top.equalTo(goalButton.snp.bottom).offset(12) make.centerX.equalToSuperview() make.width.equalTo(100) } - + exercisButton.snp.makeConstraints { make in make.top.equalTo(goalButton.snp.bottom).offset(12) make.trailing.equalTo(textView.snp.trailing) make.width.equalTo(100) } - + weatherDescriptionLabel.snp.makeConstraints { make in print("### \(weatherDescriptionLabel.bounds.height)") make.centerX.equalToSuperview() - make.top.equalTo(exercisButton.snp.bottom).offset(-50) - - completeButton.snp.makeConstraints { make in - make.top.equalTo(foodButton.snp.bottom).offset(12) - make.leading.equalTo(view.safeAreaLayoutGuide.snp.leading).offset(20) - make.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing).offset(-20) - make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-12) - } - } - } - - func checkedTag() { - if checkedExercise { - selectedTag.append("운동") - } - - if checkedHealthy { - selectedTag.append("건강") + make.top.equalTo(exercisButton.snp.bottom).offset(50) } - if checkedFood { - selectedTag.append("음식") + completeButton.snp.makeConstraints { make in + make.top.equalTo(foodButton.snp.bottom).offset(15) + make.leading.equalTo(view.safeAreaLayoutGuide.snp.leading).offset(20) + make.trailing.equalTo(view.safeAreaLayoutGuide.snp.trailing).offset(-20) + make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-60) - weatherDescriptionLabel.snp.makeConstraints { make in - print("### \(weatherDescriptionLabel.bounds.height)") - make.centerX.equalToSuperview() - make.top.equalTo(exercisButton.snp.bottom).offset(-50) - } + } + temperatureLabel.snp.makeConstraints { make in + make.trailing.equalTo(weatherDescriptionLabel.snp.trailing).offset(-120) + make.centerY.equalTo(weatherDescriptionLabel) + } + weatherIconImageView.snp.makeConstraints { make in + make.trailing.equalTo(textView) + make.centerY.equalTo(temperatureLabel) } } - - override func viewDidLoad() { - super.viewDidLoad() - setupLayout() - fetchAndDisplayWeather() +func checkedTag() { + if checkedExercise { + selectedTag.append("운동") } - - @objc func tappedGoalButton() { - print("### \(#function)") - if #available(iOS 16.0, *) { - let vc = DiaryCalendarViewController() - vc.modalPresentationStyle = .automatic - vc.dataSendClosure = { data in - self.selectedTitle = data.0 - self.selectedDate = data.1 - } - - self.present(vc, animated: true) - } + + if checkedHealthy { + selectedTag.append("건강") } - - @objc func tappedExerciseButton() { - print("### \(#function)") - checkedExercise = !checkedExercise - exercisButton.backgroundColor = (checkedExercise == false) ? .white : .systemGray + + if checkedFood { + selectedTag.append("음식") + } +} - @objc func tappedHealthyButton() { - print("### \(#function)") - checkedHealthy = !checkedHealthy - healthyButton.backgroundColor = (checkedHealthy == false) ? .white : .systemGray - } +override func viewDidLoad() { + super.viewDidLoad() + setupLayout() + fetchAndDisplayWeather() +} - @objc func tappedFoodButton() { - print("### \(#function)") - checkedFood = !checkedFood - foodButton.backgroundColor = (checkedFood == false) ? .white : .systemGray - } - - @objc func tappedCompleteButton() { - checkedTag() - FirestoreManager().addPostDocument(content: textView.text, goal: selectedTitle!, date: selectedDate!, image: "이미지", tag: selectedTag, temperature: "온도", weather: "날씨", weatherIcon: "아이콘") { _ in +@objc func tappedGoalButton() { + print("### \(#function)") + if #available(iOS 16.0, *) { + let vc = DiaryCalendarViewController() + vc.modalPresentationStyle = .automatic + vc.dataSendClosure = { data in + self.selectedTitle = data.0 + self.selectedDate = data.1 } + + self.present(vc, animated: true) } - - func fetchAndDisplayWeather() { - let city = "Busan" - WeatherManager.shared.fetchWeather(for: city) { result in - switch result { - case .success(let weatherData): - // 날씨 정보를 받아와 UI에 표시 - DispatchQueue.main.async { - self.weatherDescriptionLabel.text = weatherData.description - let celsiusTemp = round(weatherData.temperature - 273.15) +} + +@objc func tappedExerciseButton() { + print("### \(#function)") + checkedExercise = !checkedExercise + exercisButton.backgroundColor = (checkedExercise == false) ? .white : .systemGray +} - self.temperatureLabel.text = "\(celsiusTemp) °C" +@objc func tappedHealthyButton() { + print("### \(#function)") + checkedHealthy = !checkedHealthy + healthyButton.backgroundColor = (checkedHealthy == false) ? .white : .systemGray +} + +@objc func tappedFoodButton() { + print("### \(#function)") + checkedFood = !checkedFood + foodButton.backgroundColor = (checkedFood == false) ? .white : .systemGray +} - // 아이콘 이미지를 표시 - if let iconUrl = URL(string: weatherData.iconUrl) { - DispatchQueue.global().async { - if let imageData = try? Data(contentsOf: iconUrl), - let iconImage = UIImage(data: imageData) - { - DispatchQueue.main.async { - print("###이미지 다운로드 완ㄹ") +@objc func tappedCompleteButton() { + checkedTag() + FirestoreManager().addPostDocument(content: textView.text, goal: selectedTitle!, date: selectedDate!, image: "이미지", tag: selectedTag, temperature: "온도", weather: "날씨", weatherIcon: "아이콘") { _ in + } +} - self.weatherIconImageView.image = iconImage - } - } else { - print("이미지 다운로드 변환 실패 ###") +func fetchAndDisplayWeather() { + let city = "Busan" + WeatherManager.shared.fetchWeather(for: city) { result in + switch result { + case .success(let weatherData): + // 날씨 정보를 받아와 UI에 표시 + DispatchQueue.main.async { + self.weatherDescriptionLabel.text = weatherData.description + let celsiusTemp = round(weatherData.temperature - 273.15) + + self.temperatureLabel.text = "\(celsiusTemp) °C" + + // 아이콘 이미지를 표시 + if let iconUrl = URL(string: weatherData.iconUrl) { + DispatchQueue.global().async { + if let imageData = try? Data(contentsOf: iconUrl), + let iconImage = UIImage(data: imageData) + { + DispatchQueue.main.async { + print("###이미지 다운로드 완ㄹ") + + self.weatherIconImageView.image = iconImage } + } else { + print("이미지 다운로드 변환 실패 ###") } } } - case .failure(let error): - print("###날씨 정보 가져오기 실패: \(error)") } + case .failure(let error): + print("###날씨 정보 가져오기 실패: \(error)") } } } +} extension NewDiaryViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { @objc func pickImage() { showImagePicker() } - + func showImagePicker() { let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .photoLibrary present(imagePicker, animated: true, completion: nil) } - + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) { picker.dismiss(animated: true, completion: nil) if let selectedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { @@ -335,11 +341,11 @@ extension NewDiaryViewController: UIPickerViewDelegate, UIPickerViewDataSource { func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } - + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return options.count } - + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { return options[row].rawValue }