generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bugsee configuration screen as a new tab in diagnostic page
- Loading branch information
Showing
12 changed files
with
281 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
Binary file not shown.
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
final class BugseeConfigurationData { | ||
/// Gets whether the Bugsee SDK is enabled or not. if [Null] it fallbacks to a new installed app so it will be enabled. | ||
final bool? isBugseeEnabled; | ||
|
||
/// Indicate whether the video capturing feature in Bugsee is enabled or not. | ||
final bool? isVideoCaptureEnabled; | ||
|
||
const BugseeConfigurationData({ | ||
required this.isBugseeEnabled, | ||
required this.isVideoCaptureEnabled, | ||
}); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:app/access/bugsee/bugsee_configuration_data.dart'; | ||
import 'package:app/access/persistence_exception.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
abstract interface class BugseeRepository { | ||
factory BugseeRepository() = _BugseeRepository; | ||
|
||
///Load the current bugsee configuration stored in shared prefs. | ||
Future<BugseeConfigurationData> getBugseeConfiguration(); | ||
|
||
///Update the current Bugsee enabled flag in shared prefs. | ||
Future setIsBugseeEnabled(bool isBugseeEnabled); | ||
|
||
///Update the current video captured or not flag in shared prefs. | ||
Future setIsVideoCaptureEnabled(bool isVideoCaptureEnabled); | ||
} | ||
|
||
final class _BugseeRepository implements BugseeRepository { | ||
final String _bugseeEnabledKey = 'bugseeEnabledKey'; | ||
final String _videoCaptureKey = 'videoCaptureKey'; | ||
|
||
@override | ||
Future<BugseeConfigurationData> getBugseeConfiguration() async { | ||
final sharedPrefInstance = await SharedPreferences.getInstance(); | ||
return BugseeConfigurationData( | ||
isBugseeEnabled: sharedPrefInstance.getBool(_bugseeEnabledKey), | ||
isVideoCaptureEnabled: sharedPrefInstance.getBool(_videoCaptureKey), | ||
); | ||
} | ||
|
||
@override | ||
Future setIsBugseeEnabled(bool isBugseeEnabled) async { | ||
final sharedPrefInstance = await SharedPreferences.getInstance(); | ||
|
||
bool isSaved = await sharedPrefInstance.setBool( | ||
_bugseeEnabledKey, | ||
isBugseeEnabled, | ||
); | ||
|
||
if (!isSaved) { | ||
throw const PersistenceException(); | ||
} | ||
} | ||
|
||
@override | ||
Future setIsVideoCaptureEnabled(bool isVideoCaptureEnabled) async { | ||
final sharedPrefInstance = await SharedPreferences.getInstance(); | ||
|
||
bool isSaved = await sharedPrefInstance.setBool( | ||
_videoCaptureKey, | ||
isVideoCaptureEnabled, | ||
); | ||
|
||
if (!isSaved) { | ||
throw const PersistenceException(); | ||
} | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.