Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
419e4cb
feat/#161: 아토믹 폰트 시스템 타입 정의
0Hooni Jul 27, 2025
5be94f5
feat/#161: 폰트 시스템 속성 정의
0Hooni Jul 27, 2025
a00b630
refactor/#161: 변수 이름 수정
0Hooni Jul 27, 2025
bea805f
feat/#161: 새로 정의한 폰트 시스템 기반의 커스텀 폰트 extension 구현
0Hooni Jul 27, 2025
6b54f3e
feat/#161: 라벨 속성 유지한 텍스트 변경 메서드 구현
0Hooni Jul 27, 2025
8bb7057
feat/#161: 새로운 PPLabel 생성자 추가
0Hooni Jul 27, 2025
d385484
refactor/#161: Attribute 유지해주는 text 변경 메서드 적용
0Hooni Jul 28, 2025
ad02e75
fix/#161: Attribute가 적용되지 않던 문제 수정
0Hooni Jul 28, 2025
431816f
refactor/#161: 변수 이름 수정
0Hooni Jul 28, 2025
59036b6
refactor/#161: 메서드 이름 수정
0Hooni Jul 28, 2025
a415b7f
feat/#161: TextField placeholder에 타이포 시스템 적용
0Hooni Jul 28, 2025
0e5d7e5
feat/#161: 행간 배율이 아닌 실제 행간 값을 타이포시스템에 추가
0Hooni Jul 28, 2025
1fc7ef8
fix/#161: placeholder의 행간이 맞지 않던 문제 수정
0Hooni Jul 28, 2025
59c48bb
refactor/#161: PPLabel에 lineHeight 고정 적용
0Hooni Jul 28, 2025
1972091
refactor/#161: Text Attribute 적용을 UILabel의 Extension으로 이동
0Hooni Jul 28, 2025
1d04a27
refactor/#161: 메서드명 수정
0Hooni Jul 28, 2025
1be0a29
refactor/#161: UIButton에 타이포 시스템을 반영하는 메서드 추가 및 적용
0Hooni Jul 28, 2025
579f95f
docs/#161: 기존 메서드 deprecated 메세지 추가
0Hooni Jul 28, 2025
704d0a4
fix/#161: 영문 폰트에서 수직 중앙 정렬이 적용되지 않던 문제 수정
0Hooni Jul 28, 2025
8d2452c
refactor/#161: 새로운 타이포시스템 적용 메서드로 수정
0Hooni Jul 28, 2025
ea2292b
docs/#161: 추후 작업해야될 부분 주석 추가
0Hooni Jul 28, 2025
8b32702
docs/#161: deprecated 메세지 추가
0Hooni Jul 28, 2025
eee3a26
refactor/#161: 새로운 타이포 기반 컴포넌트와 메서드로 변경
0Hooni Jul 28, 2025
6580881
feat/#161: 한글 판독 extension 추가
0Hooni Jul 28, 2025
a88ba40
refactor/#161: 기존 메서드들을 새로운 메서드에 대응되도록 내부 로직 수정
0Hooni Jul 28, 2025
58085a9
refactor/#161: 새로운 타이포 방식 적용
0Hooni Jul 28, 2025
a3b44d8
feat/#161: PPButton의 새로운 생성자 추가 및 기존 생성자 변경된 타이포 대응
0Hooni Jul 28, 2025
52948f8
refactor/#161: 새로운 타이포 시스템 적용 메서드로 수정
0Hooni Jul 29, 2025
bde6ab1
style/#161: Apply SwiftLint autocorrect
github-actions[bot] Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

