@@ -13,8 +13,7 @@ public class LabelView: UIView {
1313
1414 // MARK: - Private properties
1515
16- private var heightConstraint : NSLayoutConstraint ?
17- private var textView = UILabel ( frame: . zero)
16+ private var label : UILabel = . init( frame: . zero)
1817
1918}
2019
@@ -24,7 +23,7 @@ extension LabelView: ConfigurableItem {
2423
2524 // MARK: - Model
2625
27- public struct Model : InsetsProvider , AlignmentProvider {
26+ public struct Model : AlignmentProvider {
2827
2928 // MARK: - Nested types
3029
@@ -63,42 +62,38 @@ extension LabelView: ConfigurableItem {
6362 public let text : TextType
6463 public let style : TextStyle
6564 public let layout : TextLayout
66- public var edgeInsets : UIEdgeInsets
67- public var labelClass : UILabel . Type
68- public var alignment : NSTextAlignment
65+ public let alignment : Alignment
66+ public let textAlignment : NSTextAlignment
6967
7068 // MARK: - Initialization
7169
7270 public init ( text: TextType ,
7371 style: TextStyle ,
7472 layout: TextLayout ,
75- alignment: NSTextAlignment ,
76- edgeInsets: UIEdgeInsets ,
77- labelClass: UILabel . Type = UILabel . self) {
73+ textAlignment: NSTextAlignment ,
74+ viewAlignment: Alignment = . all( . zero) ) {
7875 self . text = text
7976 self . style = style
8077 self . layout = layout
81- self . alignment = alignment
82- self . edgeInsets = edgeInsets
83- self . labelClass = labelClass
78+ self . textAlignment = textAlignment
79+ self . alignment = viewAlignment
8480 }
8581
8682 }
8783
8884 // MARK: - Methods
8985
9086 public func configure( with model: Model ) {
91- textView = model. labelClass. init ( )
9287 configureConstraints ( )
9388
9489 self . backgroundColor = . clear
95- textView . backgroundColor = . clear
96- textView . textColor = model. style. color
97- textView . font = model. style. font
90+ label . backgroundColor = . clear
91+ label . textColor = model. style. color
92+ label . font = model. style. font
9893
99- textView . textAlignment = model. alignment
100- textView . lineBreakMode = model. layout. lineBreakMode
101- textView . numberOfLines = model. layout. numberOfLines
94+ label . textAlignment = model. textAlignment
95+ label . lineBreakMode = model. layout. lineBreakMode
96+ label . numberOfLines = model. layout. numberOfLines
10297
10398 configureText ( with: model. text)
10499
@@ -112,27 +107,16 @@ extension LabelView: ConfigurableItem {
112107private extension LabelView {
113108
114109 func configureConstraints( ) {
115- wrap ( subview: textView , with: . zero)
110+ wrap ( subview: label , with: . zero)
116111 }
117112
118113 func configureText( with text: Model . TextType ) {
119114 switch text {
120115 case . string( let text) :
121- textView . text = text
116+ label . text = text
122117 case . attributedString( let attrubutedText) :
123- textView . attributedText = attrubutedText
118+ label . attributedText = attrubutedText
124119 }
125120 }
126121
127122}
128-
129- // MARK: - LabelView.Model Equatable
130-
131- extension LabelView . Model : Equatable {
132-
133- public static func == ( lhs: LabelView . Model , rhs: LabelView . Model ) -> Bool {
134- return lhs. style == rhs. style && lhs. layout == rhs. layout && lhs. text == rhs. text &&
135- lhs. edgeInsets == rhs. edgeInsets && lhs. labelClass == rhs. labelClass
136- }
137-
138- }
0 commit comments