Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions FileBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@
TargetAttributes = {
344169531C67812400B93D28 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1030;
};
3441695D1C67812400B93D28 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1030;
ProvisioningStyle = Manual;
};
};
Expand All @@ -273,6 +273,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 3441694A1C67812400B93D28;
Expand Down Expand Up @@ -477,6 +478,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -495,6 +497,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowser;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -506,6 +509,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -517,6 +521,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
12 changes: 6 additions & 6 deletions FileBrowser/FBFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import Foundation
/// FBFile is a class representing a file in FileBrowser
@objc open class FBFile: NSObject {
/// Display name. String.
@objc open let displayName: String
@objc public let displayName: String
// is Directory. Bool.
open let isDirectory: Bool
public let isDirectory: Bool
/// File extension.
open let fileExtension: String?
public let fileExtension: String?
/// File attributes (including size, creation date etc).
open let fileAttributes: NSDictionary?
public let fileAttributes: NSDictionary?
/// NSURL file path.
open let filePath: URL
public let filePath: URL
// FBFileType
open let type: FBFileType
public let type: FBFileType

open func delete()
{
Expand Down
7 changes: 7 additions & 0 deletions FileBrowser/FileBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ open class FileBrowser: UINavigationController {
let parser = FileParser.sharedInstance

var fileList: FileListViewController?

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

/// File types to exclude from the file browser.
open var excludesFileExtensions: [String]? {
Expand Down
4 changes: 2 additions & 2 deletions FileBrowser/FileListSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ extension FileListViewController: UISearchBarDelegate, UISearchControllerDelegat

// MARK: UISearchControllerDelegate
func willPresentSearchController(_ searchController: UISearchController) {
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0)
self.tableView.contentInset = UIEdgeInsets.init(top: 20, left: 0, bottom: 0, right: 0)
}

func willDismissSearchController(_ searchController: UISearchController) {
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
self.tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
}

// MARK: UISearchBarDelegate
Expand Down
6 changes: 3 additions & 3 deletions FileBrowser/FileListTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ extension FileListViewController: UITableViewDataSource, UITableViewDelegate {
return collation.section(forSectionIndexTitle: index)
}

func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if (editingStyle == UITableViewCellEditingStyle.delete) {
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if (editingStyle == UITableViewCell.EditingStyle.delete) {
let selectedFile = fileForIndexPath(indexPath)
selectedFile.delete()

prepareData()
tableView.reloadSections([indexPath.section], with: UITableViewRowAnimation.automatic)
tableView.reloadSections([indexPath.section], with: UITableView.RowAnimation.automatic)
}
}

Expand Down
17 changes: 17 additions & 0 deletions FileBrowser/FileParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class FileParser {

static let sharedInstance = FileParser()

var _excludesFileNames = [String]()

/// Case sensitive
var excludesFileNames: [String]? {
get {
return _excludesFileNames
}
set {
if let newValue = newValue {
_excludesFileNames = newValue
}
}
}

var _excludesFileExtensions = [String]()

/// Mapped for case insensitivity
Expand Down Expand Up @@ -46,6 +60,9 @@ class FileParser {
// Parse
for filePath in filePaths {
let file = FBFile(filePath: filePath)
if let excludesFileNames = excludesFileNames, excludesFileNames.contains(where: file.displayName.contains) {
continue
}
if let excludesFileExtensions = excludesFileExtensions, let fileExtensions = file.fileExtension , excludesFileExtensions.contains(fileExtensions) {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions FileBrowser/PreviewTransitionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class PreviewTransitionViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.addChildViewController(quickLookPreviewController)
self.addChild(quickLookPreviewController)
containerView.addSubview(quickLookPreviewController.view)
quickLookPreviewController.view.frame = containerView.bounds
quickLookPreviewController.didMove(toParentViewController: self)
quickLookPreviewController.didMove(toParent: self)
}

}
18 changes: 11 additions & 7 deletions FileBrowser/Resources/PreviewTransitionViewController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9532"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PreviewTransitionViewController" customModule="FileBrowser" customModuleProvider="target">
Expand All @@ -13,15 +17,15 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XU1-oS-O9g">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="XU1-oS-O9g" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="16b-EN-UAr"/>
<constraint firstItem="XU1-oS-O9g" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="LcQ-I8-kyx"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>