diff --git a/Kiwix-iOS/AppDelegate.swift b/Kiwix-iOS/AppDelegate.swift
index 75ba48c5..4566ecea 100644
--- a/Kiwix-iOS/AppDelegate.swift
+++ b/Kiwix-iOS/AppDelegate.swift
@@ -60,7 +60,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: -
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
- URLProtocol.registerClass(KiwixURLProtocol)
+ URLProtocol.registerClass(KiwixURLProtocol.self)
// Network.shared
diff --git a/Kiwix-iOS/Controller/Main/Buttons.swift b/Kiwix-iOS/Controller/Main/Buttons.swift
index 264d8be3..f302a9d7 100644
--- a/Kiwix-iOS/Controller/Main/Buttons.swift
+++ b/Kiwix-iOS/Controller/Main/Buttons.swift
@@ -10,9 +10,9 @@ import UIKit
class Buttons {
- private(set) lazy var left: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "LeftArrow"), style: .plain,
+ private(set) lazy var back: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "LeftArrow"), style: .plain,
target: self, action: #selector(tapped(button:)))
- private(set) lazy var right: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "RightArrow"), style: .plain,
+ private(set) lazy var forward: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "RightArrow"), style: .plain,
target: self, action: #selector(tapped(button:)))
private(set) lazy var toc: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "TableOfContent"), style: .plain,
target: self, action: #selector(tapped(button:)))
@@ -30,13 +30,13 @@ class Buttons {
var toolbar: [UIBarButtonItem] {
get {
- return [left, space, right, space, toc, space, bookmark, space, library, space, setting]
+ return [back, space, forward, space, toc, space, bookmark, space, library, space, setting]
}
}
var navLeft: [UIBarButtonItem] {
get {
- return [left, right, toc]
+ return [back, forward, toc]
}
}
@@ -47,7 +47,7 @@ class Buttons {
}
func addLongTapGestureRecognizer() {
- [left, right, toc, bookmark, library, setting].enumerated().forEach { (index, button) in
+ [back, forward, toc, bookmark, library, setting].enumerated().forEach { (index, button) in
guard let view = button.value(forKey: "view") as? UIView else {return}
view.tag = index
view.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(pressed(recognizer:))))
@@ -56,10 +56,10 @@ class Buttons {
@objc func tapped(button: UIBarButtonItem) {
switch button {
- case left:
- print("left tapped")
- case right:
- print("right tapped")
+ case back:
+ delegate?.didTapBackButton()
+ case forward:
+ delegate?.didTapForwardButton()
case bookmark:
delegate?.didTapBookmarkButton()
case library:
@@ -87,6 +87,8 @@ class Buttons {
}
protocol ButtonDelegates {
+ func didTapBackButton()
+ func didTapForwardButton()
func didTapBookmarkButton()
func didTapLibraryButton()
func didTapCancelButton()
diff --git a/Kiwix-iOS/Controller/Main/MainController.swift b/Kiwix-iOS/Controller/Main/MainController.swift
index 8f6e1853..7ad18c50 100644
--- a/Kiwix-iOS/Controller/Main/MainController.swift
+++ b/Kiwix-iOS/Controller/Main/MainController.swift
@@ -14,6 +14,7 @@ class MainController: UIViewController {
let searchBar = SearchBar()
lazy var controllers = Controllers()
lazy var buttons = Buttons()
+ let navigationStack = NavigationStack()
override func viewDidLoad() {
super.viewDidLoad()
diff --git a/Kiwix-iOS/Controller/Main/MainDelegates.swift b/Kiwix-iOS/Controller/Main/MainDelegates.swift
index 887c6193..11c05977 100644
--- a/Kiwix-iOS/Controller/Main/MainDelegates.swift
+++ b/Kiwix-iOS/Controller/Main/MainDelegates.swift
@@ -105,6 +105,9 @@ extension MainController: UIWebViewDelegate, SFSafariViewControllerDelegate {
func webViewDidFinishLoad(_ webView: UIWebView) {
guard let title = JS.getTitle(from: webView) else {return}
searchBar.title = title
+
+ buttons.back.tintColor = webView.canGoBack ? nil : UIColor.gray
+ buttons.forward.tintColor = webView.canGoForward ? nil : UIColor.gray
}
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
@@ -123,6 +126,14 @@ extension MainController {
// MARK: - Button Delegates
extension MainController: ButtonDelegates, SearchContainerDelegate {
+ func didTapBackButton() {
+ webView.goBack()
+ }
+
+ func didTapForwardButton() {
+ webView.goForward()
+ }
+
func didTapBookmarkButton() {
showBookmarkController()
}
diff --git a/Kiwix-iOS/Controller/Main/NavigationStack.swift b/Kiwix-iOS/Controller/Main/NavigationStack.swift
new file mode 100644
index 00000000..adfbd4ad
--- /dev/null
+++ b/Kiwix-iOS/Controller/Main/NavigationStack.swift
@@ -0,0 +1,36 @@
+//
+// NavigationStack.swift
+// Kiwix
+//
+// Created by Chris Li on 11/20/16.
+// Copyright © 2016 Chris Li. All rights reserved.
+//
+
+import UIKit
+
+class NavigationStack {
+ var backList = [URL]()
+ var forwardList = [URL]()
+ var currentURL: URL?
+
+ func webViewFinishedLoading(url: URL) {
+ guard url != currentURL else { return }
+ }
+
+ func goBack() {
+
+ }
+
+ func goForward() {
+
+ }
+
+ var canGoBack: Bool {
+ return false
+ }
+
+ var canGoForward: Bool {
+ return false
+ }
+
+}
diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index 62e4e027..72bbce61 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.2983
+ 1.8.2998
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist
index 2aaf3704..f909b816 100644
--- a/Kiwix-iOSWidgets/Bookmarks/Info.plist
+++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.8.2983
+ 1.8.2998
NSExtension
NSExtensionMainStoryboard
diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj
index ca0334f1..32628c77 100644
--- a/Kiwix.xcodeproj/project.pbxproj
+++ b/Kiwix.xcodeproj/project.pbxproj
@@ -44,6 +44,7 @@
973208271DD2238B00EDD3DC /* GlobalQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811C1D6F70AC00E5FA99 /* GlobalQueue.swift */; };
973208291DD223DB00EDD3DC /* RefreshLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973208281DD223DB00EDD3DC /* RefreshLibrary.swift */; };
9734E54E1D289D060061C39B /* Welcome.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9734E54D1D289D060061C39B /* Welcome.storyboard */; };
+ 97362EE91DE1EADB004205B5 /* NavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97362EE81DE1EADB004205B5 /* NavigationStack.swift */; };
973BCD1A1CEB402900F10B44 /* KiwixTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD181CEB402900F10B44 /* KiwixTests.swift */; };
973DD40F1D343F2F009D45DB /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4041D343F2F009D45DB /* libicudata.a */; };
973DD4101D343F2F009D45DB /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4051D343F2F009D45DB /* libicui18n.a */; };
@@ -192,6 +193,7 @@
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 = ""; };
9734E54D1D289D060061C39B /* Welcome.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Welcome.storyboard; path = "Kiwix-iOS/Storyboard/Welcome.storyboard"; sourceTree = SOURCE_ROOT; };
+ 97362EE81DE1EADB004205B5 /* NavigationStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationStack.swift; sourceTree = ""; };
973BCD001CEB3FA500F10B44 /* Kiwix_OSXTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXTests.swift; sourceTree = ""; };
973BCD021CEB3FA500F10B44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
973BCD0B1CEB3FA500F10B44 /* Kiwix_OSXUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXUITests.swift; sourceTree = ""; };
@@ -483,6 +485,7 @@
97D0E98E1DDA12B30029530E /* MainDelegates.swift */,
97BC0FC11DD92B62004BBAD1 /* Buttons.swift */,
97BC0FBD1DD90A65004BBAD1 /* JSInjection.swift */,
+ 97362EE81DE1EADB004205B5 /* NavigationStack.swift */,
972F81581DDC1B71008D7289 /* Controllers.swift */,
);
path = Main;
@@ -1161,6 +1164,7 @@
973207A01DD1983D00EDD3DC /* DownloadTasksController.swift in Sources */,
97D0E9931DDA487E0029530E /* SearchBaseController.swift in Sources */,
97A1FD321D6F723D00A80EE2 /* resourceTools.cpp in Sources */,
+ 97362EE91DE1EADB004205B5 /* NavigationStack.swift in Sources */,
97A1FD451D6F728200A80EE2 /* StringTools.swift in Sources */,
97D681411D6F712800E5FA99 /* DownloadTask+CoreDataProperties.swift in Sources */,
97D681391D6F711A00E5FA99 /* DownloadTask.swift in Sources */,