Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Feat] #155 - 습관방 만들기 화면전환 및 각종 코드 디테일 수정 #158

Merged
merged 8 commits into from
Jan 21, 2022
4 changes: 4 additions & 0 deletions Spark-iOS/Spark-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
EB9C508C2792A90400588155 /* CompleteAuth.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB9C508B2792A90400588155 /* CompleteAuth.storyboard */; };
EB9C509827931E4600588155 /* AuthUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9C509727931E4600588155 /* AuthUploadVC.swift */; };
EB9C509A27931E5F00588155 /* AuthUpload.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB9C509927931E5F00588155 /* AuthUpload.storyboard */; };
EBA2D6CF2799EAFE0022DFD6 /* UIImage+.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBA2D6CE2799EAFD0022DFD6 /* UIImage+.swift */; };
EBA77239278A2E14002958A5 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EBA77238278A2E14002958A5 /* Colors.xcassets */; };
EBA93A7D27907EF9009AE771 /* CodeJoinVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBA93A7C27907EF9009AE771 /* CodeJoinVC.swift */; };
EBA93A7F279080E2009AE771 /* JoinCheckVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBA93A7E279080E2009AE771 /* JoinCheckVC.swift */; };
Expand Down Expand Up @@ -212,6 +213,7 @@
EB9C508B2792A90400588155 /* CompleteAuth.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CompleteAuth.storyboard; sourceTree = "<group>"; };
EB9C509727931E4600588155 /* AuthUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthUploadVC.swift; sourceTree = "<group>"; };
EB9C509927931E5F00588155 /* AuthUpload.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = AuthUpload.storyboard; sourceTree = "<group>"; };
EBA2D6CE2799EAFD0022DFD6 /* UIImage+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+.swift"; sourceTree = "<group>"; };
EBA77238278A2E14002958A5 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
EBA93A7C27907EF9009AE771 /* CodeJoinVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodeJoinVC.swift; sourceTree = "<group>"; };
EBA93A7E279080E2009AE771 /* JoinCheckVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinCheckVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -840,6 +842,7 @@
2B9852062790984C00CE40A7 /* UIViewController+.swift */,
F86C68B827958AA9009A5296 /* UIImageView+.swift */,
2B13FB22279899C6004CCE46 /* UIScreen+.swift */,
EBA2D6CE2799EAFD0022DFD6 /* UIImage+.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1239,6 +1242,7 @@
2B13FB23279899C6004CCE46 /* UIScreen+.swift in Sources */,
EB625E87278F27F000C43DE9 /* StorageListDataModel.swift in Sources */,
2BE5D80E2793203C007A544D /* Stopwatch.swift in Sources */,
EBA2D6CF2799EAFE0022DFD6 /* UIImage+.swift in Sources */,
2BE5D81627932F31007A544D /* ResetPopupVC.swift in Sources */,
EB625E83278F273200C43DE9 /* FailStorageCVC.swift in Sources */,
);
Expand Down
2 changes: 1 addition & 1 deletion Spark-iOS/Spark-iOS/Source/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
}

// 백그라운드에서 자동 푸시 알림 처리
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.

Expand Down
3 changes: 1 addition & 2 deletions Spark-iOS/Spark-iOS/Source/Cells/Feed/FeedCVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FeedCVC: UICollectionViewCell {
let likeCountLabel = UILabel()
let lottieView = AnimationView(name: "icHeartActive")
var likeState: Bool = false
var likeDelegate: FeedCellDelegate?
weak var likeDelegate: FeedCellDelegate?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.....wow..

var cellId: Int = 0

// MARK: - View Life Cycles
Expand Down Expand Up @@ -182,7 +182,6 @@ extension FeedCVC {
}
}


