Skip to content

Commit

Permalink
Merge branch 'swift3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
marmelroy committed Sep 19, 2016
2 parents 90b6bda + 8798ba3 commit 7fae9fa
Show file tree
Hide file tree
Showing 43 changed files with 583 additions and 687 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
osx_image: xcode7.3
osx_image: xcode8
language: objective-c
env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
before_install:
- brew update || brew update
- brew outdated xctool || brew upgrade xctool
- gem install cocoapods
- gem install cocoapods --pre
- xcrun simctl list
install: echo "<3"
env:
Expand Down
2 changes: 1 addition & 1 deletion FileBrowser.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "FileBrowser"
s.version = "0.1.4"
s.version = "0.2.0"
s.summary = "Powerful iOS file browser in Swift."

# This description is used to generate tags and improve search results.
Expand Down
27 changes: 20 additions & 7 deletions FileBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Roy Marmelstein";
TargetAttributes = {
344169531C67812400B93D28 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
};
3441695D1C67812400B93D28 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -361,13 +363,15 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -385,7 +389,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -409,13 +413,15 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -427,9 +433,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -441,9 +448,10 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
DYLIB_CURRENT_VERSION = 6;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = FileBrowser/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -453,16 +461,18 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
3441696A1C67812400B93D28 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
DYLIB_CURRENT_VERSION = 6;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = FileBrowser/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -471,6 +481,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowser;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -481,6 +492,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -491,6 +503,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.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 = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
44 changes: 21 additions & 23 deletions FileBrowser/FBFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
import Foundation

/// FBFile is a class representing a file in FileBrowser
public class FBFile: NSObject {
open class FBFile: NSObject {
/// Display name. String.
public let displayName: String
open let displayName: String
// is Directory. Bool.
public let isDirectory: Bool
open let isDirectory: Bool
/// File extension.
public let fileExtension: String?
open let fileExtension: String?
/// File attributes (including size, creation date etc).
public let fileAttributes: NSDictionary?
open let fileAttributes: NSDictionary?
/// NSURL file path.
public let filePath: NSURL
open let filePath: URL
// FBFileType
public let type: FBFileType
open let type: FBFileType

/**
Initialize an FBFile object with a filePath
Expand All @@ -30,7 +30,7 @@ public class FBFile: NSObject {

- returns: FBFile object.
*/
init(filePath: NSURL) {
init(filePath: URL) {
self.filePath = filePath
let isDirectory = checkDirectory(filePath)
self.isDirectory = isDirectory
Expand All @@ -49,7 +49,7 @@ public class FBFile: NSObject {
self.type = .Default
}
}
self.displayName = filePath.lastPathComponent ?? String()
self.displayName = filePath.lastPathComponent
}
}

Expand Down Expand Up @@ -82,16 +82,16 @@ public enum FBFileType: String {
- returns: UIImage for file type
*/
public func image() -> UIImage? {
let bundle = NSBundle(forClass: FileParser.self)
let bundle = Bundle(for: FileParser.self)
var fileName = String()
switch self {
case Directory: fileName = "[email protected]"
case JPG, PNG, GIF: fileName = "[email protected]"
case PDF: fileName = "[email protected]"
case ZIP: fileName = "[email protected]"
case .Directory: fileName = "[email protected]"
case .JPG, .PNG, .GIF: fileName = "[email protected]"
case .PDF: fileName = "[email protected]"
case .ZIP: fileName = "[email protected]"
default: fileName = "[email protected]"
}
let file = UIImage(named: fileName, inBundle: bundle, compatibleWithTraitCollection: nil)
let file = UIImage(named: fileName, in: bundle, compatibleWith: nil)
return file
}
}
Expand All @@ -103,26 +103,24 @@ public enum FBFileType: String {

- returns: isDirectory Bool.
*/
func checkDirectory(filePath: NSURL) -> Bool {
func checkDirectory(_ filePath: URL) -> Bool {
var isDirectory = false
do {
var resourceValue: AnyObject?
try filePath.getResourceValue(&resourceValue, forKey: NSURLIsDirectoryKey)
if let number = resourceValue as? NSNumber where number == true {
try (filePath as NSURL).getResourceValue(&resourceValue, forKey: URLResourceKey.isDirectoryKey)
if let number = resourceValue as? NSNumber , number == true {
isDirectory = true
}
}
catch { }
return isDirectory
}

func getFileAttributes(filePath: NSURL) -> NSDictionary? {
guard let path = filePath.path else {
return nil
}
func getFileAttributes(_ filePath: URL) -> NSDictionary? {
let path = filePath.path
let fileManager = FileParser.sharedInstance.fileManager
do {
let attributes = try fileManager.attributesOfItemAtPath(path) as NSDictionary
let attributes = try fileManager.attributesOfItem(atPath: path) as NSDictionary
return attributes
} catch {}
return nil
Expand Down
16 changes: 8 additions & 8 deletions FileBrowser/FileBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
import Foundation

/// File browser containing navigation controller.
public class FileBrowser: UINavigationController {
open class FileBrowser: UINavigationController {

let parser = FileParser.sharedInstance

var fileList: FileListViewController?

/// File types to exclude from the file browser.
public var excludesFileExtensions: [String]? {
open var excludesFileExtensions: [String]? {
didSet {
parser.excludesFileExtensions = excludesFileExtensions
}
}

/// File paths to exclude from the file browser.
public var excludesFilepaths: [NSURL]? {
open var excludesFilepaths: [URL]? {
didSet {
parser.excludesFilepaths = excludesFilepaths
}
}

/// Override default preview and actionsheet behaviour in favour of custom file handling.
public var didSelectFile: ((FBFile) -> ())? {
open var didSelectFile: ((FBFile) -> ())? {
didSet {
fileList?.didSelectFile = didSelectFile
}
Expand All @@ -44,7 +44,7 @@ public class FileBrowser: UINavigationController {
public convenience init() {
let parser = FileParser.sharedInstance
let path = parser.documentsURL()
self.init(initialPath: path)
self.init(initialPath: path as URL)
}

/**
Expand All @@ -54,11 +54,11 @@ public class FileBrowser: UINavigationController {

- returns: File browser view controller.
*/
public convenience init(initialPath: NSURL) {
public convenience init(initialPath: URL) {
let fileListViewController = FileListViewController(initialPath: initialPath)
self.init(rootViewController: fileListViewController)
self.view.backgroundColor = UIColor.whiteColor()
self.view.backgroundColor = UIColor.white
self.fileList = fileListViewController
}

}
}
12 changes: 6 additions & 6 deletions FileBrowser/FileListPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ extension FileListViewController: UIViewControllerPreviewingDelegate {

func registerFor3DTouch() {
if #available(iOS 9.0, *) {
if self.traitCollection.forceTouchCapability == UIForceTouchCapability.Available {
registerForPreviewingWithDelegate(self, sourceView: tableView)
if self.traitCollection.forceTouchCapability == UIForceTouchCapability.available {
registerForPreviewing(with: self, sourceView: tableView)
}
}
}

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
if #available(iOS 9.0, *) {
if let indexPath = tableView.indexPathForRowAtPoint(location) {
if let indexPath = tableView.indexPathForRow(at: location) {
let selectedFile = fileForIndexPath(indexPath)
previewingContext.sourceRect = tableView.rectForRowAtIndexPath(indexPath)
previewingContext.sourceRect = tableView.rectForRow(at: indexPath)
if selectedFile.isDirectory == false {
return previewManager.previewViewControllerForFile(selectedFile, fromNavigation: false)
}
Expand All @@ -34,7 +34,7 @@ extension FileListViewController: UIViewControllerPreviewingDelegate {
return nil
}

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
if let previewTransitionViewController = viewControllerToCommit as? PreviewTransitionViewController {
self.navigationController?.pushViewController(previewTransitionViewController.quickLookPreviewController, animated: true)
}
Expand Down
8 changes: 4 additions & 4 deletions FileBrowser/FileListSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ import Foundation
extension FileListViewController: UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating {

// MARK: UISearchControllerDelegate
func willPresentSearchController(searchController: UISearchController) {
func willPresentSearchController(_ searchController: UISearchController) {
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0)
}

func willDismissSearchController(searchController: UISearchController) {
func willDismissSearchController(_ searchController: UISearchController) {
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
}

// MARK: UISearchBarDelegate
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
filterContentForSearchText(searchBar.text!)
}

// MARK: UISearchResultsUpdating
func updateSearchResultsForSearchController(searchController: UISearchController) {
func updateSearchResults(for searchController: UISearchController) {
filterContentForSearchText(searchController.searchBar.text!)
}
}
Loading

0 comments on commit 7fae9fa

Please sign in to comment.