diff --git a/Kiwix-iOS/Controller/Others/CoreDataTableBaseController.swift b/Kiwix-iOS/Controller/Others/CoreDataTableBaseController.swift
index 192948ff..4ec1294d 100644
--- a/Kiwix-iOS/Controller/Others/CoreDataTableBaseController.swift
+++ b/Kiwix-iOS/Controller/Others/CoreDataTableBaseController.swift
@@ -9,8 +9,12 @@
import UIKit
import CoreData
-// Yes, I know it'd be better to make this into a protocol.
-// But unfortunately, UIKit cannot seems to be able to recognize default protocol implementation in Swift. (iOS 10.1)
+/**
+ Base class for all controllers that use CoreData and tableView.
+
+ Yes, I know it'd be better to make this into a protocol.
+ But unfortunately, UIKit cannot seems to be able to recognize default protocol implementation in Swift. (iOS 10.1)
+ */
class CoreDataTableBaseController: UIViewController, NSFetchedResultsControllerDelegate {
@IBOutlet weak var tableView: UITableView!
diff --git a/Kiwix-iOS/Controller/Search/SearchBaseController.swift b/Kiwix-iOS/Controller/Search/SearchBaseController.swift
index f25c9f35..1c204a17 100644
--- a/Kiwix-iOS/Controller/Search/SearchBaseController.swift
+++ b/Kiwix-iOS/Controller/Search/SearchBaseController.swift
@@ -9,21 +9,32 @@
import UIKit
import DZNEmptyDataSet
+/**
+ Base class for SearchBooksController and SearchResultController.
+
+ Provides:
+
+ - tableView inset handle
+ - DZNEmptyDataSet refresh
+
+ when keyboard shows / hides
+ */
+
class SearchBaseTableController: UIViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
@IBOutlet weak var tableView: UITableView!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(notification:)), name: .UIKeyboardDidShow, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: .UIKeyboardWillHide, object: nil)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
tableView.emptyDataSetSource = nil
tableView.emptyDataSetDelegate = nil
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardDidShow, object: nil)
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.removeObserver(self, name: .UIKeyboardDidShow, object: nil)
+ NotificationCenter.default.removeObserver(self, name: .UIKeyboardWillHide, object: nil)
}
override func viewDidAppear(_ animated: Bool) {
@@ -32,7 +43,7 @@ class SearchBaseTableController: UIViewController, DZNEmptyDataSetSource, DZNEmp
tableView.emptyDataSetDelegate = self
}
- func keyboardDidShow(_ notification: Notification) {
+ func keyboardDidShow(notification: Notification) {
guard let userInfo = notification.userInfo as? [String: NSValue],
let origin = userInfo[UIKeyboardFrameEndUserInfoKey]?.cgRectValue.origin else {return}
let point = view.convert(origin, from: nil)
@@ -42,7 +53,7 @@ class SearchBaseTableController: UIViewController, DZNEmptyDataSetSource, DZNEmp
tableView.reloadEmptyDataSet()
}
- func keyboardWillHide(_ notification: Notification) {
+ func keyboardWillHide(notification: Notification) {
tableView.contentInset = UIEdgeInsetsMake(0.0, 0, 0, 0)
tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0.0, 0, 0, 0)
tableView.reloadEmptyDataSet()
diff --git a/Kiwix-iOS/Controller/Search/SearchContainer.swift b/Kiwix-iOS/Controller/Search/SearchContainer.swift
index 1ca3f3a0..fce55941 100644
--- a/Kiwix-iOS/Controller/Search/SearchContainer.swift
+++ b/Kiwix-iOS/Controller/Search/SearchContainer.swift
@@ -15,16 +15,13 @@ class SearchContainer: UIViewController {
@IBOutlet weak var scopeAndHistoryContainer: UIView!
@IBOutlet weak var resultContainer: UIView!
private var resultController: SearchResultController!
-
-
var delegate: SearchContainerDelegate?
- var searchText = "" {
- didSet {
- configureVisibility()
- startSearch()
- }
+ @IBAction func handleDimViewTap(_ sender: UITapGestureRecognizer) {
+ delegate?.didTapSearchDimView()
}
+
+ // MARK: - Overrides
override func viewDidLoad() {
super.viewDidLoad()
@@ -40,6 +37,15 @@ class SearchContainer: UIViewController {
}
}
+ // MARK: - Search
+
+ var searchText = "" {
+ didSet {
+ configureVisibility()
+ startSearch()
+ }
+ }
+
private func configureVisibility() {
let shouldHideResults = searchText == ""
scopeAndHistoryContainer.isHidden = !shouldHideResults
@@ -56,10 +62,6 @@ class SearchContainer: UIViewController {
})
})
}
-
- @IBAction func handleDimViewTap(_ sender: UITapGestureRecognizer) {
- delegate?.didTapSearchDimView()
- }
}
protocol SearchContainerDelegate: class {
diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index 4c5e8dee..c03e74f4 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.3346
+ 1.8.3347
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist
index bd926a3b..eca33a52 100644
--- a/Kiwix-iOSWidgets/Bookmarks/Info.plist
+++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.8.3346
+ 1.8.3347
NSExtension
NSExtensionMainStoryboard