diff --git a/Kiwix-iOS/Controller/Main/Controllers.swift b/Kiwix-iOS/Controller/Main/Controllers.swift
index c340982c..10da0bbb 100644
--- a/Kiwix-iOS/Controller/Main/Controllers.swift
+++ b/Kiwix-iOS/Controller/Main/Controllers.swift
@@ -25,10 +25,6 @@ class Controllers {
return (UIApplication.appDelegate.window?.rootViewController as! UINavigationController).topViewController as! MainController
}
- // MARK: - Web
-
- lazy private(set) var web = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "WebViewController") as! WebViewController
-
// // MARK: - Bookmark
//
// private var bookmark: UINavigationController?
diff --git a/Kiwix-iOS/Controller/Main/MainController.swift b/Kiwix-iOS/Controller/Main/MainController.swift
index 4b9fef05..915374a3 100644
--- a/Kiwix-iOS/Controller/Main/MainController.swift
+++ b/Kiwix-iOS/Controller/Main/MainController.swift
@@ -10,6 +10,7 @@ import UIKit
class MainController: UIViewController {
+ @IBOutlet weak var webView: UIWebView!
let searchBar = SearchBar()
lazy var controllers = Controllers()
lazy var buttons = Buttons()
@@ -17,6 +18,7 @@ class MainController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
+ webView.loadRequest(URLRequest(url: URL(string: "about:blank")!))
navigationItem.titleView = searchBar
searchBar.delegate = self
buttons.delegate = self
diff --git a/Kiwix-iOS/Controller/Main/MainDelegates.swift b/Kiwix-iOS/Controller/Main/MainDelegates.swift
index 19d525b9..0a2e8baa 100644
--- a/Kiwix-iOS/Controller/Main/MainDelegates.swift
+++ b/Kiwix-iOS/Controller/Main/MainDelegates.swift
@@ -8,9 +8,9 @@
import UIKit
-extension MainController: SearchBarDelegate, ButtonDelegates, SearchContainerDelegate {
-
- // MARK: - SearchBarDelegate
+// MARK: - Search
+
+extension MainController: SearchBarDelegate {
func didBecomeFirstResponder(searchBar: SearchBar) {
showSearch(animated: true)
@@ -24,8 +24,68 @@ extension MainController: SearchBarDelegate, ButtonDelegates, SearchContainerDel
controllers.search.searchText = text
}
- // MARK: - Button Delegates
+ private func showSearch(animated: Bool) {
+ let controller = controllers.search
+ controller.delegate = self
+ guard !childViewControllers.contains(controller) else {return}
+
+ // add cancel button if needed
+ if traitCollection.horizontalSizeClass == .compact {
+ navigationItem.setRightBarButton(buttons.cancel, animated: animated)
+ }
+
+ // manage view hierarchy
+ addChildViewController(controller)
+ controller.view.translatesAutoresizingMaskIntoConstraints = false
+ view.addSubview(controller.view)
+
+ let views = ["view": controller.view]
+ view.addConstraints(NSLayoutConstraint.constraints(
+ withVisualFormat: "H:|[view]|", options: .alignAllCenterY, metrics: nil, views: views))
+ view.addConstraint(controller.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor))
+ view.addConstraint(controller.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor))
+
+ if animated {
+ controller.view.alpha = 0.5
+ UIView.animate(withDuration: 0.15, delay: 0.0, options: .curveEaseOut, animations: { () -> Void in
+ controller.view.alpha = 1.0
+ }, completion: nil)
+ } else {
+ controller.view.alpha = 1.0
+ }
+ controller.didMove(toParentViewController: self)
+ }
+ private func hideSearch(animated: Bool) {
+ guard let searchController = childViewControllers.flatMap({$0 as? SearchContainer}).first else {return}
+
+ // remove cancel button if needed
+ if traitCollection.horizontalSizeClass == .compact {
+ navigationItem.setRightBarButton(nil, animated: animated)
+ }
+
+ let completion = { (complete: Bool) -> Void in
+ guard complete else {return}
+ searchController.view.removeFromSuperview()
+ searchController.removeFromParentViewController()
+ guard self.traitCollection.horizontalSizeClass == .compact else {return}
+ self.navigationController?.setToolbarHidden(false, animated: animated)
+ }
+
+ searchController.willMove(toParentViewController: nil)
+ if animated {
+ UIView.animate(withDuration: 0.15, delay: 0.0, options: .beginFromCurrentState, animations: {
+ searchController.view.alpha = 0.0
+ }, completion: completion)
+ } else {
+ completion(true)
+ }
+ }
+}
+
+// MARK: - Button Delegates
+
+extension MainController: ButtonDelegates, SearchContainerDelegate {
func didTapLibraryButton() {
present(controllers.library, animated: true, completion: nil)
}
@@ -33,11 +93,33 @@ extension MainController: SearchBarDelegate, ButtonDelegates, SearchContainerDel
func didTapCancelButton() {
_ = searchBar.resignFirstResponder()
}
-
- // MARK: - SearchContainerDelegate
-
+}
+
+// MARK: - SearchContainerDelegate
+
+extension MainController {
func didTapDimView() {
_ = searchBar.resignFirstResponder()
}
-
+}
+
+// MARK: - Welcome
+
+extension MainController {
+ func showWelcome() {
+ let controller = controllers.welcome
+ controller.view.translatesAutoresizingMaskIntoConstraints = false
+ addChildViewController(controller)
+ view.addSubview(controller.view)
+ let views = ["view": controller.view]
+ view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: .alignAllTop, metrics: nil, views: views))
+ view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: .alignAllLeft, metrics: nil, views: views))
+ controller.didMove(toParentViewController: self)
+ }
+
+ func hideWelcome() {
+ guard let controller = childViewControllers.flatMap({$0 as? WelcomeController}).first else {return}
+ controller.removeFromParentViewController()
+ controller.view.removeFromSuperview()
+ }
}
diff --git a/Kiwix-iOS/Controller/Main/MainShowHide.swift b/Kiwix-iOS/Controller/Main/MainShowHide.swift
deleted file mode 100644
index 24f1d02b..00000000
--- a/Kiwix-iOS/Controller/Main/MainShowHide.swift
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// MainShowHide.swift
-// Kiwix
-//
-// Created by Chris Li on 11/16/16.
-// Copyright © 2016 Chris Li. All rights reserved.
-//
-
-import UIKit
-
-extension MainController {
-
- // MARK: - Welcome
-
- func showWelcome() {
- let controller = controllers.welcome
- controller.view.translatesAutoresizingMaskIntoConstraints = false
- addChildViewController(controller)
- view.addSubview(controller.view)
- let views = ["view": controller.view]
- view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: .alignAllTop, metrics: nil, views: views))
- view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: .alignAllLeft, metrics: nil, views: views))
- controller.didMove(toParentViewController: self)
- }
-
- func hideWelcome() {
- guard let controller = childViewControllers.flatMap({$0 as? WelcomeController}).first else {return}
- controller.removeFromParentViewController()
- controller.view.removeFromSuperview()
- }
-
- // MARK: - Search
-
- func showSearch(animated: Bool) {
- let controller = controllers.search
- controller.delegate = self
- guard !childViewControllers.contains(controller) else {return}
-
- // add cancel button if needed
- if traitCollection.horizontalSizeClass == .compact {
- navigationItem.setRightBarButton(buttons.cancel, animated: animated)
- }
-
- // manage view hierarchy
- addChildViewController(controller)
- controller.view.translatesAutoresizingMaskIntoConstraints = false
- view.addSubview(controller.view)
-
- let views = ["view": controller.view]
- view.addConstraints(NSLayoutConstraint.constraints(
- withVisualFormat: "H:|[view]|", options: .alignAllCenterY, metrics: nil, views: views))
- view.addConstraint(controller.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor))
- view.addConstraint(controller.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor))
-
- if animated {
- controller.view.alpha = 0.5
- UIView.animate(withDuration: 0.15, delay: 0.0, options: .curveEaseOut, animations: { () -> Void in
- controller.view.alpha = 1.0
- }, completion: nil)
- } else {
- controller.view.alpha = 1.0
- }
- controller.didMove(toParentViewController: self)
- }
-
- func hideSearch(animated: Bool) {
- guard let searchController = childViewControllers.flatMap({$0 as? SearchContainer}).first else {return}
-
- // remove cancel button if needed
- if traitCollection.horizontalSizeClass == .compact {
- navigationItem.setRightBarButton(nil, animated: animated)
- }
-
- let completion = { (complete: Bool) -> Void in
- guard complete else {return}
- searchController.view.removeFromSuperview()
- searchController.removeFromParentViewController()
- guard self.traitCollection.horizontalSizeClass == .compact else {return}
- self.navigationController?.setToolbarHidden(false, animated: animated)
- }
-
- searchController.willMove(toParentViewController: nil)
- if animated {
- UIView.animate(withDuration: 0.15, delay: 0.0, options: .beginFromCurrentState, animations: {
- searchController.view.alpha = 0.0
- }, completion: completion)
- } else {
- completion(true)
- }
- }
-
- // MARK: - Web
-
- func showWeb() {
- let controller = controllers.web
- guard !childViewControllers.contains(controller) else {return}
-
- addChildViewController(controller)
- controller.view.translatesAutoresizingMaskIntoConstraints = false
- view.addSubview(controller.view)
-
- let views = ["view": controller.view]
- view.addConstraints(NSLayoutConstraint.constraints(
- withVisualFormat: "H:|[view]|", options: .alignAllCenterY, metrics: nil, views: views))
- view.addConstraint(controller.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor))
- view.addConstraint(controller.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor))
- controller.didMove(toParentViewController: self)
- }
-
-}
diff --git a/Kiwix-iOS/Controller/Main/WebViewController.swift b/Kiwix-iOS/Controller/Main/WebViewController.swift
deleted file mode 100644
index fd9e6a44..00000000
--- a/Kiwix-iOS/Controller/Main/WebViewController.swift
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// WebViewController.swift
-// Kiwix
-//
-// Created by Chris Li on 11/16/16.
-// Copyright © 2016 Chris Li. All rights reserved.
-//
-
-import UIKit
-
-class WebViewController: UIViewController {
-
- @IBOutlet weak var webView: UIWebView!
-
- override func viewDidLoad() {
- super.viewDidLoad()
- }
-
-
-}
diff --git a/Kiwix-iOS/Controller/Search/SearchResultController.swift b/Kiwix-iOS/Controller/Search/SearchResultController.swift
index 8dcc16ea..734fca04 100644
--- a/Kiwix-iOS/Controller/Search/SearchResultController.swift
+++ b/Kiwix-iOS/Controller/Search/SearchResultController.swift
@@ -87,6 +87,8 @@ class SearchResultController: SearchBaseTableController, UITableViewDataSource,
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let result = searchResults[indexPath.row]
+ let operation = ArticleLoadOperation(bookID: result.bookID, articlePath: result.path)
+ GlobalQueue.shared.add(articleLoadOperation: operation)
}
// MARK: - DZNEmptyDataSet
diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index b1c633c2..165a01d8 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.2903
+ 1.8.2932
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOS/Storyboard/Main.storyboard b/Kiwix-iOS/Storyboard/Main.storyboard
index e45ab619..015b69ef 100644
--- a/Kiwix-iOS/Storyboard/Main.storyboard
+++ b/Kiwix-iOS/Storyboard/Main.storyboard
@@ -10,40 +10,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -242,13 +208,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist
index 54e238f3..69607936 100644
--- a/Kiwix-iOSWidgets/Bookmarks/Info.plist
+++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.8.2903
+ 1.8.2932
NSExtension
NSExtensionMainStoryboard
diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj
index 7ee076d6..ca0334f1 100644
--- a/Kiwix.xcodeproj/project.pbxproj
+++ b/Kiwix.xcodeproj/project.pbxproj
@@ -29,8 +29,6 @@
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 */; };
- 972F815B1DDCBF71008D7289 /* MainShowHide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972F815A1DDCBF71008D7289 /* MainShowHide.swift */; };
- 972F815D1DDCBFF9008D7289 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972F815C1DDCBFF9008D7289 /* WebViewController.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 */; };
@@ -190,8 +188,6 @@
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 = ""; };
- 972F815A1DDCBF71008D7289 /* MainShowHide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainShowHide.swift; sourceTree = ""; };
- 972F815C1DDCBFF9008D7289 /* WebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebViewController.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 = ""; };
@@ -485,8 +481,6 @@
97BC0FBA1DD90A34004BBAD1 /* old */,
97BC0FBE1DD90A65004BBAD1 /* MainController.swift */,
97D0E98E1DDA12B30029530E /* MainDelegates.swift */,
- 972F815A1DDCBF71008D7289 /* MainShowHide.swift */,
- 972F815C1DDCBFF9008D7289 /* WebViewController.swift */,
97BC0FC11DD92B62004BBAD1 /* Buttons.swift */,
97BC0FBD1DD90A65004BBAD1 /* JSInjection.swift */,
972F81581DDC1B71008D7289 /* Controllers.swift */,
@@ -1189,9 +1183,7 @@
97A1FD1C1D6F71D800A80EE2 /* KiwixURLProtocol.swift in Sources */,
97C2C26A1DDCC58500A9CC64 /* ArticleOperation.swift in Sources */,
973208261DD21E9C00EDD3DC /* CoreDataContainer.swift in Sources */,
- 972F815B1DDCBF71008D7289 /* MainShowHide.swift in Sources */,
97D6813F1D6F712800E5FA99 /* Article+CoreDataProperties.swift in Sources */,
- 972F815D1DDCBFF9008D7289 /* WebViewController.swift in Sources */,
97A1FD1D1D6F71D800A80EE2 /* URLResponseCache.swift in Sources */,
97A1FD441D6F728200A80EE2 /* Preference.swift in Sources */,
97D681311D6F70EC00E5FA99 /* 1.5.xcmappingmodel in Sources */,
diff --git a/Kiwix/Operations/ArticleOperation.swift b/Kiwix/Operations/ArticleOperation.swift
index c5035034..cfab46ce 100644
--- a/Kiwix/Operations/ArticleOperation.swift
+++ b/Kiwix/Operations/ArticleOperation.swift
@@ -75,18 +75,19 @@ class ArticleLoadOperation: Procedure {
let request = URLRequest(url: url)
OperationQueue.main.addOperation {
- main.hideWelcome()
- main.showWeb()
- main.hideSearch(animated: self.animated)
+ _ = main.searchBar.resignFirstResponder()
main.presentingViewController?.dismiss(animated: self.animated, completion: nil)
- //if main.traitCollection.horizontalSizeClass == .compact {main.hideTableOfContentsController()}
+ main.hideWelcome()
- let webView = main.controllers.web.webView
- if webView.request?.url != url {
+ let webView = main.webView
+ if webView?.request?.url != url {
webView?.loadRequest(request)
}
self.finish()
+
+
+// //if main.traitCollection.horizontalSizeClass == .compact {main.hideTableOfContentsController()}
}
}
}