This commit is contained in:
Chris Li 2016-09-21 15:44:38 -04:00
parent 5285dff730
commit 33af7c07ff
13 changed files with 125 additions and 149 deletions

View File

@ -122,16 +122,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
switch shortcutItem.type {
case "org.kiwix.search":
mainController?.hidePresentedController(false, completion: {
self.mainController?.showSearch(animated: false)
completionHandler(true)
})
case "org.kiwix.bookmarks":
mainController?.hidePresentedController(false, completion: {
self.mainController?.hideSearch(animated: false)
self.mainController?.showBookmarkTBVC()
completionHandler(true)
})
case recentShortcutTypeString:
guard let urlString = shortcutItem.userInfo?["URL"] as? String,
let url = NSURL(string: urlString) else {completionHandler(false); return}

View File

@ -88,3 +88,50 @@ class CopyURLAlert: AlertOperation<UIViewController> {
addActionWithTitle(LocalizedStrings.ok)
}
}
class GetStartedAlert: AlertOperation<MainController> {
init(context: MainController) {
super.init(presentAlertFrom: context)
title = NSLocalizedString("Welcome to Kiwix", comment: "First Time Launch Message")
message = NSLocalizedString("Add a Book to Get Started", comment: "First Time Launch Message")
addActionWithTitle(NSLocalizedString("Download", comment: "First Time Launch Message"), style: .Default) { (alert) in
context.showLibraryButtonTapped()
}
addActionWithTitle(NSLocalizedString("Import", comment: "First Time Launch Message"), style: .Default) { (alert) in
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, context: context)
GlobalQueue.shared.addOperation(operation)
}
addActionWithTitle(NSLocalizedString("Dismiss", comment: "First Time Launch Message"))
preferredAction = actions[0]
}
override func execute() {
Preference.hasShowGetStartedAlert = true
super.execute()
}
}
class ShowHelpPageOperation: Operation {
private let type: WebViewControllerContentType
private let context: UIViewController
init(type: WebViewControllerContentType, context: UIViewController) {
self.type = type
self.context = context
super.init()
}
override func execute() {
defer { finish() }
guard let controller = UIStoryboard.setting.instantiateViewControllerWithIdentifier("WebViewController") as? WebViewController else {return}
controller.page = self.type
let operation = UIOperation(controller: UIViewController(),
displayControllerFrom: .Present(context),
inNavigationController: true,
sender: nil)
produceOperation(operation)
}
}

View File

