diff --git a/android/app/src/main/kotlin/io/igrant/data4diabetes/MainActivity.kt b/android/app/src/main/kotlin/io/igrant/data4diabetes/MainActivity.kt index ce5fa6e..1ac2c66 100644 --- a/android/app/src/main/kotlin/io/igrant/data4diabetes/MainActivity.kt +++ b/android/app/src/main/kotlin/io/igrant/data4diabetes/MainActivity.kt @@ -60,10 +60,15 @@ class MainActivity : FlutterActivity() { DataWallet.openShareData(this) } "Preferences" -> { - PrivacyDashboard.showPrivacyDashboard().withApiKey("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY0ZjA5Zjc3OGU1ZjM4MDAwMTRhODc5YSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTBhZTFmYmJlMWViNDAwMDE3MTFkODciLCJleHAiOjE3MzAyMjMyODh9.DlU8DjykYr3eBmbgsKLR4dnaChiRqXdxofKOuk4LiRM") - .withUserId("653fe90efec9f34efed23619") - .withOrgId("64f09f778e5f3800014a879a") - .withBaseUrl("https://demo-consent-bb-api.igrant.io/") + val apiKey: String? = call.argument("ApiKey") + val orgId: String? = call.argument("orgId") + val baseUrl: String?= call.argument("baseUrl") + val userId: String?= call.argument("userId") + println("lijo $apiKey,$orgId,$baseUrl,$userId") + PrivacyDashboard.showPrivacyDashboard().withApiKey(apiKey ?: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY0ZjA5Zjc3OGU1ZjM4MDAwMTRhODc5YSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTBhZTFmYmJlMWViNDAwMDE3MTFkODciLCJleHAiOjE3MzAyMjMyODh9.DlU8DjykYr3eBmbgsKLR4dnaChiRqXdxofKOuk4LiRM") + .withUserId(userId ?: "653fe90efec9f34efed23619") + .withOrgId(orgId ?: "64f09f778e5f3800014a879a") + .withBaseUrl(baseUrl ?: "https://demo-consent-bb-api.igrant.io/") // .enableUserRequest() // .enableAskMe() .start(this) diff --git a/lib/app/core/base/base_view.dart b/lib/app/core/base/base_view.dart index be09d9f..dc4b92c 100644 --- a/lib/app/core/base/base_view.dart +++ b/lib/app/core/base/base_view.dart @@ -96,7 +96,8 @@ abstract class BaseView } Color statusBarColor() { - return AppColors.pageBackground; + //return AppColors.pageBackground; + return Colors.transparent; } Widget? floatingActionButton() { diff --git a/lib/app/modules/developerOptions/bindings/credentials_binding.dart b/lib/app/modules/developerOptions/bindings/credentials_binding.dart new file mode 100644 index 0000000..3d02c38 --- /dev/null +++ b/lib/app/modules/developerOptions/bindings/credentials_binding.dart @@ -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(), + ); + } +} \ No newline at end of file diff --git a/lib/app/modules/developerOptions/bindings/dexcom_credential_bindings.dart b/lib/app/modules/developerOptions/bindings/dexcom_credential_bindings.dart new file mode 100644 index 0000000..6dd3243 --- /dev/null +++ b/lib/app/modules/developerOptions/bindings/dexcom_credential_bindings.dart @@ -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(), + ); + } +} \ No newline at end of file diff --git a/lib/app/modules/developerOptions/bindings/privacy_dashboard_credential_bindings.dart b/lib/app/modules/developerOptions/bindings/privacy_dashboard_credential_bindings.dart new file mode 100644 index 0000000..4b1a5e7 --- /dev/null +++ b/lib/app/modules/developerOptions/bindings/privacy_dashboard_credential_bindings.dart @@ -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(), + ); + } +} \ No newline at end of file diff --git a/lib/app/modules/developerOptions/controllers/credentials_controller.dart b/lib/app/modules/developerOptions/controllers/credentials_controller.dart new file mode 100644 index 0000000..98d905c --- /dev/null +++ b/lib/app/modules/developerOptions/controllers/credentials_controller.dart @@ -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()); +} +} \ No newline at end of file diff --git a/lib/app/modules/developerOptions/controllers/dexcom_credential_controller.dart b/lib/app/modules/developerOptions/controllers/dexcom_credential_controller.dart new file mode 100644 index 0000000..a2cfd50 --- /dev/null +++ b/lib/app/modules/developerOptions/controllers/dexcom_credential_controller.dart @@ -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 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 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); + } +} \ No newline at end of file diff --git a/lib/app/modules/developerOptions/controllers/privacy_dashboard_credential_controller.dart b/lib/app/modules/developerOptions/controllers/privacy_dashboard_credential_controller.dart new file mode 100644 index 0000000..cebe926 --- /dev/null +++ b/lib/app/modules/developerOptions/controllers/privacy_dashboard_credential_controller.dart @@ -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(); + } +} diff --git a/lib/app/modules/developerOptions/views/credentials_view.dart b/lib/app/modules/developerOptions/views/credentials_view.dart new file mode 100644 index 0000000..ace761c --- /dev/null +++ b/lib/app/modules/developerOptions/views/credentials_view.dart @@ -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 { + 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'); + // } + }, + ); + + } +} diff --git a/lib/app/modules/developerOptions/views/dexcom_credential_view.dart b/lib/app/modules/developerOptions/views/dexcom_credential_view.dart new file mode 100644 index 0000000..64cb5d8 --- /dev/null +++ b/lib/app/modules/developerOptions/views/dexcom_credential_view.dart @@ -0,0 +1,137 @@ +import 'package:Data4Diabetes/app/core/base/base_view.dart'; +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/values/app_colors.dart'; +import '../../../core/widget/app_bar_title.dart'; +import '../controllers/dexcom_credential_controller.dart'; + +class DexcomCredentialView extends BaseView { + final DexcomCredentailController _dexcomCredentailController = 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: 'Dexcom Credentials'), + ); + } + + @override + Widget body(BuildContext context) { + return Scaffold( + backgroundColor: Palette.backgroundColor, + body: SingleChildScrollView( + child: 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: [ + _baseUrlWidget(), + ], + ), + ), + ), + ), + ); + } + + _baseUrlWidget() { + // return 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: [ + // Padding( + // padding: const EdgeInsets.symmetric( + // horizontal: 0.0, vertical: 3.0), + // child: TextFormField( + // autofocus: false, + // controller:_dexcomCredentailController + // .baseUrlController, + // decoration: const InputDecoration( + // contentPadding: + // EdgeInsets.fromLTRB(16, 0, 0, 0), + // hintText: 'Base URL', + // fillColor: AppColors.pageBackground, + // filled: true, + // errorStyle: + // TextStyle(height: 0, color: Colors.red), + // hintStyle: TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.w400, + // color: AppColors.silverAppBarOverlayColor, + // fontStyle: FontStyle.italic, + // ), + // border: InputBorder.none, + // focusedBorder: InputBorder.none, + // enabledBorder: InputBorder.none, + // errorBorder: InputBorder.none, + // disabledBorder: InputBorder.none, + // ), + // ), + // + // + // ), + // ], + // ), + // ), + // ); + // + return Obx(() { + return ListTileTheme( + dense: true, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + RadioListTile( + title: const Text('Sandbox URL'), + value: true, // Set this to 'true' to make it selected by default + groupValue: + _dexcomCredentailController.firstRadioButtonSelected.value, + onChanged: (value) { + _dexcomCredentailController.updateSelectedValue(value as bool); + _dexcomCredentailController.defaultDexcomEnvironment(); + }, + ), + const Divider(), + RadioListTile( + title: const Text('Limited Users url'), + value: false, // Set this to 'false' as the other option + groupValue: + _dexcomCredentailController.firstRadioButtonSelected.value, + onChanged: (value) { + _dexcomCredentailController.updateSelectedValue(value as bool); + _dexcomCredentailController.limitedDexcomEnvironment(); + }, + ), + ], + ), + ); + }); + } +} diff --git a/lib/app/modules/developerOptions/views/privacy_dashboard_credential_view.dart b/lib/app/modules/developerOptions/views/privacy_dashboard_credential_view.dart new file mode 100644 index 0000000..5d21413 --- /dev/null +++ b/lib/app/modules/developerOptions/views/privacy_dashboard_credential_view.dart @@ -0,0 +1,270 @@ +import 'package:Data4Diabetes/app/core/base/base_view.dart'; +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 '../../../Constants/app_text_files.dart'; +import '../../../core/values/app_colors.dart'; +import '../../../core/widget/app_bar_title.dart'; +import '../controllers/privacy_dashboard_credential_controller.dart'; + +class PrivacyDashboardCredentialView + extends BaseView { + static const double containerRaduis = 20; + final double radiusConst = 18.0; + final double fontSize = 16; + final PrivacyDashboardCredentialController + _privacyDashboardCredentialController = Get.find(); + final GlobalKey formKey = GlobalKey(); + final _validate = false.obs; + @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: 'Privacy Dashboard Credentials'), + ); + } + + @override + Widget body(BuildContext context) { + return Scaffold( + backgroundColor: Palette.backgroundColor, + body: SingleChildScrollView( + child: Form( + key: formKey, + 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: [ + _apiKeyWidget(), + const Divider(), + _baseUrlWidget(), + const Divider(), + _orgIdWidget(), + const Divider(), + _userIdWidget(), + ], + ), + ), + ), + const SizedBox( + height: 20, + ), + _buttonSet(), + ], + ), + ), + ), + ); + } + + _apiKeyWidget() { + return Obx(() { + return TextField( + maxLines: null, + autofocus: false, + controller: _privacyDashboardCredentialController.apiKeyController, + decoration: InputDecoration( + contentPadding: const EdgeInsets.fromLTRB(16, 10, 0, 10), + label: const Text('API Key'), + errorText: _validate.value ? "Please enter a API key" : null, + fillColor: Colors.transparent, + filled: true, + errorStyle: const TextStyle(height: 0, color: Colors.red), + labelStyle: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColors.silverAppBarOverlayColor, + fontStyle: FontStyle.italic, + ), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), + ); + }); + } + + _baseUrlWidget() { + return TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Please enter a base URL'; + } + + return null; + }, + autofocus: false, + controller: _privacyDashboardCredentialController.baseUrlController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(16, 10, 0, 10), + fillColor: Colors.transparent, + filled: true, + errorStyle: TextStyle(height: 0, color: Colors.red), + label: Text('Base URL'), + labelStyle: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColors.silverAppBarOverlayColor, + fontStyle: FontStyle.italic, + ), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), + ); + } + + _orgIdWidget() { + return TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Please enter a organization Id'; + } + + return null; + }, + autofocus: false, + controller: _privacyDashboardCredentialController.orgIdController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(16, 10, 0, 10), + label: Text('Organization ID'), + fillColor: Colors.transparent, + filled: true, + errorStyle: TextStyle(height: 0, color: Colors.red), + labelStyle: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColors.silverAppBarOverlayColor, + fontStyle: FontStyle.italic, + ), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), + ); + } + + _userIdWidget() { + return TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Please enter a user Id'; + } + + return null; + }, + autofocus: false, + controller: _privacyDashboardCredentialController.userIdController, + decoration: const InputDecoration( + contentPadding: EdgeInsets.fromLTRB(16, 10, 0, 10), + label: Text('User ID'), + fillColor: Colors.transparent, + filled: true, + errorStyle: TextStyle(height: 0, color: Colors.red), + labelStyle: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColors.silverAppBarOverlayColor, + fontStyle: FontStyle.italic, + ), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), + ); + } + + _submitButton() { + return ElevatedButton( + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(AppColors.colorAccent), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(radiusConst), + ))), + onPressed: () async { + _validate.value = _privacyDashboardCredentialController + .apiKeyController.text.isEmpty; + if (formKey.currentState?.validate() ?? false) { + _privacyDashboardCredentialController.submitButtonAction(); + } else { + print('At least one form field is invalid'); + } + }, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + 'Submit', + style: AppTextStyles.normalText( + fontSize: fontSize, color: Colors.white), + ), + )); + } + + _resetButton() { + return ElevatedButton( + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(AppColors.colorAccent), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(radiusConst), + ))), + onPressed: () async { + _privacyDashboardCredentialController.resetButtonAction(); + }, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + 'Reset ', + style: AppTextStyles.normalText( + fontSize: fontSize, color: Colors.white), + ), + )); + } + + _buttonSet() { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _resetButton(), + _submitButton(), + ], + ); + } +} diff --git a/lib/app/modules/dexcom/controllers/dexcom_controller.dart b/lib/app/modules/dexcom/controllers/dexcom_controller.dart index 208910c..c8c18a6 100644 --- a/lib/app/modules/dexcom/controllers/dexcom_controller.dart +++ b/lib/app/modules/dexcom/controllers/dexcom_controller.dart @@ -31,9 +31,10 @@ class DexcomController extends BaseController { Timer? timer; final UserRepositoryImpl _impl = UserRepositoryImpl(); @override - void onInit() { - - dexComBaseUrl.value = BuildConfig.instance.config.dexComBaseUrl!; + Future onInit() async { + final prefs = await SharedPreferences.getInstance(); + var dexcomBaseURL=prefs.getString('dexcomStoredBaseUrl'); + dexComBaseUrl.value =dexcomBaseURL?? BuildConfig.instance.config.dexComBaseUrl!; clientID = _dexcomValues.clientID; clientSecret = _dexcomValues.clientSecret; redirectUri = _dexcomValues.redirectUri; diff --git a/lib/app/modules/launcher/bindings/launcher_binding.dart b/lib/app/modules/launcher/bindings/launcher_binding.dart index 7905174..e76e688 100644 --- a/lib/app/modules/launcher/bindings/launcher_binding.dart +++ b/lib/app/modules/launcher/bindings/launcher_binding.dart @@ -6,6 +6,9 @@ import 'package:Data4Diabetes/app/modules/termsOfService/controllers/termsOfServ import 'package:get/get.dart'; import '../../Otp/controllers/otp_controller.dart'; import '../../Register/controllers/register_controller.dart'; +import '../../developerOptions/controllers/credentials_controller.dart'; +import '../../developerOptions/controllers/dexcom_credential_controller.dart'; +import '../../developerOptions/controllers/privacy_dashboard_credential_controller.dart'; import '../../home/controllers/home_controller.dart'; import '../../language/controllers/language_controller.dart'; import '../../login/controllers/login_controller.dart'; @@ -56,7 +59,6 @@ class LauncherBinding extends Bindings { () => PrivacyPolicyController(), fenix: true, ); - Get.lazyPut( () => InsightsController(), fenix: true, @@ -69,5 +71,17 @@ class LauncherBinding extends Bindings { () => DexcomController(), fenix: true, ); + Get.lazyPut( + () => CredentialsController(), + fenix: true, + ); + Get.lazyPut( + () => PrivacyDashboardCredentialController(), + fenix: true, + ); + Get.lazyPut( + () => DexcomCredentailController(), + fenix: true, + ); } } diff --git a/lib/app/modules/login/bindings/login_binding.dart b/lib/app/modules/login/bindings/login_binding.dart index d3af168..c0cd326 100644 --- a/lib/app/modules/login/bindings/login_binding.dart +++ b/lib/app/modules/login/bindings/login_binding.dart @@ -7,6 +7,9 @@ import 'package:Data4Diabetes/app/modules/privacyPolicy/controllers/privacyPolic import 'package:get/get.dart'; import '../../../bindings/initial_binding.dart'; +import '../../developerOptions/controllers/credentials_controller.dart'; +import '../../developerOptions/controllers/dexcom_credential_controller.dart'; +import '../../developerOptions/controllers/privacy_dashboard_credential_controller.dart'; import '../../home/controllers/home_controller.dart'; import '../../language/controllers/language_controller.dart'; import '../../main/controllers/main_controller.dart'; @@ -62,5 +65,17 @@ class LoginBinding extends Bindings { () => TermsOfServiceController(), fenix: true, ); + Get.lazyPut( + () => CredentialsController(), + fenix: true, + ); + Get.lazyPut( + () => PrivacyDashboardCredentialController(), + fenix: true, + ); + Get.lazyPut( + () => DexcomCredentailController(), + fenix: true, + ); } } diff --git a/lib/app/modules/settings/views/settings_view.dart b/lib/app/modules/settings/views/settings_view.dart index f29290a..b7d2107 100644 --- a/lib/app/modules/settings/views/settings_view.dart +++ b/lib/app/modules/settings/views/settings_view.dart @@ -9,11 +9,10 @@ import 'package:Data4Diabetes/app/modules/settings/controllers/settings_controll import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:webview_flutter/webview_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:webview_flutter/webview_flutter.dart'; import '../../../core/values/app_colors.dart'; import '../../../core/widget/app_bar_title.dart'; +import '../../developerOptions/views/credentials_view.dart'; import '/app/core/base/base_view.dart'; import '/app/core/widget/custom_app_bar.dart'; import 'dart:io' show Platform; @@ -255,8 +254,18 @@ class SettingsView extends BaseView { Icons.arrow_forward_ios, size: 15.0, ), - onTap: () { - _settingsController.platform.invokeMethod('Preferences'); + onTap: () 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'); + _settingsController.platform.invokeMethod('Preferences', { + "ApiKey": apiKey, + "orgId": orgId, + "baseUrl": baseUrl, + "userId":userId + }); }, ); } @@ -264,30 +273,35 @@ class SettingsView extends BaseView { Widget _igrantLogo() { _settingsController.packageInfo(); - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Image.asset( - 'images/igrant_icon.png', - height: imagelogoHeight, - ), - InkWell( - onTap: () { - Get.to(PrivacyPolicyView()); - }, - child: Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: Text(appLocalization.settingsPrivacyPolicy, - style: const TextStyle(fontSize: 14)), - )), - Text("v " + - _settingsController.ver.value + - " - " + - _settingsController.build.value), - const SizedBox( - height: 10, - ), - ], + return GestureDetector( + onLongPress: (){ + Get.to(CredentailsView()); + }, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset( + 'images/igrant_icon.png', + height: imagelogoHeight, + ), + InkWell( + onTap: () { + Get.to(PrivacyPolicyView()); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text(appLocalization.settingsPrivacyPolicy, + style: const TextStyle(fontSize: 14)), + )), + Text("v " + + _settingsController.ver.value + + " - " + + _settingsController.build.value), + const SizedBox( + height: 10, + ), + ], + ), ); } @@ -385,65 +399,6 @@ class SettingsView extends BaseView { onTap: () { _settingsController.dexcomLoginWidget(context); }, - onLongPress: () { - _showDialogueWidget(context); - }, - ); - } - - void _showDialogueWidget(BuildContext context) { - - showDialog( - context: context, - builder: (BuildContext context) { - return Obx((){ - return AlertDialog( - title: Text('Switch Dexcom Envionment'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - RadioListTile( - title: Text('Default url'), - value: true, - groupValue: _settingsController.firstRadioButtonSelected.value, - - onChanged: (value) { - _settingsController.firstRadioButtonSelected.value = - value as bool; - _settingsController.defaultDexcomEnvironment(); - - - }, - ), - RadioListTile( - title: Text('Limited Users url'), - value: false, - groupValue: _settingsController.firstRadioButtonSelected.value, - onChanged: (value) { - _settingsController.firstRadioButtonSelected.value = - value as bool; - _settingsController.limitedDexcomEnvironment(); - }, - ), - ], - ), - actions: [ - Center( - child: ElevatedButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Padding( - padding: EdgeInsets.symmetric(horizontal: 15,vertical: 8.0), - child: Text('Close',style: TextStyle(color: Colors.white),), - ), - ), - ), - ], - ); - }); - - }, ); } } diff --git a/lib/app/routes/app_pages.dart b/lib/app/routes/app_pages.dart index 626ba1f..ad66a13 100644 --- a/lib/app/routes/app_pages.dart +++ b/lib/app/routes/app_pages.dart @@ -23,6 +23,12 @@ import 'package:Data4Diabetes/app/modules/termsOfService/views/termsOfService_vi import 'package:get/get.dart'; import '../data/local/preference/preference_manager_impl.dart'; +import '../modules/developerOptions/bindings/credentials_binding.dart'; +import '../modules/developerOptions/bindings/dexcom_credential_bindings.dart'; +import '../modules/developerOptions/bindings/privacy_dashboard_credential_bindings.dart'; +import '../modules/developerOptions/views/credentials_view.dart'; +import '../modules/developerOptions/views/dexcom_credential_view.dart'; +import '../modules/developerOptions/views/privacy_dashboard_credential_view.dart'; import '/app/modules/home/bindings/home_binding.dart'; import '/app/modules/home/views/home_view.dart'; import '/app/modules/main/bindings/main_binding.dart'; @@ -100,5 +106,20 @@ class AppPages { page: () => TermsOfServiceView(), binding: TermsOfServiceBinding(), ), + GetPage( + name: _Paths.CREDENTIALSPANEL, + page: () => CredentailsView(), + binding: CredentialsBinding(), + ), + GetPage( + name: _Paths.PRIVACYDASHBOARDCREDENTIAL, + page: () => PrivacyDashboardCredentialView(), + binding: PrivacyDashboardCredentialsBinding(), + ), + GetPage( + name: _Paths.DEXCOMCREDENTIAL, + page: () => DexcomCredentialView(), + binding: DexcomCredentialsBinding(), + ), ]; } diff --git a/lib/app/routes/app_routes.dart b/lib/app/routes/app_routes.dart index 82e0db2..fd36fa9 100644 --- a/lib/app/routes/app_routes.dart +++ b/lib/app/routes/app_routes.dart @@ -16,6 +16,9 @@ abstract class Routes { static const PRIVACYPOLICY = _Paths.PRIVACYPOLICY; static const INSIGHTS = _Paths.INSIGHTS; static const TERMSOFSERVICE = _Paths.TERMSOFSERVICE; + static const CREDENTIALSPANEL = _Paths.CREDENTIALSPANEL; + static const PRIVACYDASHBOARDCREDENTIAL = _Paths.PRIVACYDASHBOARDCREDENTIAL; + static const DEXCOMCREDENTIAL = _Paths.DEXCOMCREDENTIAL; } abstract class _Paths { @@ -32,4 +35,7 @@ abstract class _Paths { static const PRIVACYPOLICY = '/privacyPolicy'; static const INSIGHTS = '/insights'; static const TERMSOFSERVICE = '/termsOfService'; + static const CREDENTIALSPANEL = '/credentialsPanel'; + static const PRIVACYDASHBOARDCREDENTIAL = '/credentialsPanel'; + static const DEXCOMCREDENTIAL = '/credentialsPanel'; }