-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from susemi99/develop
v3.7
- Loading branch information
Showing
16 changed files
with
337 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,84 @@ | ||
import UIKit | ||
import PKHUD | ||
import UIKit | ||
|
||
class FileListViewController: UITableViewController { | ||
var items: [GTFile] = [] | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad{ | ||
|
||
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad { | ||
navigationItem.leftBarButtonItems = [] | ||
} | ||
|
||
if !UserDefaults.standard.bool(forKey: IS_FIRST_RUN) { | ||
FileController.copyBundleToFolder() | ||
UserDefaults.standard.set(true, forKey: IS_FIRST_RUN) | ||
} | ||
|
||
reload() | ||
} | ||
|
||
override func didReceiveMemoryWarning() { | ||
super.didReceiveMemoryWarning() | ||
} | ||
|
||
// MARK: - User Action | ||
|
||
@IBAction func cancelButtonClicked(_ sender: AnyObject) { | ||
close() | ||
} | ||
|
||
func close() { | ||
dismiss(animated: true, completion: nil) | ||
} | ||
|
||
@IBAction func reloadButtonClicked(_ sender: Any) { | ||
reload() | ||
} | ||
|
||
func reload() { | ||
self.items.removeAll() | ||
items.removeAll() | ||
|
||
HUD.show(.progress) | ||
|
||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | ||
self.items = FileController.files() | ||
self.tableView.reloadData() | ||
HUD.hide() | ||
} | ||
} | ||
|
||
// MARK: - UITableView | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return items.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) | ||
let file = items[indexPath.row] | ||
cell.textLabel?.text = file.fullName | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { | ||
if editingStyle == .delete { | ||
let row = indexPath.row | ||
FileController.delete(file: self.items[row]) | ||
self.items.remove(at: row) | ||
FileController.delete(file: items[row]) | ||
items.remove(at: row) | ||
tableView.deleteRows(at: [indexPath], with: .fade) | ||
} | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
NotificationCenter.default.post(name: Notification.Name(rawValue: SELECTED_FILE), | ||
object: nil, | ||
userInfo: [SELECTED_FILE_PATH : self.items[indexPath.row]]) | ||
userInfo: [SELECTED_FILE_PATH: self.items[indexPath.row]]) | ||
close() | ||
} | ||
} |
Oops, something went wrong.