Skip to content

Commit

Permalink
[Merge] #58 - 홈 + 게시글 뷰 액션 추가
Browse files Browse the repository at this point in the history
Feat [#58] 홈 + 게시글 뷰 액션 추가
  • Loading branch information
yeonsu0-0 authored Jan 14, 2024
2 parents 499add0 + 667b194 commit 77c336c
Show file tree
Hide file tree
Showing 13 changed files with 554 additions and 61 deletions.
16 changes: 16 additions & 0 deletions DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
2FB818D92B5186FC00B7498F /* PostReplyCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB818D82B5186FC00B7498F /* PostReplyCollectionView.swift */; };
2FB818DC2B51875D00B7498F /* PostReplyCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB818DB2B51875D00B7498F /* PostReplyCollectionViewCell.swift */; };
2FBBADF12B53AF9B002D6286 /* PostReplyCollectionFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FBBADF02B53AF9B002D6286 /* PostReplyCollectionFooterView.swift */; };
2FBBADF42B53BEB5002D6286 /* TransparentPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FBBADF32B53BEB5002D6286 /* TransparentPopupViewController.swift */; };
2FBBADF62B53EEBD002D6286 /* CancelReplyPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FBBADF52B53EEBD002D6286 /* CancelReplyPopupViewController.swift */; };
2FBBADF82B53EF63002D6286 /* PostPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FBBADF72B53EF63002D6286 /* PostPopupView.swift */; };
2FBBADFA2B54401A002D6286 /* DeletePopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FBBADF92B54401A002D6286 /* DeletePopupViewController.swift */; };
3C01692A2B4DC82D0075334B /* DontBePopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0920DB2B4D78DA003BD080 /* DontBePopupView.swift */; };
3C0920DE2B4D98CD003BD080 /* DontBeToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0920DD2B4D98CD003BD080 /* DontBeToastView.swift */; };
3C2854FD2B3A9FD800369C99 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2854FC2B3A9FD800369C99 /* ExampleViewController.swift */; };
Expand Down Expand Up @@ -185,6 +189,10 @@
2FB818D82B5186FC00B7498F /* PostReplyCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostReplyCollectionView.swift; sourceTree = "<group>"; };
2FB818DB2B51875D00B7498F /* PostReplyCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostReplyCollectionViewCell.swift; sourceTree = "<group>"; };
2FBBADF02B53AF9B002D6286 /* PostReplyCollectionFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostReplyCollectionFooterView.swift; sourceTree = "<group>"; };
2FBBADF32B53BEB5002D6286 /* TransparentPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransparentPopupViewController.swift; sourceTree = "<group>"; };
2FBBADF52B53EEBD002D6286 /* CancelReplyPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelReplyPopupViewController.swift; sourceTree = "<group>"; };
2FBBADF72B53EF63002D6286 /* PostPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostPopupView.swift; sourceTree = "<group>"; };
2FBBADF92B54401A002D6286 /* DeletePopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeletePopupViewController.swift; sourceTree = "<group>"; };
3C0920DB2B4D78DA003BD080 /* DontBePopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DontBePopupView.swift; sourceTree = "<group>"; };
3C0920DD2B4D98CD003BD080 /* DontBeToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DontBeToastView.swift; sourceTree = "<group>"; };
3C2854FC2B3A9FD800369C99 /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -457,6 +465,8 @@
children = (
2FB64FEF2B5310DD0082A414 /* WriteReplyViewController.swift */,
2FB818D02B51693400B7498F /* PostViewController.swift */,
2FBBADF32B53BEB5002D6286 /* TransparentPopupViewController.swift */,
2FBBADF52B53EEBD002D6286 /* CancelReplyPopupViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand All @@ -466,6 +476,7 @@
children = (
2FB818D42B517EE700B7498F /* PostDetailView.swift */,
2FB818D22B51694F00B7498F /* PostView.swift */,
2FBBADF72B53EF63002D6286 /* PostPopupView.swift */,
2FB818D82B5186FC00B7498F /* PostReplyCollectionView.swift */,
2FBBADF02B53AF9B002D6286 /* PostReplyCollectionFooterView.swift */,
2FB769CF2B5277BD004C7752 /* PostReplyTextFieldView.swift */,
Expand Down Expand Up @@ -658,6 +669,7 @@
isa = PBXGroup;
children = (
2F8735412B4BE66500E55552 /* HomeViewController.swift */,
2FBBADF92B54401A002D6286 /* DeletePopupViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -854,6 +866,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2FBBADF62B53EEBD002D6286 /* CancelReplyPopupViewController.swift in Sources */,
2A8D70CA2B4D9787009F4C6C /* IntroductionView.swift in Sources */,
2A8D70CA2B4D9787009F4C6C /* IntroductionView.swift in Sources */,
3C6193172B3A7A7B00220CEB /* UIStackView+.swift in Sources */,
Expand All @@ -870,6 +883,7 @@
2FB64FF22B5318C50082A414 /* WriteReplyPostView.swift in Sources */,
2FB818D52B517EE700B7498F /* PostDetailView.swift in Sources */,
2F8735462B4C34A500E55552 /* HomeCollectionView.swift in Sources */,
2FBBADFA2B54401A002D6286 /* DeletePopupViewController.swift in Sources */,
3CEE4CBD2B500A7800F506AF /* DontBeTransparencyInfoView.swift in Sources */,
2F8735422B4BE66500E55552 /* HomeViewController.swift in Sources */,
2A0A730E2B5438B5004478C1 /* KeychainWrapper.swift in Sources */,
Expand All @@ -884,6 +898,7 @@
3CE9C1352B4C4BC20086E4A3 /* CircleProgressbar.swift in Sources */,
2AF069B22B518F8E00CA3E48 /* MyPageNicknameEditView.swift in Sources */,
2FB64FF42B531A5C0082A414 /* WriteReplyView.swift in Sources */,
2FBBADF42B53BEB5002D6286 /* TransparentPopupViewController.swift in Sources */,
3C6193192B3A7AC700220CEB /* Config.swift in Sources */,
3CF184D12B4EFF9900816D5F /* MyPageProfileView.swift in Sources */,
3C61931B2B3A7AD000220CEB /* NetworkError.swift in Sources */,
Expand Down Expand Up @@ -951,6 +966,7 @@
2A28453E2B531DDE0023F9B5 /* NetworkService.swift in Sources */,
2AC9FB1B2B4DE77400D31071 /* AgreementListCustomView.swift in Sources */,
2F17418A2B500CC20089FC4D /* HomeBottomsheetView.swift in Sources */,
2FBBADF82B53EF63002D6286 /* PostPopupView.swift in Sources */,
2FB64FF02B5310DD0082A414 /* WriteReplyViewController.swift in Sources */,
3C01692A2B4DC82D0075334B /* DontBePopupView.swift in Sources */,
2A2671FF2B4C3AF0009D214F /* Publisher+UIControl.swift in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions DontBe-iOS/DontBe-iOS/Global/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,18 @@ enum StringLiterals {
static let transparentPopupContentLabel = "지금 누르신 투명도 기능이 Don’t be를 더 온화한 커뮤니티로 만들기 위한 일이겠죠?"
static let transparentPopupLefteftButtonTitle = "조금 더 고민하기"
static let transparentPopupRightButtonTitle = "네, 맞아요"
static let deletePopupTitleLabel = "게시글을 삭제하시겠어요?"
static let deletePopupContentLabel = "삭제한 게시글은 영구히 사라져요."
static let deletePopupLefteftButtonTitle = "취소"
static let deletePopupRightButtonTitle = "삭제"
}

enum Post {
static let navigationTitleLabel = "게시글"
static let textFieldLabel = "님에게 답글 남기기"
static let popupReplyContentLabel = "작성 중인 글을 삭제하시겠어요?"
static let popupReplyCancelButtonTitle = "취소"
static let popupReplyConfirmButtonTitle = "삭제"

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ final class DontBeBottomSheetView: UIView {

// MARK: - UI Components

private let dimView: UIView = {
let dimView: UIView = {
let view = UIView()
view.backgroundColor = .donBlack.withAlphaComponent(0.6)
return view
}()

private let bottomsheetView: UIView = {
let bottomsheetView: UIView = {
let view = UIView()
view.backgroundColor = .donWhite
view.layer.cornerRadius = 8.adjusted
Expand All @@ -37,12 +37,18 @@ final class DontBeBottomSheetView: UIView {
return view
}()

let singleButton: UIButton = {
let deleteButton: UIButton = {
let button = UIButton()
button.setImage(ImageLiterals.Posting.btnDelete, for: .normal)
return button
}()

let warnButton: UIButton = {
let button = UIButton()
button.setImage(ImageLiterals.Posting.btnWarn, for: .normal)
return button
}()

let profileEditButton: UIButton = {
let button = UIButton()
button.setImage(ImageLiterals.Posting.btnDelete, for: .normal)
Expand Down Expand Up @@ -72,8 +78,6 @@ final class DontBeBottomSheetView: UIView {
init(singleButtonImage: UIImage) {
super.init(frame: .zero)

singleButton.setImage(singleButtonImage, for: .normal)

setUI()
setHierarchy()
setLayout()
Expand Down Expand Up @@ -111,7 +115,7 @@ extension DontBeBottomSheetView {
self.addSubviews(dimView,
bottomsheetView)
bottomsheetView.addSubviews(dragIndicatorView,
singleButton)
deleteButton)
}

private func setLayout() {
Expand All @@ -126,7 +130,7 @@ extension DontBeBottomSheetView {
$0.top.equalTo(19.adjusted)
}

singleButton.snp.makeConstraints {
deleteButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.width.equalTo(344.adjusted)
$0.height.equalTo(60.adjusted)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// DeletePopupViewController.swift
// DontBe-iOS
//
// Created by yeonsu on 1/15/24.
//

import UIKit

final class DeletePopupViewController: UIViewController {

// MARK: - Properties

// MARK: - UI Components

private let deletePostPopupView = DontBePopupView(popupTitle: StringLiterals.Home.deletePopupTitleLabel,
popupContent: StringLiterals.Home.deletePopupContentLabel,
leftButtonTitle: StringLiterals.Home.deletePopupLefteftButtonTitle,
rightButtonTitle: StringLiterals.Home.deletePopupRightButtonTitle)

private let myView = PostPopupView()

// MARK: - Life Cycles

override func loadView() {
super.loadView()

view = myView
}

override func viewDidLoad() {
super.viewDidLoad()

getAPI()
setUI()
setHierarchy()
setLayout()
setDelegate()
}
}

// MARK: - Extensions

extension DeletePopupViewController {
private func setUI() {

}

private func setHierarchy() {
view.addSubviews(deletePostPopupView)
}

private func setLayout() {
deletePostPopupView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}

private func setDelegate() {
deletePostPopupView.delegate = self
}
}

// MARK: - Network

extension DeletePopupViewController {
private func getAPI() {

}
}

extension DeletePopupViewController: DontBePopupDelegate {
func cancleButtonTapped() {
self.dismiss(animated: false)
}

func confirmButtonTapped() {
self.dismiss(animated: false)
// ✅ 투명도 주기 버튼 클릭 시 액션 추가
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@ final class HomeViewController: UIViewController {
var showUploadToastView: Bool = false
var deleteBottomsheet = DontBeBottomSheetView(singleButtonImage: ImageLiterals.Posting.btnDelete)
private let refreshControl = UIRefreshControl()
var transparentPopupVC = TransparentPopupViewController()
var deletePostPopupVC = CancelReplyPopupViewController()

// MARK: - UI Components

private let myView = HomeView()
private lazy var homeCollectionView = HomeCollectionView().collectionView
private let uploadToastView = DontBeToastView()

private let transparentButtonPopupView = DontBePopupView(popupImage: ImageLiterals.Popup.transparentButtonImage,
popupTitle: StringLiterals.Home.transparentPopupTitleLabel,
popupContent: StringLiterals.Home.transparentPopupContentLabel,
leftButtonTitle: StringLiterals.Home.transparentPopupLefteftButtonTitle,
rightButtonTitle: StringLiterals.Home.transparentPopupRightButtonTitle)

// MARK: - Life Cycles

override func loadView() {
Expand All @@ -48,6 +44,7 @@ final class HomeViewController: UIViewController {
setDelegate()
setNotification()
setRefreshControll()
setAddTarget()
}

// MARK: - TabBar Height
Expand All @@ -69,13 +66,13 @@ extension HomeViewController {
private func setUI() {
self.view.backgroundColor = UIColor.donGray1
uploadToastView.alpha = 0
transparentButtonPopupView.alpha = 0
transparentPopupVC.modalPresentationStyle = .overFullScreen
deletePostPopupVC.modalPresentationStyle = .overFullScreen
}

private func setHierarchy() {
view.addSubviews(homeCollectionView,
uploadToastView,
transparentButtonPopupView)
uploadToastView)
}

private func setLayout() {
Expand All @@ -90,16 +87,43 @@ extension HomeViewController {
$0.bottom.equalTo(tabBarHeight.adjusted).inset(6.adjusted)
$0.height.equalTo(44)
}

transparentButtonPopupView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

private func setAddTarget() {
deleteBottomsheet.deleteButton.addTarget(self, action: #selector(deletePost), for: .touchUpInside)
}

@objc
func deletePost() {
popView()
presentView()
}

func popView() {
if UIApplication.shared.keyWindowInConnectedScenes != nil {
UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
self.deleteBottomsheet.dimView.alpha = 0
if let window = UIApplication.shared.keyWindowInConnectedScenes {
self.deleteBottomsheet.bottomsheetView.frame = CGRect(x: 0, y: window.frame.height, width: self.deleteBottomsheet.frame.width, height: self.deleteBottomsheet.bottomsheetView.frame.height)
}
})
deleteBottomsheet.dimView.removeFromSuperview()
deleteBottomsheet.bottomsheetView.removeFromSuperview()
}
}

func presentView() {
self.present(self.deletePostPopupVC, animated: false, completion: nil)
}

@objc
private func dismissViewController() {
self.dismiss(animated: false)
}

private func setDelegate() {
homeCollectionView.dataSource = self
homeCollectionView.delegate = self
transparentButtonPopupView.delegate = self
}

private func setNotification() {
Expand All @@ -112,7 +136,7 @@ extension HomeViewController {
refreshControl.backgroundColor = .donGray1
}

@objc
@objc
func refreshPost() {
DispatchQueue.main.async {
// ✅ 서버 통신 영역
Expand All @@ -121,13 +145,11 @@ extension HomeViewController {
self.homeCollectionView.reloadData()
self.perform(#selector(self.finishedRefreshing), with: nil, afterDelay: 0.1)
}

@objc
func finishedRefreshing() {
refreshControl.endRefreshing()
}


@objc
func finishedRefreshing() {
refreshControl.endRefreshing()
}

@objc func showToast(_ notification: Notification) {
if let showToast = notification.userInfo?["showToast"] as? Bool {
Expand Down Expand Up @@ -196,7 +218,8 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega
cell.likeButton.setImage(cell.isLiked ? ImageLiterals.Posting.btnFavoriteActive : ImageLiterals.Posting.btnFavoriteInActive, for: .normal)
}
cell.TransparentButtonAction = {
self.transparentButtonPopupView.alpha = 1
// present
self.present(self.transparentPopupVC, animated: false, completion: nil)
}
return cell
}
Expand All @@ -216,14 +239,3 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted)
}
}

extension HomeViewController: DontBePopupDelegate {
func cancleButtonTapped() {
transparentButtonPopupView.alpha = 0
}

func confirmButtonTapped() {
transparentButtonPopupView.alpha = 0
// ✅ 투명도 주기 버튼 클릭 시 액션 추가
}
}
Loading

0 comments on commit 77c336c

Please sign in to comment.