Skip to content

[IDLE-450] Foundation수정 및 사이드 이펙트 해결 #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -13,21 +13,26 @@ public class StateButtonTyp1: UIView {
// Init values
public private(set) var state: State

public var normalAppearance = StateSetting.normalDefault
public var accentAppearance = StateSetting.accentDefault
public var normalAppearance: StateSetting
public var accentAppearance: StateSetting

public let eventPublisher: PublishRelay<State> = .init()

// View
public let label: IdleLabel = {

let view = IdleLabel(typography: .Body3)

return view
}()

public init(text: String, initial: State) {
public init(
text: String,
initial: State,
normalAppearance: StateSetting = .normalDefault,
accentAppearance: StateSetting = .accentDefault
) {
self.state = initial
self.normalAppearance = normalAppearance
self.accentAppearance = accentAppearance

super.init(frame: .zero)

Expand All @@ -46,7 +51,7 @@ public class StateButtonTyp1: UIView {
self.layer.cornerRadius = 6.0
self.clipsToBounds = true

applySetting(setting: self.state == .accent ? .accentDefault : .normalDefault)
applySetting(setting: self.state == .accent ? accentAppearance : normalAppearance)
}

private func setAutoLayout() {
Expand Down Expand Up @@ -114,13 +119,13 @@ public extension StateButtonTyp1 {

struct StateSetting {

let textColor: UIColor
let typography: Typography
public var textColor: UIColor
public var typography: Typography

let borderColor: UIColor
let backgroundColor: UIColor
public var borderColor: UIColor
public var backgroundColor: UIColor

static var normalDefault: StateSetting {
public static var normalDefault: StateSetting {
StateSetting(
textColor: DSKitAsset.Colors.gray500.color,
typography: .Body3,
Expand All @@ -129,7 +134,7 @@ public extension StateButtonTyp1 {
)
}

static var accentDefault: StateSetting {
public static var accentDefault: StateSetting {
StateSetting(
textColor: DSKitAsset.Colors.orange500.color,
typography: .Subtitle4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public class IdleLabel: UILabel {
let attributedStr = NSMutableAttributedString(string: currentText, attributes: currentAttributes)

self.attributedText = attributedStr
self.sizeToFit()
self.invalidateIntrinsicContentSize()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class MultiLineTextField: UITextView {
placeHolderLabel.topAnchor.constraint(equalTo: frameGuide.topAnchor, constant: textContainerInset.top),
placeHolderLabel.leftAnchor.constraint(equalTo: frameGuide.leftAnchor, constant: textContainerInset.left),
placeHolderLabel.rightAnchor.constraint(equalTo: frameGuide.rightAnchor, constant: -textContainerInset.right),
placeHolderLabel.bottomAnchor.constraint(equalTo: frameGuide.bottomAnchor, constant: -textContainerInset.bottom),
])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum Typography {
case Heading2
case Heading3
case Heading4
case Heading5

case Subtitle1
case Subtitle2
Expand All @@ -37,23 +38,25 @@ public enum Typography {
var lineHeight: CGFloat? {
switch self {
case .Heading1:
36
38
case .Heading2:
32
36
case .Heading3:
30
32
case .Heading4:
30
case .Heading5:
26


case .Subtitle1:
32
36
case .Subtitle2:
30
32
case .Subtitle3:
26
30
case .Subtitle4:
22
26


case .Body1:
Expand All @@ -63,6 +66,9 @@ public enum Typography {
case .Body3:
22

case .caption:
22

default:
nil
}
Expand All @@ -89,77 +95,93 @@ public enum Typography {
case .Heading2:
createAttribute(
weight: .Bold,
size: 20,
size: 22,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Heading3:
createAttribute(
weight: .Bold,
size: 18,
size: 20,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Heading4:
createAttribute(
weight: .Bold,
size: 18,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Heading5:
createAttribute(
weight: .Bold,
size: 16,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)


case .Subtitle1:
createAttribute(
weight: .Semibold,
size: 20,
size: 22,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Subtitle2:
createAttribute(
weight: .Semibold,
size: 18,
size: 20,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Subtitle3:
createAttribute(
weight: .Semibold,
size: 16,
size: 18,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Subtitle4:
createAttribute(
weight: .Semibold,
size: 14,
size: 16,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)



case .Body1:
createAttribute(
weight: .medium,
size: 18,
size: 20,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Body2:
createAttribute(
weight: .medium,
size: 16,
size: 18,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
case .Body3:
createAttribute(
weight: .medium,
size: 14,
size: 16,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)




case .caption:
createAttribute(
weight: .medium,
size: 12,
size: 14,
letterSpacing: -0.2,
color: DSKitAsset.Colors.gray900.color
)
Expand Down Expand Up @@ -198,7 +220,9 @@ public enum Typography {
paragraphStyle.minimumLineHeight = lineHeight
paragraphStyle.maximumLineHeight = lineHeight

baseLineOffset = (lineHeight-font.lineHeight)/2
let wordMinHeight = font.ascender + abs(font.descender)

baseLineOffset = (lineHeight-wordMinHeight)/2
}

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ public class WorkTimeAndPayContentView: UIView {
// 근무 요일
let workDayButtons: [StateButtonTyp1] = {
WorkDay.allCases.map { day in
StateButtonTyp1(
var normalSetting = StateButtonTyp1.StateSetting.normalDefault
normalSetting.typography = .Body2

let button = StateButtonTyp1(
text: day.korOneLetterText,
initial: .normal
initial: .normal,
normalAppearance: normalSetting
)

return button
}
}()

Expand Down Expand Up @@ -107,7 +113,7 @@ public class WorkTimeAndPayContentView: UIView {
IdleContentTitleLabel(titleText: "근무 요일"),
HStack([
workDayButtons as [UIView],
[UIView()]
[Spacer()]
].flatMap({ $0 }), spacing: 4),
],
spacing: 6,
Expand Down
Loading