-
Notifications
You must be signed in to change notification settings - Fork 5
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
[FIX] #133 - 메인에서 카드셀 좌우 스와이프로 바꾸기 구현 #138
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,4 +133,3 @@ extension FrontCardCell { | |
linkURLLabel.text = linkURL | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import UIKit | ||
import VerticalCardSwiper | ||
import KakaoSDKCommon | ||
|
||
class MainCardCell: CardCell { | ||
|
||
|
@@ -16,35 +17,30 @@ class MainCardCell: CardCell { | |
|
||
public var cardDataModel: Card? | ||
|
||
// MARK: - @IBOutlet Properties | ||
|
||
@IBOutlet weak var cardView: UIView! | ||
|
||
// MARK: - View Life Cycle | ||
|
||
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
|
||
setUI() | ||
setGestureRecognizer() | ||
} | ||
|
||
// MARK: - Methods | ||
|
||
static func nib() -> UINib { | ||
return UINib(nibName: Const.Xib.mainCardCell, bundle: Bundle(for: MainCardCell.self)) | ||
} | ||
} | ||
|
||
// MARK: - Extensions | ||
|
||
extension MainCardCell { | ||
private func setGestureRecognizer() { | ||
let swipeLeftGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(transitionCardWithAnimation(_:))) | ||
swipeLeftGestureRecognizer.direction = .left | ||
self.cardView.addGestureRecognizer(swipeLeftGestureRecognizer) | ||
|
||
let swipeRightGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(transitionCardWithAnimation(_:))) | ||
swipeRightGestureRecognizer.direction = .right | ||
self.cardView.addGestureRecognizer(swipeRightGestureRecognizer) | ||
} | ||
private func setFrontCard() { | ||
private func setUI() { } | ||
public func setFrontCard() { | ||
guard let frontCard = FrontCardCell.nib().instantiate(withOwner: self, options: nil).first as? FrontCardCell else { return } | ||
|
||
frontCard.frame = CGRect(x: 0, y: 0, width: cardView.frame.width, height: cardView.frame.height) | ||
frontCard.frame = CGRect(x: 0, y: 0, width: contentView.frame.width, height: contentView.frame.height) | ||
guard let cardDataModel = cardDataModel else { return } | ||
frontCard.initCell(cardDataModel.background, | ||
cardDataModel.title, | ||
|
@@ -55,16 +51,27 @@ extension MainCardCell { | |
cardDataModel.instagram ?? "", | ||
cardDataModel.link ?? "") | ||
|
||
cardView.addSubview(frontCard) | ||
contentView.addSubview(frontCard) | ||
} | ||
private func setGestureRecognizer() { | ||
let swipeLeftGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(transitionCardWithAnimation(_:))) | ||
swipeLeftGestureRecognizer.direction = .left | ||
self.contentView.addGestureRecognizer(swipeLeftGestureRecognizer) | ||
|
||
let swipeRightGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(transitionCardWithAnimation(_:))) | ||
swipeRightGestureRecognizer.direction = .right | ||
self.contentView.addGestureRecognizer(swipeRightGestureRecognizer) | ||
} | ||
public func initCell(cardDataModel: Card) { | ||
self.cardDataModel = cardDataModel | ||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 감싸합니ㄷㅏ👍🏻 |
||
} | ||
|
||
// MARK: - @objc Methods | ||
|
||
@objc | ||
private func transitionCardWithAnimation(_ swipeGesture: UISwipeGestureRecognizer) { | ||
if isFront { | ||
guard let backCard = BackCardCell.nib().instantiate(withOwner: self, options: nil).first as? BackCardCell else { return } | ||
backCard.frame = CGRect(x: 0, y: 0, width: cardView.frame.width, height: cardView.frame.height) | ||
backCard.frame = CGRect(x: 0, y: 0, width: contentView.frame.width, height: contentView.frame.height) | ||
guard let cardDataModel = cardDataModel else { return } | ||
backCard.initCell(cardDataModel.background, | ||
cardDataModel.isMincho, | ||
|
@@ -75,12 +82,12 @@ extension MainCardCell { | |
cardDataModel.twoTMI ?? "", | ||
cardDataModel.thirdTMI ?? "") | ||
|
||
cardView.addSubview(backCard) | ||
contentView.addSubview(backCard) | ||
isFront = false | ||
} else { | ||
guard let frontCard = FrontCardCell.nib().instantiate(withOwner: self, options: nil).first as? FrontCardCell else { return } | ||
|
||
frontCard.frame = CGRect(x: 0, y: 0, width: cardView.frame.width, height: cardView.frame.height) | ||
frontCard.frame = CGRect(x: 0, y: 0, width: contentView.frame.width, height: contentView.frame.height) | ||
guard let cardDataModel = cardDataModel else { return } | ||
frontCard.initCell(cardDataModel.background, | ||
cardDataModel.title, | ||
|
@@ -91,18 +98,17 @@ extension MainCardCell { | |
cardDataModel.instagram ?? "", | ||
cardDataModel.link ?? "") | ||
|
||
cardView.addSubview(frontCard) | ||
contentView.addSubview(frontCard) | ||
isFront = true | ||
} | ||
if swipeGesture.direction == .right { | ||
UIView.transition(with: cardView, duration: 1, options: .transitionFlipFromLeft, animations: nil) { _ in | ||
self.cardView.subviews[0].removeFromSuperview() | ||
UIView.transition(with: contentView, duration: 1, options: .transitionFlipFromLeft, animations: nil) { _ in | ||
self.contentView.subviews[0].removeFromSuperview() | ||
} | ||
} else { | ||
UIView.transition(with: cardView, duration: 1, options: .transitionFlipFromRight, animations: nil) { _ in | ||
self.cardView.subviews[0].removeFromSuperview() | ||
UIView.transition(with: contentView, duration: 1, options: .transitionFlipFromRight, animations: nil) { _ in | ||
self.contentView.subviews[0].removeFromSuperview() | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,48 +4,25 @@ | |
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="MainCardCell" customModule="NADA_iOS_forRelease" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="219" height="219"/> | ||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" restorationIdentifier="MainCardCell" id="gTV-IL-0wX" customClass="MainCardCell" customModule="NADA_iOS_forRelease" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="327" height="540"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> | ||
<rect key="frame" x="0.0" y="0.0" width="219" height="219"/> | ||
<rect key="frame" x="0.0" y="0.0" width="327" height="540"/> | ||
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 고뇌의 흔적이군요 ^__^ |
||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<subviews> | ||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="t8s-2k-kGK"> | ||
<rect key="frame" x="0.0" y="0.0" width="219" height="219"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
<userDefinedRuntimeAttributes> | ||
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius"> | ||
<real key="value" value="20"/> | ||
</userDefinedRuntimeAttribute> | ||
</userDefinedRuntimeAttributes> | ||
</view> | ||
</subviews> | ||
</view> | ||
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/> | ||
<constraints> | ||
<constraint firstAttribute="bottom" secondItem="t8s-2k-kGK" secondAttribute="bottom" id="BZT-mt-kON"/> | ||
<constraint firstItem="t8s-2k-kGK" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="MD9-Ct-jCL"/> | ||
<constraint firstAttribute="trailing" secondItem="t8s-2k-kGK" secondAttribute="trailing" id="iGJ-dk-0lZ"/> | ||
<constraint firstItem="t8s-2k-kGK" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="pgR-nj-dsj"/> | ||
</constraints> | ||
<size key="customSize" width="219" height="219"/> | ||
<connections> | ||
<outlet property="cardView" destination="t8s-2k-kGK" id="bA4-0N-vMR"/> | ||
</connections> | ||
<userDefinedRuntimeAttributes> | ||
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius"> | ||
<real key="value" value="20"/> | ||
</userDefinedRuntimeAttribute> | ||
</userDefinedRuntimeAttributes> | ||
<point key="canvasLocation" x="260.14492753623188" y="170.42410714285714"/> | ||
</collectionViewCell> | ||
</objects> | ||
<resources> | ||
<systemColor name="systemBackgroundColor"> | ||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
</systemColor> | ||
</resources> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
미처 지우지 못한거 죄송합니다 ㅠㅠ