@@ -33,23 +33,28 @@ public extension DropdownMenuDelegate {
3333}
3434
3535open class DropdownMenu : UIView {
36- fileprivate weak var navigationController : UINavigationController !
36+ private weak var navigationController : UINavigationController !
3737
38- fileprivate var sections : [ DropdownSection ] = [ ]
39- fileprivate var selectedIndexPath : IndexPath
38+ private var sections : [ DropdownSection ] = [ ]
39+ private var selectedIndexPath : IndexPath
4040
41- open var tableView : UITableView !
42- fileprivate var barCoverView : UIView ?
41+ open var tableView : UITableView = {
42+ let tableView = UITableView ( frame: CGRect . zero, style: . grouped)
43+ tableView. estimatedSectionFooterHeight = 0
44+ tableView. estimatedSectionHeaderHeight = 0
45+ return tableView
46+ } ( )
47+ private var barCoverView : UIView ?
4348 open var isShow = false
44- fileprivate var addedWindow : UIWindow ?
45- fileprivate var windowRootView : UIView ?
46- fileprivate var topConstraint : NSLayoutConstraint ?
47- fileprivate var navigationBarCoverViewHeightConstraint : NSLayoutConstraint ?
48- fileprivate var tableViewHeightConstraint : NSLayoutConstraint ?
49- fileprivate let iPhoneXPortraitTopOffset : CGFloat = 88.0
50- fileprivate let portraitTopOffset : CGFloat = 64.0
51- fileprivate let landscapeTopOffset : CGFloat = 32.0
52- fileprivate var topLayoutConstraintConstant : CGFloat {
49+ private var addedWindow : UIWindow ?
50+ private var windowRootView : UIView ?
51+ private var topConstraint : NSLayoutConstraint ?
52+ private var navigationBarCoverViewHeightConstraint : NSLayoutConstraint ?
53+ private var tableViewHeightConstraint : NSLayoutConstraint ?
54+ private let iPhoneXPortraitTopOffset : CGFloat = 88.0
55+ private let portraitTopOffset : CGFloat = 64.0
56+ private let landscapeTopOffset : CGFloat = 32.0
57+ private var topLayoutConstraintConstant : CGFloat {
5358 var offset : CGFloat = 0
5459 if !navigationController. isNavigationBarHidden {
5560 offset = navigationController. navigationBar. frame. height + navigationController. navigationBar. frame. origin. y
@@ -108,7 +113,7 @@ open class DropdownMenu: UIView {
108113
109114 clipsToBounds = true
110115 setupGestureView ( )
111- initTableView ( )
116+ setupTableView ( )
112117
113118 NotificationCenter . default. addObserver ( self , selector: #selector( self . updateForOrientationChange ( _: ) ) , name: UIApplication . willChangeStatusBarOrientationNotification, object: nil )
114119 }
@@ -123,7 +128,7 @@ open class DropdownMenu: UIView {
123128
124129 clipsToBounds = true
125130 setupGestureView ( )
126- initTableView ( )
131+ setupTableView ( )
127132
128133 NotificationCenter . default. addObserver ( self , selector: #selector( self . updateForOrientationChange ( _: ) ) , name: UIApplication . willChangeStatusBarOrientationNotification, object: nil )
129134 }
@@ -186,7 +191,7 @@ open class DropdownMenu: UIView {
186191 }
187192 }
188193
189- fileprivate func setupGestureView( ) {
194+ private func setupGestureView( ) {
190195 let gestureView = UIView ( )
191196 gestureView. backgroundColor = UIColor . clear
192197 addSubview ( gestureView)
@@ -199,17 +204,14 @@ open class DropdownMenu: UIView {
199204 gestureView. addGestureRecognizer ( UITapGestureRecognizer ( target: self , action: #selector( hideMenu) ) )
200205 }
201206
202- fileprivate func initTableView( ) {
203- tableView = UITableView ( frame: CGRect . zero, style: . grouped)
207+ private func setupTableView( ) {
204208 tableView. separatorStyle = separatorStyle
205209 tableView. delegate = self
206210 tableView. dataSource = self
207- tableView. estimatedSectionFooterHeight = 0
208- tableView. estimatedSectionHeaderHeight = 0
209211 addSubview ( tableView)
210212 }
211213
212- fileprivate func layoutTableView( ) {
214+ private func layoutTableView( ) {
213215 tableView. translatesAutoresizingMaskIntoConstraints = false
214216
215217 updateTableViewHeight ( )
@@ -222,7 +224,7 @@ open class DropdownMenu: UIView {
222224 self . tableViewHeightConstraint = tableViewHeightConstraint
223225 }
224226
225- fileprivate func updateTableViewHeight( ) {
227+ private func updateTableViewHeight( ) {
226228 tableViewHeight = tableviewHeight ( )
227229
228230 let maxHeight = navigationController. view. frame. height - topLayoutConstraintConstant - defaultBottonMargin
@@ -236,7 +238,7 @@ open class DropdownMenu: UIView {
236238 }
237239 }
238240
239- fileprivate func updateForSectionsChange( _ animations: ( ( ) -> Void ) ? = nil ) {
241+ private func updateForSectionsChange( _ animations: ( ( ) -> Void ) ? = nil ) {
240242 updateTableViewHeight ( )
241243 tableViewHeightConstraint? . constant = tableViewHeight
242244 UIView . animate ( withDuration: 0.3 ) { [ weak self] in
@@ -248,7 +250,7 @@ open class DropdownMenu: UIView {
248250 }
249251 }
250252
251- fileprivate func setupTopSeperatorView( ) {
253+ private func setupTopSeperatorView( ) {
252254 let seperatorView = UIView ( )
253255 seperatorView. backgroundColor = tableViewSeperatorColor
254256 addSubview ( seperatorView)
@@ -259,7 +261,7 @@ open class DropdownMenu: UIView {
259261 NSLayoutConstraint . activate ( [ NSLayoutConstraint . init ( item: seperatorView, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . notAnAttribute, multiplier: 1.0 , constant: 0.5 ) ] )
260262 }
261263
262- fileprivate func setupNavigationBarCoverView( on view: UIView ) {
264+ private func setupNavigationBarCoverView( on view: UIView ) {
263265 barCoverView = UIView ( )
264266 barCoverView? . backgroundColor = UIColor . clear
265267 view. addSubview ( barCoverView!)
@@ -273,7 +275,7 @@ open class DropdownMenu: UIView {
273275 barCoverView? . addGestureRecognizer ( UITapGestureRecognizer ( target: self , action: #selector( hideMenu) ) )
274276 }
275277
276- fileprivate func tableviewHeight( ) -> CGFloat {
278+ private func tableviewHeight( ) -> CGFloat {
277279 var height : CGFloat = 0
278280 sections. enumerated ( ) . forEach {
279281 if displaySectionHeader {
0 commit comments