Closed YassinNouh21 closed 3 months ago
Please move the initialization of
_initialRealTime
,_initialDebugTime
&_timeDifference
to the now() method itself. This way, the time difference will be recalculated every time without needing to restart the app to see the changes.
do you mean this.
static DateTime now() {
final DateTime _initialRealTime = DateTime.now();
final DateTime _initialDebugTime = DateTime(
_initialRealTime.year,
_initialRealTime.month,
_initialRealTime.day,
13,
5
);
final _timeDifference = _initialDebugTime.difference(_initialRealTime);
if (kDebugMode) {
return DateTime.now().add(_timeDifference);
} else {
return FeatureManagerProvider.featureManager
.isFeatureEnabled("timezone_shift") &&
_timeManager.deviceModel == "MAWABOX" &&
_timeManager.isLauncherInstalled
? DateTime.now().add(Duration(
hours: _timeManager.shift, minutes: _timeManager.shiftInMinutes))
: DateTime.now();
}
}
๐ Summary
This PR introduces improvements to the handling of debug time in the application, making it easier to test and debug time-related features.
This PR is for issue
1075
Description
The changes in this PR refactor the way debug time is calculated and used within the application. Previously, a static
difference
was used to simulate time changes for debugging. This approach was less flexible and could lead to confusion during development. The new implementation introduces_initialRealTime
and_initialDebugTime
, along with a computed_timeDifference
that allows for more intuitive and manageable debugging of time-dependent features. This change aims to facilitate easier testing and development by providing a clear and adjustable method for simulating different times within the app.Tests
๐งช Use case 1
๐ฌ Description: Testing the functionality of the debug time adjustment feature.
_initialDebugTime
to a different time.๐ท Screenshots or GIFs (if applicable):
Checklist: