Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from teambition/swift5
Browse files Browse the repository at this point in the history
update: swift 5 support
  • Loading branch information
suricforever authored Apr 15, 2019
2 parents b6f0c31 + b5420b9 commit ecfae63
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "teambition/RefreshView" "1.4.1"
github "teambition/RefreshView" "1.4.2"
15 changes: 8 additions & 7 deletions STTableBoard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,22 @@
EB793B0A1C1E608900BF1148 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = StormXX;
TargetAttributes = {
EB793B121C1E608900BF1148 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = EB793B0D1C1E608900BF1148 /* Build configuration list for PBXProject "STTableBoard" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = EB793B091C1E608900BF1148;
productRefGroup = EB793B141C1E608900BF1148 /* Products */;
Expand Down Expand Up @@ -333,6 +334,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -392,6 +394,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -463,8 +466,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -489,8 +491,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.StormXX.STTableBoard;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions STTableBoard/Classes/constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ var currentOrientation: STTableBoardOrientation {
orientation = .portrait
case .landscapeLeft, .landscapeRight:
orientation = .landscape
@unknown default:
break
}
return orientation
}
Expand Down
40 changes: 20 additions & 20 deletions STTableBoard/Extensions/STTableBoard+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import UIKit
// MARK: - Public methods
// swiftlint:disable identifier_name
public extension STTableBoard {
public func updateLocalizedString(_ value: String, forKey key: String) {
func updateLocalizedString(_ value: String, forKey key: String) {
localizedString.updateValue(value, forKey: key)
}

public func reloadData(_ resetPage: Bool = true, resetMode: Bool = false) {
func reloadData(_ resetPage: Bool = true, resetMode: Bool = false) {
resetContentSize()

if boards.count != 0 {
Expand Down Expand Up @@ -52,7 +52,7 @@ public extension STTableBoard {
}
}

public func reloadBoard(at index: Int, animated: Bool) {
func reloadBoard(at index: Int, animated: Bool) {
guard index < boards.count else {
fatalError("index is not exist!!")
}
Expand All @@ -61,35 +61,35 @@ public extension STTableBoard {
autoAdjustTableBoardHeight(board, animated: animated)
}

public func reloadBoardTitle(at index: Int) {
func reloadBoardTitle(at index: Int) {
guard index < boards.count else {
fatalError("index is not exist!!")
}
let board = boards[index]
board.title = dataSource?.tableBoard(self, titleForBoardAt: index)
}

public func reloadBoardNumber(at index: Int) {
func reloadBoardNumber(at index: Int) {
guard index < boards.count else {
fatalError("index is not exist!!")
}
let board = boards[index]
board.number = dataSource?.tableBoard(self, numberForBoardAt: index) ?? 0
}

public func reloadBoardActionButton(at index: Int) {
func reloadBoardActionButton(at index: Int) {
guard index < boards.count else {
fatalError("index is not exist!!")
}
let board = boards[index]
board.shouldShowActionButton = dataSource?.tableBoard(self, shouldShowActionButtonAt: index) ?? true
}

public func reloadAddBoardButtonTitle() {
func reloadAddBoardButtonTitle() {
newBoardButtonView.title = localizedString["STTableBoard.AddBoard"]
}

public func removeBoard(at index: Int) {
func removeBoard(at index: Int) {
guard index < boards.count else {
fatalError("index is not exist!!")
}
Expand All @@ -109,11 +109,11 @@ public extension STTableBoard {
pageControl.numberOfPages = numberOfPage
}

public func insertBoard(at index: Int, animated: Bool) {
func insertBoard(at index: Int, animated: Bool) {
insertBoardAtIndex(index, animation: animated)
}

public func exchangeBoard(originIndex: Int, destinationIndex: Int, animated: Bool) {
func exchangeBoard(originIndex: Int, destinationIndex: Int, animated: Bool) {
guard originIndex != destinationIndex && originIndex < boards.count && destinationIndex < boards.count else {
return
}
Expand All @@ -137,7 +137,7 @@ public extension STTableBoard {
}

public extension STTableBoard {
public func insertRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
func insertRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
var indexPathsDic = [String: [STIndexPath]]()
indexPaths.forEach { (indexPath) -> Void in
if var indexPathsInBoard = indexPathsDic[String(indexPath.board)] {
Expand All @@ -164,7 +164,7 @@ public extension STTableBoard {
}
}

public func insertSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
func insertSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
let board = boards[boardIndex]
guard let tableView = board.tableView else {
return
Expand All @@ -183,7 +183,7 @@ public extension STTableBoard {
}
}

public func deleteRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
func deleteRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
var indexPathsDic = [String: [STIndexPath]]()
indexPaths.forEach { (indexPath) -> Void in
if var indexPathsInBoard = indexPathsDic[String(indexPath.board)] {
Expand All @@ -210,7 +210,7 @@ public extension STTableBoard {
}
}

public func deleteSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
func deleteSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
let board = boards[boardIndex]
guard let tableView = board.tableView else {
return
Expand All @@ -221,7 +221,7 @@ public extension STTableBoard {
autoAdjustTableBoardHeight(board, animated: true)
}

public func moveRowWithinBoard(at indexPath: STIndexPath, to newIndexPath: STIndexPath, reloadAfterMoving: Bool = false, with animation: UITableView.RowAnimation = .none) {
func moveRowWithinBoard(at indexPath: STIndexPath, to newIndexPath: STIndexPath, reloadAfterMoving: Bool = false, with animation: UITableView.RowAnimation = .none) {
guard indexPath.board == newIndexPath.board else {
return
}
Expand All @@ -241,7 +241,7 @@ public extension STTableBoard {
self.autoAdjustTableBoardHeight(board, animated: true)
}

public func insertRow(at indexPath: STIndexPath, withRowAnimation animation: UITableView.RowAnimation, atScrollPosition scrollPosition: UITableView.ScrollPosition) {
func insertRow(at indexPath: STIndexPath, withRowAnimation animation: UITableView.RowAnimation, atScrollPosition scrollPosition: UITableView.ScrollPosition) {
let board = boards[indexPath.board]
guard let tableView = board.tableView else {
return
Expand All @@ -261,7 +261,7 @@ public extension STTableBoard {
}
}

public func reloadRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
func reloadRows(at indexPaths: [STIndexPath], with animation: UITableView.RowAnimation) {
var indexPathsDic = [String: [STIndexPath]]()
indexPaths.forEach { (indexPath) -> Void in
if var indexPathsInBoard = indexPathsDic[String(indexPath.board)] {
Expand All @@ -288,7 +288,7 @@ public extension STTableBoard {
}
}

public func reloadSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
func reloadSections(_ sections: IndexSet, atBoard boardIndex: Int, with animation: UITableView.RowAnimation) {
let board = boards[boardIndex]
guard let tableView = board.tableView else {
return
Expand All @@ -299,15 +299,15 @@ public extension STTableBoard {
autoAdjustTableBoardHeight(board, animated: true)
}

public func cellForRow(at indexPath: STIndexPath) -> STBoardCell? {
func cellForRow(at indexPath: STIndexPath) -> STBoardCell? {
let board = boards[indexPath.board]
guard let tableView = board.tableView else {
return nil
}
return tableView.cellForRow(at: indexPath.toIndexPath()) as? STBoardCell
}

public func scrollToRow(at indexPath: STIndexPath, at scrollPosition: UITableView.ScrollPosition, animated: Bool) {
func scrollToRow(at indexPath: STIndexPath, at scrollPosition: UITableView.ScrollPosition, animated: Bool) {
let board = boards[indexPath.board]
guard let tableView = board.tableView else {
return
Expand Down
2 changes: 1 addition & 1 deletion STTableBoard/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.6.4</string>
<string>0.6.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
20 changes: 10 additions & 10 deletions STTableBoard/Views/STBoardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class STBoardView: UIView {
}

lazy var footerViewHeightConstraint: NSLayoutConstraint = {
let constraint = NSLayoutConstraint(item: self.footerView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: shouldEnableAddRow ? footerViewNormalHeight : footerViewDisabledHeight)
let constraint = NSLayoutConstraint(item: footerView!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: shouldEnableAddRow ? footerViewNormalHeight : footerViewDisabledHeight)
return constraint
}()

Expand Down Expand Up @@ -143,10 +143,10 @@ class STBoardView: UIView {
headerView.translatesAutoresizingMaskIntoConstraints = false
footerView.translatesAutoresizingMaskIntoConstraints = false
tableView.translatesAutoresizingMaskIntoConstraints = false
let headerViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[headerView]|", options: [], metrics: nil, views: ["headerView": headerView])
let tableViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[tableView]|", options: [], metrics: nil, views: ["tableView": tableView])
let footerViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[footerView]|", options: [], metrics: nil, views: ["footerView": footerView])
let verticalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|[headerView(==headerViewHeight)][tableView][footerView]|", options: [], metrics: ["headerViewHeight": headerViewHeight], views: ["headerView": headerView, "tableView": tableView, "footerView": footerView])
let headerViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[headerView]|", options: [], metrics: nil, views: ["headerView": headerView!])
let tableViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[tableView]|", options: [], metrics: nil, views: ["tableView": tableView!])
let footerViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[footerView]|", options: [], metrics: nil, views: ["footerView": footerView!])
let verticalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|[headerView(==headerViewHeight)][tableView][footerView]|", options: [], metrics: ["headerViewHeight": headerViewHeight], views: ["headerView": headerView!, "tableView": tableView!, "footerView": footerView!])

let horizontalConstraints = headerViewHorizontalConstraints + tableViewHorizontalConstraints + footerViewHorizontalConstraints
NSLayoutConstraint.activate(horizontalConstraints + verticalConstraints + [footerViewHeightConstraint])
Expand All @@ -168,12 +168,12 @@ class STBoardView: UIView {
dropMaskView.layer.borderColor = UIColor.primaryBlueColor.cgColor

dropMaskView.addSubview(dropMessageLabel)
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMessageLabel, attribute: .leading, relatedBy: .equal, toItem: dropMaskView, attribute: .leading, multiplier: 1, constant: 10))
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMaskView, attribute: .trailing, relatedBy: .equal, toItem: dropMessageLabel, attribute: .trailing, multiplier: 1, constant: 10))
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMessageLabel, attribute: .top, relatedBy: .equal, toItem: dropMaskView, attribute: .top, multiplier: 1, constant: 10))
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMessageLabel!, attribute: .leading, relatedBy: .equal, toItem: dropMaskView, attribute: .leading, multiplier: 1, constant: 10))
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMaskView!, attribute: .trailing, relatedBy: .equal, toItem: dropMessageLabel, attribute: .trailing, multiplier: 1, constant: 10))
dropMaskView.addConstraint(NSLayoutConstraint(item: dropMessageLabel!, attribute: .top, relatedBy: .equal, toItem: dropMaskView, attribute: .top, multiplier: 1, constant: 10))
addSubview(dropMaskView)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[dropMaskView]|", options: [], metrics: nil, views: ["dropMaskView": dropMaskView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[dropMaskView]|", options: [], metrics: nil, views: ["dropMaskView": dropMaskView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[dropMaskView]|", options: [], metrics: nil, views: ["dropMaskView": dropMaskView!]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[dropMaskView]|", options: [], metrics: nil, views: ["dropMaskView": dropMaskView!]))

bringSubviewToFront(dropMaskView)
deactivateDropMask()
Expand Down
14 changes: 7 additions & 7 deletions STTableBoardDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = StormXX;
TargetAttributes = {
EB793BA51C1E653400BF1148 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = EB793BA11C1E653400BF1148 /* Build configuration list for PBXProject "STTableBoardDemo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -279,6 +279,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -334,6 +335,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -399,8 +401,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -425,8 +426,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion STTableBoardDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.6.4</string>
<string>0.6.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions STTableBoardDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ extension ViewController {

fileprivate func layoutView() {
tableBoard.view.translatesAutoresizingMaskIntoConstraints = false
let views: [String: Any] = ["tableBoard": tableBoard.view]
let views: [String: Any] = ["tableBoard": tableBoard.view!]
let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[tableBoard]|", options: [], metrics: nil, views: views)
let top = NSLayoutConstraint(item: tableBoard.view, attribute: .top, relatedBy: .equal, toItem: containerView, attribute: .bottom, multiplier: 1, constant: 0)
let bottom = NSLayoutConstraint(item: tableBoard.view, attribute: .bottom, relatedBy: .equal, toItem: bottomLayoutGuide, attribute: .top, multiplier: 1, constant: 0)
let top = NSLayoutConstraint(item: tableBoard.view!, attribute: .top, relatedBy: .equal, toItem: containerView, attribute: .bottom, multiplier: 1, constant: 0)
let bottom = NSLayoutConstraint(item: tableBoard.view!, attribute: .bottom, relatedBy: .equal, toItem: bottomLayoutGuide, attribute: .top, multiplier: 1, constant: 0)
NSLayoutConstraint.activate(horizontalConstraints + [top, bottom])
}

Expand Down

0 comments on commit ecfae63

Please sign in to comment.