From 89a3a17b06aba4d8ff9978c815f9ffb69ed75ea2 Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Mon, 18 Oct 2021 13:46:15 +0900
Subject: [PATCH 1/7] =?UTF-8?q?[FEAT]=20#47=20-=20=EB=A6=AC=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=EB=B7=B0=20=EB=B0=B1=20=EC=8A=A4=EC=99=80=EC=9D=B4?=
=?UTF-8?q?=ED=94=84=20=EC=A0=9C=EC=8A=A4=EC=B2=98=20=ED=99=94=EB=A9=B4=20?=
=?UTF-8?q?=EC=A0=84=ED=99=98=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Sources/Cells/CardList/CardListTableViewCell.xib | 6 +++++-
.../ViewControllers/CardList/CardListViewController.swift | 7 +++++++
.../CustomTabBar/CustomTabBarController.swift | 2 +-
.../Sources/ViewControllers/Main/FrontViewController.swift | 1 +
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
index 5b1b484a..5e887c45 100644
--- a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
+++ b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
@@ -4,6 +4,7 @@
+
@@ -56,7 +57,7 @@
-
+
@@ -80,5 +81,8 @@
+
+
+
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
index aa0394bd..a11c1a5a 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
@@ -20,12 +20,15 @@ class CardListViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
+ navigationBackSwipeMotion()
+
setCardList()
cardListTableView.register(CardListTableViewCell.nib(), forCellReuseIdentifier: "CardListTableViewCell")
cardListTableView.delegate = self
cardListTableView.dataSource = self
+
}
// MARK: - IBAction Properties
@@ -45,6 +48,10 @@ class CardListViewController: UIViewController {
CardListDataModel(title: "SOPT 28기 명함", date: "2021/08/29")
])
}
+
+ func navigationBackSwipeMotion() {
+ self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
+ }
}
// MARK: - UITableViewDelegate
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
index a9442767..e880cd1e 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
@@ -65,7 +65,7 @@ class CustomTabBarController: UITabBarController {
}
// MARK: - Functions
- public func setTabBarHidden(_ isHidden: Bool, animated: Bool) {
+ private func setTabBarHidden(_ isHidden: Bool, animated: Bool) {
let block = {
self.customTabBar.alpha = isHidden ? 0 : 1
self.additionalSafeAreaInsets = isHidden ? .zero : UIEdgeInsets(top: 0, left: 0, bottom: self.tabBarHeight + self.bottomSpacing, right: 0)
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
index 31cfa3b1..a35930f6 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
@@ -63,6 +63,7 @@ class FrontViewController: UIViewController {
// 명함 리스트 뷰로 화면 전환
@IBAction func pushToCardListView(_ sender: Any) {
let nextVC = UIStoryboard(name: Const.Storyboard.Name.cardList, bundle: nil).instantiateViewController(identifier: Const.ViewController.Identifier.cardListViewController)
+
self.navigationController?.pushViewController(nextVC, animated: true)
}
From 7e16d5a8827a5bcfd363480650c7163b0c62b009 Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Mon, 18 Oct 2021 13:47:07 +0900
Subject: [PATCH 2/7] =?UTF-8?q?[FEAT]=20#47=20-=20=ED=95=80=20=ED=81=B4?=
=?UTF-8?q?=EB=A6=AD=EC=8B=9C=20=EB=B0=B0=EA=B2=BD=EC=83=89=20=EB=B3=80?=
=?UTF-8?q?=EA=B2=BD=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
---
.../Sources/Cells/CardList/CardListTableViewCell.swift | 2 ++
1 file changed, 2 insertions(+)
diff --git a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
index 913b8068..0c984784 100644
--- a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
+++ b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
@@ -34,8 +34,10 @@ class CardListTableViewCell: UITableViewCell {
if pinButton.currentImage == pinImage {
pinButton.setImage(UIImage(named: "pushPinBlack"), for: UIControl.State.normal)
+ self.contentView.backgroundColor = UIColor.black1
} else {
pinButton.setImage(UIImage(named: "pushPinBlackFilled"), for: UIControl.State.normal)
+ self.contentView.backgroundColor = UIColor.listSelectedBlack3
}
}
From f1c31bd8ac7db5a296ed7e1ad9a2eaebd13f6726 Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Mon, 18 Oct 2021 14:13:39 +0900
Subject: [PATCH 3/7] =?UTF-8?q?[FIX]=20#47=20-=20=ED=85=8C=EC=9D=B4?=
=?UTF-8?q?=EB=B8=94=EB=B7=B0=20=EC=85=80=20=EA=B5=AC=EB=B6=84=EC=84=A0=20?=
=?UTF-8?q?=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Resouces/Storyboards/CardList.storyboard | 18 +++++++++--
.../Cells/CardList/CardListTableViewCell.xib | 31 +++++++++++++------
.../CardList/CardListViewController.swift | 2 +-
3 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
index 67914de2..e662cc78 100644
--- a/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
+++ b/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
@@ -4,6 +4,7 @@
+
@@ -36,22 +37,32 @@
-
+
+
+
+
+
+
+
+
+
+
+
@@ -63,10 +74,13 @@
-
+
+
+
+
diff --git a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
index 5e887c45..a39ccd3e 100644
--- a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
+++ b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
@@ -12,14 +12,14 @@
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
@@ -74,7 +84,7 @@
-
+
@@ -84,5 +94,8 @@
+
+
+
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
index a11c1a5a..26c40a9b 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
@@ -57,7 +57,7 @@ class CardListViewController: UIViewController {
// MARK: - UITableViewDelegate
extension CardListViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 75
+ return 76
}
// Swipe Action
From 4ea4c35976c097a8ef326a355830fd6bc2a3d7c9 Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Mon, 18 Oct 2021 15:37:06 +0900
Subject: [PATCH 4/7] =?UTF-8?q?[FEAT]=20#47=20-=20Drag=20&=20Drop=EC=9C=BC?=
=?UTF-8?q?=EB=A1=9C=20cell=20=EC=A0=95=EB=A0=AC=20=ED=95=A8=EC=88=98=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CardList/CardListViewController.swift | 89 ++++++++++++++++++-
1 file changed, 88 insertions(+), 1 deletion(-)
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
index 26c40a9b..4beb02d7 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
@@ -7,6 +7,7 @@
import UIKit
import Moya
+import KakaoSDKCommon
class CardListViewController: UIViewController {
@@ -29,6 +30,9 @@ class CardListViewController: UIViewController {
cardListTableView.delegate = self
cardListTableView.dataSource = self
+ let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCalled(_:)))
+ cardListTableView.addGestureRecognizer(longPressGesture)
+
}
// MARK: - IBAction Properties
@@ -52,12 +56,95 @@ class CardListViewController: UIViewController {
func navigationBackSwipeMotion() {
self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
+
+ func snapShotOfCall(_ inputView: UIView) -> UIView {
+ UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, false, 0.0)
+ inputView.layer.render(in: UIGraphicsGetCurrentContext()!)
+ let image = UIGraphicsGetImageFromCurrentImageContext()! as UIImage
+
+ let cellSnapshot: UIView = UIImageView(image: image)
+ cellSnapshot.layer.masksToBounds = false
+ cellSnapshot.layer.cornerRadius = 0.0
+ cellSnapshot.layer.shadowOffset = CGSize(width: -5.0, height: 0.0)
+ cellSnapshot.layer.shadowRadius = 5.0
+ cellSnapshot.layer.shadowOpacity = 0.4
+
+ return cellSnapshot
+ }
+
+ @objc func longPressCalled(_ longPress: UILongPressGestureRecognizer) {
+ let locationInView = longPress.location(in: cardListTableView)
+ let indexPath = cardListTableView.indexPathForRow(at: locationInView)
+
+ struct MyCell {
+ static var cellSnapShot: UIView?
+ }
+
+ struct Path {
+ static var initialIndexPath: IndexPath?
+ }
+
+ switch longPress.state {
+
+ case UIGestureRecognizer.State.began:
+ guard let indexPath = indexPath else {
+ return
+ }
+ guard let cell = cardListTableView.cellForRow(at: indexPath) else { return }
+ Path.initialIndexPath = indexPath
+ MyCell.cellSnapShot = snapShotOfCall(cell)
+
+ var center = cell.center
+ MyCell.cellSnapShot?.center = center
+ MyCell.cellSnapShot?.alpha = 0.0
+ cardListTableView.addSubview(MyCell.cellSnapShot!)
+
+ UIImageView.animate(withDuration: 0.25, animations: { () -> Void in
+ center.y = locationInView.y
+ MyCell.cellSnapShot?.center = center
+ MyCell.cellSnapShot?.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
+ MyCell.cellSnapShot?.alpha = 0.98
+ cell.alpha = 0.0
+ }, completion: { (finished) -> Void in
+ if finished {
+ cell.isHidden = true
+ }
+ })
+
+ case UIGestureRecognizer.State.changed:
+ var center = MyCell.cellSnapShot?.center
+ center?.y = locationInView.y
+ MyCell.cellSnapShot?.center = center!
+
+ if (indexPath != nil) && (indexPath != Path.initialIndexPath) {
+ swap(&cardItems[indexPath!.row], &cardItems[Path.initialIndexPath!.row])
+ cardListTableView.moveRow(at: Path.initialIndexPath!, to: indexPath!)
+ Path.initialIndexPath = indexPath
+ }
+ default:
+ guard let cell = cardListTableView.cellForRow(at: Path.initialIndexPath!) else {return}
+ cell.isHidden = true
+ cell.alpha = 0.0
+
+ UIView.animate(withDuration: 0.25, animations: { () -> Void in
+ MyCell.cellSnapShot?.center = cell.center
+ MyCell.cellSnapShot?.transform = CGAffineTransform.identity
+ MyCell.cellSnapShot?.alpha = 0.0
+ }, completion: { (finished) -> Void in
+ if finished {
+ Path.initialIndexPath = nil
+ MyCell.cellSnapShot?.removeFromSuperview()
+ MyCell.cellSnapShot = nil
+ }
+ })
+ }
+ }
}
// MARK: - UITableViewDelegate
extension CardListViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 76
+ return 76
}
// Swipe Action
From 1b9eb249e790d24a8d02686c77019936a170f7b1 Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Mon, 18 Oct 2021 16:17:20 +0900
Subject: [PATCH 5/7] =?UTF-8?q?[FEAT]=20#47=20-=20=EB=A6=AC=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=20=EB=B7=B0=EC=97=90=EC=84=9C=20=ED=83=AD=EB=B0=94=20?=
=?UTF-8?q?hidden=20=EA=B5=AC=ED=98=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Storyboards/CustomTabBar.storyboard | 2 +-
.../CustomTabBar/CustomTabBarController.swift | 24 ++++++++++++++++++-
.../Main/FrontViewController.swift | 8 +++++++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
index a1109eca..18930dad 100644
--- a/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
+++ b/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
@@ -11,7 +11,7 @@
-
+
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
index e880cd1e..8aee68e0 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
@@ -62,6 +62,15 @@ class CustomTabBarController: UITabBarController {
customTabBar.setGradient(color1: UIColor(red: 1, green: 1, blue: 1, alpha: 0.35),
color2: UIColor(red: 1, green: 1, blue: 1, alpha: 0.15))
customTabBar.setBlur()
+
+ NotificationCenter.default.addObserver(self,
+ selector: #selector(nextClickRecieved),
+ name: NSNotification.Name("deleteTabBar"),
+ object: nil)
+ NotificationCenter.default.addObserver(self,
+ selector: #selector(prviousClickRecieved),
+ name: NSNotification.Name("expressTabBar"),
+ object: nil)
}
// MARK: - Functions
@@ -113,6 +122,7 @@ class CustomTabBarController: UITabBarController {
customTabBar.tintColor = tintColor
}
}
+
// MARK: - CardTabBarDelegate
extension CustomTabBarController: CardTabBarDelegate {
func cardTabBar(_ sender: CustomTabBar, didSelectItemAt index: Int) {
@@ -120,7 +130,19 @@ extension CustomTabBarController: CardTabBarDelegate {
}
}
-// MARK: - Extensions
+// MARK: - CustomTabBarController Extensions
+extension CustomTabBarController {
+ // 탭바의 hidden 상태처리 함수
+ @objc func nextClickRecieved() {
+ setTabBarHidden(true, animated: false)
+ }
+
+ @objc func prviousClickRecieved() {
+ setTabBarHidden(false, animated: false)
+ }
+}
+
+// MARK: - CustomTabBar Extensions
extension CustomTabBar {
// 그라데이션 효과 적용
func setGradient(color1: UIColor, color2: UIColor) {
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
index a35930f6..e66afa5a 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift
@@ -59,10 +59,18 @@ class FrontViewController: UIViewController {
}
+ override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
+ NotificationCenter.default.post(name: NSNotification.Name("expressTabBar"), object: nil)
+
+ }
+
// MARK: - @IBAction Properties
// 명함 리스트 뷰로 화면 전환
@IBAction func pushToCardListView(_ sender: Any) {
let nextVC = UIStoryboard(name: Const.Storyboard.Name.cardList, bundle: nil).instantiateViewController(identifier: Const.ViewController.Identifier.cardListViewController)
+
+ NotificationCenter.default.post(name: NSNotification.Name("deleteTabBar"), object: nil)
self.navigationController?.pushViewController(nextVC, animated: true)
}
From bf1f71a4ad4d929942879d324750a1a90606512f Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Sun, 31 Oct 2021 00:06:02 +0900
Subject: [PATCH 6/7] =?UTF-8?q?[FEAT]=20#47=20-=20Drag=20&=20Drop=EC=9C=BC?=
=?UTF-8?q?=EB=A1=9C=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=B7=B0=20=EC=85=80?=
=?UTF-8?q?=20=EC=A0=95=EB=A0=AC=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
---
.swiftlint.yml | 1 +
.../Storyboards/CustomTabBar.storyboard | 4 +-
.../CardList/CardListTableViewCell.swift | 4 +
.../Cells/CardList/CardListTableViewCell.xib | 3 +
.../CardList/CardListViewController.swift | 183 +++++++++++-------
5 files changed, 123 insertions(+), 72 deletions(-)
diff --git a/.swiftlint.yml b/.swiftlint.yml
index a2ce896a..e3fbf4e5 100644
--- a/.swiftlint.yml
+++ b/.swiftlint.yml
@@ -3,6 +3,7 @@ disabled_rules:
- trailing_whitespace
- nesting
- function_parameter_count
+- function_body_length
excluded:
- Pods
- NADA-iOS-forRelease/Sources/AppDelegate.swift
diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
index 18930dad..0eea2460 100644
--- a/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
+++ b/NADA-iOS-forRelease/Resouces/Storyboards/CustomTabBar.storyboard
@@ -1,9 +1,9 @@
-
+
-
+
diff --git a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
index 0c984784..362ecbbf 100644
--- a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
+++ b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.swift
@@ -41,6 +41,10 @@ class CardListTableViewCell: UITableViewCell {
}
}
+ @IBAction func reorderButtonClicked(_ sender: Any) {
+
+ }
+
func initData(title: String,
date: String) {
titleLabel.text = title
diff --git a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
index a39ccd3e..7fa08414 100644
--- a/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
+++ b/NADA-iOS-forRelease/Sources/Cells/CardList/CardListTableViewCell.xib
@@ -55,6 +55,9 @@
+
+
+
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
index 4beb02d7..783b8887 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
@@ -30,9 +30,17 @@ class CardListViewController: UIViewController {
cardListTableView.delegate = self
cardListTableView.dataSource = self
- let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCalled(_:)))
+ self.cardListTableView.allowsSelection = false
+
+ let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCalled(gestureRecognizer:)))
cardListTableView.addGestureRecognizer(longPressGesture)
+
+ }
+
+ override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
+ cardListTableView.reloadData()
}
// MARK: - IBAction Properties
@@ -60,7 +68,8 @@ class CardListViewController: UIViewController {
func snapShotOfCall(_ inputView: UIView) -> UIView {
UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, false, 0.0)
inputView.layer.render(in: UIGraphicsGetCurrentContext()!)
- let image = UIGraphicsGetImageFromCurrentImageContext()! as UIImage
+ let image = UIGraphicsGetImageFromCurrentImageContext()!
+ UIGraphicsEndImageContext()
let cellSnapshot: UIView = UIImageView(image: image)
cellSnapshot.layer.masksToBounds = false
@@ -71,74 +80,6 @@ class CardListViewController: UIViewController {
return cellSnapshot
}
-
- @objc func longPressCalled(_ longPress: UILongPressGestureRecognizer) {
- let locationInView = longPress.location(in: cardListTableView)
- let indexPath = cardListTableView.indexPathForRow(at: locationInView)
-
- struct MyCell {
- static var cellSnapShot: UIView?
- }
-
- struct Path {
- static var initialIndexPath: IndexPath?
- }
-
- switch longPress.state {
-
- case UIGestureRecognizer.State.began:
- guard let indexPath = indexPath else {
- return
- }
- guard let cell = cardListTableView.cellForRow(at: indexPath) else { return }
- Path.initialIndexPath = indexPath
- MyCell.cellSnapShot = snapShotOfCall(cell)
-
- var center = cell.center
- MyCell.cellSnapShot?.center = center
- MyCell.cellSnapShot?.alpha = 0.0
- cardListTableView.addSubview(MyCell.cellSnapShot!)
-
- UIImageView.animate(withDuration: 0.25, animations: { () -> Void in
- center.y = locationInView.y
- MyCell.cellSnapShot?.center = center
- MyCell.cellSnapShot?.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
- MyCell.cellSnapShot?.alpha = 0.98
- cell.alpha = 0.0
- }, completion: { (finished) -> Void in
- if finished {
- cell.isHidden = true
- }
- })
-
- case UIGestureRecognizer.State.changed:
- var center = MyCell.cellSnapShot?.center
- center?.y = locationInView.y
- MyCell.cellSnapShot?.center = center!
-
- if (indexPath != nil) && (indexPath != Path.initialIndexPath) {
- swap(&cardItems[indexPath!.row], &cardItems[Path.initialIndexPath!.row])
- cardListTableView.moveRow(at: Path.initialIndexPath!, to: indexPath!)
- Path.initialIndexPath = indexPath
- }
- default:
- guard let cell = cardListTableView.cellForRow(at: Path.initialIndexPath!) else {return}
- cell.isHidden = true
- cell.alpha = 0.0
-
- UIView.animate(withDuration: 0.25, animations: { () -> Void in
- MyCell.cellSnapShot?.center = cell.center
- MyCell.cellSnapShot?.transform = CGAffineTransform.identity
- MyCell.cellSnapShot?.alpha = 0.0
- }, completion: { (finished) -> Void in
- if finished {
- Path.initialIndexPath = nil
- MyCell.cellSnapShot?.removeFromSuperview()
- MyCell.cellSnapShot = nil
- }
- })
- }
- }
}
// MARK: - UITableViewDelegate
@@ -180,3 +121,105 @@ extension CardListViewController: UITableViewDataSource {
return serviceCell
}
}
+
+// MARK: - Extension: 테이블 뷰 Drag & Drop 기능
+extension CardListViewController {
+ // FIX: cyclomatic_complexity 워닝 발생 -> decision이 복잡해서라는데...일단 보류...
+ @objc func longPressCalled(gestureRecognizer: UIGestureRecognizer) {
+ guard let longPress = gestureRecognizer as? UILongPressGestureRecognizer else { return }
+ let state = longPress.state
+ let locationInView = longPress.location(in: cardListTableView)
+ let indexPath = cardListTableView.indexPathForRow(at: locationInView)
+
+ // 최초 indexPath 변수
+ struct Initial {
+ static var initialIndexPath: IndexPath?
+ }
+
+ // 스냅샷
+ struct MyCell {
+ static var cellSnapshot: UIView?
+ static var cellIsAnimating: Bool = false
+ static var cellNeedToShow: Bool = false
+ }
+
+ // UIGestureRecognizer 상태에 따른 case 분기처리
+ switch state {
+
+ // longPress 제스처가 시작할 때 case
+ case UIGestureRecognizer.State.began:
+ if indexPath != nil {
+ Initial.initialIndexPath = indexPath
+ var cell: UITableViewCell? = UITableViewCell()
+ cell = cardListTableView.cellForRow(at: indexPath!)
+
+ MyCell.cellSnapshot = snapShotOfCall(cell!)
+
+ var center = cell?.center
+ MyCell.cellSnapshot!.center = center!
+ MyCell.cellSnapshot!.alpha = 0.0
+ cardListTableView.addSubview(MyCell.cellSnapshot!)
+
+ UIView.animate(withDuration: 0.25, animations: { () -> Void in
+ center?.y = locationInView.y
+ MyCell.cellIsAnimating = true
+ MyCell.cellSnapshot!.center = center!
+ MyCell.cellSnapshot!.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
+ MyCell.cellSnapshot!.alpha = 0.98
+ cell?.alpha = 0.0
+ }, completion: { (finished) -> Void in
+ if finished {
+ MyCell.cellIsAnimating = false
+ if MyCell.cellNeedToShow {
+ MyCell.cellNeedToShow = false
+ UIView.animate(withDuration: 0.25, animations: { () -> Void in
+ cell?.alpha = 1
+ })
+ } else {
+ cell?.isHidden = true
+ }
+ }
+ })
+ }
+ // longPress 제스처가 변경될 때 case
+ case UIGestureRecognizer.State.changed:
+ if MyCell.cellSnapshot != nil {
+ var center = MyCell.cellSnapshot!.center
+ center.y = locationInView.y
+ MyCell.cellSnapshot!.center = center
+
+ if ((indexPath != nil) && (indexPath != Initial.initialIndexPath)) && Initial.initialIndexPath != nil {
+ // this line change row index
+ self.cardItems.insert(self.cardItems.remove(at: Initial.initialIndexPath!.row), at: indexPath!.row)
+ cardListTableView.moveRow(at: Initial.initialIndexPath!, to: indexPath!)
+ Initial.initialIndexPath = indexPath
+ }
+ }
+ // longPress 제스처가 끝났을 때 case
+ default:
+ if Initial.initialIndexPath != nil {
+ let cell = cardListTableView.cellForRow(at: Initial.initialIndexPath!)
+ if MyCell.cellIsAnimating {
+ MyCell.cellNeedToShow = true
+ } else {
+ cell?.isHidden = false
+ cell?.alpha = 0.0
+ }
+
+ UIView.animate(withDuration: 0.2, animations: { () -> Void in
+ MyCell.cellSnapshot!.center = (cell?.center)!
+ MyCell.cellSnapshot!.transform = CGAffineTransform.identity
+ MyCell.cellSnapshot!.alpha = 0.0
+ cell?.alpha = 1.0
+
+ }, completion: { (finished) -> Void in
+ if finished {
+ Initial.initialIndexPath = nil
+ MyCell.cellSnapshot!.removeFromSuperview()
+ MyCell.cellSnapshot = nil
+ }
+ })
+ }
+ }
+ }
+}
From d609b08f58e883cd363264883a482ccdd4cc1b7a Mon Sep 17 00:00:00 2001
From: MinjaeLee <2alswo7@khu.ac.kr>
Date: Sun, 31 Oct 2021 15:44:22 +0900
Subject: [PATCH 7/7] =?UTF-8?q?[CHORE]=20#47=20-=20=EC=BD=94=EB=93=9C?=
=?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Resouces/Constants/Notification.swift | 2 ++
.../Resouces/Storyboards/CardList.storyboard | 4 ++--
.../Resouces/Storyboards/Main/Front.storyboard | 4 ++--
.../CardList/CardListViewController.swift | 13 ++++++++-----
.../CustomTabBar/CustomTabBarController.swift | 4 ++--
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift
index 4dd813d5..49b3b20d 100644
--- a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift
+++ b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift
@@ -10,4 +10,6 @@ import Foundation
extension Notification.Name {
static let frontCardtextFieldIsEmpty = Notification.Name("frontCardtextFieldIsEmpty")
static let backCardtextFieldIsEmpty = Notification.Name("backCardtextFieldIsEmpty")
+ static let deleteTabBar = NSNotification.Name("deleteTabBar")
+ static let expressTabBar = NSNotification.Name("expressTabBar")
}
diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
index e662cc78..9a0433df 100644
--- a/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
+++ b/NADA-iOS-forRelease/Resouces/Storyboards/CardList.storyboard
@@ -1,9 +1,9 @@
-
+
-
+
diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/Main/Front.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/Main/Front.storyboard
index 3c3b8f12..e7f64bf2 100644
--- a/NADA-iOS-forRelease/Resouces/Storyboards/Main/Front.storyboard
+++ b/NADA-iOS-forRelease/Resouces/Storyboards/Main/Front.storyboard
@@ -1,9 +1,9 @@
-
+
-
+
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
index 783b8887..15a65ab0 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardList/CardListViewController.swift
@@ -24,16 +24,12 @@ class CardListViewController: UIViewController {
navigationBackSwipeMotion()
setCardList()
+ setLongPressGesture()
cardListTableView.register(CardListTableViewCell.nib(), forCellReuseIdentifier: "CardListTableViewCell")
cardListTableView.delegate = self
cardListTableView.dataSource = self
-
- self.cardListTableView.allowsSelection = false
-
- let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCalled(gestureRecognizer:)))
- cardListTableView.addGestureRecognizer(longPressGesture)
}
@@ -61,6 +57,13 @@ class CardListViewController: UIViewController {
])
}
+ func setLongPressGesture() {
+ self.cardListTableView.allowsSelection = false
+
+ let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCalled(gestureRecognizer:)))
+ cardListTableView.addGestureRecognizer(longPressGesture)
+ }
+
func navigationBackSwipeMotion() {
self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
index 8aee68e0..204bb1ed 100644
--- a/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
+++ b/NADA-iOS-forRelease/Sources/ViewControllers/CustomTabBar/CustomTabBarController.swift
@@ -65,11 +65,11 @@ class CustomTabBarController: UITabBarController {
NotificationCenter.default.addObserver(self,
selector: #selector(nextClickRecieved),
- name: NSNotification.Name("deleteTabBar"),
+ name: .deleteTabBar,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(prviousClickRecieved),
- name: NSNotification.Name("expressTabBar"),
+ name: .expressTabBar,
object: nil)
}