@@ -88,29 +88,28 @@ class QuestionsViewController: UIViewController {
8888 // If user shake the device, an alert to repeat the quiz pop ups
8989 override func motionEnded( _ motion: UIEventSubtype , with event: UIEvent ? ) {
9090
91- if motion == . motionShake {
91+ guard motion == . motionShake else { return }
92+
93+ let currentQuestion = Int ( String ( remainingQuestionsLabel. text? . characters. first ?? " 0 " ) ) ?? 0
94+
95+ if #available( iOS 10 . 0 , * ) , Settings . sharedInstance. hapticFeedbackEnabled {
96+ let feedbackGenerator = UIImpactFeedbackGenerator ( style: . medium)
97+ feedbackGenerator. impactOccurred ( )
98+ }
99+
100+ if repeatTimes < 2 && currentQuestion > 1 {
92101
93- let currentQuestion = Int ( String ( remainingQuestionsLabel. text? . characters. first ?? " 0 " ) ) ?? 0
102+ let alertViewController = UIAlertController ( title: " Repeat? " . localized,
103+ message: " Do you want to start again? " . localized,
104+ preferredStyle: . alert)
94105
95- if repeatTimes < 2 && currentQuestion > 1 {
96-
97- if #available( iOS 10 . 0 , * ) , Settings . sharedInstance. hapticFeedbackEnabled {
98- let feedbackGenerator = UIImpactFeedbackGenerator ( style: . medium)
99- feedbackGenerator. impactOccurred ( )
100- }
101-
102- let alertViewController = UIAlertController ( title: " Repeat? " . localized,
103- message: " Do you want to start again? " . localized,
104- preferredStyle: . alert)
105-
106- alertViewController. addAction ( title: " OK " . localized, style: . default) { action in self . repeatActionDetailed ( ) }
107- alertViewController. addAction ( title: " Cancel " . localized, style: . cancel, handler: nil )
108-
109- present ( alertViewController, animated: true , completion: nil )
110- }
111- else if repeatTimes >= 2 {
112- showOKAlertWith ( title: " Attention " , message: " Maximum help tries per question reached " )
113- }
106+ alertViewController. addAction ( title: " OK " . localized, style: . default) { action in self . repeatActionDetailed ( ) }
107+ alertViewController. addAction ( title: " Cancel " . localized, style: . cancel, handler: nil )
108+
109+ present ( alertViewController, animated: true , completion: nil )
110+ }
111+ else if repeatTimes >= 2 {
112+ showOKAlertWith ( title: " Attention " , message: " Maximum help tries per question reached " )
114113 }
115114 }
116115
@@ -313,7 +312,7 @@ class QuestionsViewController: UIViewController {
313312 answerButtons [ 2 ] . frame = CGRect ( x: xPosition, y: yPosition4 - fullLabelHeight, width: labelWidth, height: labelHeight)
314313 answerButtons [ 3 ] . frame = CGRect ( x: xPosition, y: yPosition4, width: labelWidth, height: labelHeight)
315314
316- let currentStatusBarHeight = isPortrait ? self . statusBarHeight : 0.0
315+ let currentStatusBarHeight = isPortrait ? statusBarHeight : 0.0
317316 let yPosition6 = ( ( yPosition / 2.0 ) - labelHeight) + currentStatusBarHeight + ( pauseButton. bounds. height / 2.0 )
318317 questionLabel. frame = CGRect ( x: xPosition, y: yPosition6, width: labelWidth, height: labelHeight * 2 )
319318
@@ -347,7 +346,7 @@ class QuestionsViewController: UIViewController {
347346 }
348347 }
349348 else {
350- self . endOfQuestionsAlert ( )
349+ endOfQuestionsAlert ( )
351350 }
352351 }
353352
@@ -414,7 +413,7 @@ class QuestionsViewController: UIViewController {
414413 self . answerButtons [ Int ( answer) ] . backgroundColor = . themeStyle( dark: . orange, light: . defaultTintColor)
415414 }
416415
417- self . pickQuestion ( )
416+ pickQuestion ( )
418417 }
419418
420419 func pausePreviousSounds( ) {
0 commit comments