mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 04:03:03 -04:00
First Time Use Alert
This commit is contained in:
parent
60e8deb1a9
commit
d282238f35
File diff suppressed because it is too large
Load Diff
@ -110,10 +110,8 @@ class LibraryLocalTBVC: UITableViewController, NSFetchedResultsControllerDelegat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func emptyDataSetDidTapButton(scrollView: UIScrollView!) {
|
func emptyDataSetDidTapButton(scrollView: UIScrollView!) {
|
||||||
guard let navController = UIStoryboard.setting.instantiateViewControllerWithIdentifier("WebViewNav") as? UINavigationController,
|
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, presentationContext: self)
|
||||||
let controller = navController.topViewController as? WebViewVC else {return}
|
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||||
controller.page = .ImportBookLearnMore
|
|
||||||
presentViewController(navController, animated: true, completion: nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - TableView Data Source
|
// MARK: - TableView Data Source
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import SCLAlertView
|
||||||
|
|
||||||
class MainVC: UIViewController {
|
class MainVC: UIViewController {
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ class MainVC: UIViewController {
|
|||||||
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewNotInjectJavascriptToAdjustPageLayout", options: .New, context: context)
|
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewNotInjectJavascriptToAdjustPageLayout", options: .New, context: context)
|
||||||
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewZoomScale", options: .New, context: context)
|
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewZoomScale", options: .New, context: context)
|
||||||
configureButtonColor()
|
configureButtonColor()
|
||||||
|
showGetStartedAlert()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
@ -63,6 +65,15 @@ class MainVC: UIViewController {
|
|||||||
configureUIElements(self.traitCollection)
|
configureUIElements(self.traitCollection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - First Time Launch Alert
|
||||||
|
|
||||||
|
func showGetStartedAlert() {
|
||||||
|
guard !Preference.hasShowGetStartedAlert else {return}
|
||||||
|
let operation = GetStartedAlert(mainController: self)
|
||||||
|
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||||
|
Preference.hasShowGetStartedAlert = true
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Configure
|
// MARK: - Configure
|
||||||
|
|
||||||
func configureUIElements(traitCollection: UITraitCollection) {
|
func configureUIElements(traitCollection: UITraitCollection) {
|
||||||
@ -85,7 +96,6 @@ class MainVC: UIViewController {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
configureWebViewInsets()
|
configureWebViewInsets()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureButtonColor() {
|
func configureButtonColor() {
|
||||||
@ -126,10 +136,6 @@ class MainVC: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureSearchBarCancelButton() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - UIViewAnimations
|
// MARK: - UIViewAnimations
|
||||||
|
|
||||||
func animateInSearchResultController() {
|
func animateInSearchResultController() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// AlertOperations.swift
|
// UIOperations.swift
|
||||||
// Kiwix
|
// Kiwix
|
||||||
//
|
//
|
||||||
// Created by Chris Li on 3/22/16.
|
// Created by Chris Li on 3/22/16.
|
||||||
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
// MARK: - Alerts
|
||||||
|
|
||||||
class SpaceCautionAlert: AlertOperation {
|
class SpaceCautionAlert: AlertOperation {
|
||||||
init(book: Book, presentationContext: UIViewController?) {
|
init(book: Book, presentationContext: UIViewController?) {
|
||||||
super.init(presentationContext: presentationContext)
|
super.init(presentationContext: presentationContext)
|
||||||
@ -103,3 +105,43 @@ class RefreshLibraryInternetRequiredAlert: AlertOperation {
|
|||||||
addAction(LocalizedStrings.ok)
|
addAction(LocalizedStrings.ok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GetStartedAlert: AlertOperation {
|
||||||
|
init(mainController: MainVC?) {
|
||||||
|
super.init(presentationContext: mainController)
|
||||||
|
|
||||||
|
let comment = "First Time Launch Message"
|
||||||
|
|
||||||
|
title = NSLocalizedString("Welcome to Kiwix", comment: comment)
|
||||||
|
message = NSLocalizedString("Add a Book to Get Started", comment: comment)
|
||||||
|
addAction(NSLocalizedString("Download", comment: comment), style: .Default) { (alert) in
|
||||||
|
mainController?.showLibraryButtonTapped()
|
||||||
|
}
|
||||||
|
addAction(NSLocalizedString("Import", comment: comment), style: .Default) { (alert) in
|
||||||
|
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, presentationContext: mainController)
|
||||||
|
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||||
|
}
|
||||||
|
addAction(NSLocalizedString("Dismiss", comment: comment))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Help Pages
|
||||||
|
|
||||||
|
class ShowHelpPageOperation: Operation {
|
||||||
|
private let type: WebViewVCContentType
|
||||||
|
private weak var presentationContext: UIViewController?
|
||||||
|
|
||||||
|
init(type: WebViewVCContentType, presentationContext: UIViewController?) {
|
||||||
|
self.type = type
|
||||||
|
self.presentationContext = presentationContext
|
||||||
|
}
|
||||||
|
|
||||||
|
override func execute() {
|
||||||
|
NSOperationQueue.mainQueue().addOperationWithBlock {
|
||||||
|
guard let navController = UIStoryboard.setting.instantiateViewControllerWithIdentifier("WebViewNav") as? UINavigationController,
|
||||||
|
let controller = navController.topViewController as? WebViewVC else {return}
|
||||||
|
controller.page = self.type
|
||||||
|
self.presentationContext?.presentViewController(navController, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ class WebViewVC: UIViewController, UIWebViewDelegate {
|
|||||||
|
|
||||||
@IBOutlet weak var webView: UIWebView!
|
@IBOutlet weak var webView: UIWebView!
|
||||||
|
|
||||||
var page: WebViewVCHTML?
|
var page: WebViewVCContentType?
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
@ -46,6 +46,6 @@ class WebViewVC: UIViewController, UIWebViewDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum WebViewVCHTML: String {
|
enum WebViewVCContentType: String {
|
||||||
case DownloaderLearnMore, ImportBookLearnMore
|
case DownloaderLearnMore, ImportBookLearnMore
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user