-
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.
To test demo, and staging environment from the app side, developers can change the API key, base URL, org ID, and user ID.
- Loading branch information
1 parent
c1fe26a
commit 803f2e7
Showing
17 changed files
with
812 additions
and
96 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
14 changes: 14 additions & 0 deletions
14
lib/app/modules/developerOptions/bindings/credentials_binding.dart
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,14 @@ | ||
|
||
import 'package:get/get.dart'; | ||
import 'package:get/get_instance/src/bindings_interface.dart'; | ||
|
||
import '../controllers/credentials_controller.dart'; | ||
|
||
class CredentialsBinding extends Bindings { | ||
@override | ||
void dependencies() { | ||
Get.lazyPut<CredentialsController>( | ||
() => CredentialsController(), | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/app/modules/developerOptions/bindings/dexcom_credential_bindings.dart
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,14 @@ | ||
|
||
import 'package:get/get.dart'; | ||
import 'package:get/get_instance/src/bindings_interface.dart'; | ||
|
||
import '../controllers/dexcom_credential_controller.dart'; | ||
|
||
class DexcomCredentialsBinding extends Bindings { | ||
@override | ||
void dependencies() { | ||
Get.lazyPut<DexcomCredentailController>( | ||
() => DexcomCredentailController(), | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/app/modules/developerOptions/bindings/privacy_dashboard_credential_bindings.dart
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,14 @@ | ||
|
||
import 'package:get/get.dart'; | ||
import 'package:get/get_instance/src/bindings_interface.dart'; | ||
|
||
import '../controllers/privacy_dashboard_credential_controller.dart'; | ||
|
||
class PrivacyDashboardCredentialsBinding extends Bindings { | ||
@override | ||
void dependencies() { | ||
Get.lazyPut<PrivacyDashboardCredentialController>( | ||
() => PrivacyDashboardCredentialController(), | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
lib/app/modules/developerOptions/controllers/credentials_controller.dart
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,15 @@ | ||
import 'package:Data4Diabetes/app/core/base/base_controller.dart'; | ||
|
||
import 'package:get/get.dart'; | ||
|
||
import '../views/dexcom_credential_view.dart'; | ||
import '../views/privacy_dashboard_credential_view.dart'; | ||
|
||
class CredentialsController extends BaseController{ | ||
setPrivacyDashboardCred(){ | ||
Get.to(PrivacyDashboardCredentialView()); | ||
} | ||
setDexcomCred(){ | ||
Get.to(DexcomCredentialView()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
lib/app/modules/developerOptions/controllers/dexcom_credential_controller.dart
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,53 @@ | ||
import 'package:Data4Diabetes/app/core/base/base_controller.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
import '../../../../flavors/build_config.dart'; | ||
import '../../Dexcom/controllers/dexcom_controller.dart'; | ||
|
||
class DexcomCredentailController extends BaseController{ | ||
final DexcomController _dexcomController = Get.find(); | ||
var firstRadioButtonSelected = true.obs; | ||
final TextEditingController baseUrlController = TextEditingController(); | ||
@override | ||
void onInit() async { | ||
super.onInit(); | ||
// Retrieve the stored value from SharedPreferences | ||
final prefs = await SharedPreferences.getInstance(); | ||
final storedValue = prefs.getBool('firstRadioButtonSelected'); | ||
|
||
if (storedValue != null) { | ||
// Use the stored value if it exists | ||
firstRadioButtonSelected.value = storedValue; | ||
} else { | ||
// If no value is stored, set the default value | ||
firstRadioButtonSelected.value = true; | ||
|
||
// You may also want to store the default value | ||
prefs.setBool('firstRadioButtonSelected', true); | ||
} | ||
} | ||
// Update the selected value and store it in SharedPreferences | ||
void updateSelectedValue(bool value) async { | ||
firstRadioButtonSelected.value = value; | ||
final prefs = await SharedPreferences.getInstance(); | ||
prefs.setBool('firstRadioButtonSelected', value); | ||
} | ||
Future<void> defaultDexcomEnvironment() async { | ||
final prefs = await SharedPreferences.getInstance(); | ||
prefs.setString('dexcomStoredBaseUrl', BuildConfig.instance.config.dexComBaseUrl!); | ||
_dexcomController.dexComBaseUrl.value = | ||
BuildConfig.instance.config.dexComBaseUrl!; | ||
Get.rawSnackbar(message: 'Changed url successfully',backgroundColor: Colors.green); | ||
} | ||
|
||
Future<void> limitedDexcomEnvironment() async { | ||
final prefs = await SharedPreferences.getInstance(); | ||
prefs.setString('dexcomStoredBaseUrl', 'https://api.dexcom.com'); | ||
_dexcomController.dexComBaseUrl.value = 'https://api.dexcom.com'; | ||
|
||
print('changed url${_dexcomController.dexComBaseUrl.value}'); | ||
Get.rawSnackbar(message: 'Changed url successfully',backgroundColor: Colors.green); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
lib/app/modules/developerOptions/controllers/privacy_dashboard_credential_controller.dart
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,66 @@ | ||
import 'package:Data4Diabetes/app/core/base/base_controller.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class PrivacyDashboardCredentialController extends BaseController { | ||
var platform = const MethodChannel('io.igrant.data4diabetes.channel'); | ||
|
||
final TextEditingController apiKeyController = TextEditingController(); | ||
final TextEditingController baseUrlController = TextEditingController(); | ||
final TextEditingController orgIdController = TextEditingController(); | ||
final TextEditingController userIdController = TextEditingController(); | ||
@override | ||
void onInit() { | ||
super.onInit(); | ||
privacyDashboardCredentials(); | ||
} | ||
|
||
privacyDashboardCredentials() async { | ||
SharedPreferences _prefs = await SharedPreferences.getInstance(); | ||
var apiKey = _prefs.getString('privacyDashboardApiKey'); | ||
var orgId = _prefs.getString('privacyDashboardorgId'); | ||
var baseUrl = _prefs.getString('privacyDashboardbaseUrl'); | ||
var userId = _prefs.getString('privacyDashboarduserId'); | ||
print('apikey now:$apiKey'); | ||
apiKey != null | ||
? apiKeyController.text = apiKey | ||
: apiKeyController.text = | ||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY0ZjA5Zjc3OGU1ZjM4MDAwMTRhODc5YSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTBhZTFmYmJlMWViNDAwMDE3MTFkODciLCJleHAiOjE3MzAyMjMyODh9.DlU8DjykYr3eBmbgsKLR4dnaChiRqXdxofKOuk4LiRM"; | ||
orgId != null | ||
? orgIdController.text = orgId | ||
: orgIdController.text = "64f09f778e5f3800014a879a"; | ||
baseUrl != null | ||
? baseUrlController.text = baseUrl | ||
: baseUrlController.text = "https://demo-consent-bb-api.igrant.io/"; | ||
userId != null | ||
? userIdController.text = userId | ||
: userIdController.text = "653fe90efec9f34efed23619"; | ||
print('apiKeyController.text${apiKeyController.text}'); | ||
} | ||
|
||
submitButtonAction() async { | ||
SharedPreferences _prefs = await SharedPreferences.getInstance(); | ||
_prefs.setString('privacyDashboardApiKey', apiKeyController.text); | ||
_prefs.setString('privacyDashboardorgId', orgIdController.text); | ||
_prefs.setString('privacyDashboardbaseUrl', baseUrlController.text); | ||
_prefs.setString('privacyDashboarduserId', userIdController.text); | ||
Get.rawSnackbar( | ||
message: 'updated credentials successfully', | ||
backgroundColor: Colors.green); | ||
privacyDashboardCredentials(); | ||
} | ||
resetButtonAction() async { | ||
SharedPreferences _prefs = await SharedPreferences.getInstance(); | ||
_prefs.setString('privacyDashboardApiKey', "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY0ZjA5Zjc3OGU1ZjM4MDAwMTRhODc5YSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTBhZTFmYmJlMWViNDAwMDE3MTFkODciLCJleHAiOjE3MzAyMjMyODh9.DlU8DjykYr3eBmbgsKLR4dnaChiRqXdxofKOuk4LiRM"); | ||
_prefs.setString('privacyDashboardorgId', "64f09f778e5f3800014a879a"); | ||
_prefs.setString('privacyDashboardbaseUrl', "https://demo-consent-bb-api.igrant.io/"); | ||
_prefs.setString('privacyDashboarduserId', "653fe90efec9f34efed23619"); | ||
privacyDashboardCredentials(); | ||
Get.rawSnackbar( | ||
message: 'Reset to default credentials', | ||
backgroundColor: Colors.green); | ||
privacyDashboardCredentials(); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
lib/app/modules/developerOptions/views/credentials_view.dart
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,115 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/src/widgets/framework.dart'; | ||
import 'package:flutter/src/widgets/preferred_size.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import '../../../Constants/Palette.dart'; | ||
import '../../../core/base/base_view.dart'; | ||
import '../../../core/values/app_colors.dart'; | ||
import '../../../core/widget/app_bar_title.dart'; | ||
import '../controllers/credentials_controller.dart'; | ||
|
||
class CredentailsView extends BaseView<CredentialsController> { | ||
final CredentialsController _credentialsController = Get.find(); | ||
static const double containerRaduis = 20; | ||
@override | ||
PreferredSizeWidget? appBar(BuildContext context) { | ||
return AppBar( | ||
backgroundColor: Palette.backgroundColor, | ||
//centerTitle: true, | ||
elevation: 0, | ||
automaticallyImplyLeading: true, | ||
leading: IconButton( | ||
onPressed: () { | ||
Get.back(); | ||
}, | ||
icon: const Icon(Icons.arrow_back_ios), | ||
), | ||
iconTheme: const IconThemeData(color: AppColors.appBarIconColor), | ||
title: const AppBarTitle(text: 'Developer Options'), | ||
); | ||
} | ||
|
||
@override | ||
Widget body(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: Palette.backgroundColor, | ||
body: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: | ||
const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), | ||
child: Container( | ||
decoration: BoxDecoration( | ||
color: Palette.white, | ||
border: Border.all(color: Palette.white), | ||
borderRadius: const BorderRadius.all( | ||
Radius.circular(containerRaduis))), | ||
child: Column( | ||
children: [ | ||
_privacyDashboardCredWidget(), | ||
const Divider(), | ||
_dexcomCredWidget(), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
_privacyDashboardCredWidget() { | ||
return ListTile( | ||
dense: true, | ||
visualDensity: const VisualDensity(horizontal: 0, vertical: -3), | ||
title: const Text( | ||
'Privacy Dashboard', | ||
style: TextStyle( | ||
fontSize: 14, | ||
), | ||
), | ||
trailing: const Icon( | ||
Icons.arrow_forward_ios, | ||
size: 15.0, | ||
), | ||
onTap: () { | ||
// if (Platform.isAndroid) { | ||
|
||
_credentialsController.setPrivacyDashboardCred(); | ||
// } else if (Platform.isIOS) { | ||
// showToast('Coming soon'); | ||
// } | ||
}, | ||
); | ||
|
||
} | ||
|
||
_dexcomCredWidget() { | ||
return ListTile( | ||
dense: true, | ||
visualDensity: const VisualDensity(horizontal: 0, vertical: -3), | ||
title: const Text( | ||
'Dexcom', | ||
style: TextStyle( | ||
fontSize: 14, | ||
), | ||
), | ||
trailing: const Icon( | ||
Icons.arrow_forward_ios, | ||
size: 15.0, | ||
), | ||
onTap: () { | ||
// if (Platform.isAndroid) { | ||
_credentialsController.setDexcomCred(); | ||
// } else if (Platform.isIOS) { | ||
// showToast('Coming soon'); | ||
// } | ||
}, | ||
); | ||
|
||
} | ||
} |
Oops, something went wrong.