From 71c8e68beb8855f6fc5b475a873140037d6ce50a Mon Sep 17 00:00:00 2001 From: Rakshithasai123 Date: Fri, 14 Nov 2025 12:23:51 +0530 Subject: [PATCH 1/4] In the global config settings without making any of the changes Submit button should not enabled Signed-off-by: Rakshithasai123 # Conflicts: # lib/ui/settings/widgets/global_config_settings_tab.dart --- .../widgets/global_config_settings_tab.dart | 92 +++++++------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/lib/ui/settings/widgets/global_config_settings_tab.dart b/lib/ui/settings/widgets/global_config_settings_tab.dart index 98eb3adfc..430f6c05e 100644 --- a/lib/ui/settings/widgets/global_config_settings_tab.dart +++ b/lib/ui/settings/widgets/global_config_settings_tab.dart @@ -26,6 +26,9 @@ class _GlobalConfigSettingsTabState extends State { final Map _controllers = {}; bool isLoading = true; String? errorMessage; + Map originalLocalConfig = {}; + Map currentLocalConfig = {}; + bool isModified = false; @override void initState() { @@ -56,7 +59,7 @@ class _GlobalConfigSettingsTabState extends State { text: _getLocalValue(key) == '-' ? '' : _getLocalValue(key), ); } - + originalLocalConfig = Map.from(localConfigurations); setState(() { isLoading = false; }); @@ -110,25 +113,11 @@ class _GlobalConfigSettingsTabState extends State { } for (String key in localValues.keys) { - final String localValue = localValues[key]!; - final String? previousLocal = localConfigurations[key]; - - if (localValue.isEmpty) { - if (previousLocal != null) { - return true; - } - final String serverValue = serverValues?[key]?.toString() ?? ''; - if (serverValue.isNotEmpty) { - return true; - } - continue; - } + String original = originalLocalConfig[key] ?? ""; + String current = localValues[key] ?? ""; - if (previousLocal == null || previousLocal != localValue) { - return true; - } + if (original != current) return true; } - return false; } @@ -187,6 +176,8 @@ class _GlobalConfigSettingsTabState extends State { // Save configuration changes await GlobalConfigSettingsApi().modifyConfigurations(localValues); + originalLocalConfig = Map.from(localConfigurations); + currentLocalConfig = Map.from(localConfigurations); // Update local configurations with the saved values setState(() { @@ -325,26 +316,6 @@ class _GlobalConfigSettingsTabState extends State { ], ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, - floatingActionButton: SafeArea( - top: false, - child: Padding( - padding: const EdgeInsets.only(right: 16), - child: ElevatedButton( - onPressed: _onSaveChanges, - style: ElevatedButton.styleFrom( - backgroundColor: solidPrimary, - foregroundColor: Colors.white, - padding: const EdgeInsets.symmetric( - vertical: 18, - horizontal: 56, - ), - elevation: 4, - ), - child: Text(AppLocalizations.of(context)!.submit), - ), - ), - ), ); } @@ -380,25 +351,35 @@ class _GlobalConfigSettingsTabState extends State { } final configs = _getConfigurations(); - if (configs.isEmpty) { - return Center( - child: Text(AppLocalizations.of(context)!.no_configurations_found), - ); - } + return ListView.separated( + padding: const EdgeInsets.all(10), - return SizedBox( - width: double.infinity, - child: ListView.separated( - padding: const EdgeInsets.only(top: 10, bottom: 90), - itemCount: configs.length, - separatorBuilder: (_, __) => - Divider(height: 1, color: Colors.grey[300]), + itemCount: configs.length + 1, + separatorBuilder: (_, __) => Divider(height: 1, color: Colors.grey[300]), itemBuilder: (context, index) { + if (index == configs.length) { + bool enabled = _hasChanges(); + return Padding( + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), + child: Align( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: enabled ? _onSaveChanges : null, + style: ElevatedButton.styleFrom( + backgroundColor: enabled ? solidPrimary : Colors.grey, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 60), + elevation: enabled ? 4 : 0, + ), + child: Text(AppLocalizations.of(context)!.submit), + ), + ), + ); + } final config = configs[index]; return Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Expanded( flex: 2, @@ -406,9 +387,7 @@ class _GlobalConfigSettingsTabState extends State { config.key, style: TextStyle( fontSize: 12, - fontWeight: config.isModified - ? FontWeight.bold - : FontWeight.normal, + fontWeight: config.isModified ? FontWeight.bold : FontWeight.normal, color: config.isModified ? Colors.blue : Colors.black, ), ), @@ -418,9 +397,7 @@ class _GlobalConfigSettingsTabState extends State { flex: 1, child: Text( config.serverValue, - style: const TextStyle( - fontSize: 12, - ), + style: const TextStyle(fontSize: 12), ), ), Expanded( @@ -431,7 +408,6 @@ class _GlobalConfigSettingsTabState extends State { ), ); }, - ), ); } From a02dccfd88e9d907690a779a8181afb6ed2455ac Mon Sep 17 00:00:00 2001 From: Rakshithasai123 Date: Tue, 18 Nov 2025 18:25:15 +0530 Subject: [PATCH 2/4] While packet creating Threshold values and score values are giving same, continue button is not enable in biometric page Signed-off-by: Rakshithasai123 --- lib/ui/process_ui/generic_process.dart | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/ui/process_ui/generic_process.dart b/lib/ui/process_ui/generic_process.dart index 9e5521a3c..dc4de8803 100644 --- a/lib/ui/process_ui/generic_process.dart +++ b/lib/ui/process_ui/generic_process.dart @@ -523,9 +523,16 @@ class _GenericProcessState extends State break; } if (globalProvider.isValidBiometricCapture) { - isValid = false; - break; + List list = globalProvider.fieldInputValue[field.id!] ?? []; + if (list.isNotEmpty) { + BiometricAttributeData lastCapture = list.last; + if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) { + isValid = false; + break; + } + } } + } } } @@ -565,9 +572,16 @@ class _GenericProcessState extends State break; } if (globalProvider.isValidBiometricCapture) { - isValid = false; - break; + List list = globalProvider.fieldInputValue[field.id!] ?? []; + if (list.isNotEmpty) { + BiometricAttributeData lastCapture = list.last; + if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) { + isValid = false; + break; + } + } } + } } if (response.compareTo( From d9c67a1477443e521db6712a9249666a85644df2 Mon Sep 17 00:00:00 2001 From: Rakshithasai123 Date: Tue, 18 Nov 2025 18:33:44 +0530 Subject: [PATCH 3/4] Delete lib/ui/settings/widgets/global_config_settings_tab.dart Signed-off-by: Rakshithasai123 --- .../widgets/global_config_settings_tab.dart | 489 ------------------ 1 file changed, 489 deletions(-) delete mode 100644 lib/ui/settings/widgets/global_config_settings_tab.dart diff --git a/lib/ui/settings/widgets/global_config_settings_tab.dart b/lib/ui/settings/widgets/global_config_settings_tab.dart deleted file mode 100644 index 430f6c05e..000000000 --- a/lib/ui/settings/widgets/global_config_settings_tab.dart +++ /dev/null @@ -1,489 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:registration_client/utils/app_config.dart'; -import '../../../model/settings.dart'; -import '../../../pigeon/common_details_pigeon.dart'; -import '../../../pigeon/global_config_settings_pigeon.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:provider/provider.dart'; -import '../../../provider/global_provider.dart'; -import 'package:restart_app/restart_app.dart'; - -class GlobalConfigSettingsTab extends StatefulWidget { - final Settings settings; - final String selectedLan; - GlobalConfigSettingsTab({Key? key,required this.settings,required this.selectedLan,}) : super(key: key); - - @override - State createState() => - _GlobalConfigSettingsTabState(); -} - -class _GlobalConfigSettingsTabState extends State { - Map? serverValues; - Map localValues = {}; - Map localConfigurations = {}; - List permittedConfigurations = []; - final Map _controllers = {}; - bool isLoading = true; - String? errorMessage; - Map originalLocalConfig = {}; - Map currentLocalConfig = {}; - bool isModified = false; - - @override - void initState() { - super.initState(); - _loadInitialData(); - } - - // Load initial data from the server and local storage - Future _loadInitialData() async { - setState(() { - isLoading = true; - errorMessage = null; - }); - try { - // Load registration params, local configurations, and permitted configurations in parallel - serverValues = (await GlobalConfigSettingsApi().getRegistrationParams()) - .cast(); - localConfigurations = - (await GlobalConfigSettingsApi().getLocalConfigurations()) - .cast(); - permittedConfigurations = - (await GlobalConfigSettingsApi().getPermittedConfigurationNames()) - .cast(); - - for (var key in serverValues!.keys) { - _controllers[key]?.dispose(); - _controllers[key] = TextEditingController( - text: _getLocalValue(key) == '-' ? '' : _getLocalValue(key), - ); - } - originalLocalConfig = Map.from(localConfigurations); - setState(() { - isLoading = false; - }); - } catch (e) { - setState(() { - errorMessage = e.toString(); - isLoading = false; - }); - } - } - - @override - void dispose() { - for (var controller in _controllers.values) { - controller.dispose(); - } - super.dispose(); - } - - // Update _updateLocalValue to also update the controller's text if needed: - void _updateLocalValue(String key, String value) { - setState(() { - if (value.isEmpty) { - localValues.remove(key); - } else { - localValues[key] = value; - } - }); - } - - bool _isConfigurationPermitted(String configName) { - return permittedConfigurations.contains(configName); - } - - String _getLocalValue(String key) { - // First check if user has modified it in this session - if (localValues.containsKey(key)) { - return localValues[key]!; - } - // Then check if there's a saved local configuration - if (localConfigurations.containsKey(key)) { - return localConfigurations[key]!; - } - // Return empty if no local value - return ''; - } - - bool _hasChanges() { - if (localValues.isEmpty) { - return false; - } - - for (String key in localValues.keys) { - String original = originalLocalConfig[key] ?? ""; - String current = localValues[key] ?? ""; - - if (original != current) return true; - } - return false; - } - - void _onSaveChanges() { - if (!_hasChanges()) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('No changes to save')), - ); - return; - } - - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Submit Changes'), - content: SizedBox( - width: 250, - height: 20, - child: Center( - child: Text('${localValues.length} configuration will be updated.'), - ), - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: Text(AppLocalizations.of(context)!.cancel), - ), - ElevatedButton( - onPressed: () async { - Navigator.pop(context); - await _saveChanges(); - }, - child: Text(AppLocalizations.of(context)!.confirm), - ), - ], - ), - ); - } - - Future _saveChanges() async { - try { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) => const Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CircularProgressIndicator(), - SizedBox(height: 16), - Text('Saving configuration changes...'), - ], - ), - ), - ); - - // Save configuration changes - await GlobalConfigSettingsApi().modifyConfigurations(localValues); - originalLocalConfig = Map.from(localConfigurations); - currentLocalConfig = Map.from(localConfigurations); - - // Update local configurations with the saved values - setState(() { - localConfigurations.addAll(localValues); - localValues.clear(); - }); - - // Hide loading indicator - if (mounted) { - Navigator.of(context).pop(); - } - - // Show success message - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Configuration saved successfully. Restarting app...'), - duration: Duration(seconds: 2), - ), - ); - - // Wait a moment for the user to see the message, then restart the app - await Future.delayed(const Duration(seconds: 2)); - - // Restart the app to apply configuration changes - Restart.restartApp(); - } catch (e) { - if (mounted) { - Navigator.of(context).pop(); - } - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Error saving changes: $e')), - ); - } - } - - List _getConfigurations() { - if (serverValues == null) return []; - - List globalConfigItems = []; - - for (String key in serverValues!.keys) { - String serverValue = serverValues![key]?.toString() ?? '-'; - String localValue = _getLocalValue(key); - bool isEditable = _isConfigurationPermitted(key); - bool isModified = localValues.containsKey(key); - - GlobalConfigItem item = GlobalConfigItem( - key: key, - serverValue: serverValue, - localValue: localValue, - editable: isEditable, - isModified: isModified, - ); - globalConfigItems.add(item); - } - - return globalConfigItems; - } - - @override - Widget build(BuildContext context) { - final heading = widget.settings.label?[widget.selectedLan] ?? - widget.settings.label?['eng'] ?? - (widget.settings.label?.values.first ?? 'Unknown'); - - return Scaffold( - body: Card( - margin: const EdgeInsets.all(5), - elevation: 2, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 10), - Padding( - padding: const EdgeInsets.only(left: 12.0, right: 8.0), - child: Text( - heading, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ), - const SizedBox(height: 12), - Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.blue[50], - ), - child: Column( - children: [ - Row( - children: [ - Expanded( - flex: 2, - child: Text( - AppLocalizations.of(context)!.key, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - ), - ), - ), - Expanded( - flex: 1, - child: Text( - AppLocalizations.of(context)!.server_value, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - ), - ), - ), - Expanded( - flex: 1, - child: Text( - AppLocalizations.of(context)!.local_value, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ], - ), - ), - Expanded( - child: _buildContent(), - ), - ], - ), - ), - ); - } - - Widget _buildContent() { - if (isLoading) { - return const Center(child: CircularProgressIndicator()); - } - if (errorMessage != null) { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(Icons.error, size: 64, color: Colors.red[300]), - const SizedBox(height: 16), - Text( - 'Error: $errorMessage', - style: TextStyle(color: Colors.red[700]), - textAlign: TextAlign.center, - ), - const SizedBox(height: 16), - ElevatedButton( - onPressed: _loadInitialData, - child: Text(AppLocalizations.of(context)!.retry), - ), - ], - ), - ); - } - if (serverValues == null || serverValues!.isEmpty) { - return Center( - child: Text( - AppLocalizations.of(context)!.no_configuration_parameters_found)); - } - - final configs = _getConfigurations(); - return ListView.separated( - padding: const EdgeInsets.all(10), - - itemCount: configs.length + 1, - separatorBuilder: (_, __) => Divider(height: 1, color: Colors.grey[300]), - itemBuilder: (context, index) { - if (index == configs.length) { - bool enabled = _hasChanges(); - return Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), - child: Align( - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: enabled ? _onSaveChanges : null, - style: ElevatedButton.styleFrom( - backgroundColor: enabled ? solidPrimary : Colors.grey, - foregroundColor: Colors.white, - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 60), - elevation: enabled ? 4 : 0, - ), - child: Text(AppLocalizations.of(context)!.submit), - ), - ), - ); - } - final config = configs[index]; - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), - child: Row( - children: [ - Expanded( - flex: 2, - child: Text( - config.key, - style: TextStyle( - fontSize: 12, - fontWeight: config.isModified ? FontWeight.bold : FontWeight.normal, - color: config.isModified ? Colors.blue : Colors.black, - ), - ), - ), - const SizedBox(width: 10), - Expanded( - flex: 1, - child: Text( - config.serverValue, - style: const TextStyle(fontSize: 12), - ), - ), - Expanded( - flex: 1, - child: _buildEditableCell(config), - ), - ], - ), - ); - }, - ); - } - - // Builds either an editable TextField or read-only text based on config permissions - Widget _buildEditableCell(GlobalConfigItem config) { - if (config.editable) { - return _buildEditableTextField(config); - } else { - return _buildReadOnlyText(config); - } - } - - // Builds an editable TextField for permitted configurations - Widget _buildEditableTextField(GlobalConfigItem config) { - final controller = _controllers[config.key]!; - return TextField( - controller: controller, - onChanged: (newValue) => _updateLocalValue(config.key, newValue), - style: TextStyle( - color: config.isModified ? Colors.blue : Colors.black, - fontSize: 12, - fontWeight: config.isModified ? FontWeight.bold : FontWeight.normal, - ), - decoration: InputDecoration( - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(4), - borderSide: BorderSide( - color: config.isModified ? Colors.blue : Colors.grey, - ), - ), - contentPadding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - isDense: true, - hintText: config.serverValue, - ), - ); - } - - // Builds read-only styled text for non-permitted configurations - Widget _buildReadOnlyText(GlobalConfigItem config) { - return Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - decoration: BoxDecoration( - border: Border.all(color: Colors.grey[300]!), - borderRadius: BorderRadius.circular(4), - color: Colors.grey[100], - ), - child: Text( - config.localValue.isEmpty ? '-' : config.localValue, - style: TextStyle( - color: config.isModified ? Colors.blue : Colors.grey[600], - fontSize: 12, - fontWeight: config.isModified ? FontWeight.bold : FontWeight.normal, - ), - ), - ); - } -} - -class GlobalConfigItem { - final String key; - final String serverValue; - final String localValue; - final bool editable; - final bool isModified; - - GlobalConfigItem({ - required this.key, - required this.serverValue, - required this.localValue, - required this.editable, - required this.isModified, - }); -} From cce232ca66d0dffb1cb8c5aae89f67589a96f7a4 Mon Sep 17 00:00:00 2001 From: Rakshithasai123 Date: Thu, 18 Dec 2025 17:24:22 +0530 Subject: [PATCH 4/4] Refactor comments in global_config_settings_tab.dart Signed-off-by: Rakshithasai123 --- lib/ui/settings/widgets/global_config_settings_tab.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ui/settings/widgets/global_config_settings_tab.dart b/lib/ui/settings/widgets/global_config_settings_tab.dart index 9ced4690a..595779fb0 100644 --- a/lib/ui/settings/widgets/global_config_settings_tab.dart +++ b/lib/ui/settings/widgets/global_config_settings_tab.dart @@ -28,7 +28,7 @@ class _GlobalConfigSettingsTabState extends State { String? errorMessage; Map originalLocalConfig = {}; Map currentLocalConfig = {}; - + @override void initState() { @@ -174,10 +174,10 @@ class _GlobalConfigSettingsTabState extends State { ), ); - // Save configuration changes + // Save configuration changes await GlobalConfigSettingsApi().modifyConfigurations(localValues); - // Update local configurations with the saved values + // Update local configurations with the saved values setState(() { localConfigurations.addAll(localValues); localValues.clear();