Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nghialv committed Feb 11, 2015
1 parent 6af79bc commit 917f169
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Source/MYBaseClasses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MYBaseViewData : NSObject, MYBaseViewDelegate {
weak var delegate: MYBaseViewDataDelegate?
var userData: AnyObject?

init(userData: AnyObject? = nil, selectionHandler: MYSelectionHandler?) {
public init(userData: AnyObject? = nil, selectionHandler: MYSelectionHandler?) {
self.userData = userData
self.action = selectionHandler
}
Expand Down
16 changes: 8 additions & 8 deletions Source/MYHeaderFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MYHeaderFooterViewData : MYBaseViewData {
var viewHeight: CGFloat = 44
var isEnabled = true

init(viewClass: AnyClass, userData: AnyObject?, selectionHandler: MYSelectionHandler? = nil) {
public init(viewClass: AnyClass, userData: AnyObject?, selectionHandler: MYSelectionHandler? = nil) {
self.identifier = String.className(viewClass)
super.init(userData: userData, selectionHandler: selectionHandler)
}
Expand All @@ -23,7 +23,7 @@ public class MYHeaderFooterView : UITableViewHeaderFooterView, MYBaseViewProtoco
class var identifier: String { return String.className(self) }
private weak var delegate: MYBaseViewDelegate?

override init() {
public override init() {
super.init()
setup()
}
Expand All @@ -33,20 +33,20 @@ public class MYHeaderFooterView : UITableViewHeaderFooterView, MYBaseViewProtoco
setup()
}

override init(frame: CGRect) {
public override init(frame: CGRect) {
super.init(frame: frame)
setup()
}

override init(reuseIdentifier: String?) {
public override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
setup()
}

func setup() {
public func setup() {
}

func configureView(data: MYHeaderFooterViewData) {
public func configureView(data: MYHeaderFooterViewData) {
self.delegate = data
}

Expand All @@ -61,10 +61,10 @@ public class MYHeaderFooterView : UITableViewHeaderFooterView, MYBaseViewProtoco

// MARK - Hightlight
public extension MYHeaderFooterView {
public func highlight(animated: Bool) {
func highlight(animated: Bool) {
}

public func unhighlight(animated: Bool) {
func unhighlight(animated: Bool) {
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/MYLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import UIKit

class MYLabel : UILabel {
override var bounds: CGRect {
public class MYLabel : UILabel {
override public var bounds: CGRect {
didSet {
self.preferredMaxLayoutWidth = self.bounds.width
}
Expand Down
8 changes: 4 additions & 4 deletions Source/MYTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MYTableViewCellData : MYBaseViewData {
}
}

init(cellClass: AnyClass, height: CGFloat = 44, userData: AnyObject?, selectionHandler: MYSelectionHandler? = nil) {
public init(cellClass: AnyClass, height: CGFloat = 44, userData: AnyObject?, selectionHandler: MYSelectionHandler? = nil) {
self.identifier = String.className(cellClass)
self.cellHeight = height
super.init(userData: userData, selectionHandler: selectionHandler)
Expand All @@ -32,7 +32,7 @@ public class MYTableViewCell : UITableViewCell, MYBaseViewProtocol {
private weak var delegate: MYBaseViewDelegate?
weak var cellData: MYTableViewCellData?

override init() {
public override init() {
super.init()
setup()
}
Expand All @@ -42,12 +42,12 @@ public class MYTableViewCell : UITableViewCell, MYBaseViewProtocol {
setup()
}

override init(frame: CGRect) {
public override init(frame: CGRect) {
super.init(frame: frame)
setup()
}

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
Expand Down
19 changes: 2 additions & 17 deletions Source/MYTableViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum MYReloadType {
case None
}

@objc protocol MYTableViewManagerDelegate : class {
@objc public protocol MYTableViewManagerDelegate : class {
optional func scrollViewDidScroll(scrollView: UIScrollView)
optional func scrollViewWillBeginDecelerating(scrollView: UIScrollView)
optional func scrollViewWillBeginDragging(scrollView: UIScrollView)
Expand All @@ -53,22 +53,7 @@ public class MYTableViewManager : NSObject {
var loadmoreEnabled = false
var loadmoreThreshold: CGFloat = 25

subscript(index: Int) -> [MYTableViewCellData] {
get {
if dataSource.indexForKey(index) != nil {
return dataSource[index]!
} else {
numberOfSections = max(numberOfSections, index + 1)
dataSource[index] = []
return dataSource[index]!
}
}
set(newValue) {
dataSource[index] = newValue
}
}

init(tableView: UITableView) {
public init(tableView: UITableView) {
super.init()
self.tableView = tableView
tableView.delegate = self
Expand Down

0 comments on commit 917f169

Please sign in to comment.