diff --git a/14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPageTitleView.swift b/14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPageTitleView.swift index 4c550a018..f13c3200a 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPageTitleView.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPageTitleView.swift @@ -21,7 +21,7 @@ final public class MemoriesCalendarPageTitleView: BaseView Observable { + 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 + } } diff --git a/14th-team5-iOS/App/Sources/Presentation/Management/View/ManagementTableHeaderView.swift b/14th-team5-iOS/App/Sources/Presentation/Management/View/ManagementTableHeaderView.swift index e1c9fd2d9..680d5662f 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Management/View/ManagementTableHeaderView.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Management/View/ManagementTableHeaderView.swift @@ -20,7 +20,7 @@ public final class ManagementTableHeaderView: BaseView Void)? = nil) { + switch style { + case .waitingSurvivalImage: + self.contentView = BBThumbnailToolTipView(toolTipType: style) + default: + self.contentView = BBTextToolTipView(toolTipType: style) + } + + completion?() + } +} diff --git a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipConfiguration.swift b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipConfiguration.swift index f46711b80..6f4cfd0f2 100644 --- a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipConfiguration.swift +++ b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipConfiguration.swift @@ -12,27 +12,30 @@ import DesignSystem /// BBToolTip에 (UI, Width, Height) Properties를 설정하기 위한 구조체입니다. public struct BBToolTipConfiguration { /// ToolTip Corner Radius - public var cornerRadius: CGFloat + public let cornerRadius: CGFloat /// TooTip TextFont Foreground Color - public var foregroundColor: UIColor + public let foregroundColor: UIColor /// TooTip Background Color - public var backgroundColor: UIColor - /// ToolTip Arrow Position - public var position: BBToolTipVerticalPosition + public let backgroundColor: UIColor + /// ToolTip Arrow YPosition + public let yPosition: BBToolTipVerticalPosition + /// ToolTip Arrow XPosition + public let xPosition: BBToolTipHorizontalPosition /// ToolTip Text Font - public var font: BBFontStyle + public let font: BBFontStyle /// ToolTip Content Text - public var contentText: String + public let contentText: String /// ToolTip Arrow Width - public var arrowWidth: CGFloat + public let arrowWidth: CGFloat /// ToolTip Arrow Height - public var arrowHeight: CGFloat + public let arrowHeight: CGFloat public init( cornerRadius: CGFloat = 12, foregroundColor: UIColor = .bibbiBlack, backgroundColor: UIColor = .mainYellow, - position: BBToolTipVerticalPosition = .top, + yPosition: BBToolTipVerticalPosition = .bottom, + xPosition: BBToolTipHorizontalPosition = .center, font: BBFontStyle = .body2Regular, contentText: String = "", arrowWidth: CGFloat = 15, @@ -41,7 +44,8 @@ public struct BBToolTipConfiguration { self.cornerRadius = cornerRadius self.foregroundColor = foregroundColor self.backgroundColor = backgroundColor - self.position = position + self.xPosition = xPosition + self.yPosition = yPosition self.font = font self.contentText = contentText self.arrowWidth = arrowWidth diff --git a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipType.swift b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipType.swift index 21b428435..4cabc0c7d 100644 --- a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipType.swift +++ b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipType.swift @@ -11,7 +11,7 @@ import DesignSystem /// BBToolTip의 Style을 설정하기 위한 Nested types입니다. /// 해당 **BBToolTipType** 을 통해 BBToolTip의 Layout을 구성합니다. -public enum BBToolTipType { +public enum BBToolTipType: Equatable { /// 홈 화면 inactive Camera Button State ToolTip Type case inactiveCameraTime /// 홈 화면 active Camera Button State ToolTip Type @@ -52,70 +52,80 @@ public enum BBToolTipType { return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "오늘의 생존신고는 완료되었어요" ) case .activeCameraTime: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "하루에 한 번 사진을 올릴 수 있어요" ) case .familyNameEdit: return .init( foregroundColor: .bibbiBlack, backgroundColor: .mainYellow, - position: .bottom, + yPosition: .bottom, + xPosition: .right, contentText: "가족 방 이름을 변경해보세요!" ) case .inactiveSurvivalCameraNoUpload: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "생존신고 후 미션 사진을 올릴 수 있어요" ) case .inactiveMissionCameraPostUpload: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "오늘의 미션은 완료되었어요" ) case .inactiveMissionCamera: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "아직 미션 사진을 찍을 수 없어요" ) case .activeMissionCamera: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "미션 사진을 찍으러 가볼까요?" ) case .contributor: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .top, + yPosition: .top, + xPosition: .midLeft, contentText: "생존신고 횟수가 동일한 경우\n이모지, 댓글 수를 합산해서 등수를 정해요" ) case .monthlyCalendar: return .init( foregroundColor: .bibbiWhite, backgroundColor: .gray700, - position: .top, + yPosition: .top, + xPosition: .midLeft, contentText: "모두가 참여한 날과 업로드한 사진 수로\n이 달의 친밀도를 측정합니다" ) case let .waitingSurvivalImage(contentText, profile): return .init( foregroundColor: .bibbiBlack, backgroundColor: .mainYellow, - position: .bottom, + yPosition: .bottom, + xPosition: .center, contentText: "\(contentText)님 외 \(profile.count - 1)명이 기다리고 있어요" ) } diff --git a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipView.swift b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipView.swift deleted file mode 100644 index 22612f967..000000000 --- a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToolTip/BBToolTipView.swift +++ /dev/null @@ -1,127 +0,0 @@ -// -// BBToolTipView.swift -// Core -// -// Created by Kim dohyun on 9/13/24. -// - -import UIKit - -import DesignSystem -import Kingfisher -import SnapKit -import Then - - -public final class BBToolTipView: UIView, BBDrawable, BBComponentPresentable { - - //MARK: Properties - private let contentLabel: BBLabel = BBLabel() - private let profileStackView: UIStackView = UIStackView() - public var toolTipType: BBToolTipType = .activeCameraTime { - didSet { - setupToolTipContent() - setupAutoLayout(toolTipType) - setNeedsDisplay() - } - } - - public init() { - super.init(frame: .zero) - setupToolTipUI() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public override func draw(_ rect: CGRect) { - super.draw(rect) - guard let context = UIGraphicsGetCurrentContext() else { return } - context.saveGState() - drawToolTip(rect, type: toolTipType, context: context) - context.restoreGState() - } - - //MARK: Configure - private func setupToolTipContent() { - - profileStackView.do { - $0.spacing = -4 - $0.distribution = .fillEqually - } - - contentLabel.do { - $0.text = toolTipType.configure.contentText - $0.fontStyle = toolTipType.configure.font - $0.textAlignment = .center - $0.numberOfLines = 0 - $0.textColor = toolTipType.configure.foregroundColor - $0.sizeToFit() - } - - self.do { - $0.backgroundColor = .clear - } - } - - private func setupToolTipUI() { - addSubviews(contentLabel, profileStackView) - } - - - private func setupWaitingToolTipUI(imageURL: [URL]) { - imageURL.forEach { - createProfileImageView(imageURL: $0) - } - } - - private func createProfileImageView(imageURL: URL) { - let imageView = UIImageView(frame: .init(x: 0, y: 0, width: 20, height: 20)) - imageView.contentMode = .scaleAspectFill - imageView.layer.borderColor = UIColor.mainYellow.cgColor - imageView.layer.borderWidth = 2 - imageView.clipsToBounds = true - imageView.layer.cornerRadius = 10 - imageView.kf.setImage(with: imageURL) - profileStackView.addArrangedSubview(imageView) - } - - private func setupAutoLayout(_ type: BBToolTipType) { - let arrowHeight = toolTipType.configure.arrowHeight - let textPadding: CGFloat = 10 - - switch type { - case .monthlyCalendar, .contributor: - contentLabel.snp.remakeConstraints { - $0.left.equalToSuperview().inset(16) - $0.right.equalToSuperview().inset(16) - $0.top.equalToSuperview().inset((arrowHeight + textPadding)) - $0.bottom.equalToSuperview().inset(textPadding) - } - case let .waitingSurvivalImage(_ ,imageURL): - setupWaitingToolTipUI(imageURL: imageURL) - - profileStackView.snp.remakeConstraints { - $0.width.equalTo(24 * imageURL.count) - $0.left.equalToSuperview().offset(16) - $0.height.equalTo(24) - $0.centerY.equalTo(contentLabel) - } - - contentLabel.snp.remakeConstraints { - $0.left.equalTo(profileStackView.snp.right).offset(2) - $0.right.equalToSuperview().inset(16) - $0.bottom.equalToSuperview().inset((arrowHeight + textPadding)) - $0.top.equalToSuperview().inset(textPadding) - } - default: - contentLabel.snp.remakeConstraints { - $0.left.equalToSuperview().inset(16) - $0.right.equalToSuperview().inset(16) - $0.bottom.equalToSuperview().inset((arrowHeight + textPadding)) - $0.top.equalToSuperview().inset(textPadding) - } - } - } -}