-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c13d105
commit 8349704
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...-iOS/Projects/Features/HomeFeature/Interface/Sources/Components/HomeCategoryTagView.swift
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// HomeCategoryTagView.swift | ||
// HomeFeature | ||
// | ||
// Created by Jae Hyun Lee on 11/20/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
import Core | ||
import DSKit | ||
|
||
final public class HomeCategoryTagView: UIView { | ||
|
||
// MARK: - UI Components | ||
|
||
private let titleLabel = UILabel().then { | ||
$0.font = DSKitFontFamily.SuitV1.extraBold.font(size: 12) | ||
$0.textColor = DSKitAsset.Colors.secondary.color | ||
$0.textAlignment = .center | ||
} | ||
|
||
private let contentStackView = UIStackView().then { | ||
$0.axis = .horizontal | ||
} | ||
|
||
private let hotIconImageView = UIImageView().then { | ||
$0.image = DSKitAsset.Assets.icHot.image | ||
} | ||
|
||
// MARK: - Initialization | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setStackView() | ||
setLayout() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
// MARK: - UI & Layout | ||
|
||
extension HomeCategoryTagView { | ||
private func setStackView() { | ||
self.contentStackView.addArrangedSubviews( | ||
titleLabel | ||
) | ||
} | ||
|
||
private func setLayout() { | ||
self.addSubview(self.contentStackView) | ||
|
||
contentStackView.snp.makeConstraints { make in | ||
make.edges.equalToSuperview() | ||
} | ||
|
||
hotIconImageView.snp.makeConstraints { make in | ||
make.size.equalTo(12) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Methods | ||
|
||
extension HomeCategoryTagView { | ||
func setData(with text: String, isHotTag: Bool) { | ||
self.titleLabel.text = text | ||
if isHotTag { | ||
self.contentStackView.insertArrangedSubview(hotIconImageView, at: 0) | ||
} | ||
layoutIfNeeded() | ||
} | ||
} |