@ -77,10 +77,10 @@ class ControllerRetainer {
// MARK: - Welcome
private var welcome: UIViewController?
private var welcome: WelcomeController?
class var welcome: UIViewController {
let controller = ControllerRetainer.shared.welcome ?? UIStoryboard(name: "Welcome", bundle: nil).instantiateInitialViewController()!
class var welcome: WelcomeController {
let controller = ControllerRetainer.shared.welcome ?? UIStoryboard(name: "Welcome", bundle: nil).instantiateInitialViewController() as! WelcomeController
ControllerRetainer.shared.welcome = controller
return controller
}

View File

@ -61,7 +61,6 @@ class MainController: UIViewController {
configureButtonColor()
showGetStartedAlert()
showWelcome()
// load(webViewInitialURL)
}
deinit {
@ -118,18 +117,6 @@ class MainController: UIViewController {
}
}
// MARK: - Load
// func load(url: NSURL?) {
// if webView == nil {
// webViewInitialURL = url
// return
// }
// guard let url = url else {return}
// let request = NSURLRequest(URL: url)
// webView.loadRequest(request)
// }
func loadExternalResource(url: NSURL) {
let controller = SFSafariViewController(URL: url)
controller.delegate = self

View File

@ -10,43 +10,52 @@ import UIKit
extension MainController {
func hidePresentedController(animated: Bool, completion: (() -> Void)? = nil) {
guard let controller = presentedViewController else {
completion?()
return
}
controller.dismissViewControllerAnimated(animated, completion: completion)
}
// MARK: - Show/Hide Search
func showSearch(animated animated: Bool) {
navigationController?.setToolbarHidden(true, animated: animated)
showSearchResultController(animated: animated)
searchBar.placeholder = LocalizedStrings.search
if !searchBar.isFirstResponder() {
searchBar.becomeFirstResponder()
}
if traitCollection.horizontalSizeClass == .Compact {
searchBar.setShowsCancelButton(true, animated: animated)
}
if UIDevice.currentDevice().userInterfaceIdiom == .Pad && traitCollection.horizontalSizeClass == .Compact {
navigationItem.setRightBarButtonItem(cancelButton, animated: animated)
}
// Hide any presenting controller
presentedViewController?.dismissViewControllerAnimated(animated, completion: nil)
// Hide TOC
if isShowingTableOfContents && traitCollection.horizontalSizeClass == .Compact {
animateOutTableOfContentsController()
}
// Hide ToolBar &
navigationController?.setToolbarHidden(true, animated: animated)
// Show Search Result Controller
showSearchResultController(animated: animated)
// SearchBar
searchBar.placeholder = LocalizedStrings.search
if !searchBar.isFirstResponder() {searchBar.becomeFirstResponder()}
// Show Cancel Button If Needed
if traitCollection.horizontalSizeClass == .Compact {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
navigationItem.setRightBarButtonItem(cancelButton, animated: animated)
} else if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
searchBar.setShowsCancelButton(true, animated: animated)
}
}
}
func hideSearch(animated animated: Bool) {
// Hide Search Result Controller
hideSearchResultController(animated: true)
searchBar.setShowsCancelButton(false, animated: animated)
// Search Bar
searchBar.text = nil
if searchBar.isFirstResponder() {
searchBar.resignFirstResponder()
}
if UIDevice.currentDevice().userInterfaceIdiom == .Pad && traitCollection.horizontalSizeClass == .Compact {
if searchBar.isFirstResponder() {searchBar.resignFirstResponder()}
// Hide Cancel Button If Needed
if traitCollection.horizontalSizeClass == .Compact {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
navigationItem.setRightBarButtonItem(nil, animated: animated)
} else if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
searchBar.setShowsCancelButton(false, animated: animated)
}
}
}
@ -60,10 +69,6 @@ extension MainController {
let views = ["SearchController": controller.view]
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[SearchController]|", options: .AlignAllCenterY, metrics: nil, views: views))
// Not working in iOS 10, but work in iOS 9
//view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[SearchController]|", options: .AlignAllCenterX, metrics: nil, views: views))
// Fix for top layout guide issue in iOS 10
view.addConstraint(controller.view.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor))
view.addConstraint(controller.view.bottomAnchor.constraintEqualToAnchor(bottomLayoutGuide.topAnchor))
@ -168,33 +173,22 @@ extension MainController {
controller.view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(controller)
view.addSubview(controller.view)
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options: NSLayoutFormatOptions.AlignAllTop, metrics: nil, views: ["view": controller.view]))
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options: NSLayoutFormatOptions.AlignAllLeft, metrics: nil, views: ["view": controller.view]))
controller.didMoveToParentViewController(self)
}
func hideWelcome() {
let controller = ControllerRetainer.welcome
guard let controller = childViewControllers.flatMap({$0 as? WelcomeController}).first else {return}
controller.removeFromParentViewController()
controller.view.removeFromSuperview()
}
// MARK: - Show/Hide Get Started
func showGetStarted() {
guard let controller = UIStoryboard.welcome.initViewController(GetStartedController.self) else {return}
controller.modalPresentationStyle = .FormSheet
presentViewController(controller, animated: true, completion: nil)
}
// MARK: - Show First Time Launch Alert
func showGetStartedAlert() {
guard !Preference.hasShowGetStartedAlert else {return}
let operation = GetStartedAlert(presentationContext: self)
let operation = GetStartedAlert(context: self)
GlobalQueue.shared.addOperation(operation)
Preference.hasShowGetStartedAlert = true
}
}

View File

