-
Notifications
You must be signed in to change notification settings - Fork 203
Customizable Time Limits for Alarm Challenges #734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mahendra-918
wants to merge
11
commits into
CCExtractor:main
Choose a base branch
from
mahendra-918:challenge-time-limit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1fff9bb
Create time_imit_view.dart
mahendra-918 2b64c38
Update time_imit_view.dart
mahendra-918 54005c7
Update settings_view.dart
mahendra-918 15d32c1
Update settings_controller.dart
mahendra-918 93a7ceb
Update alarm_challenge_controller.dart
mahendra-918 76ca871
Update alarm_challenge_view.dart
mahendra-918 e43d8de
Update secure_storage_provider.dart
mahendra-918 1c285d5
final code
mahendra-918 8d134d5
changes
mahendra-918 64d61ef
Merge branch 'CCExtractor:main' into challenge-time-limit
mahendra-918 a228fdd
changes
mahendra-918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import 'package:ultimate_alarm_clock/app/data/models/alarm_model.dart'; | |
import 'package:ultimate_alarm_clock/app/utils/audio_utils.dart'; | ||
import 'package:ultimate_alarm_clock/app/utils/constants.dart'; | ||
import 'package:ultimate_alarm_clock/app/utils/utils.dart'; | ||
import 'package:ultimate_alarm_clock/app/data/providers/secure_storage_provider.dart'; // Import secure storage provider | ||
|
||
class AlarmChallengeController extends GetxController { | ||
AlarmModel alarmRecord = Get.arguments; | ||
|
@@ -42,6 +43,7 @@ class AlarmChallengeController extends GetxController { | |
bool shouldProcessStepCount = false; | ||
|
||
late Stream<StepCount> _stepCountStream; | ||
Timer? _timer; | ||
|
||
void onButtonPressed(String buttonText) { | ||
displayValue.value += buttonText; | ||
|
@@ -89,7 +91,7 @@ class AlarmChallengeController extends GetxController { | |
@override | ||
void onInit() async { | ||
super.onInit(); | ||
_startTimer(); | ||
await _startTimer(); | ||
|
||
String ringtoneName = alarmRecord.ringtoneName; | ||
|
||
|
@@ -199,29 +201,23 @@ class AlarmChallengeController extends GetxController { | |
} | ||
} | ||
|
||
void _startTimer() async { | ||
const duration = Duration(seconds: 15); | ||
const totalIterations = 1500000; | ||
const decrement = 0.000001; | ||
|
||
for (var i = totalIterations; i > 0; i--) { | ||
if (!isTimerEnabled) { | ||
debugPrint('THIS IS THE BUG'); | ||
break; | ||
} | ||
if (progress.value <= 0.0) { | ||
Future<void> _startTimer() async { | ||
int challengeTimeLimit = await SecureStorageProvider().readChallengeTimeLimit(); | ||
progress.value = 1.0; | ||
_timer = Timer.periodic(Duration(milliseconds: 100), (timer) { | ||
if (progress.value > 0) { | ||
progress.value -= 1 / (challengeTimeLimit * 10); | ||
} else { | ||
timer.cancel(); | ||
shouldProcessStepCount = false; | ||
Get.until((route) => route.settings.name == '/alarm-ring'); | ||
break; | ||
} | ||
await Future.delayed(duration ~/ i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was done like this to keep the timer decreasing smoothly. |
||
progress.value -= decrement; | ||
} | ||
}); | ||
} | ||
|
||
restartTimer() { | ||
progress.value = 1.0; // Reset the progress to its initial value | ||
_startTimer(); // Start a new timer | ||
_timer?.cancel(); | ||
_startTimer(); | ||
} | ||
|
||
isChallengesComplete() { | ||
|
@@ -235,7 +231,7 @@ class AlarmChallengeController extends GetxController { | |
@override | ||
void onClose() async { | ||
super.onClose(); | ||
|
||
_timer?.cancel(); | ||
shouldProcessStepCount = false; | ||
|
||
String ringtoneName = alarmRecord.ringtoneName; | ||
|
@@ -255,4 +251,3 @@ class AlarmChallengeController extends GetxController { | |
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ class AlarmChallengeView extends GetView<AlarmChallengeController> { | |
|
||
@override | ||
Widget build(BuildContext context) { | ||
// var width = Get.width; | ||
// var height = Get.height; | ||
final double width = MediaQuery.of(context).size.width; | ||
final double height = MediaQuery.of(context).size.height; | ||
|
||
|
@@ -157,7 +155,7 @@ class AlarmChallengeView extends GetView<AlarmChallengeController> { | |
), | ||
Obx( | ||
() => Icon( | ||
controller.isQrOngoing.value == | ||
controller.isMathsOngoing.value == | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have you changed the flag? |
||
Status.completed | ||
? Icons.done | ||
: Icons.arrow_forward_ios_sharp, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bring back these comments, helps us keep track of the logic.