Skip to content

Commit

Permalink
feat: rxgestrue로 imageview에 탭 바인딩 (TeamNADA#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwns33 committed Feb 28, 2023
1 parent c2d79ad commit f30ca58
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
// Created by Yi Joon Choi on 2023/02/06.
//

import UIKit
import RxSwift
import RxRelay
import RxCocoa
import RxGesture
import SnapKit
import Then
import UIKit

final class HomeViewController: UIViewController {

// MARK: - Properties

private let disposeBag = DisposeBag()
private let aroundMeTapGesture = UITapGestureRecognizer()

// MARK: - UI Components

private let nadaIcon = UIImageView().then {
$0.image = UIImage(named: "nadaLogoTxt")
}
Expand Down Expand Up @@ -54,6 +62,7 @@ final class HomeViewController: UIViewController {
super.viewDidLoad()
setUI()
setLayout()
bindActions()
}

}
Expand All @@ -65,6 +74,7 @@ extension HomeViewController {
private func setUI() {
self.view.backgroundColor = .white
self.navigationController?.navigationBar.isHidden = true
aroundMeImageView.addGestureRecognizer(aroundMeTapGesture)
}

private func setLayout() {
Expand Down Expand Up @@ -118,4 +128,30 @@ extension HomeViewController {
}

// MARK: - Methods

private func bindActions() {
giveCardImageView.rx.tapGesture()
.when(.recognized) // bind시에도 이벤트가 발생하기 때문 .skip(1)으로도 처리 가능
.withUnretained(self)
.bind { owner, _ in
owner.makeVibrate()
print("명함 주기")
}.disposed(by: self.disposeBag)

takeCardImageView.rx.tapGesture()
.when(.recognized) // bind시에도 이벤트가 발생하기 때문 .skip(1)으로도 처리 가능
.withUnretained(self)
.bind { owner, _ in
owner.makeVibrate()
print("명함 받기")
}.disposed(by: self.disposeBag)

aroundMeImageView.rx.tapGesture()
.when(.recognized) // bind시에도 이벤트가 발생하기 때문 .skip(1)으로도 처리 가능
.withUnretained(self)
.bind { owner, _ in
owner.makeVibrate()
print("근처의 명함")
}.disposed(by: self.disposeBag)
}
}

0 comments on commit f30ca58

Please sign in to comment.