Skip to content

Commit

Permalink
fix: BBAnimatable, BBTextToolTipView, BBThumbnailToolTipView, BBToolT…
Browse files Browse the repository at this point in the history
…IpView 코드리뷰 반영

- ManagementTableHeaderView ToolTipView 추가
  • Loading branch information
Do-hyun-Kim committed Dec 19, 2024
1 parent d873e2a commit 2ce2660
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ final public class MemoriesCalendarPageTitleView: BaseView<MemoriesCalendarTitle

private func bindOutput(reactor: Reactor) {
reactor.pulse(\.$hiddenTooltipView)
.bind(with: self) {
$1 ? $0.toolTipView.hide()
: $0.toolTipView.show()
}
.bind(to: toolTipView.rx.isHidden)
.disposed(by: disposeBag)
}

Expand Down Expand Up @@ -100,7 +97,6 @@ final public class MemoriesCalendarPageTitleView: BaseView<MemoriesCalendarTitle

toolTipView.do {
$0.superview = tipButton
$0.hide()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ public final class ManagementTableHeaderReactor {

// MARK: - Action

public enum Action { }
public enum Action {
case didTappedToolTipButton
}


// MARK: - Mutation

public enum Mutation { }
public enum Mutation {
case setToolTipHidden(Bool)
}


// MARK: - State

public struct State { }
public struct State {
@Pulse var isHidden: Bool = false
}


// MARK: - Properties
Expand All @@ -39,4 +45,19 @@ public final class ManagementTableHeaderReactor {
self.initialState = State()
}

public func mutate(action: Action) -> Observable<Mutation> {
switch action {
case .didTappedToolTipButton:
return .just(.setToolTipHidden(!currentState.isHidden))
}
}

public func reduce(state: State, mutation: Mutation) -> State {
var newState = state
switch mutation {
case let .setToolTipHidden(isHidden):
newState.isHidden = isHidden
}
return newState
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class ManagementTableHeaderView: BaseView<ManagementTableHeaderReac
private let familyNameLabel: BBLabel = BBLabel(.head1, textColor: .gray200)
private let memberCountLabel: BBLabel = BBLabel(.body1Regular, textColor: .gray400)
private let familyNameEditButton: BBButton = BBButton()

private let familyNameToolTipeView: BBToolTip = BBToolTip(.familyNameEdit)

// MARK: - Properties

Expand Down Expand Up @@ -58,6 +58,9 @@ public final class ManagementTableHeaderView: BaseView<ManagementTableHeaderReac
$0.setImage(DesignSystemAsset.edit.image, for: .normal)
$0.addTarget(self, action: #selector(didTapFamilyNameEditButton(_:event:)), for: .touchUpInside)
}
familyNameToolTipeView.do {
$0.superview = familyNameEditButton
}
}

public override func setupAutoLayout() {
Expand All @@ -75,6 +78,18 @@ public final class ManagementTableHeaderView: BaseView<ManagementTableHeaderReac
}
}

public override func bind(reactor: Reactor) {
familyNameEditButton.rx.tap
.throttle(RxInterval._300milliseconds, scheduler: RxScheduler.main)
.map { Reactor.Action.didTappedToolTipButton }
.bind(to: reactor.action)
.disposed(by: disposeBag)

reactor.pulse(\.$isHidden)
.bind(to: familyNameToolTipeView.rx.isHidden)
.disposed(by: disposeBag)
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public extension BBComponentShowable where Self: BBToolTip {
superview?.addSubview(contentView)
updateLayout()

UIView.animate(withDuration: duration, delay: 0, options: options) { [weak self] in
guard let self else { return }
UIView.animate(withDuration: duration, delay: 0, options: options) {
self.contentView?.transform = CGAffineTransform.identity
self.contentView?.alpha = 1
}
Expand All @@ -55,13 +54,12 @@ public extension BBComponentClosable where Self: BBToolTip {
alpha: CGFloat = 0
) {

UIView.animate(withDuration: duration, delay: 0, options: options, animations: { [weak self] in
guard let self = self else { return }
UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
self.contentView?.transform = transform
self.contentView?.alpha = 0
}, completion: { [weak self] _ in
self?.contentView?.removeFromSuperview()
self?.contentView?.transform = .identity
}, completion: { _ in
self.contentView?.removeFromSuperview()
self.contentView?.transform = .identity
})

self.contentView?.layoutIfNeeded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BBTextToolTipView: BBBaseToolTipView {
super.init(toolTipType: toolTipType)
setupToolTipUI()
setupToolTipContent()
setupAutoLayount()
setupAutoLayout()
}

required init?(coder: NSCoder) {
Expand All @@ -54,7 +54,7 @@ public class BBTextToolTipView: BBBaseToolTipView {
}
}

private func setupAutoLayount() {
private func setupAutoLayout() {
let position = toolTipType.configure.yPosition
let arrowHeight: CGFloat = toolTipType.configure.arrowHeight
let textPadding: CGFloat = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BBThumbnailToolTipView: BBBaseToolTipView {
}
setupToolTipUI()
setupToolTipContent()
setupAutoLayount()
setupAutoLayout()
setupThumbnailImageView(imageURL: imageURLs)
}

Expand All @@ -51,7 +51,7 @@ public class BBThumbnailToolTipView: BBBaseToolTipView {
}


public func setupAutoLayount() {
public func setupAutoLayout() {
let arrowHeight: CGFloat = toolTipType.configure.arrowHeight
let textPadding: CGFloat = 10
guard case let .waitingSurvivalImage(_, imageURLs) = toolTipType else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public final class BBToolTip: NSObject, BBComponentPresentable {
// MARK: - Properties
public var contentView: BBBaseToolTipView?
public var superview: UIView?
public var isHidden: Bool = true {
didSet { isHidden ? self.hide() : self.show() }
}

public var toolTipStyle: BBToolTipType {
didSet {
contentView?.removeFromSuperview()
Expand Down

0 comments on commit 2ce2660

Please sign in to comment.