article load operation

This commit is contained in:
Chris Li 2016-11-16 11:56:09 -05:00
parent afdb46793e
commit 54aeeb6ac7
7 changed files with 21 additions and 13 deletions

View File

@ -24,9 +24,9 @@ extension MainController {
}
func hideWelcome() {
let controller = childViewControllers.flatMap({$0 as? WelcomeController}).first
controller?.removeFromParentViewController()
controller?.view.removeFromSuperview()
guard let controller = childViewControllers.flatMap({$0 as? WelcomeController}).first else {return}
controller.removeFromParentViewController()
controller.view.removeFromSuperview()
}
// MARK: - Search

View File

@ -10,10 +10,10 @@ import UIKit
class WebViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.8.2900</string>
<string>1.8.2902</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -36,6 +36,9 @@
</constraints>
</view>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections>
<outlet property="webView" destination="MjM-In-ehJ" id="tud-dZ-b7q"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3pg-HH-V5d" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.8.2900</string>
<string>1.8.2902</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>

View File

@ -96,6 +96,7 @@
97BC0FC01DD90A65004BBAD1 /* MainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97BC0FBE1DD90A65004BBAD1 /* MainController.swift */; };
97BC0FC21DD92B62004BBAD1 /* Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97BC0FC11DD92B62004BBAD1 /* Buttons.swift */; };
97C005D61D64B3B0004352E8 /* Library.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C005D51D64B3B0004352E8 /* Library.storyboard */; };
97C2C26A1DDCC58500A9CC64 /* ArticleOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9764CBD21D8083AA00072D6A /* ArticleOperation.swift */; };
97C601DC1D7F15C400362D4F /* Bookmark.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C601DB1D7F15C400362D4F /* Bookmark.storyboard */; };
97C601DE1D7F342100362D4F /* HTMLHeading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C601DD1D7F342100362D4F /* HTMLHeading.swift */; };
97D0E98F1DDA12B30029530E /* MainDelegates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D0E98E1DDA12B30029530E /* MainDelegates.swift */; };
@ -1186,6 +1187,7 @@
97A1FD191D6F71CE00A80EE2 /* ZimMultiReader.swift in Sources */,
97A1FD261D6F71E200A80EE2 /* ZimReader.mm in Sources */,
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 */,

View File

@ -50,7 +50,7 @@ class ArticleLoadOperation: Procedure {
}
override func execute() {
let controller = ((UIApplication.shared.delegate as! AppDelegate)
let main = ((UIApplication.shared.delegate as! AppDelegate)
.window?.rootViewController as! UINavigationController)
.topViewController as! MainController
guard let url: URL = {
@ -75,12 +75,15 @@ class ArticleLoadOperation: Procedure {
let request = URLRequest(url: url)
OperationQueue.main.addOperation {
controller.hideSearch(animated: self.animated)
controller.presentingViewController?.dismiss(animated: self.animated, completion: nil)
if controller.traitCollection.horizontalSizeClass == .compact {controller.hideTableOfContentsController()}
main.hideWelcome()
main.showWeb()
main.hideSearch(animated: self.animated)
main.presentingViewController?.dismiss(animated: self.animated, completion: nil)
//if main.traitCollection.horizontalSizeClass == .compact {main.hideTableOfContentsController()}
if controller.webView.request?.url != url {
controller.webView.loadRequest(request)
let webView = main.controllers.web.webView
if webView.request?.url != url {
webView?.loadRequest(request)
}
self.finish()