99import UIKit
1010
1111@objc open class LOKTextViewLayout : LOKBaseLayout {
12+ @objc public let attributedText : NSAttributedString ?
13+ @objc public let text : String ?
14+ @objc public let font : UIFont ?
15+ @objc public let lineFragmentPadding : CGFloat
16+ @objc public let textContainerInset : UIEdgeInsets
17+ @objc public let layoutAlignment : LOKAlignment
18+ @objc public let viewClass : UITextView . Type
19+ @objc public let configure : ( ( UITextView ) -> Void ) ?
20+
1221 @objc public init ( text: String ? = nil ,
1322 font: UIFont ? = nil ,
1423 lineFragmentPadding: CGFloat = 0 ,
@@ -18,16 +27,24 @@ import UIKit
1827 viewReuseId: String ? = nil ,
1928 viewClass: UITextView . Type ? = nil ,
2029 configure: ( ( UITextView ) -> Void ) ? = nil ) {
30+ self . text = text ?? " "
31+ self . attributedText = nil
32+ self . font = font
33+ self . lineFragmentPadding = lineFragmentPadding
34+ self . textContainerInset = textContainerInset
35+ self . layoutAlignment = layoutAlignment ?? LOKAlignment ( alignment: TextViewLayoutDefaults . defaultAlignment)
36+ self . viewClass = viewClass ?? UITextView . self
37+ self . configure = configure
2138 super. init ( layout: TextViewLayout (
22- text: text ?? " " ,
23- font: font,
24- lineFragmentPadding: lineFragmentPadding,
25- textContainerInset: textContainerInset,
26- layoutAlignment: layoutAlignment? . alignment ?? TextViewLayoutDefaults . defaultAlignment ,
39+ text: self . text ?? " " ,
40+ font: self . font,
41+ lineFragmentPadding: self . lineFragmentPadding,
42+ textContainerInset: self . textContainerInset,
43+ layoutAlignment: self . layoutAlignment. alignment,
2744 flexibility: flexibility? . flexibility ?? TextViewLayoutDefaults . defaultFlexibility,
2845 viewReuseId: viewReuseId,
29- viewClass: viewClass,
30- config: configure) )
46+ viewClass: self . viewClass,
47+ config: self . configure) )
3148 }
3249
3350 @objc public init ( attributedText: NSAttributedString ? = nil ,
@@ -39,15 +56,23 @@ import UIKit
3956 viewReuseId: String ? = nil ,
4057 viewClass: UITextView . Type ? = nil ,
4158 configure: ( ( UITextView ) -> Void ) ? = nil ) {
59+ self . text = nil
60+ self . attributedText = attributedText ?? NSAttributedString ( )
61+ self . font = font
62+ self . lineFragmentPadding = lineFragmentPadding
63+ self . textContainerInset = textContainerInset
64+ self . layoutAlignment = layoutAlignment ?? LOKAlignment ( alignment: TextViewLayoutDefaults . defaultAlignment)
65+ self . viewClass = viewClass ?? UITextView . self
66+ self . configure = configure
4267 super. init ( layout: TextViewLayout (
43- attributedText: attributedText ?? NSAttributedString ( ) ,
44- font: font,
45- lineFragmentPadding: lineFragmentPadding,
46- textContainerInset: textContainerInset,
47- layoutAlignment: layoutAlignment? . alignment ?? TextViewLayoutDefaults . defaultAlignment ,
68+ attributedText: self . attributedText ?? NSAttributedString ( ) ,
69+ font: self . font,
70+ lineFragmentPadding: self . lineFragmentPadding,
71+ textContainerInset: self . textContainerInset,
72+ layoutAlignment: self . layoutAlignment. alignment,
4873 flexibility: flexibility? . flexibility ?? TextViewLayoutDefaults . defaultFlexibility,
4974 viewReuseId: viewReuseId,
50- viewClass: viewClass,
51- config: configure) )
75+ viewClass: self . viewClass,
76+ config: self . configure) )
5277 }
5378}
0 commit comments