Skip to content

Commit dc50ced

Browse files
- Improved settings
- Updated screenshots
1 parent 2506b6c commit dc50ced

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

Questions/SettingsTableViewController.swift

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class SettingsTableViewController: UITableViewController {
4646
self.setUpSwitches()
4747
self.loadSwitchesStates()
4848
self.loadCurrentTheme(animated: false)
49+
50+
self.clearsSelectionOnViewWillAppear = true
4951

5052
// If user enables Reduce Motion setting, the parallax effect switch updates its value
5153
NotificationCenter.default.addObserver(self, selector: #selector(self.setParallaxEffectSwitch), name: .UIAccessibilityReduceMotionStatusDidChange, object: nil)
@@ -76,20 +78,27 @@ class SettingsTableViewController: UITableViewController {
7678
case 1:
7779
switch indexPath.row {
7880
case 0:
79-
self.resetProgressAlert()
81+
self.resetProgressAlert(cellIndexpath: indexPath)
8082
FeedbackGenerator.notificationOcurredOf(type: .warning)
83+
self.viewWillAppear(false) // called so it clears the selection properly
8184
case 1:
82-
self.resetCachedImages()
85+
self.resetCachedImages(cellIndexpath: indexPath)
8386
FeedbackGenerator.notificationOcurredOf(type: .warning)
87+
self.viewWillAppear(false)
8488
default: break
8589
}
8690
default: break
8791
}
8892
}
8993

9094
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
95+
let textLabelColor: UIColor = .themeStyle(dark: .white, light: .black)
96+
switch indexPath.section {
97+
case 0: cell.textLabel?.textColor = textLabelColor
98+
case 1: cell.textLabel?.textColor = UIColor.themeStyle(dark: .lightRed, light: .alternativeRed)
99+
default: break
100+
}
101+
93102
cell.backgroundColor = .themeStyle(dark: .veryDarkGray, light: .white)
94103
}
95104

@@ -107,7 +116,7 @@ class SettingsTableViewController: UITableViewController {
107116
cell.textLabel?.text = cellLabelsForSection0.backgroundMusic.rawValue.localized
108117
cell.accessoryView = backgroundMusicSwitch
109118
case 1:
110-
cell.textLabel?.text = cellLabelsForSection0.hapticFeedback.rawValue.localized
119+
cell.textLabel?.text = cellLabelsForSection0.hapticFeedback.rawValue.localized + "*"
111120
cell.accessoryView = hapticFeedbackSwitch
112121
case 2:
113122
cell.textLabel?.text = cellLabelsForSection0.darkTheme.rawValue.localized
@@ -337,9 +346,9 @@ class SettingsTableViewController: UITableViewController {
337346
})
338347
}
339348

340-
private func resetProgressAlert() {
349+
private func resetProgressAlert(cellIndexpath: IndexPath) {
341350

342-
let alertViewController = UIAlertController(title: "Reset progress".localized, message: nil, preferredStyle: .alert)
351+
let alertViewController = UIAlertController(title: "Reset progress".localized, message: nil, preferredStyle: .actionSheet)
343352

344353
alertViewController.addAction(title: "Cancel".localized, style: .cancel)
345354
alertViewController.addAction(title: "Everything".localized, style: .destructive) { action in
@@ -348,17 +357,24 @@ class SettingsTableViewController: UITableViewController {
348357
alertViewController.addAction(title: "Only Statistics".localized, style: .default) { action in
349358
self.resetProgressStatistics()
350359
}
351-
360+
361+
alertViewController.popoverPresentationController?.sourceView = self.tableView
362+
alertViewController.popoverPresentationController?.sourceRect = self.tableView.rectForRow(at: cellIndexpath)
363+
352364
self.present(alertViewController, animated: true)
353365
}
354366

355-
private func resetCachedImages() {
367+
private func resetCachedImages(cellIndexpath: IndexPath) {
356368

357-
let alertViewController = UIAlertController(title: "Clear cached images".localized, message: nil, preferredStyle: .alert)
369+
let alertViewController = UIAlertController(title: "Clear cached images".localized, message: nil, preferredStyle: .actionSheet)
358370
alertViewController.addAction(title: "Cancel".localized, style: .cancel)
359371
alertViewController.addAction(title: "Reset".localized, style: .destructive) { action in
360372
CachedImages.shared.clear()
361373
}
374+
375+
alertViewController.popoverPresentationController?.sourceView = self.tableView
376+
alertViewController.popoverPresentationController?.sourceRect = self.tableView.rectForRow(at: cellIndexpath)
377+
362378
self.present(alertViewController, animated: true)
363379
}
364380
}

images/screenshots.jpg

64.3 KB
Loading

0 commit comments

Comments
 (0)