mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-28 14:35:03 -04:00
go back go forward
This commit is contained in:
parent
8ca00766d3
commit
5cd6ae6625
@ -60,7 +60,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||||
URLProtocol.registerClass(KiwixURLProtocol)
|
URLProtocol.registerClass(KiwixURLProtocol.self)
|
||||||
|
|
||||||
// Network.shared
|
// Network.shared
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ import UIKit
|
|||||||
|
|
||||||
class Buttons {
|
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:)))
|
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:)))
|
target: self, action: #selector(tapped(button:)))
|
||||||
private(set) lazy var toc: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "TableOfContent"), style: .plain,
|
private(set) lazy var toc: UIBarButtonItem = GrayBarButtonItem(image: UIImage(named: "TableOfContent"), style: .plain,
|
||||||
target: self, action: #selector(tapped(button:)))
|
target: self, action: #selector(tapped(button:)))
|
||||||
@ -30,13 +30,13 @@ class Buttons {
|
|||||||
|
|
||||||
var toolbar: [UIBarButtonItem] {
|
var toolbar: [UIBarButtonItem] {
|
||||||
get {
|
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] {
|
var navLeft: [UIBarButtonItem] {
|
||||||
get {
|
get {
|
||||||
return [left, right, toc]
|
return [back, forward, toc]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class Buttons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addLongTapGestureRecognizer() {
|
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}
|
guard let view = button.value(forKey: "view") as? UIView else {return}
|
||||||
view.tag = index
|
view.tag = index
|
||||||
view.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(pressed(recognizer:))))
|
view.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(pressed(recognizer:))))
|
||||||
@ -56,10 +56,10 @@ class Buttons {
|
|||||||
|
|
||||||
@objc func tapped(button: UIBarButtonItem) {
|
@objc func tapped(button: UIBarButtonItem) {
|
||||||
switch button {
|
switch button {
|
||||||
case left:
|
case back:
|
||||||
print("left tapped")
|
delegate?.didTapBackButton()
|
||||||
case right:
|
case forward:
|
||||||
print("right tapped")
|
delegate?.didTapForwardButton()
|
||||||
case bookmark:
|
case bookmark:
|
||||||
delegate?.didTapBookmarkButton()
|
delegate?.didTapBookmarkButton()
|
||||||
case library:
|
case library:
|
||||||
@ -87,6 +87,8 @@ class Buttons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protocol ButtonDelegates {
|
protocol ButtonDelegates {
|
||||||
|
func didTapBackButton()
|
||||||
|
func didTapForwardButton()
|
||||||
func didTapBookmarkButton()
|
func didTapBookmarkButton()
|
||||||
func didTapLibraryButton()
|
func didTapLibraryButton()
|
||||||
func didTapCancelButton()
|
func didTapCancelButton()
|
||||||
|
@ -14,6 +14,7 @@ class MainController: UIViewController {
|
|||||||
let searchBar = SearchBar()
|
let searchBar = SearchBar()
|
||||||
lazy var controllers = Controllers()
|
lazy var controllers = Controllers()
|
||||||
lazy var buttons = Buttons()
|
lazy var buttons = Buttons()
|
||||||
|
let navigationStack = NavigationStack()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
@ -105,6 +105,9 @@ extension MainController: UIWebViewDelegate, SFSafariViewControllerDelegate {
|
|||||||
func webViewDidFinishLoad(_ webView: UIWebView) {
|
func webViewDidFinishLoad(_ webView: UIWebView) {
|
||||||
guard let title = JS.getTitle(from: webView) else {return}
|
guard let title = JS.getTitle(from: webView) else {return}
|
||||||
searchBar.title = title
|
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) {
|
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
|
||||||
@ -123,6 +126,14 @@ extension MainController {
|
|||||||
// MARK: - Button Delegates
|
// MARK: - Button Delegates
|
||||||
|
|
||||||
extension MainController: ButtonDelegates, SearchContainerDelegate {
|
extension MainController: ButtonDelegates, SearchContainerDelegate {
|
||||||
|
func didTapBackButton() {
|
||||||
|
webView.goBack()
|
||||||
|
}
|
||||||
|
|
||||||
|
func didTapForwardButton() {
|
||||||
|
webView.goForward()
|
||||||
|
}
|
||||||
|
|
||||||
func didTapBookmarkButton() {
|
func didTapBookmarkButton() {
|
||||||
showBookmarkController()
|
showBookmarkController()
|
||||||
}
|
}
|
||||||
|
36
Kiwix-iOS/Controller/Main/NavigationStack.swift
Normal file
36
Kiwix-iOS/Controller/Main/NavigationStack.swift
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -49,7 +49,7 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.8.2983</string>
|
<string>1.8.2998</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.8.2983</string>
|
<string>1.8.2998</string>
|
||||||
<key>NSExtension</key>
|
<key>NSExtension</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExtensionMainStoryboard</key>
|
<key>NSExtensionMainStoryboard</key>
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
973208271DD2238B00EDD3DC /* GlobalQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811C1D6F70AC00E5FA99 /* GlobalQueue.swift */; };
|
973208271DD2238B00EDD3DC /* GlobalQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811C1D6F70AC00E5FA99 /* GlobalQueue.swift */; };
|
||||||
973208291DD223DB00EDD3DC /* RefreshLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973208281DD223DB00EDD3DC /* RefreshLibrary.swift */; };
|
973208291DD223DB00EDD3DC /* RefreshLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973208281DD223DB00EDD3DC /* RefreshLibrary.swift */; };
|
||||||
9734E54E1D289D060061C39B /* Welcome.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9734E54D1D289D060061C39B /* Welcome.storyboard */; };
|
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 */; };
|
973BCD1A1CEB402900F10B44 /* KiwixTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD181CEB402900F10B44 /* KiwixTests.swift */; };
|
||||||
973DD40F1D343F2F009D45DB /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4041D343F2F009D45DB /* libicudata.a */; };
|
973DD40F1D343F2F009D45DB /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4041D343F2F009D45DB /* libicudata.a */; };
|
||||||
973DD4101D343F2F009D45DB /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4051D343F2F009D45DB /* libicui18n.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 = "<group>"; };
|
973208251DD21E9C00EDD3DC /* CoreDataContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataContainer.swift; sourceTree = "<group>"; };
|
||||||
973208281DD223DB00EDD3DC /* RefreshLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibrary.swift; sourceTree = "<group>"; };
|
973208281DD223DB00EDD3DC /* RefreshLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibrary.swift; sourceTree = "<group>"; };
|
||||||
9734E54D1D289D060061C39B /* Welcome.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Welcome.storyboard; path = "Kiwix-iOS/Storyboard/Welcome.storyboard"; sourceTree = SOURCE_ROOT; };
|
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 = "<group>"; };
|
||||||
973BCD001CEB3FA500F10B44 /* Kiwix_OSXTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXTests.swift; sourceTree = "<group>"; };
|
973BCD001CEB3FA500F10B44 /* Kiwix_OSXTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXTests.swift; sourceTree = "<group>"; };
|
||||||
973BCD021CEB3FA500F10B44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
973BCD021CEB3FA500F10B44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
973BCD0B1CEB3FA500F10B44 /* Kiwix_OSXUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXUITests.swift; sourceTree = "<group>"; };
|
973BCD0B1CEB3FA500F10B44 /* Kiwix_OSXUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kiwix_OSXUITests.swift; sourceTree = "<group>"; };
|
||||||
@ -483,6 +485,7 @@
|
|||||||
97D0E98E1DDA12B30029530E /* MainDelegates.swift */,
|
97D0E98E1DDA12B30029530E /* MainDelegates.swift */,
|
||||||
97BC0FC11DD92B62004BBAD1 /* Buttons.swift */,
|
97BC0FC11DD92B62004BBAD1 /* Buttons.swift */,
|
||||||
97BC0FBD1DD90A65004BBAD1 /* JSInjection.swift */,
|
97BC0FBD1DD90A65004BBAD1 /* JSInjection.swift */,
|
||||||
|
97362EE81DE1EADB004205B5 /* NavigationStack.swift */,
|
||||||
972F81581DDC1B71008D7289 /* Controllers.swift */,
|
972F81581DDC1B71008D7289 /* Controllers.swift */,
|
||||||
);
|
);
|
||||||
path = Main;
|
path = Main;
|
||||||
@ -1161,6 +1164,7 @@
|
|||||||
973207A01DD1983D00EDD3DC /* DownloadTasksController.swift in Sources */,
|
973207A01DD1983D00EDD3DC /* DownloadTasksController.swift in Sources */,
|
||||||
97D0E9931DDA487E0029530E /* SearchBaseController.swift in Sources */,
|
97D0E9931DDA487E0029530E /* SearchBaseController.swift in Sources */,
|
||||||
97A1FD321D6F723D00A80EE2 /* resourceTools.cpp in Sources */,
|
97A1FD321D6F723D00A80EE2 /* resourceTools.cpp in Sources */,
|
||||||
|
97362EE91DE1EADB004205B5 /* NavigationStack.swift in Sources */,
|
||||||
97A1FD451D6F728200A80EE2 /* StringTools.swift in Sources */,
|
97A1FD451D6F728200A80EE2 /* StringTools.swift in Sources */,
|
||||||
97D681411D6F712800E5FA99 /* DownloadTask+CoreDataProperties.swift in Sources */,
|
97D681411D6F712800E5FA99 /* DownloadTask+CoreDataProperties.swift in Sources */,
|
||||||
97D681391D6F711A00E5FA99 /* DownloadTask.swift in Sources */,
|
97D681391D6F711A00E5FA99 /* DownloadTask.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user