This commit is contained in:
Chris Li 2017-01-20 10:50:14 -05:00
parent 1e50af26e2
commit ab2fbea8db
5 changed files with 92 additions and 9 deletions

View File

@ -55,6 +55,11 @@ class SettingController: UITableViewController {
}
case Localized.Setting.rateApp:
UIQueue.shared.add(operation: AlertProcedure.rateKiwix(context: self, userInitiated: true))
case Localized.Setting.about:
let controller = UIStoryboard(name: "Setting", bundle: nil).instantiateViewController(withIdentifier: "StaticWebController") as! StaticWebController
controller.title = Localized.Setting.about
controller.load(htmlFileName: "About")
navigationController?.pushViewController(controller, animated: true)
default:
return
}

View File

@ -0,0 +1,48 @@
//
// StaticWebController.swift
// Kiwix
//
// Created by Chris Li on 1/20/17.
// Copyright © 2017 Chris Li. All rights reserved.
//
import UIKit
import SafariServices
class StaticWebController: UIViewController, UIWebViewDelegate, SFSafariViewControllerDelegate {
@IBOutlet weak var webView: UIWebView!
private var url: URL?
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
guard let url = url, webView.request?.url != url else {return}
webView.loadRequest(URLRequest(url: url))
}
func load(htmlFileName: String) {
url = Bundle.main.url(forResource: htmlFileName, withExtension: "html")
guard let url = url, webView != nil, webView.request?.url != url else {return}
webView.loadRequest(URLRequest(url: url))
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
guard let url = request.url else {return false}
if url == self.url {
return true
} else {
let controller = SFSafariViewController(url: url)
controller.delegate = self
present(controller, animated: true, completion: nil)
return false
}
}
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.dismiss(animated: true, completion: nil)
}
}

View File

@ -53,6 +53,39 @@
</objects>
<point key="canvasLocation" x="1040.8" y="224.4377811094453"/>
</scene>
<!--Static Web Controller-->
<scene sceneID="BAo-fm-zbn">
<objects>
<viewController storyboardIdentifier="StaticWebController" id="NZ8-xj-UdR" customClass="StaticWebController" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="q6h-wV-M9K"/>
<viewControllerLayoutGuide type="bottom" id="ts2-NC-gzs"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="noq-fM-QpC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="F9v-t9-ijZ">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</webView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="ts2-NC-gzs" firstAttribute="top" secondItem="F9v-t9-ijZ" secondAttribute="bottom" id="ADZ-HF-JiF"/>
<constraint firstItem="F9v-t9-ijZ" firstAttribute="top" secondItem="noq-fM-QpC" secondAttribute="top" id="LLu-GE-M2a"/>
<constraint firstAttribute="trailing" secondItem="F9v-t9-ijZ" secondAttribute="trailing" id="Svb-CH-deN"/>
<constraint firstItem="F9v-t9-ijZ" firstAttribute="leading" secondItem="noq-fM-QpC" secondAttribute="leading" id="TGA-uK-7VS"/>
</constraints>
</view>
<connections>
<outlet property="webView" destination="F9v-t9-ijZ" id="P7e-k5-3w4"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="uxQ-jA-31z" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1772" y="224.4377811094453"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="y2e-Kj-oGf">
<objects>

View File

@ -70,6 +70,7 @@
976C1DD01E3000B6005EDEC4 /* Setting.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 976C1DCF1E3000B6005EDEC4 /* Setting.storyboard */; };
976C1DD21E3000F1005EDEC4 /* SettingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976C1DD11E3000F1005EDEC4 /* SettingController.swift */; };
976C1DD41E300695005EDEC4 /* UIProcedure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976C1DD31E300695005EDEC4 /* UIProcedure.swift */; };
976C1DD61E32628B005EDEC4 /* StaticWebController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976C1DD51E32628B005EDEC4 /* StaticWebController.swift */; };
9771A5BD1DD269BD005F1795 /* Book+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6813C1D6F712800E5FA99 /* Book+CoreDataProperties.swift */; };
9779C3141D4575AD0064CC8E /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */; };
9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779C3161D4575AE0064CC8E /* TodayViewController.swift */; };
@ -230,6 +231,7 @@
976C1DCF1E3000B6005EDEC4 /* Setting.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Setting.storyboard; sourceTree = "<group>"; };
976C1DD11E3000F1005EDEC4 /* SettingController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingController.swift; sourceTree = "<group>"; };
976C1DD31E300695005EDEC4 /* UIProcedure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProcedure.swift; sourceTree = "<group>"; };
976C1DD51E32628B005EDEC4 /* StaticWebController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticWebController.swift; sourceTree = "<group>"; };
9779C3131D4575AD0064CC8E /* Bookmarks.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Bookmarks.appex; sourceTree = BUILT_PRODUCTS_DIR; };
9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = "<group>"; };
9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -585,6 +587,7 @@
isa = PBXGroup;
children = (
976C1DD11E3000F1005EDEC4 /* SettingController.swift */,
976C1DD51E32628B005EDEC4 /* StaticWebController.swift */,
);
path = Setting;
sourceTree = "<group>";
@ -1122,6 +1125,7 @@
976C1DCB1E2FD5FC005EDEC4 /* TableOfContentsController.swift in Sources */,
9771A5BD1DD269BD005F1795 /* Book+CoreDataProperties.swift in Sources */,
9764CBD11D806AD800072D6A /* RefreshLibControl.swift in Sources */,
976C1DD61E32628B005EDEC4 /* StaticWebController.swift in Sources */,
97C601DE1D7F342100362D4F /* HTMLHeading.swift in Sources */,
975B90FE1CEB909100D13906 /* iOSExtensions.swift in Sources */,
971A10521D022D9D007FC62C /* AppDelegate.swift in Sources */,

View File

@ -164,11 +164,7 @@ sup {
<h3>Release</h3>
<p>This software is released under the terms of the <a href="https://en.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a> version 3.<br/>
View the source code on <a href="https://github.com/automactic/Kiwix">Github</a>.</p>
<h3>Developer</h3>
<p>Chris: <a href="mailto: chris@kiwix.org?Subject=I have%20an%20idea%20about%20Kiwix." target="_top">Send Email</a></p>
View the source code on <a href="https://github.com/kiwix/iOS">Github</a>.</p>
<h3>Libraries</h3>
@ -178,8 +174,5 @@ View the source code on <a href="https://github.com/automactic/Kiwix">Github</a>
<span class="wysiwyg-font-size-large">Icon made by <a title="Freepik" href="http://www.freepik.com">Freepik</a> from <a title="Flaticon" href="http://www.flaticon.com">www.flaticon.com</a>&nbsp;</span>
<h3>Contact</h3>
<p>Contact Kiwix: <a href="mailto: contact@kiwix.org?Subject=I have%20an%20idea%20about%20Kiwix." target="_top">Send Email</a></p>
</body>
</html>
</html>