// MARK: - Layout
extension FeedCVC {
private func setLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ extension HabitRoomMemberCVC {

if status == "CONSIDER" {
statusLabel.text = "지금은 고민중이에요."
// TODO: - 이미지 에셋 받아서 수정
stickerImage.image = UIImage(named: "stickerThingking")
stickerImage.isHidden = false
} else if status == "DONE" {
Expand Down
2 changes: 0 additions & 2 deletions Spark-iOS/Spark-iOS/Source/Cells/Home/HomeWaitingCVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ extension HomeWaitingCVC {
habitTitleLabel.textColor = .sparkDeepGray
}

// TODO: - initCell

func initCell(roomName: String) {
habitTitleLabel.text = roomName

Expand Down
23 changes: 18 additions & 5 deletions Spark-iOS/Spark-iOS/Source/Cells/StorageMore/MoreStorageCVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,33 @@ class MoreStorageCVC: UICollectionViewCell {
dDayLabel.text = "D-day"
}

override func prepareForReuse() {
certificationImage.image = UIImage()
dDayLabel.text = ""
sparkCountLabel.text = ""
}

func initCell(leftDay: Int,
mainImage: String,
sparkCount: Int) {
if mainImage == "" {
certificationImage.image = UIImage(named: "stickerRestBigMybox")
certificationImage.contentMode = .scaleAspectFit
} else {
sparkCount: Int,
status: String) {
switch status {
case "NONE":
certificationImage.image = UIImage()
case "DONE":
certificationImage.updateImage(mainImage)
certificationImage.contentMode = .scaleAspectFill
default:
certificationImage.image = UIImage(named: "stickerRestBigMybox")
}

sparkCountLabel.text = String(sparkCount)

if leftDay == 0 {
dDayLabel.text = "D-day"
} else if leftDay == 66 {
dDayLabel.text = "D-\(leftDay)"
certificationImage.image = UIImage()
Comment on lines +51 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

66일은 모아보기 서버에서 안넘겨준다고 했지만 혹시 서버에서 잘못줄수도있으니 분기는 처리해둡시당

} else {
dDayLabel.text = "D-\(leftDay)"
}
Expand Down
19 changes: 19 additions & 0 deletions Spark-iOS/Spark-iOS/Source/Extensions/UIImage+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UIImage+.swift
// Spark-iOS
//
// Created by Junho Lee on 2022/01/21.
//

import UIKit

extension UIImage {
func resize(newWidth: CGFloat) -> UIImage {
let scale = newWidth / self.size.width
let newHeight = self.size.height * scale
let size = CGSize(width: newWidth, height: newHeight)
let render = UIGraphicsImageRenderer(size: size)
let renderImage = render.image { context in self.draw(in: CGRect(origin: .zero, size: size)) }
return renderImage
}
Comment on lines +11 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

호오... newWidth 는 어떤 기준이될까 궁금하네여

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension FeedService: TargetType {
}
}

var headers: [String : String]? {
var headers: [String: String]? {
switch self {
case .feedFetch:
return Const.Header.authorizationHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ extension AuthUploadVC: UIImagePickerControllerDelegate, UINavigationControllerD

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
uploadImageView.image = image
uploadImageView.image = image.resize(newWidth: 250)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤 기준이 됐을까여?

fadeImageView.isHidden = false
buttonStackView.isHidden = false
photoAuthButton.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class HabitAuthVC: UIViewController {
setAddTargets()
}


@IBAction func touchOutsideDismiss(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
Expand Down Expand Up @@ -78,9 +77,15 @@ extension HabitAuthVC {
restButton.layer.borderColor = UIColor.sparkLightPinkred.cgColor
restButton.layer.borderWidth = 1
restButton.layer.cornerRadius = 2
// if restNumber == 0 {
// restButton.isEnabled = false
// }

restNumberLabel.text = String(rest ?? 0)

if rest == 0 {
restButton.isEnabled = false
restButton.layer.borderColor = UIColor.sparkGray.cgColor
restButton.setTitleColor(.sparkGray, for: .normal)
restButton.tintColor = .sparkGray
}
}

private func setAddTargets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ extension HabitRoomVC: UIImagePickerControllerDelegate, UINavigationControllerDe

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
imageContainer = image
imageContainer = image.resize(newWidth: 250)
}

dismiss(animated: true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ extension ProfileSettingVC: UIImagePickerControllerDelegate, UINavigationControl
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
// UIImage 타입인 originalImage를 빼옴
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
profileImageView.image = image
profileImageView.image = image.resize(newWidth: 150)
profileImageView.contentMode = .scaleAspectFill
}
dismiss(animated: true, completion: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ extension StorageMoreVC {

extension StorageMoreVC: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// 컬렉션뷰 크기 정하기
// 컬렉션뷰 위드에 맞게 셀 위드 정하기
// 셀 위드에 대해서 간격과 높이 정하기
let cellWidth: CGFloat = collectionView.frame.width
let cellWidthRatio: CGFloat = 160/375
let widthHeightRatio: CGFloat = 203/160
Expand All @@ -116,13 +113,20 @@ extension StorageMoreVC: UICollectionViewDelegateFlowLayout {

extension StorageMoreVC: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return myRoomCertificationList?.count ?? 0
if myRoomCertificationList?.last?.leftDay == 66 {
return ((myRoomCertificationList?.count ?? 0) - 1)
} else {
return myRoomCertificationList?.count ?? 0
}
Comment on lines +116 to +120
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 66일 넘어올까봐에 대한 분기처리인가용?

}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Const.Xib.NibName.moreStorageCVC, for: indexPath) as? MoreStorageCVC else {return UICollectionViewCell()}

cell.initCell(leftDay: myRoomCertificationList?[indexPath.row].leftDay ?? 0, mainImage: myRoomCertificationList?[indexPath.row].certifyingImg ?? "", sparkCount: myRoomCertificationList?[indexPath.row].sparkNum ?? 0)
cell.initCell(leftDay: myRoomCertificationList?[indexPath.row].leftDay ?? 0,
mainImage: myRoomCertificationList?[indexPath.row].certifyingImg ?? "",
sparkCount: myRoomCertificationList?[indexPath.row].sparkNum ?? 0,
status: myRoomCertificationList?[indexPath.row].status ?? "")

return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ extension HomeVC {
self.mainCollectionView.reloadData()
}

// FIXME: - 아래의 목적인데 한번 체크해야할듯
// 성공적으로 한번의 통신이 마무리된 후 무한스크롤 허용. 즉, 연속적으로 통신을 요청하지 않게 하기 위함.
Comment on lines -227 to -228
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요건 fixme 가 필요한 상태라 살려주실 수 있을까여 ㅜ

completion()
case .requestErr(let message):
print("habitRoomFetchWithAPI - requestErr: \(message)")
Expand Down
23 changes: 17 additions & 6 deletions Spark-iOS/Spark-iOS/Source/ViewControllers/Waiting/WaitingVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class WaitingVC: UIViewController {
backgroundColor: .sparkWhite,
reftButtonImage: UIImage(named: "icBackWhite"),
rightButtonImage: UIImage(),
reftButtonSelector: #selector(goToHomeVC),
reftButtonSelector: #selector(popToHomeVC),
rightButtonSelector: #selector(touchToMore))
} else {
navigationController?.initWithTwoCustomButtonsTitle(navigationItem: self.navigationItem,
Expand All @@ -88,7 +88,7 @@ class WaitingVC: UIViewController {
backgroundColor: .sparkWhite,
reftButtonImage: UIImage(named: "icHome"),
rightButtonImage: UIImage(),
reftButtonSelector: #selector(goToHomeVC),
reftButtonSelector: #selector(dismissToHomeVC),
rightButtonSelector: #selector(touchToMore))
}
}
Expand Down Expand Up @@ -245,10 +245,15 @@ class WaitingVC: UIViewController {
// MARK: - 화면 전환

@objc
func goToHomeVC() {
func popToHomeVC() {
navigationController?.popViewController(animated: true)
}

@objc
func dismissToHomeVC() {
presentingViewController?.presentingViewController?.dismiss(animated: true)
}

@objc
func touchToMore() {
// 더보기 버튼
Expand All @@ -262,8 +267,13 @@ class WaitingVC: UIViewController {

@objc
func touchToCreateButton() {
postStartRoomWithAPI(roomID: roomId ?? 0)
// TODO: - 상세뷰로 화면 전환
postStartRoomWithAPI(roomID: roomId ?? 0) {
if self.isFromHome ?? false {
self.navigationController?.popViewController(animated: true)
} else {
self.presentingViewController?.presentingViewController?.dismiss(animated: true)
}
}
}
}

Expand Down Expand Up @@ -380,10 +390,11 @@ extension WaitingVC {
}
}

func postStartRoomWithAPI(roomID: Int) {
func postStartRoomWithAPI(roomID: Int, completion: @escaping () -> Void) {
RoomAPI.shared.startRoomWithAPI(roomID: roomID) { response in
switch response {
case .success(let message):
completion()
print("postStartRoomWithAPI - success: \(message)")
case .requestErr(let message):
print("postStartRoomWithAPI - requestErr: \(message)")
Expand Down