diff --git a/Kiwix-iOS/Controller/Main/Controllers.swift b/Kiwix-iOS/Controller/Main/Controllers.swift
new file mode 100644
index 00000000..d872e261
--- /dev/null
+++ b/Kiwix-iOS/Controller/Main/Controllers.swift
@@ -0,0 +1,84 @@
+//
+// Controllers.swift
+// Kiwix
+//
+// Created by Chris Li on 11/15/16.
+// Copyright © 2016 Chris Li. All rights reserved.
+//
+
+import UIKit
+
+class Controllers {
+
+ public func cleanUp() {
+ //_bookmark = nil
+ //bookmarkHUD = nil
+ _library = nil
+ _search = nil
+ //setting = nil
+ _welcome = nil
+ }
+
+ // MARK: - Main
+
+ class var main: MainController {
+ return (UIApplication.appDelegate.window?.rootViewController as! UINavigationController).topViewController as! MainController
+ }
+
+// // MARK: - Bookmark
+//
+// private var bookmark: UINavigationController?
+//
+// class var bookmark: UINavigationController {
+// let controller = Controllers.shared.bookmark ?? UIStoryboard(name: "Bookmark", bundle: nil).instantiateInitialViewController() as! UINavigationController
+// Controllers.shared.bookmark = controller
+// return controller
+// }
+//
+// private var bookmarkHUD: BookmarkHUD?
+//
+// class var bookmarkHUD: BookmarkHUD {
+// let controller = Controllers.shared.bookmarkHUD ?? UIStoryboard(name: "Bookmark", bundle: nil).instantiateViewController(withIdentifier: "BookmarkHUD") as! BookmarkHUD
+// Controllers.shared.bookmarkHUD = controller
+// return controller
+// }
+
+ // MARK: - Library
+
+ private var _library: UIViewController?
+ var library: UIViewController {
+ let controller = _library ?? UIStoryboard(name: "Library", bundle: nil).instantiateInitialViewController()!
+ _library = controller
+ return controller
+ }
+
+
+ // MARK: - Search
+
+ private var _search: SearchContainer?
+ var search: SearchContainer {
+ let controller = _search ?? UIStoryboard(name: "Search", bundle: nil).instantiateInitialViewController() as! SearchContainer
+ _search = controller
+ return controller
+ }
+//
+// // MARK: - Setting
+//
+// private var setting: UIViewController?
+//
+// class var setting: UIViewController {
+// let controller = Controllers.shared.setting ?? UIStoryboard(name: "Setting", bundle: nil).instantiateInitialViewController()!
+// Controllers.shared.setting = controller
+// return controller
+// }
+
+ // MARK: - Welcome
+
+ private var _welcome: WelcomeController?
+ var welcome: WelcomeController {
+ let controller = _welcome ?? UIStoryboard(name: "Welcome", bundle: nil).instantiateInitialViewController() as! WelcomeController
+ _welcome = controller
+ return controller
+ }
+
+}
diff --git a/Kiwix-iOS/Controller/Main/MainController.swift b/Kiwix-iOS/Controller/Main/MainController.swift
index 5ac21b46..633861c2 100644
--- a/Kiwix-iOS/Controller/Main/MainController.swift
+++ b/Kiwix-iOS/Controller/Main/MainController.swift
@@ -11,6 +11,7 @@ import UIKit
class MainController: UIViewController {
let searchBar = SearchBar()
+ lazy var controllers = Controllers()
lazy var buttons = Buttons()
override func viewDidLoad() {
@@ -54,7 +55,7 @@ class MainController: UIViewController {
// MARK: - Show / Hide
func showWelcome() {
- let controller = Controllers.welcome
+ let controller = controllers.welcome
controller.view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(controller)
view.addSubview(controller.view)
@@ -71,7 +72,7 @@ class MainController: UIViewController {
}
func showSearch(animated: Bool) {
- let controller = Controllers.search
+ let controller = controllers.search
controller.delegate = self
guard !childViewControllers.contains(controller) else {return}
diff --git a/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift b/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift
index a04777f0..19d525b9 100644
--- a/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift
+++ b/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift
@@ -21,13 +21,13 @@ extension MainController: SearchBarDelegate, ButtonDelegates, SearchContainerDel
}
func textDidChange(text: String, searchBar: SearchBar) {
- Controllers.search.searchText = text
+ controllers.search.searchText = text
}
// MARK: - Button Delegates
func didTapLibraryButton() {
- present(Controllers.library, animated: true, completion: nil)
+ present(controllers.library, animated: true, completion: nil)
}
func didTapCancelButton() {
diff --git a/Kiwix-iOS/Controller/Others/ControllerRetainer.swift b/Kiwix-iOS/Controller/Others/ControllerRetainer.swift
deleted file mode 100644
index 1098b794..00000000
--- a/Kiwix-iOS/Controller/Others/ControllerRetainer.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Controllers.swift
-// Kiwix
-//
-// Created by Chris Li on 8/31/16.
-// Copyright © 2016 Chris Li. All rights reserved.
-//
-
-import UIKit
-
-class Controllers {
- static let shared = Controllers()
- private init() {
- NotificationCenter.default.addObserver(self, selector: #selector(Controllers.removeStrongReference), name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil)
- }
-
- deinit {
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil)
- }
-
- @objc private func removeStrongReference() {
- bookmark = nil
- bookmarkHUD = nil
- library = nil
- search = nil
- setting = nil
- welcome = nil
- }
-
- // MARK: - Main
-
- class var main: MainController {
- return (UIApplication.appDelegate.window?.rootViewController as! UINavigationController).topViewController as! MainController
- }
-
- // MARK: - Bookmark
-
- private var bookmark: UINavigationController?
-
- class var bookmark: UINavigationController {
- let controller = Controllers.shared.bookmark ?? UIStoryboard(name: "Bookmark", bundle: nil).instantiateInitialViewController() as! UINavigationController
- Controllers.shared.bookmark = controller
- return controller
- }
-
- private var bookmarkHUD: BookmarkHUD?
-
- class var bookmarkHUD: BookmarkHUD {
- let controller = Controllers.shared.bookmarkHUD ?? UIStoryboard(name: "Bookmark", bundle: nil).instantiateViewController(withIdentifier: "BookmarkHUD") as! BookmarkHUD
- Controllers.shared.bookmarkHUD = controller
- return controller
- }
-
- // MARK: - Library
-
- private var library: UIViewController?
-
- class var library: UIViewController {
- let controller = Controllers.shared.library ?? UIStoryboard(name: "Library", bundle: nil).instantiateInitialViewController()!
- Controllers.shared.library = controller
- return controller
- }
-
-
- // MARK: - Search
-
- private var search: SearchContainer?
-
- class var search: SearchContainer {
- let controller = Controllers.shared.search ??
- UIStoryboard(name: "Search", bundle: nil).instantiateInitialViewController() as! SearchContainer
- Controllers.shared.search = controller
- return controller
- }
-
- // MARK: - Setting
-
- private var setting: UIViewController?
-
- class var setting: UIViewController {
- let controller = Controllers.shared.setting ?? UIStoryboard(name: "Setting", bundle: nil).instantiateInitialViewController()!
- Controllers.shared.setting = controller
- return controller
- }
-
- // MARK: - Welcome
-
- private var welcome: WelcomeController?
-
- class var welcome: WelcomeController {
- let controller = Controllers.shared.welcome ?? UIStoryboard(name: "Welcome", bundle: nil).instantiateInitialViewController() as! WelcomeController
- Controllers.shared.welcome = controller
- return controller
- }
-
-}
diff --git a/Kiwix-iOS/Controller/Search/SearchController.swift b/Kiwix-iOS/Controller/Search/SearchController.swift
deleted file mode 100644
index 0e8039aa..00000000
--- a/Kiwix-iOS/Controller/Search/SearchController.swift
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// SearchController.swift
-// Kiwix
-//
-// Created by Chris Li on 1/30/16.
-// Copyright © 2016 Chris Li. All rights reserved.
-//
-
-import UIKit
-import DZNEmptyDataSet
-
-class SearchController: UIViewController, UISearchBarDelegate, UIGestureRecognizerDelegate {
-
- @IBOutlet weak var tabControllerContainer: UIView!
- @IBOutlet weak var searchResultTBVCContainer: UIView!
- @IBOutlet var tapGestureRecognizer: UITapGestureRecognizer!
- var searchResultController: SearchResultController?
-
- fileprivate var searchTerm = "" // last searchTerm
-
- override func viewDidLoad() {
- super.viewDidLoad()
- tapGestureRecognizer.addTarget(self, action: #selector(SearchController.handleTap(_:)))
- tapGestureRecognizer.delegate = self
- }
-
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- configureViewVisibility(searchTerm)
- }
-
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- if segue.identifier == "EmbeddedSearchResultController" {
- guard let destinationViewController = segue.destination as? SearchResultController else {return}
- searchResultController = destinationViewController
- }
- }
-
- func configureViewVisibility(_ searchTerm: String) {
- if searchTerm == "" {
- searchResultTBVCContainer.isHidden = true
- tabControllerContainer.isHidden = false
- } else {
- searchResultTBVCContainer.isHidden = false
- tabControllerContainer.isHidden = true
- }
- }
-
- // MARK: - Search
-
- func startSearch(_ searchTerm: String, delayed: Bool) {
- guard self.searchTerm != searchTerm else {return}
- self.searchTerm = searchTerm
- configureViewVisibility(searchTerm)
- if delayed {
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(275 * USEC_PER_SEC)) / Double(NSEC_PER_SEC)) {
- guard searchTerm == self.searchTerm else {return}
- self.searchResultController?.startSearch(self.searchTerm)
- }
- } else {
- searchResultController?.startSearch(searchTerm)
- }
- }
-
- // MARK: - Handle Gesture
-
- func handleTap(_ tapGestureRecognizer: UIGestureRecognizer) {
- guard let mainVC = parent as? MainController else {return}
-// mainVC.hideSearch(animated: true)
- }
-
- func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
- return touch.view == view ? true : false
- }
-}
-
-
diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index a561dd96..5214daff 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.2861
+ 1.8.2874
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist
index c2a452bc..cbe7c29b 100644
--- a/Kiwix-iOSWidgets/Bookmarks/Info.plist
+++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.8.2861
+ 1.8.2874
NSExtension
NSExtensionMainStoryboard
diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj
index 14b2a049..5318a40e 100644
--- a/Kiwix.xcodeproj/project.pbxproj
+++ b/Kiwix.xcodeproj/project.pbxproj
@@ -13,7 +13,6 @@
970E7F771D9DBEA900741290 /* SettingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F761D9DBEA900741290 /* SettingController.swift */; };
970E7F791DA003FA00741290 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F781DA003FA00741290 /* WebViewController.swift */; };
970E7F7B1DA0069600741290 /* FontSizeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F7A1DA0069600741290 /* FontSizeController.swift */; };
- 970E7F811DA0305000741290 /* ControllerRetainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F7D1DA0305000741290 /* ControllerRetainer.swift */; };
970E7F821DA0305000741290 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F7E1DA0305000741290 /* TableOfContentsController.swift */; };
970E7F831DA0305000741290 /* WelcomeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 970E7F7F1DA0305000741290 /* WelcomeController.swift */; };
9711871E1CEB449A00B9909D /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9711871D1CEB449A00B9909D /* libz.tbd */; };
@@ -29,6 +28,7 @@
971A10811D022F74007FC62C /* Pic_P.png in Resources */ = {isa = PBXBuildFile; fileRef = 971A107D1D022F74007FC62C /* Pic_P.png */; };
9726591D1D90A64600D1DFFB /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9726591C1D90A64500D1DFFB /* Notifications.swift */; };
972F81571DDBFC79008D7289 /* Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972F81561DDBFC79008D7289 /* Search.swift */; };
+ 972F81591DDC1B71008D7289 /* Controllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972F81581DDC1B71008D7289 /* Controllers.swift */; };
9732075C1DD136BB00EDD3DC /* CoreDataExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9732075B1DD136BB00EDD3DC /* CoreDataExtension.swift */; };
9732079E1DD197EA00EDD3DC /* LibrarySplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C005D71D64B99E004352E8 /* LibrarySplitViewController.swift */; };
9732079F1DD197F400EDD3DC /* CloudBooksController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C005DB1D64BEFE004352E8 /* CloudBooksController.swift */; };
@@ -164,7 +164,6 @@
970E7F781DA003FA00741290 /* WebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = ""; };
970E7F7A1DA0069600741290 /* FontSizeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontSizeController.swift; sourceTree = ""; };
970E7F7C1DA0305000741290 /* Alerts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Alerts.swift; sourceTree = ""; };
- 970E7F7D1DA0305000741290 /* ControllerRetainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControllerRetainer.swift; sourceTree = ""; };
970E7F7E1DA0305000741290 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableOfContentsController.swift; sourceTree = ""; };
970E7F7F1DA0305000741290 /* WelcomeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WelcomeController.swift; sourceTree = ""; };
9711871B1CEB448400B9909D /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
@@ -187,6 +186,7 @@
9726591A1D8DB91200D1DFFB /* DownloadProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadProgress.swift; sourceTree = ""; };
9726591C1D90A64500D1DFFB /* Notifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = ""; };
972F81561DDBFC79008D7289 /* Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = ""; };
+ 972F81581DDC1B71008D7289 /* Controllers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Controllers.swift; sourceTree = ""; };
9732075B1DD136BB00EDD3DC /* CoreDataExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataExtension.swift; sourceTree = ""; };
973208251DD21E9C00EDD3DC /* CoreDataContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataContainer.swift; sourceTree = ""; };
973208281DD223DB00EDD3DC /* RefreshLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibrary.swift; sourceTree = ""; };
@@ -231,7 +231,6 @@
9788419C1DA2FF2A00D22D3C /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = ""; };
97A127C51D777CF100FB204D /* RecentSearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentSearchController.swift; sourceTree = ""; };
97A127C61D777CF100FB204D /* SearchBooksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBooksController.swift; sourceTree = ""; };
- 97A127C71D777CF100FB204D /* SearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchController.swift; sourceTree = ""; };
97A127C81D777CF100FB204D /* SearchResultController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResultController.swift; sourceTree = ""; };
97A1FD121D6F71CE00A80EE2 /* DirectoryMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DirectoryMonitor.swift; sourceTree = ""; };
97A1FD141D6F71CE00A80EE2 /* SearchResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResult.swift; sourceTree = ""; };
@@ -483,6 +482,7 @@
97D0E98E1DDA12B30029530E /* MainControllerDelegates.swift */,
97BC0FC11DD92B62004BBAD1 /* Buttons.swift */,
97BC0FBD1DD90A65004BBAD1 /* JSInjection.swift */,
+ 972F81581DDC1B71008D7289 /* Controllers.swift */,
);
path = Main;
sourceTree = "";
@@ -627,7 +627,6 @@
isa = PBXGroup;
children = (
970E7F7C1DA0305000741290 /* Alerts.swift */,
- 970E7F7D1DA0305000741290 /* ControllerRetainer.swift */,
970E7F7E1DA0305000741290 /* TableOfContentsController.swift */,
970E7F7F1DA0305000741290 /* WelcomeController.swift */,
);
@@ -778,7 +777,6 @@
97A127C61D777CF100FB204D /* SearchBooksController.swift */,
97A127C51D777CF100FB204D /* RecentSearchController.swift */,
97A127C81D777CF100FB204D /* SearchResultController.swift */,
- 97A127C71D777CF100FB204D /* SearchController.swift */,
);
path = Search;
sourceTree = "";
@@ -1139,7 +1137,7 @@
970A2A221DD562CB0078BB7C /* BookOperations.swift in Sources */,
971A10301D022AD5007FC62C /* LTBarButtonItem.swift in Sources */,
97A1FD391D6F724E00A80EE2 /* pathTools.cpp in Sources */,
- 970E7F811DA0305000741290 /* ControllerRetainer.swift in Sources */,
+ 972F81591DDC1B71008D7289 /* Controllers.swift in Sources */,
976B86D81DDA0C7E00FA7FD1 /* SearchContainer.swift in Sources */,
97FDACC41D85A3B300DEDACB /* Language+CoreDataProperties.swift in Sources */,
97BC0FC21DD92B62004BBAD1 /* Buttons.swift in Sources */,
diff --git a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index c9e24b5a..5bbee8dd 100644
--- a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -43,21 +43,5 @@
stopOnStyle = "0">
-
-
-
-