@@ -24,13 +24,11 @@ final class SettingsTableViewController: SettingTableViewController {
2424 @IBOutlet var appVersionLabel : UILabel !
2525 @IBOutlet var designedByLabel : UILabel !
2626
27- // MARK: - Localizable Outlets.
28-
2927 /// Switch types.
30-
3128 private enum Switch : Int {
3229 case Sounds = 0
33- case MotionEffects = 1
30+ case Haptics = 1
31+ case MotionEffects = 2
3432 }
3533
3634 // MARK: - View Life Cycle.
@@ -52,7 +50,6 @@ final class SettingsTableViewController: SettingTableViewController {
5250 }
5351
5452 /// Localize interface.
55-
5653 override func localizeInterface( ) {
5754 super. localizeInterface ( )
5855
@@ -62,7 +59,6 @@ final class SettingsTableViewController: SettingTableViewController {
6259 }
6360
6461 /// Configure app icon to be cornered.
65-
6662 fileprivate func configureAppIconImage( ) {
6763 appIconImageView. cornerRadius = 6
6864 appIconImageView. layer. masksToBounds = true
@@ -74,7 +70,6 @@ final class SettingsTableViewController: SettingTableViewController {
7470 }
7571
7672 /// Configure icon image views.
77-
7873 fileprivate func configureIconImages( ) {
7974 iconImageViews. forEach {
8075 // Bulk set image tint colors
@@ -84,13 +79,14 @@ final class SettingsTableViewController: SettingTableViewController {
8479 }
8580
8681 /// Configure switches.
87-
8882 fileprivate func configureSwitches( ) {
8983 switches. forEach {
9084 switch $0. tag {
9185 case Switch . Sounds. rawValue:
9286 // Sounds switch
9387 $0. setOn ( UserDefaultManager . settingSoundsEnabled ( ) , animated: false )
88+ case Switch . Haptics. rawValue:
89+ $0. setOn ( UserDefaultManager . settingHapticsEnabled ( ) , animated: false )
9490 case Switch . MotionEffects. rawValue:
9591 // Motion switch
9692 $0. setOn ( UserDefaultManager . settingMotionEffectsEnabled ( ) , animated: false )
@@ -101,7 +97,6 @@ final class SettingsTableViewController: SettingTableViewController {
10197 }
10298
10399 /// Set up table view.
104-
105100 internal override func setupTableView( ) {
106101 super. setupTableView ( )
107102
@@ -110,19 +105,16 @@ final class SettingsTableViewController: SettingTableViewController {
110105 }
111106
112107 /// Set cell labels
113-
114108 override func getCellLabels( ) -> [ UILabel ] ? {
115109 return cellLabels
116110 }
117111
118112 /// Set app version text.
119-
120113 fileprivate func setVersionText( ) {
121114 appVersionLabel. text = Bundle . main. localizedVersionLabelString
122115 }
123116
124117 /// Set up designed and developed label.
125-
126118 fileprivate func setDesignedByText( ) {
127119 let text = " designed by " . localized
128120 let separatedText = text. components ( separatedBy: " | " )
@@ -134,60 +126,27 @@ final class SettingsTableViewController: SettingTableViewController {
134126 }
135127
136128 /// Sounds switch value changed.
137-
138129 @IBAction func soundsSwitchChanged( _ sender: UISwitch ) {
139130 UserDefaultManager . set ( value: sender. isOn, forKey: . Sounds)
140131 }
141132
142- /// Motion effects switch changed.
133+ /// Haptics switch changed.
134+ @IBAction func hapticsSwitchChanged( _ sender: UISwitch ) {
135+ UserDefaultManager . set ( value: sender. isOn, forKey: . Haptics)
136+ }
143137
138+ /// Motion effects switch changed.
144139 @IBAction func motionEffectSwitchChanged( _ sender: UISwitch ) {
145140 UserDefaultManager . set ( value: sender. isOn, forKey: . MotionEffects)
146141 NotificationManager . send ( notification: . SettingMotionEffectsChanged)
147142 }
148143
149- /// Authentication switch value changed.
150-
151- @IBAction func authenticationSwitchChanged( _ sender: UISwitch ) {
152- let context = LAContext ( )
153- let reason = " permission.authentication.reason " . localized
154-
155- var authError : NSError ?
156-
157- if context. canEvaluatePolicy ( . deviceOwnerAuthenticationWithBiometrics, error: & authError) {
158- context. evaluatePolicy ( . deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, evaluateError in
159- if success {
160- // User authenticated successfully
161- DispatchQueue . main. async {
162- UserDefaultManager . set ( value: sender. isOn, forKey: . LockBiometric)
163- }
164- } else {
165- // User did not authenticate successfully
166- self . authenticationFailed ( sender)
167- }
168- }
169- } else {
170- // Could not evaluate policy
171- authenticationFailed ( sender)
172- }
173- }
174-
175- /// Set authentication switch to off state.
176-
177- private func authenticationFailed( _ sender: UISwitch ) {
178- DispatchQueue . main. async {
179- sender. setOn ( false , animated: true )
180- }
181- }
182-
183144 /// When cell is about to be displayed.
184-
185145 override func tableView( _ tableView: UITableView , willDisplay cell: UITableViewCell , forRowAt indexPath: IndexPath ) {
186146 cell. prepareDisclosureIndicator ( )
187147 }
188148
189149 /// Table header titles.
190-
191150 override func tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
192151 switch section {
193152 case 0 :
@@ -201,26 +160,7 @@ final class SettingsTableViewController: SettingTableViewController {
201160 }
202161 }
203162
204- /// Table view rows.
205-
206- // override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
207- // switch section {
208- // case 0:
209- // // Generals
210- // return 3
211- // case 1:
212- // // Look & Feel
213- // return 3
214- // case 2:
215- // // Privacy
216- // return 1
217- // default:
218- // return 1
219- // }
220- // }
221-
222163 /// Prepare for segue.
223-
224164 override func prepare( for segue: UIStoryboardSegue , sender: Any ? ) {
225165 DispatchQueue . main. async {
226166 // Generate haptic feedback
0 commit comments