88
99import UIKit
1010
11- public class MenuItemView : UIView {
12- lazy public var titleLabel : UILabel = self . initLabel ( )
13- lazy public var descriptionLabel : UILabel = self . initLabel ( )
14- lazy public var menuImageView : UIImageView = {
11+ open class MenuItemView : UIView {
12+ lazy open var titleLabel : UILabel = self . initLabel ( )
13+ lazy open var descriptionLabel : UILabel = self . initLabel ( )
14+ lazy open var menuImageView : UIImageView = {
1515 $0. isUserInteractionEnabled = true
1616 $0. translatesAutoresizingMaskIntoConstraints = false
1717 return $0
1818 } ( UIImageView ( frame: . zero) )
19- public private ( set) var customView : UIView ? {
19+ open fileprivate ( set) var customView : UIView ? {
2020 didSet {
2121 guard let customView = customView else { return }
2222
2323 addSubview ( customView)
2424 }
2525 }
26- public internal( set) var selected : Bool = false {
26+ open internal( set) var selected : Bool = false {
2727 didSet {
2828 if case . roundRect = menuOptions. focusMode {
29- backgroundColor = UIColor . clear ( )
29+ backgroundColor = UIColor . clear
3030 } else {
3131 backgroundColor = selected ? menuOptions. selectedBackgroundColor : menuOptions. backgroundColor
3232 }
@@ -51,18 +51,18 @@ public class MenuItemView: UIView {
5151 }
5252 }
5353 }
54- lazy public private ( set) var dividerImageView : UIImageView ? = { [ unowned self] in
54+ lazy open fileprivate ( set) var dividerImageView : UIImageView ? = { [ unowned self] in
5555 guard let image = self . menuOptions. dividerImage else { return nil }
5656 let imageView = UIImageView ( image: image)
5757 imageView. translatesAutoresizingMaskIntoConstraints = false
5858 return imageView
5959 } ( )
6060
61- private var menuOptions : MenuViewCustomizable !
62- private var menuItemOptions : MenuItemViewCustomizable !
63- private var widthConstraint : NSLayoutConstraint !
64- private var descriptionWidthConstraint : NSLayoutConstraint !
65- private var horizontalMargin : CGFloat {
61+ fileprivate var menuOptions : MenuViewCustomizable !
62+ fileprivate var menuItemOptions : MenuItemViewCustomizable !
63+ fileprivate var widthConstraint : NSLayoutConstraint !
64+ fileprivate var descriptionWidthConstraint : NSLayoutConstraint !
65+ fileprivate var horizontalMargin : CGFloat {
6666 switch menuOptions. displayMode {
6767 case . segmentedControl: return 0.0
6868 default : return menuItemOptions. horizontalMargin
@@ -101,15 +101,15 @@ public class MenuItemView: UIView {
101101 }
102102 }
103103
104- private func commonInit( _ setupContentView: ( ) -> Void ) {
104+ fileprivate func commonInit( _ setupContentView: ( ) -> Void ) {
105105 setupView ( )
106106 setupContentView ( )
107107
108108 setupDivider ( )
109109 layoutDivider ( )
110110 }
111111
112- private func initLabel( ) -> UILabel {
112+ fileprivate func initLabel( ) -> UILabel {
113113 let label = UILabel ( frame: . zero)
114114 label. numberOfLines = 1
115115 label. textAlignment = . center
@@ -142,51 +142,51 @@ public class MenuItemView: UIView {
142142
143143 // MARK: - Constructor
144144
145- private func setupView( ) {
145+ fileprivate func setupView( ) {
146146 if case . roundRect = menuOptions. focusMode {
147- backgroundColor = UIColor . clear ( )
147+ backgroundColor = UIColor . clear
148148 } else {
149149 backgroundColor = menuOptions. backgroundColor
150150 }
151151 translatesAutoresizingMaskIntoConstraints = false
152152 }
153153
154- private func setupTitleLabel( _ text: MenuItemText ) {
154+ fileprivate func setupTitleLabel( _ text: MenuItemText ) {
155155 setupLabel ( titleLabel, text: text)
156156 }
157157
158- private func setupMultilineLabel( _ text: MenuItemText , description: MenuItemText ) {
158+ fileprivate func setupMultilineLabel( _ text: MenuItemText , description: MenuItemText ) {
159159 setupLabel ( titleLabel, text: text)
160160 setupLabel ( descriptionLabel, text: description)
161161 }
162162
163- private func setupLabel( _ label: UILabel , text: MenuItemText ) {
163+ fileprivate func setupLabel( _ label: UILabel , text: MenuItemText ) {
164164 label. text = text. text
165165 updateLabel ( label, text: text)
166166 addSubview ( label)
167167 }
168168
169- private func updateLabel( _ label: UILabel , text: MenuItemText ) {
169+ fileprivate func updateLabel( _ label: UILabel , text: MenuItemText ) {
170170 label. textColor = selected ? text. selectedColor : text. color
171171 label. font = selected ? text. selectedFont : text. font
172172 }
173173
174- private func setupImageView( _ image: UIImage ) {
174+ fileprivate func setupImageView( _ image: UIImage ) {
175175 menuImageView. image = image
176176 addSubview ( menuImageView)
177177 }
178178
179- private func setupCustomView( _ view: UIView ) {
179+ fileprivate func setupCustomView( _ view: UIView ) {
180180 customView = view
181181 }
182182
183- private func setupDivider( ) {
183+ fileprivate func setupDivider( ) {
184184 guard let dividerImageView = dividerImageView else { return }
185185
186186 addSubview ( dividerImageView)
187187 }
188188
189- private func layoutMultiLineLabel( ) {
189+ fileprivate func layoutMultiLineLabel( ) {
190190 let titleLabelSize = calculateLabelSize ( titleLabel, maxWidth: maxWindowSize)
191191 let descriptionLabelSize = calculateLabelSize ( descriptionLabel, maxWidth: maxWindowSize)
192192 let verticalMargin = max ( menuOptions. height - ( titleLabelSize. height + descriptionLabelSize. height) , 0 ) / 2
@@ -202,7 +202,7 @@ public class MenuItemView: UIView {
202202 NSLayoutConstraint . activate ( horizontalConstraints + verticalConstraints + descriptionHorizontalConstraints + [ widthConstraint, descriptionWidthConstraint] )
203203 }
204204
205- private func layoutLabel( ) {
205+ fileprivate func layoutLabel( ) {
206206 let viewsDictionary = [ " label " : titleLabel]
207207 let labelSize = calculateLabelSize ( titleLabel, maxWidth: maxWindowSize)
208208
@@ -214,13 +214,13 @@ public class MenuItemView: UIView {
214214
215215 }
216216
217- private func layoutImageView( ) {
217+ fileprivate func layoutImageView( ) {
218218 guard let image = menuImageView. image else { return }
219219
220220 let width : CGFloat
221221 switch menuOptions. displayMode {
222222 case . segmentedControl:
223- width = UIApplication . shared ( ) . keyWindow!. bounds. size. width / CGFloat( menuOptions. itemsOptions. count)
223+ width = UIApplication . shared. keyWindow!. bounds. size. width / CGFloat( menuOptions. itemsOptions. count)
224224 default :
225225 width = image. size. width + horizontalMargin * 2
226226 }
@@ -236,7 +236,7 @@ public class MenuItemView: UIView {
236236 ] )
237237 }
238238
239- private func layoutCustomView( ) {
239+ fileprivate func layoutCustomView( ) {
240240 guard let customView = customView else { return }
241241
242242 widthConstraint = NSLayoutConstraint ( item: self , attribute: . width, relatedBy: . equal, toItem: nil , attribute: . width, multiplier: 1.0 , constant: customView. frame. width)
@@ -250,7 +250,7 @@ public class MenuItemView: UIView {
250250 ] )
251251 }
252252
253- private func layoutDivider( ) {
253+ fileprivate func layoutDivider( ) {
254254 guard let dividerImageView = dividerImageView else { return }
255255
256256 let centerYConstraint = NSLayoutConstraint ( item: dividerImageView, attribute: . centerY, relatedBy: . equal, toItem: self , attribute: . centerY, multiplier: 1.0 , constant: 1.0 )
@@ -307,7 +307,7 @@ extension MenuItemView: LabelSizeCalculatable {
307307 return CGSize ( width: itemWidth + horizontalMargin * 2 , height: itemHeight)
308308 }
309309
310- private var maxWindowSize : CGFloat {
311- return UIApplication . shared ( ) . keyWindow? . bounds. width ?? UIScreen . main ( ) . bounds. width
310+ fileprivate var maxWindowSize : CGFloat {
311+ return UIApplication . shared. keyWindow? . bounds. width ?? UIScreen . main. bounds. width
312312 }
313313}
0 commit comments