@ -1,18 +1,19 @@
//
// GetStartedController.swift
// WelcomeController.swift
// Kiwix
//
// Created by Chris Li on 7/5/16.
// Created by Chris Li on 9/21/16.
// Copyright © 2016 Chris. All rights reserved.
//
import UIKit
class GetStartedController: UIViewController {
class WelcomeController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
preferredContentSize = CGSizeMake(400, 400)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
@ -21,14 +22,11 @@ class GetStartedController: UIViewController {
}
@IBAction func dismissButtonTapped(sender: UIButton) {
dismissViewControllerAnimated(true, completion: nil)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}

View File

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

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2Bo-lO-qA9">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2Bo-lO-qA9">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<!--Welcome Controller-->
<scene sceneID="k00-DS-oLZ">
<objects>
<viewController storyboardIdentifier="Welcome" id="2Bo-lO-qA9" sceneMemberID="viewController">
<viewController storyboardIdentifier="Welcome" id="2Bo-lO-qA9" customClass="WelcomeController" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Vb9-0b-fxU"/>
<viewControllerLayoutGuide type="bottom" id="erc-nt-iny"/>

View File

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

View File

@ -86,6 +86,8 @@
9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779C3161D4575AE0064CC8E /* TodayViewController.swift */; };
9779C31A1D4575AE0064CC8E /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9779C3181D4575AE0064CC8E /* MainInterface.storyboard */; };
9779C31E1D4575AE0064CC8E /* Bookmarks.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9779C3131D4575AD0064CC8E /* Bookmarks.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
9787BC211D9318300030D311 /* WelcomeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9787BC201D9318300030D311 /* WelcomeController.swift */; };
9787BC231D9318570030D311 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9787BC221D9318570030D311 /* TableOfContentsController.swift */; };
979C518D1CECAE4C001707F2 /* PreferenceWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979C518B1CECAE4C001707F2 /* PreferenceWindowController.swift */; };
979CB60F1D04AD04005E1BA1 /* PreferenceTabController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979CB60E1D04AD04005E1BA1 /* PreferenceTabController.swift */; };
979CB6C81D05CF37005E1BA1 /* SearchResultController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979CB6C71D05CF37005E1BA1 /* SearchResultController.swift */; };
@ -109,7 +111,6 @@
97A1FD421D6F728200A80EE2 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A1FD3D1D6F728200A80EE2 /* Extensions.swift */; };
97A1FD441D6F728200A80EE2 /* Preference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A1FD401D6F728200A80EE2 /* Preference.swift */; };
97A1FD451D6F728200A80EE2 /* StringTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A1FD411D6F728200A80EE2 /* StringTools.swift */; };
97A7017F1D2C59CA00AAE2D8 /* GetStartedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A7017E1D2C59CA00AAE2D8 /* GetStartedController.swift */; };
97A8AD841D6C951A00584ED1 /* LocalBooksController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A8AD831D6C951A00584ED1 /* LocalBooksController.swift */; };
97A8AD871D6CF38000584ED1 /* EmptyTableConfigExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A8AD861D6CF38000584ED1 /* EmptyTableConfigExtension.swift */; };
97BA32A51CEBC36300339A47 /* RootWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97BA32A31CEBC29500339A47 /* RootWindowController.swift */; };
@ -120,12 +121,10 @@
97C601DE1D7F342100362D4F /* HTMLHeading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C601DD1D7F342100362D4F /* HTMLHeading.swift */; };
97D452BE1D1723FF0033666F /* CollectionViewCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BD1D1723FF0033666F /* CollectionViewCells.swift */; };
97D4D64F1D874E6E00C1B065 /* SearchOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D4D64E1D874E6E00C1B065 /* SearchOperation.swift */; };
97D55EF61D2075180081B523 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D55EF51D2075180081B523 /* TableOfContentsController.swift */; };
97D6811B1D6E2A7100E5FA99 /* DownloadTasksController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811A1D6E2A7100E5FA99 /* DownloadTasksController.swift */; };
97D681231D6F70AC00E5FA99 /* GlobalQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811C1D6F70AC00E5FA99 /* GlobalQueue.swift */; };
97D681241D6F70AC00E5FA99 /* RefreshLibraryOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811D1D6F70AC00E5FA99 /* RefreshLibraryOperation.swift */; };
97D681251D6F70AC00E5FA99 /* ScanLocalBookOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811E1D6F70AC00E5FA99 /* ScanLocalBookOperation.swift */; };
97D681271D6F70AC00E5FA99 /* UIOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D681201D6F70AC00E5FA99 /* UIOperations.swift */; };
97D681281D6F70AC00E5FA99 /* UpdateWidgetDataSourceOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D681211D6F70AC00E5FA99 /* UpdateWidgetDataSourceOperation.swift */; };
97D6812E1D6F70DE00E5FA99 /* Kiwix.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 97D6812A1D6F70DE00E5FA99 /* Kiwix.xcdatamodeld */; };
97D681311D6F70EC00E5FA99 /* 1.5.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 97D6812F1D6F70EC00E5FA99 /* 1.5.xcmappingmodel */; };
@ -309,6 +308,8 @@
9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = "<group>"; };
9779C3191D4575AE0064CC8E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9787BC201D9318300030D311 /* WelcomeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WelcomeController.swift; path = Others/WelcomeController.swift; sourceTree = "<group>"; };
9787BC221D9318570030D311 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentsController.swift; path = Others/TableOfContentsController.swift; sourceTree = "<group>"; };
979C518B1CECAE4C001707F2 /* PreferenceWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferenceWindowController.swift; path = "Kiwix-OSX/Controllers/PreferenceWindowController.swift"; sourceTree = SOURCE_ROOT; };
979CB60E1D04AD04005E1BA1 /* PreferenceTabController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferenceTabController.swift; path = Controllers/PreferenceTabController.swift; sourceTree = "<group>"; };
979CB6C71D05CF37005E1BA1 /* SearchResultController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchResultController.swift; path = Controllers/SearchResultController.swift; sourceTree = "<group>"; };
@ -341,7 +342,6 @@
97A2AB881C1B80FF00052E74 /* Kiwix.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Kiwix.app; sourceTree = BUILT_PRODUCTS_DIR; };
97A2AB9F1C1B80FF00052E74 /* Kiwix-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Kiwix-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
97A2ABAA1C1B810000052E74 /* Kiwix-iOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Kiwix-iOSUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
97A7017E1D2C59CA00AAE2D8 /* GetStartedController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GetStartedController.swift; path = "Kiwix-iOS/Controller/Welcome/GetStartedController.swift"; sourceTree = SOURCE_ROOT; };
97A8AD831D6C951A00584ED1 /* LocalBooksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalBooksController.swift; sourceTree = "<group>"; };
97A8AD861D6CF38000584ED1 /* EmptyTableConfigExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyTableConfigExtension.swift; sourceTree = "<group>"; };
97BA32A31CEBC29500339A47 /* RootWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RootWindowController.swift; path = "Kiwix-OSX/Controllers/RootWindowController.swift"; sourceTree = SOURCE_ROOT; };
@ -352,12 +352,10 @@
97C601DD1D7F342100362D4F /* HTMLHeading.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLHeading.swift; sourceTree = "<group>"; };
97D452BD1D1723FF0033666F /* CollectionViewCells.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCells.swift; sourceTree = "<group>"; };
97D4D64E1D874E6E00C1B065 /* SearchOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchOperation.swift; sourceTree = "<group>"; };
97D55EF51D2075180081B523 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentsController.swift; path = "Kiwix-iOS/Controller/TableOfContentsController.swift"; sourceTree = SOURCE_ROOT; };
97D6811A1D6E2A7100E5FA99 /* DownloadTasksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadTasksController.swift; sourceTree = "<group>"; };
97D6811C1D6F70AC00E5FA99 /* GlobalQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlobalQueue.swift; sourceTree = "<group>"; };
97D6811D1D6F70AC00E5FA99 /* RefreshLibraryOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibraryOperation.swift; sourceTree = "<group>"; };
97D6811E1D6F70AC00E5FA99 /* ScanLocalBookOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScanLocalBookOperation.swift; sourceTree = "<group>"; };
97D681201D6F70AC00E5FA99 /* UIOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIOperations.swift; sourceTree = "<group>"; };
97D681211D6F70AC00E5FA99 /* UpdateWidgetDataSourceOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateWidgetDataSourceOperation.swift; sourceTree = "<group>"; };
97D681221D6F70AC00E5FA99 /* URLSessionDownloadTaskOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLSessionDownloadTaskOperation.swift; sourceTree = "<group>"; };
97D6812B1D6F70DE00E5FA99 /* 1.5.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = 1.5.xcdatamodel; sourceTree = "<group>"; };
@ -794,6 +792,15 @@
path = Bookmarks;
sourceTree = "<group>";
};
9787BC1F1D9318080030D311 /* Others */ = {
isa = PBXGroup;
children = (
9787BC221D9318570030D311 /* TableOfContentsController.swift */,
9787BC201D9318300030D311 /* WelcomeController.swift */,
);
name = Others;
sourceTree = "<group>";
};
978C58791C1CCC920077AE47 /* Supporting */ = {
isa = PBXGroup;
children = (
@ -831,8 +838,7 @@
972B007D1C35DBAB00B5FDC5 /* Main */,
97E108221C5D5A0D00E27FD3 /* Search */,
9771DC4B1C37278E009ECFF0 /* Setting */,
97D55EF51D2075180081B523 /* TableOfContentsController.swift */,
97A7017E1D2C59CA00AAE2D8 /* GetStartedController.swift */,
9787BC1F1D9318080030D311 /* Others */,
97A127C31D774C9900FB204D /* ControllerRetainer.swift */,
);
name = Controllers;
@ -992,7 +998,6 @@
97D6811D1D6F70AC00E5FA99 /* RefreshLibraryOperation.swift */,
97D6811E1D6F70AC00E5FA99 /* ScanLocalBookOperation.swift */,
97D4D64E1D874E6E00C1B065 /* SearchOperation.swift */,
97D681201D6F70AC00E5FA99 /* UIOperations.swift */,
97D681211D6F70AC00E5FA99 /* UpdateWidgetDataSourceOperation.swift */,
97D681221D6F70AC00E5FA99 /* URLSessionDownloadTaskOperation.swift */,
);
@ -1517,7 +1522,6 @@
970E68B61D37E224001E8514 /* SettingSearchHistoryTBVC.swift in Sources */,
97C005D81D64B99E004352E8 /* LibrarySplitViewController.swift in Sources */,
97FDACC41D85A3B300DEDACB /* Language+CoreDataProperties.swift in Sources */,
97A7017F1D2C59CA00AAE2D8 /* GetStartedController.swift in Sources */,
97A8AD871D6CF38000584ED1 /* EmptyTableConfigExtension.swift in Sources */,
971A102E1D022AD5007FC62C /* TableViewCells.swift in Sources */,
97DF259D1D6F9053001648A3 /* URLSessionDownloadTaskOperation.swift in Sources */,
@ -1552,7 +1556,6 @@
9764CBD11D806AD800072D6A /* RefreshLibControl.swift in Sources */,
971A10381D022C15007FC62C /* WebViewController.swift in Sources */,
97C601DE1D7F342100362D4F /* HTMLHeading.swift in Sources */,
97D681271D6F70AC00E5FA99 /* UIOperations.swift in Sources */,
975B90FE1CEB909100D13906 /* iOSExtensions.swift in Sources */,
971A10521D022D9D007FC62C /* AppDelegate.swift in Sources */,
9764F5991D833F2B00E0B1C4 /* KiwixURL.swift in Sources */,
@ -1561,7 +1564,6 @@
97D4D64F1D874E6E00C1B065 /* SearchOperation.swift in Sources */,
97D452BE1D1723FF0033666F /* CollectionViewCells.swift in Sources */,
971A102F1D022AD5007FC62C /* Logo.swift in Sources */,
97D55EF61D2075180081B523 /* TableOfContentsController.swift in Sources */,
9722122B1D3FCCE200C0DCF2 /* MainControllerShowHide.swift in Sources */,
970722AA1D6B4D1700A45620 /* LanguageFilterController.swift in Sources */,
97A1FD191D6F71CE00A80EE2 /* ZimMultiReader.swift in Sources */,
@ -1578,12 +1580,14 @@
971A10341D022AEC007FC62C /* BookmarkTBVC.swift in Sources */,
97A1FD1D1D6F71D800A80EE2 /* URLResponseCache.swift in Sources */,
9764F5971D8339D500E0B1C4 /* JSInjection.swift in Sources */,
9787BC211D9318300030D311 /* WelcomeController.swift in Sources */,
97A1FD441D6F728200A80EE2 /* Preference.swift in Sources */,
97D681311D6F70EC00E5FA99 /* 1.5.xcmappingmodel in Sources */,
97D681441D6F713200E5FA99 /* CoreDataExtension.swift in Sources */,
97DF259C1D6F7613001648A3 /* BookOperation.swift in Sources */,
97A1FD181D6F71CE00A80EE2 /* SearchResult.swift in Sources */,
9763275E1D64FE0F0034F120 /* BookDetailController.swift in Sources */,
9787BC231D9318570030D311 /* TableOfContentsController.swift in Sources */,
973DD4281D36E3E4009D45DB /* SettingSingleSwitchTBVC.swift in Sources */,
971A10431D022C54007FC62C /* SettingTBVC.swift in Sources */,
97D681251D6F70AC00E5FA99 /* ScanLocalBookOperation.swift in Sources */,