public extension String {
var isHangul: Bool {
return "\(self)".range(of: "\\p{Hangul}", options: .regularExpression) != nil
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import UIKit

import Infrastructure

public class PPButton: UIButton {

public enum ButtonStyle {
Expand Down Expand Up @@ -62,6 +64,29 @@ public class PPButton: UIButton {
}
}

public init(
buttonStyle: ButtonStyle,
fontStyle: PPFontStyle = .KOm16,
text: String,
disabledText: String = " ",
cornerRadius: CGFloat = 4
) {
super.init(frame: .zero)

self.setTitleColor(buttonStyle.textColor, for: .normal)
self.setTitleColor(buttonStyle.disabledTextColor, for: .disabled)

self.setBackgroundColor(buttonStyle.backgroundColor, for: .normal)
self.setBackgroundColor(buttonStyle.disabledBackgroundColor, for: .disabled)

self.setText(to: text, with: fontStyle, for: .normal)
self.setText(to: disabledText, with: fontStyle, for: .disabled)

self.layer.cornerRadius = cornerRadius
self.clipsToBounds = true
}

@available(*, deprecated, message: "PPFontStyle로 파싱하는 init을 사용해주세요.")
public init(
style: ButtonStyle,
text: String,
Expand All @@ -71,16 +96,22 @@ public class PPButton: UIButton {
) {
super.init(frame: .zero)

self.setTitle(text, for: .normal)
self.setTitle(disabledText, for: .disabled)
guard let parseResult = parseToPPFontStyle(text: text, font: font),
let PPFontStyle = PPFontStyle(rawValue: parseResult)
else {
Logger.log("PPFontStyle로 파싱할 수 없는 폰트입니다.", category: .error)
return
}

self.setTitleColor(style.textColor, for: .normal)
self.setTitleColor(style.disabledTextColor, for: .disabled)

self.setBackgroundColor(style.backgroundColor, for: .normal)
self.setBackgroundColor(style.disabledBackgroundColor, for: .disabled)

self.titleLabel?.font = font
self.setText(to: text, with: PPFontStyle, for: .normal)
self.setText(to: disabledText, with: PPFontStyle, for: .disabled)

self.layer.cornerRadius = cornerRadius
self.clipsToBounds = true
}
Expand All @@ -105,3 +136,26 @@ public class PPButton: UIButton {
self.setBackgroundImage(backgroundImage, for: state)
}
}

private extension PPButton {
func parseToPPFontStyle(text: String?, font: UIFont?) -> String? {
guard let font = font else { return nil }

var result = ""

let splitResult = font.fontName.split(separator: "-")
splitResult[0] == "Poppins" ? result.append("EN") : result.append("KO")

switch splitResult[1] {
case "Light": result.append("l")
case "Regular": result.append("r")
case "Medium": result.append("m")
case "Bold": result.append("b")
default: return nil
}

result.append("\(Int(font.pointSize))")

return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ public final class PPCancelHeaderView: UIView {

public let cancelButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle("취소", for: .normal)
button.titleLabel?.font = .korFont(style: .regular, size: 14)
button.setTitleColor(.black, for: .normal)
button.setText(to: "취소", with: .KOr14, for: .normal)
return button
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,61 @@ import UIKit

public class PPLabel: UILabel {

@available(*, deprecated, renamed: "init(text:style:)", message: "타이포를 직접 지정하는 대신 PPFontStyle을 이용하세요")
public init(
style: UIFont.FontStyle = .regular,
fontSize: CGFloat = 12,
text: String = "",
text: String = " ",
lineHeight: CGFloat = 1.2
) {
super.init(frame: .zero)
self.font = .korFont(style: style, size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineHeightMultiple = lineHeight
self.attributedText = NSMutableAttributedString(
string: text,
attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle]
)
// self.font = .korFont(style: style, size: fontSize)
// let paragraphStyle = NSMutableParagraphStyle()
// paragraphStyle.lineHeightMultiple = lineHeight
// self.attributedText = NSMutableAttributedString(
// string: text,
// attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle]
// )

guard let parseResult = parseToPPFontStyle(
style: style,
fontSize: fontSize,
text: text
) else { return }

self.setText(to: text, with: PPFontStyle(rawValue: parseResult) ?? .KOb32)
}

public init(
text: String = " ", // 값이 없으면 Attribute가 적용이 안돼서 기본값은 공백
style: PPFontStyle
) {
super.init(frame: .zero)
self.setText(to: text, with: style)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

private extension PPLabel {
func parseToPPFontStyle(
style: UIFont.FontStyle,
fontSize: CGFloat,
text: String
) -> String? {
var result = text.isHangul ? "KO" : "EN"

switch style {
case .bold: result.append("b")
case .medium: result.append("m")
case .regular: result.append("r")
case .light: result.append("l")
}

result.append("\(Int(fontSize))")

return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public class PPSearchBarView: UIView {
}

public let searchBar = UISearchBar().then {
$0.searchTextField.setPlaceholder(text: "팝업스토어명을 입력해보세요", color: .g400, font: .korFont(style: .regular, size: 14))
$0.searchTextField.setPlaceholder(
text: "팝업스토어명을 입력해보세요",
color: .g400,
style: .KOr14
)
$0.tintColor = .g400
$0.backgroundColor = .g50
$0.layer.cornerRadius = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class PPTagCollectionViewCell: UICollectionViewCell {

public var disposeBag = DisposeBag()

public let titleLabel = PPLabel(style: .medium, fontSize: 11)
public let titleLabel = PPLabel(style: .KOm11)

public let cancelButton = UIButton()

Expand Down Expand Up @@ -83,6 +83,7 @@ private extension PPTagCollectionViewCell {
}
}

// FIXME: Chip 컴포넌트화 및 분기적용 필요 (디자인 시스템 도입 필요)
extension PPTagCollectionViewCell {
public func configureCell(title: String? = nil, id: Int?, isSelected: Bool = false, isCancelable: Bool = true, fontSize: CGFloat = 11, cornerRadius: CGFloat = 15.5) {
let xmarkImage = isSelected ? UIImage(named: "icon_xmark_white") : UIImage(named: "icon_xmark_gray")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,35 @@ public final class PPPopupGridCollectionViewCell: UICollectionViewCell {
$0.contentMode = .scaleAspectFill
}

private let categoryLabel = PPLabel(style: .bold, fontSize: 11).then {
private let categoryLabel = PPLabel(style: .KOb11).then {
$0.textColor = .blu500
$0.setLineHeightText(text: "category", font: .korFont(style: .bold, size: 11))
}

private let titleLabel = PPLabel(style: .bold, fontSize: 14).then {
private let titleLabel = PPLabel(style: .KOb14).then {
$0.numberOfLines = 2
$0.lineBreakMode = .byTruncatingTail
$0.setLineHeightText(text: "title", font: .korFont(style: .bold, size: 14))
}

private let addressLabel = PPLabel(style: .medium, fontSize: 11).then {
private let addressLabel = PPLabel(style: .KOm11).then {
$0.numberOfLines = 1
$0.lineBreakMode = .byTruncatingTail
$0.textColor = .g400
$0.setLineHeightText(text: "address", font: .korFont(style: .medium, size: 11))
}

private let dateLabel = PPLabel(style: .medium, fontSize: 11).then {
private let dateLabel = PPLabel(style: .ENr11).then {
$0.lineBreakMode = .byTruncatingTail
$0.textColor = .g400
$0.setLineHeightText(text: "date", font: .korFont(style: .medium, size: 11))
}

public let bookmarkButton = UIButton()

private let rankLabel = UILabel().then {
private let rankLabel = PPLabel(style: .KOm11).then {
$0.backgroundColor = .w10
$0.layer.cornerRadius = 12
$0.clipsToBounds = true
$0.isHidden = true
$0.textColor = .w100
$0.textAlignment = .center
$0.setLineHeightText(text: "rank", font: .korFont(style: .medium, size: 11), lineHeight: 1)
}

// MARK: - init
Expand Down Expand Up @@ -103,14 +98,12 @@ private extension PPPopupGridCollectionViewCell {

dateLabel.snp.makeConstraints { make in
make.leading.equalToSuperview()
make.height.equalTo(15).priority(.high)
make.bottom.equalToSuperview()
}

addressLabel.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
make.bottom.equalTo(dateLabel.snp.top)
make.height.equalTo(17).priority(.high)
}

bookmarkButton.snp.makeConstraints { make in
Expand All @@ -137,12 +130,12 @@ private extension PPPopupGridCollectionViewCell {
extension PPPopupGridCollectionViewCell {
public func configureCell(imagePath: String?, id: Int64, category: String?, title: String?, address: String?, startDate: String?, endDate: String?, isBookmark: Bool, isLogin: Bool, isPopular: Bool = false, row: Int?) {

categoryLabel.text = "#" + (category ?? "")
titleLabel.text = title
addressLabel.text = address
categoryLabel.updateText(to: "#" + (category ?? ""))
titleLabel.updateText(to: title)
addressLabel.updateText(to: address)

let date = startDate.toDate().toPPDateString() + " ~ " + endDate.toDate().toPPDateString()
dateLabel.text = date
dateLabel.updateText(to: date)

let bookmarkImage = isBookmark ? UIImage(named: "icon_bookmark_fill") : UIImage(named: "icon_bookmark")
bookmarkButton.setImage(bookmarkImage, for: .normal)
Expand All @@ -153,7 +146,7 @@ extension PPPopupGridCollectionViewCell {
rankLabel.isHidden = !isPopular

if let rank = row {
rankLabel.text = "\(rank)"
rankLabel.updateText(to: "\(rank)")
rankLabel.isHidden = rank > 2
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import UIKit

public extension UIButton {
/// Style을 필요로하는 Text가 포함된 일반 버튼에서 사용
func setText(
to text: String = " ",
with style: PPFontStyle,
for controlState: UIControl.State = .normal
) {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineHeightMultiple = style.lineHeightMultiple
paragraphStyle.maximumLineHeight = style.lineHeight
paragraphStyle.minimumLineHeight = style.lineHeight

let attributedString = NSAttributedString(
string: text,
attributes: [
.font: UIFont.PPFont(style: style),
.paragraphStyle: paragraphStyle,
.baselineOffset: style.baseLineOffset
]
)

self.setAttributedTitle(attributedString, for: controlState)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public extension UIFont {
if let font = UIFont(name: fontName, size: size) { return font } else { return registerAndGetFont(name: fontName, size: size) }
}

static func PPFont(style: PPFontStyle) -> UIFont {
if let font = UIFont(name: style.fontName, size: style.size) {
return font
} else {
return registerAndGetFont(name: style.fontName, size: style.size)
}
}

private static func registerAndGetFont(name: String, size: CGFloat) -> UIFont {
let url = Bundle.module.url(forResource: name, withExtension: "ttf")!
CTFontManagerRegisterFontURLs([url as CFURL] as CFArray, .process, true, nil)
Expand Down
Loading