From a35460dce7185f9ad9df4f78d9dffcd1020b9ec4 Mon Sep 17 00:00:00 2001 From: kpk0616 Date: Fri, 13 Jan 2023 21:53:04 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20#46=20-=20=EC=9D=B8=ED=8F=AC=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?API=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContentDetailViewController.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Keyneez/Keyneez/Tab/Home/Controllers/ContentDetailViewController.swift b/Keyneez/Keyneez/Tab/Home/Controllers/ContentDetailViewController.swift index 479a008..fb82f77 100644 --- a/Keyneez/Keyneez/Tab/Home/Controllers/ContentDetailViewController.swift +++ b/Keyneez/Keyneez/Tab/Home/Controllers/ContentDetailViewController.swift @@ -11,6 +11,8 @@ import SnapKit final class ContentDetailViewController: NiblessViewController, NavigationBarProtocol { + var isLiked: Bool = false + lazy var navigationView: UIView = NavigationViewBuilder(barViews: [.iconButton(with: backButton), .flexibleBox, .iconButton(with: shareButton), .sizedBox(width: 16), .iconButton(with: likeButton)]).build() private lazy var backButton = makeIconButton(imageName: "ic_arrowback_search", action: touchUpBackButton) private lazy var shareButton = makeIconButton(imageName: "ic_share3", action: touchUpShareButton) @@ -22,7 +24,9 @@ final class ContentDetailViewController: NiblessViewController, NavigationBarPro print("touch up ShareButton") }) private lazy var touchUpLikeButton: UIAction = .init(handler: { _ in - print("touch up LikeButton") +// self.likeButton.isSelected = !self.likeButton.isSelected + print("touch up like button") + self.setLikeButton(isLiked: !self.isLiked) }) var contentView: UIView = .init() private let scrollView: UIScrollView = .init().then { @@ -211,6 +215,7 @@ extension ContentDetailViewController { usageLabel.text = model.usage benefitLabel.setLineSpacing(spacing: 8) usageLabel.setLineSpacing(spacing: 8) + setLikeButton(isLiked: model.liked) } } @@ -261,5 +266,13 @@ extension ContentDetailViewController { if model.startAt!.isEmpty || model.endAt!.isEmpty { return "2023 ~" } return getDate(fullDate: model.startAt!) + " ~ " + getDate(fullDate: model.endAt!) } - + private func setLikeButton(isLiked: Bool) { + if isLiked { + likeButton.setImage(UIImage(named: "Property 1=fill"), for: .normal) + self.isLiked = true + } else { + likeButton.setImage(UIImage(named: "Property 1=line"), for: .normal) + self.isLiked = false + } + } }