Skip to content

Commit

Permalink
[Feat] #193 - 링크 저장/홈 뷰 클립 추가 바텀시트 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-min committed Aug 31, 2024
1 parent 8476ed2 commit 05fa8a9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
8 changes: 4 additions & 4 deletions TOASTER-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
83474A6D2BED0750009B9C48 /* PatchEditLinkTitleResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8364220B2BE7BFB2005C4085 /* PatchEditLinkTitleResponseDTO.swift */; };
8364220C2BE7BFB2005C4085 /* PatchEditLinkTitleResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8364220B2BE7BFB2005C4085 /* PatchEditLinkTitleResponseDTO.swift */; };
8388E98C2BC8FAB200858C5C /* PatchEditLinkTitleRequestDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8388E98B2BC8FAB200858C5C /* PatchEditLinkTitleRequestDTO.swift */; };
8388E98E2BC8FC6700858C5C /* DetailEditLinkBottomSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8388E98D2BC8FC6700858C5C /* DetailEditLinkBottomSheetView.swift */; };
8388E98E2BC8FC6700858C5C /* EditLinkBottomSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8388E98D2BC8FC6700858C5C /* EditLinkBottomSheetView.swift */; };
83CFC3372B564F1100A2EB2B /* WeeklyLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83CFC3362B564F1100A2EB2B /* WeeklyLinkModel.swift */; };
83CFC3392B568BE700A2EB2B /* RecommendSiteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83CFC3382B568BE700A2EB2B /* RecommendSiteModel.swift */; };
83CFC33B2B57324700A2EB2B /* SaveLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83CFC33A2B57324700A2EB2B /* SaveLinkModel.swift */; };
Expand Down Expand Up @@ -487,7 +487,7 @@
8315CD902B5521F70061F377 /* SelectClipModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectClipModel.swift; sourceTree = "<group>"; };
8364220B2BE7BFB2005C4085 /* PatchEditLinkTitleResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchEditLinkTitleResponseDTO.swift; sourceTree = "<group>"; };
8388E98B2BC8FAB200858C5C /* PatchEditLinkTitleRequestDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchEditLinkTitleRequestDTO.swift; sourceTree = "<group>"; };
8388E98D2BC8FC6700858C5C /* DetailEditLinkBottomSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailEditLinkBottomSheetView.swift; sourceTree = "<group>"; };
8388E98D2BC8FC6700858C5C /* EditLinkBottomSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditLinkBottomSheetView.swift; sourceTree = "<group>"; };
83CFC3362B564F1100A2EB2B /* WeeklyLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeeklyLinkModel.swift; sourceTree = "<group>"; };
83CFC3382B568BE700A2EB2B /* RecommendSiteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSiteModel.swift; sourceTree = "<group>"; };
83CFC33A2B57324700A2EB2B /* SaveLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SaveLinkModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -679,7 +679,7 @@
39BE4BBD2B4ABB7C002B471D /* DetailClipSegmentedControlView.swift */,
39BE4BBF2B4ABB9E002B471D /* DetailClipEmptyView.swift */,
39BE4BC12B4ABBB0002B471D /* DeleteLinkBottomSheetView.swift */,
8388E98D2BC8FC6700858C5C /* DetailEditLinkBottomSheetView.swift */,
8388E98D2BC8FC6700858C5C /* EditLinkBottomSheetView.swift */,
);
path = Component;
sourceTree = "<group>";
Expand Down Expand Up @@ -1948,7 +1948,7 @@
6BE6DA9C2B54752B008B06FA /* GetTimerMainpageResponseDTO.swift in Sources */,
6B6AE6AA2B3FF6EA000E2366 /* UIStackView+.swift in Sources */,
8305178A2B4D1E09009FFB60 /* UserClipCollectionViewCell.swift in Sources */,
8388E98E2BC8FC6700858C5C /* DetailEditLinkBottomSheetView.swift in Sources */,
8388E98E2BC8FC6700858C5C /* EditLinkBottomSheetView.swift in Sources */,
3913B0AE2BCEC9C00031A3EB /* UpdateAlertManager.swift in Sources */,
3F2FA17D2B4928B700EDBF95 /* LoginUseCase.swift in Sources */,
6BE6DA9A2B54747B008B06FA /* TimerAPIService.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ final class SelectClipViewController: UIViewController {
private let clipSelectCollectionView: UICollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
private let completeButton: UIButton = UIButton()
private let addClipBottomSheetView = AddClipBottomSheetView()
private lazy var addClipBottom = ToasterBottomSheetViewController(bottomType: .white,
private lazy var addClipBottom = ToasterBottomSheetViewController(bottomType: .white,
bottomTitle: "클립 추가",
height: 198,
insertView: addClipBottomSheetView)

private var selectedClipTapped: RemindClipModel? {
Expand Down Expand Up @@ -63,10 +62,10 @@ private extension SelectClipViewController {
view.backgroundColor = .toasterBackground

clipSelectCollectionView.do {
$0.register(RemindSelectClipCollectionViewCell.self,
$0.register(RemindSelectClipCollectionViewCell.self,
forCellWithReuseIdentifier: RemindSelectClipCollectionViewCell.className)

$0.register(SelectClipHeaderView.self,
$0.register(SelectClipHeaderView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: SelectClipHeaderView.className)

Expand All @@ -84,7 +83,7 @@ private extension SelectClipViewController {
}

func setupHierarchy() {
view.addSubviews(clipSelectCollectionView,
view.addSubviews(clipSelectCollectionView,
completeButton)
}

Expand Down Expand Up @@ -129,7 +128,7 @@ private extension SelectClipViewController {
func moveBottomAction(isDuplicated: Bool) {
if isDuplicated {
addHeightBottom()
addClipBottomSheetView.changeTextField(addButton: false,
addClipBottomSheetView.changeTextField(addButton: false,
border: true,
error: true,
clearButton: true)
Expand All @@ -140,11 +139,12 @@ private extension SelectClipViewController {
}

func addClipAction() {
addClipBottomSheetView.resetTextField()
addClipBottom.hideBottomSheet()
showToastMessage(width: 157,
status: .check,
message: StringLiterals.ToastMessage.completeAddClip)
dismiss(animated: true) {
self.addClipBottomSheetView.resetTextField()
self.showToastMessage(width: 157,
status: .check,
message: StringLiterals.ToastMessage.completeAddClip)
}
}

func saveLinkAction() {
Expand All @@ -154,7 +154,7 @@ private extension SelectClipViewController {

func saveFailAction() {
self.navigationController?.popToRootViewController(animated: true)
self.navigationController?.showToastMessage(width: 200,
self.navigationController?.showToastMessage(width: 200,
status: .warning,
message: "링크 저장에 실패했어요!")
}
Expand Down Expand Up @@ -186,14 +186,14 @@ private extension SelectClipViewController {
}

@objc func completeButtonTapped() {
viewModel.postSaveLink(url: linkURL,
viewModel.postSaveLink(url: linkURL,
category: categoryID)
}
}

// MARK: - UICollectionViewDelegate

extension SelectClipViewController: UICollectionViewDelegate {
extension SelectClipViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.item != 0 {
if let cell = collectionView.cellForItem(at: .SubSequence(item: 0, section: 0)) {
Expand All @@ -203,7 +203,7 @@ extension SelectClipViewController: UICollectionViewDelegate {
categoryID = viewModel.selectedClip[indexPath.item].id
}

func collectionView(_ collectionView: UICollectionView,
func collectionView(_ collectionView: UICollectionView,
willDisplay cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
if indexPath.item == 0 {
Expand Down Expand Up @@ -233,7 +233,7 @@ extension SelectClipViewController: UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader {
guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader,
guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: SelectClipHeaderView.className,
for: indexPath) as? SelectClipHeaderView else { return UICollectionReusableView() }
headerView.selectClipHeaderViewDelegate = self
Expand All @@ -245,7 +245,7 @@ extension SelectClipViewController: UICollectionViewDataSource {
}

// Header 크기 지정
func collectionView(_ collectionView: UICollectionView,
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: 335, height: 68)
Expand All @@ -255,19 +255,19 @@ extension SelectClipViewController: UICollectionViewDataSource {
// MARK: - UICollectionViewDelegateFlowLayout

extension SelectClipViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.convertByWidthRatio(335), height: 52)
}

func collectionView(_ collectionView: UICollectionView,
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
}

func collectionView(_ collectionView: UICollectionView,
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 8
Expand All @@ -277,12 +277,12 @@ extension SelectClipViewController: UICollectionViewDelegateFlowLayout {
extension SelectClipViewController: SelectClipHeaderViewlDelegate {
func addClipCellTapped() {
if viewModel.selectedClip.count > 15 {
showToastMessage(width: 243,
status: .warning,
showToastMessage(width: 243,
status: .warning,
message: StringLiterals.ToastMessage.noticeMaxClip)
} else {
addClipBottom.modalPresentationStyle = .overFullScreen
self.present(addClipBottom, animated: false)
addClipBottom.setupSheetPresentation(bottomHeight: 198)
self.present(addClipBottom, animated: true)
}
}
}
Expand All @@ -297,17 +297,16 @@ extension SelectClipViewController: AddClipBottomSheetViewDelegate {
}

func addHeightBottom() {
addClipBottom.changeHeightBottomSheet(height: 219)
addClipBottom.setupSheetHeightChanges(bottomHeight: 219)
}

func minusHeightBottom() {
addClipBottom.changeHeightBottomSheet(height: 198)
addClipBottom.setupSheetHeightChanges(bottomHeight: 198)
}

func dismissButtonTapped() {
addClipBottom.hideBottomSheet()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.showToastMessage(width: 157,
dismiss(animated: true) {
self.showToastMessage(width: 157,
status: .check,
message: StringLiterals.ToastMessage.completeAddClip)
self.addClipBottomSheetView.resetTextField()
Expand Down
20 changes: 10 additions & 10 deletions TOASTER-iOS/Present/Home/View/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ final class HomeViewController: UIViewController {
private let addClipBottomSheetView = AddClipBottomSheetView()
private lazy var addClipBottom = ToasterBottomSheetViewController(bottomType: .white,
bottomTitle: "클립 추가",
height: 198,
insertView: addClipBottomSheetView)

// MARK: - Life Cycle
Expand Down Expand Up @@ -277,11 +276,12 @@ private extension HomeViewController {
}

func addClipAction() {
addClipBottomSheetView.resetTextField()
addClipBottom.hideBottomSheet()
showToastMessage(width: 157,
status: .check,
message: StringLiterals.ToastMessage.completeAddClip)
dismiss(animated: true) {
self.addClipBottomSheetView.resetTextField()
self.showToastMessage(width: 157,
status: .check,
message: StringLiterals.ToastMessage.completeAddClip)
}
}

func setupNavigationBar() {
Expand Down Expand Up @@ -318,11 +318,11 @@ extension HomeViewController: AddClipBottomSheetViewDelegate {
}

func addHeightBottom() {
addClipBottom.changeHeightBottomSheet(height: 219)
addClipBottom.setupSheetHeightChanges(bottomHeight: 219)
}

func minusHeightBottom() {
addClipBottom.changeHeightBottomSheet(height: 198)
addClipBottom.setupSheetHeightChanges(bottomHeight: 198)
}

func dismissButtonTapped(title: String) {
Expand All @@ -334,8 +334,8 @@ extension HomeViewController: AddClipBottomSheetViewDelegate {

extension HomeViewController: UserClipCollectionViewCellDelegate {
func addClipCellTapped() {
addClipBottom.modalPresentationStyle = .overFullScreen
self.present(addClipBottom, animated: false)
addClipBottom.setupSheetPresentation(bottomHeight: 198)
self.present(addClipBottom, animated: true)
}
}

Expand Down

0 comments on commit 05fa8a9

Please sign in to comment.