Skip to content

Commit 941fb4a

Browse files
- Highly improved speed when loading the topic creator
- The topic creator doesn't need internet now - Fixed some weird behaviour when loading a theme in the settings view controller
1 parent 32a6801 commit 941fb4a

File tree

5 files changed

+21
-36
lines changed

5 files changed

+21
-36
lines changed

Questions/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.14-beta</string>
18+
<string>3.14.1-beta</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Questions/QuestionsCreatorWeb/QuestionsCreatorWrapper.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ struct QuestionsCreatorWrapper {
2222

2323
var web: String {
2424

25-
let bootstrapp = """
26-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
25+
/* REMOVED:
2726
<script async src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
2827
<script async src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
29-
<script async src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
28+
*/
29+
let bootstrapp = """
30+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous" media="none" onload="if(media!='all')media='all'"><noscript><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"></noscript>
31+
32+
<script async defer src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
3033
"""
3134
let extraStyles = """
3235
<style>
3336
.body-style {
3437
margin: 10pt 10pt;
3538
background-color: \(UserDefaultsManager.darkThemeSwitchIsOn ? "black" : "white");
3639
color: \(UserDefaultsManager.darkThemeSwitchIsOn ? "white" : "black");
40+
font-family: system-ui;
3741
}
3842
.rounded-button {
3943
width: 24pt;

Questions/SettingsTableViewController.swift

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class SettingsTableViewController: UITableViewController {
8787
}
8888
}
8989

90+
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
91+
let textLabelColor = UIColor.themeStyle(dark: .white, light: .black)
92+
cell.textLabel?.textColor = textLabelColor
93+
cell.backgroundColor = .themeStyle(dark: .veryDarkGray, light: .white)
94+
}
95+
9096
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
9197

9298
let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
@@ -320,23 +326,13 @@ class SettingsTableViewController: UITableViewController {
320326
self.tableView.backgroundColor = .themeStyle(dark: .black, light: .groupTableViewBackground)
321327
self.tableView.separatorColor = .themeStyle(dark: .black, light: .defaultSeparatorColor)
322328

323-
let textLabelColor = UIColor.themeStyle(dark: .white, light: .black)
324329
let switchTintColor = UIColor.themeStyle(dark: .warmColor, light: .coolBlue)
325330

326331
self.switches.forEach { $0.onTintColor = switchTintColor; $0.dontInvertColors() }
327-
328-
self.tableView.reloadData()
329-
330-
for i in 0..<cellLabelsForSection0.count {
331-
let cell = self.tableView.cellForRow(at: IndexPath(row: i, section: 0))
332-
cell?.textLabel?.textColor = textLabelColor
333-
cell?.backgroundColor = .themeStyle(dark: .veryDarkGray, light: .white)
334-
}
335-
336-
for i in 0..<cellLabelsForSection1.count {
337-
let cell = self.tableView.cellForRow(at: IndexPath(row: i, section: 1))
338-
cell?.textLabel?.textColor = textLabelColor
339-
cell?.backgroundColor = .themeStyle(dark: .veryDarkGray, light: .white)
332+
333+
}, completion: { completed in
334+
if completed {
335+
self.tableView.reloadData()
340336
}
341337
})
342338
}

Questions/WebCreatorViewController.swift

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,29 @@ extension UIWebView {
1717
}
1818
}
1919

20-
// TODO: translate
2120
class WebCreatorViewController: UIViewController, UIWebViewDelegate {
2221

2322
@IBOutlet weak var webView: UIWebView!
2423

2524
var questionsCreatorWrapper: QuestionsCreatorWrapper?
26-
var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .themeStyle(dark: .white, light: .gray))
2725

2826
override func viewDidLoad() {
2927
super.viewDidLoad()
3028
self.setupWebView()
31-
self.setupActivityIndicator()
3229
self.promptUserWithFormGenerator()
3330
}
3431

3532
// MARK: - Web view Delegate
36-
37-
func webViewDidStartLoad(_ webView: UIWebView) {
38-
self.activityIndicator.startAnimating()
39-
}
40-
33+
4134
func webViewDidFinishLoad(_ webView: UIWebView) {
42-
self.activityIndicator.stopAnimating()
4335
self.webView.stringByEvaluatingJavaScript(from: "document.documentElement.style.webkitUserSelect='none'")
4436
self.webView.stringByEvaluatingJavaScript(from: "document.documentElement.style.webkitTouchCallout='none'")
4537
}
4638

4739
/// We'll retrieve the info from the form, validate it and promt the user what to do with it
4840
@IBAction func outputBarButtonAction(_ sender: UIBarButtonItem) {
4941

50-
guard !self.activityIndicator.isAnimating, let questionsCreatorWrapper = self.questionsCreatorWrapper else { return }
42+
guard let questionsCreatorWrapper = self.questionsCreatorWrapper else { return }
5143

5244
let name = self.webView.getInputValueFrom(id: "topic-name")
5345
let topicTime = self.webView.getInputValueFrom(id: "topic-time") ?? ""
@@ -136,12 +128,6 @@ class WebCreatorViewController: UIViewController, UIWebViewDelegate {
136128
self.view.backgroundColor = .themeStyle(dark: .black, light: .white)
137129
}
138130

139-
private func setupActivityIndicator() {
140-
self.activityIndicator.frame = self.view.bounds
141-
self.activityIndicator.autoresizingMask = [.flexibleWidth, .flexibleHeight]
142-
self.view.addSubview(self.activityIndicator)
143-
}
144-
145131
private func promptUserWithFormGenerator() {
146132
let questionsCreatorSetupAlert = UIAlertController(title: "Create Topic".localized, message: nil, preferredStyle: .alert)
147133

@@ -174,7 +160,6 @@ class WebCreatorViewController: UIViewController, UIWebViewDelegate {
174160
let answersPerQuestionStr = textFields[2].text, let answersPerQuestion = UInt8(answersPerQuestionStr),
175161
numberOfSets > 0, questionsPerSet > 0, answersPerQuestion > 1 {
176162

177-
self.activityIndicator.startAnimating()
178163
self.questionsCreatorWrapper = QuestionsCreatorWrapper(numberOfSets: numberOfSets, questionsPerSet: questionsPerSet, answersPerQuestion: answersPerQuestion)
179164
self.webView.loadHTMLString(self.questionsCreatorWrapper?.web ?? "", baseURL: nil)
180165
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Questions
22
[![Swift version](https://img.shields.io/badge/Swift-4-orange.svg)](https://swift.org/download)
3-
[![Version](https://img.shields.io/badge/version-3.14--beta-green.svg)](https://github.com/illescasDaniel/Questions/releases)
3+
[![Version](https://img.shields.io/badge/version-3.14.1--beta-green.svg)](https://github.com/illescasDaniel/Questions/releases)
44
[![Trello](https://img.shields.io/badge/-trello-blue.svg)](https://trello.com/b/9YLvTM6S)
55
[![Hockeyapp](https://img.shields.io/badge/-hockeyapp-blue.svg)](https://rink.hockeyapp.net/apps/4a9339e52aca4e629bee0b48aef1df5d)
66
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/illescasDaniel/Questions/blob/master/LICENSE)

0 commit comments

Comments
 (0)