View File

@ -15,6 +15,8 @@ class ArticleLoadOperation: Operation {
let title: String?
let url: NSURL?
var animated = true
init(url: NSURL) {
self.bookID = nil
self.path = nil
@ -73,6 +75,10 @@ class ArticleLoadOperation: Operation {
let request = NSURLRequest(URL: url)
NSOperationQueue.mainQueue().addOperationWithBlock {
controller.hideSearch(animated: self.animated)
controller.presentingViewController?.dismissViewControllerAnimated(self.animated, completion: nil)
// hide toc
guard controller.webView.request?.URL != url else {return}
controller.webView.loadRequest(request)
self.finish()

View File

@ -1,55 +0,0 @@
//
// UIOperations.swift
// Kiwix
//
// Created by Chris Li on 3/22/16.
// Copyright © 2016 Chris. All rights reserved.
//
import UIKit
import Operations
// MARK: - Alerts
class GetStartedAlert: AlertOperation<MainController> {
let comment = "First Time Launch Message"
init(presentationContext mainController: MainController) {
super.init(presentAlertFrom: mainController)
title = NSLocalizedString("Welcome to Kiwix", comment: comment)
message = NSLocalizedString("Add a Book to Get Started", comment: comment)
addActionWithTitle(NSLocalizedString("Download", comment: comment), style: .Default) { (alert) in
mainController.showLibraryButtonTapped()
}
addActionWithTitle(NSLocalizedString("Import", comment: comment), style: .Default) { (alert) in
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, presentationContext: mainController)
GlobalQueue.shared.addOperation(operation)
}
addActionWithTitle(NSLocalizedString("Dismiss", comment: comment))
}
}
// MARK: - Help Pages
class ShowHelpPageOperation: Operation {
private let type: WebViewControllerContentType
private let presentationContext: UIViewController
init(type: WebViewControllerContentType, presentationContext: UIViewController) {
self.type = type
self.presentationContext = presentationContext
super.init()
}
override func execute() {
defer { finish() }
guard let controller = UIStoryboard.setting.instantiateViewControllerWithIdentifier("WebViewController") as? WebViewController else {return}
controller.page = self.type
let operation = UIOperation(controller: UIViewController(),
displayControllerFrom: .Present(presentationContext),
inNavigationController: true,
sender: nil)
produceOperation(operation)
}
}