@@ -10,6 +10,24 @@ import SnapKit
1010import UIKit
1111
1212final class RoutineCardView : UIView {
13+ private enum Layout {
14+ static let horizontalMargin : CGFloat = 16
15+ static let cornerRadius : CGFloat = 12
16+ static let headerInfoStackViewSpacing : CGFloat = 10
17+ static let headerInfoStackViewTopSpacing : CGFloat = 14
18+ static let subRoutineStackViewSpacing : CGFloat = 2
19+ static let subRoutineStackViewTopSpacing : CGFloat = 10
20+ static let subRoutineStackViewBottomSpacing : CGFloat = 14
21+ static let subRoutineLabelHeight : CGFloat = 20
22+ static let categoryIconSize : CGFloat = 32
23+ static let plusImageSize : CGFloat = 24
24+ static let plusButtonTopSpacing : CGFloat = 14
25+ static let plusButtonTrailingSpacing : CGFloat = 7
26+ static let plusButtonSize : CGFloat = 32
27+ static let grayLineTopSpacing : CGFloat = 10
28+ static let grayLineHeight : CGFloat = 1
29+ }
30+
1331 private let headerInfoStackView = UIStackView ( )
1432 private let categoryIconView = RoutineCategoryIcon ( routineCategory: . connection)
1533 private let titleLabel = UILabel ( )
@@ -33,29 +51,30 @@ final class RoutineCardView: UIView {
3351 private func configureAttribute( ) {
3452 backgroundColor = . white
3553 layer. masksToBounds = true
36- layer. cornerRadius = 12
54+ layer. cornerRadius = Layout . cornerRadius
3755
3856 headerInfoStackView. axis = . horizontal
39- headerInfoStackView. spacing = 10
57+ headerInfoStackView. spacing = Layout . headerInfoStackViewSpacing
4058
4159 titleLabel. text = " 개운하게 일어나기 "
4260 titleLabel. font = BitnagilFont ( style: . body1, weight: . semiBold) . font
4361 titleLabel. textColor = BitnagilColor . gray10
4462
45- let plusImage = BitnagilIcon . plusIcon? . resizeAspectFit ( to: CGSize ( width: 24 , height: 24 ) )
63+ let plusImage = BitnagilIcon . plusIcon?
64+ . resizeAspectFit ( to: CGSize ( width: Layout . plusImageSize, height: Layout . plusImageSize) )
4665 plusButton. setImage ( plusImage, for: . normal)
4766 plusButton. tintColor = BitnagilColor . gray10
4867
4968 grayLine. backgroundColor = BitnagilColor . gray97
5069
5170 subRoutineStackView. axis = . vertical
52- subRoutineStackView. spacing = 2
71+ subRoutineStackView. spacing = Layout . subRoutineStackViewSpacing
5372
5473 subRoutineLabel. text = " 세부 루틴 "
5574 subRoutineLabel. font = BitnagilFont ( style: . body2, weight: . medium) . font
5675 subRoutineLabel. textColor = BitnagilColor . gray40
5776 subRoutineLabel. snp. makeConstraints { make in
58- make. height. equalTo ( 20 )
77+ make. height. equalTo ( Layout . subRoutineLabelHeight )
5978 }
6079 subRoutineStackView. addArrangedSubview ( subRoutineLabel)
6180
@@ -65,7 +84,7 @@ final class RoutineCardView: UIView {
6584 subRoutineTitleLabel. font = BitnagilFont ( style: . body2, weight: . medium) . font
6685 subRoutineTitleLabel. textColor = BitnagilColor . gray40
6786 subRoutineTitleLabel. snp. makeConstraints { make in
68- make. height. equalTo ( 20 )
87+ make. height. equalTo ( Layout . subRoutineLabelHeight )
6988 }
7089 subRoutineStackView. addArrangedSubview ( subRoutineTitleLabel)
7190 }
@@ -81,37 +100,42 @@ final class RoutineCardView: UIView {
81100 addSubview ( subRoutineStackView)
82101
83102 categoryIconView. snp. makeConstraints { make in
84- make. size. equalTo ( 32 )
103+ make. size. equalTo ( Layout . categoryIconSize )
85104 }
86105
87106 headerInfoStackView. snp. makeConstraints { make in
88- make. top. equalToSuperview ( ) . offset ( 14 )
89- make. leading. equalToSuperview ( ) . offset ( 16 )
107+ make. top. equalToSuperview ( ) . offset ( Layout . headerInfoStackViewTopSpacing )
108+ make. leading. equalToSuperview ( ) . offset ( Layout . horizontalMargin )
90109 }
91110
92111 plusButton. snp. makeConstraints { make in
93- make. top. equalToSuperview ( ) . offset ( 14 )
94- make. trailing. equalToSuperview ( ) . inset ( 7 )
95- make. size. equalTo ( 32 )
112+ make. top. equalToSuperview ( ) . offset ( Layout . plusButtonTopSpacing )
113+ make. trailing. equalToSuperview ( ) . inset ( Layout . plusButtonTrailingSpacing )
114+ make. size. equalTo ( Layout . plusButtonSize )
96115 }
97116
98117 grayLine. snp. makeConstraints { make in
99- make. top. equalTo ( headerInfoStackView. snp. bottom) . offset ( 10 )
100- make. leading. equalToSuperview ( ) . offset ( 16 )
101- make. trailing. equalToSuperview ( ) . inset ( 16 )
102- make. height. equalTo ( 1 )
118+ make. top. equalTo ( headerInfoStackView. snp. bottom) . offset ( Layout . grayLineTopSpacing )
119+ make. leading. equalToSuperview ( ) . offset ( Layout . horizontalMargin )
120+ make. trailing. equalToSuperview ( ) . inset ( Layout . horizontalMargin )
121+ make. height. equalTo ( Layout . grayLineHeight )
103122 }
104123
105124 subRoutineStackView. snp. makeConstraints { make in
106- make. top. equalTo ( grayLine. snp. bottom) . offset ( 10 )
107- make. leading. equalToSuperview ( ) . offset ( 16 )
108- make. trailing. equalToSuperview ( ) . inset ( 16 )
109- make. bottom. equalToSuperview ( ) . inset ( 14 )
125+ make. top. equalTo ( grayLine. snp. bottom) . offset ( Layout . subRoutineStackViewTopSpacing )
126+ make. leading. equalToSuperview ( ) . offset ( Layout . horizontalMargin )
127+ make. trailing. equalToSuperview ( ) . inset ( Layout . horizontalMargin )
128+ make. bottom. equalToSuperview ( ) . inset ( Layout . subRoutineStackViewBottomSpacing )
110129 }
111130 }
112131}
113132
114- private class RoutineCategoryIcon : UIView {
133+ fileprivate class RoutineCategoryIcon : UIView {
134+ private enum Layout {
135+ static let cornerRadius : CGFloat = 3.76
136+ static let iconSize : CGFloat = 24
137+ }
138+
115139 private let routineCategoryIcon = UIImageView ( )
116140 private let routineCategory : RoutineCategoryType
117141 init ( routineCategory: RoutineCategoryType ) {
@@ -120,22 +144,22 @@ private class RoutineCategoryIcon: UIView {
120144 configureAttribute ( )
121145 configureLayout ( )
122146 }
123-
147+
124148 required init ? ( coder: NSCoder ) {
125149 fatalError ( " init(coder:) has not been implemented " )
126150 }
127151
128152 private func configureAttribute( ) {
129153 layer. masksToBounds = true
130- layer. cornerRadius = 3.76
154+ layer. cornerRadius = Layout . cornerRadius
131155 backgroundColor = routineCategory. iconBackgroundColor ?? BitnagilColor . yellow10
132156 routineCategoryIcon. image = routineCategory. iconImage ?? BitnagilIcon . shineIcon
133157 }
134158
135159 private func configureLayout( ) {
136160 addSubview ( routineCategoryIcon)
137161 routineCategoryIcon. snp. makeConstraints { make in
138- make. size. equalTo ( 24 )
162+ make. size. equalTo ( Layout . iconSize )
139163 make. center. equalToSuperview ( )
140164 }
141165 }
0 commit comments