diff --git a/lib/components/location_selector.dart b/lib/components/location_selector.dart index 8cb1f6a..84872b3 100644 --- a/lib/components/location_selector.dart +++ b/lib/components/location_selector.dart @@ -171,7 +171,7 @@ class LocationSelectorState extends State { 'Location permissions are permanently denied, we cannot request permissions.'); } } catch (e) { - print('Error getting location permission: $e'); + debugPrint('Error getting location permission: $e'); } try { @@ -194,7 +194,7 @@ class LocationSelectorState extends State { triggerCallback(); } } catch (e) { - print('Error getting current location: $e'); + debugPrint('Error getting current location: $e'); } } } diff --git a/lib/forms/corporate_culture_form.dart b/lib/forms/corporate_culture_form.dart index 8828440..c980b3d 100644 --- a/lib/forms/corporate_culture_form.dart +++ b/lib/forms/corporate_culture_form.dart @@ -121,7 +121,7 @@ class CultureValuesFormPageState extends State { } // Handle the form submission logic here bool success = await _saveDataToFirebase(); - if (success) { + if (success && mounted) { if (widget.isRegProcess) { Navigator.push( context, diff --git a/lib/forms/risks_form.dart b/lib/forms/risks_form.dart index df1234b..07d3a43 100644 --- a/lib/forms/risks_form.dart +++ b/lib/forms/risks_form.dart @@ -77,9 +77,9 @@ class RisksFormPageState extends State { } void _showSnackBar(String message) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(message), - )); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(message)), + ); } Future handleSubmit() async { @@ -98,33 +98,33 @@ class RisksFormPageState extends State { // Handle the form submission logic here bool success = await _saveDataToFirebase(); if (success) { - if (widget.isRegProcess) { - Navigator.push( - context, - MaterialPageRoute( - // - // TODO set following registration page HERE - // - builder: (context) => const RegistrationCompletePage(), - ), - ); - } else { - if (widget.isEditMode == true) { - // pass selectedOptions data back to caller - Navigator.pop(context, { - Constants.dbFieldUsersCommunication: communicationPreference, - Constants.dbFieldUsersRiskTolerance: riskPreference, - }); - } else { - Navigator.pop(context); - } - } + _navigate(); } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Failed to save data.'), + _showSnackBar('Failed to save data.'); + } + } + + void _navigate() { + if (widget.isRegProcess) { + Navigator.push( + context, + MaterialPageRoute( + // + // TODO set following registration page HERE + // + builder: (context) => const RegistrationCompletePage(), ), ); + } else { + if (widget.isEditMode == true) { + // pass selectedOptions data back to caller + Navigator.pop(context, { + Constants.dbFieldUsersCommunication: communicationPreference, + Constants.dbFieldUsersRiskTolerance: riskPreference, + }); + } else { + Navigator.pop(context); + } } } diff --git a/lib/pages/edit_profile_page.dart b/lib/pages/edit_profile_page.dart index 4d296d9..68d1365 100644 --- a/lib/pages/edit_profile_page.dart +++ b/lib/pages/edit_profile_page.dart @@ -66,7 +66,7 @@ class EditProfilePageState extends State { title: 'Cropper', minimumAspectRatio: 1.0, ), - if (kIsWeb) + if (kIsWeb && mounted) WebUiSettings( context: context, presentStyle: CropperPresentStyle.page, @@ -227,7 +227,7 @@ class EditProfilePageState extends State { child: Stack( children: [ CircleAvatar( - radius: 50, + radius: 80, backgroundImage: _profileImage != null ? FileImage(_profileImage!) : (_webProfileImage != null @@ -240,7 +240,7 @@ class EditProfilePageState extends State { child: _profileImage == null && _webProfileImage == null && widget.userData.profilePictureUrl == null - ? const Icon(Icons.person, size: 50) + ? const Icon(Icons.person, size: 80) : null, ), ), @@ -253,7 +253,7 @@ class EditProfilePageState extends State { color: Theme.of(context).colorScheme.primary, shape: const CircleBorder(), ), - child: const Icon(Icons.edit), + child: const Icon(Icons.camera_alt), ), onPressed: _pickImage, ), diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 4cb0756..3f5c8b9 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -17,10 +17,8 @@ class HomePage extends StatelessWidget { return Scaffold( appBar: AppBar( title: const Text('Home'), - // TODO appbar style: remove background and set elevation to 0 ? + // different appbar style for homepage backgroundColor: Colors.transparent, - foregroundColor: Colors.grey.shade800, - elevation: 0, ), drawer: const MyDrawer(), body: _buildUserList(), diff --git a/lib/pages/user_profile_page.dart b/lib/pages/user_profile_page.dart index c7ba041..1e7f886 100644 --- a/lib/pages/user_profile_page.dart +++ b/lib/pages/user_profile_page.dart @@ -608,13 +608,13 @@ class _UserProfilePageState extends State { ), ), CircleAvatar( - radius: 50, + radius: 80, backgroundImage: ((profileImageUrl != null && profileImageUrl!.isNotEmpty)) ? NetworkImage(profileImageUrl!) : null, child: (profileImageUrl == null || profileImageUrl!.isEmpty) - ? const Icon(Icons.person, size: 50) + ? const Icon(Icons.person, size: 80) : null, ), const SizedBox(height: 16), diff --git a/lib/pages/user_vision_page.dart b/lib/pages/user_vision_page.dart index a41bb7b..063ee3f 100644 --- a/lib/pages/user_vision_page.dart +++ b/lib/pages/user_vision_page.dart @@ -26,7 +26,6 @@ class UserVisionPageState extends State { }; AvailabilityOption? availability; - // get instance of auth final AuthService _authService = AuthService(); @override @@ -43,21 +42,24 @@ class UserVisionPageState extends State { if (snapshot.exists) { final data = snapshot.data(); - setState(() { - // Load Vision options - if (data?[Constants.dbFieldUsersVisions] != null) { - for (var option in VisionOption.values) { - selectedVisionOptions[option] = data?[Constants.dbFieldUsersVisions] - .contains(option.toString()); + setState( + () { + // Load Vision options + if (data?[Constants.dbFieldUsersVisions] != null) { + for (var option in VisionOption.values) { + selectedVisionOptions[option] = + data?[Constants.dbFieldUsersVisions] + .contains(option.toString()); + } } - } - // Load Availability option - if (data?[Constants.dbFieldUsersAvailability] != null) { - availability = AvailabilityOption.values.firstWhereOrNull( - (e) => e.toString() == data?[Constants.dbFieldUsersAvailability], - ); - } - }); + // Load Availability option + if (data?[Constants.dbFieldUsersAvailability] != null) { + availability = AvailabilityOption.values.firstWhereOrNull( + (e) => e.toString() == data?[Constants.dbFieldUsersAvailability], + ); + } + }, + ); } } @@ -85,9 +87,9 @@ class UserVisionPageState extends State { } void _showSnackBar(String message) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(message), - )); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(message)), + ); } bool isVisionSelected() { @@ -96,53 +98,49 @@ class UserVisionPageState extends State { Future handleSubmit() async { if (!isVisionSelected()) { - ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text('Please select at least one long-term vision.'), - )); + _showSnackBar('Please select at least one long-term vision.'); return; } if (availability == null) { - ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text('Please select an availability option.'), - )); + _showSnackBar('Please select an availability option.'); return; } // Handle the form submission logic here bool success = await _saveDataToFirebase(); if (success) { - if (widget.isRegProcess) { - Navigator.push( - context, - MaterialPageRoute( - // - // set following registration page HERE - // - builder: (context) => CultureValuesFormPage( - isRegProcess: widget.isRegProcess, - isEditMode: false, - ), - ), - ); - } else { - if (widget.isEditMode == true) { - // pass selectedOptions data back to caller - Navigator.pop(context, { - Constants.dbFieldUsersVisions: selectedVisionOptions.entries - .where((entry) => entry.value) - .map((entry) => entry.key) - .toList(), - Constants.dbFieldUsersAvailability: availability, - }); - } else { - Navigator.pop(context); - } - } + _navigate(); } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Failed to save data.'), + _showSnackBar('Failed to save data.'); + } + } + + void _navigate() { + if (widget.isRegProcess) { + Navigator.push( + context, + MaterialPageRoute( + // + // set following registration page HERE + // + builder: (context) => CultureValuesFormPage( + isRegProcess: widget.isRegProcess, + isEditMode: false, + ), ), ); + } else { + if (widget.isEditMode == true) { + // pass selectedOptions data back to caller + Navigator.pop(context, { + Constants.dbFieldUsersVisions: selectedVisionOptions.entries + .where((entry) => entry.value) + .map((entry) => entry.key) + .toList(), + Constants.dbFieldUsersAvailability: availability, + }); + } else { + Navigator.pop(context); + } } } diff --git a/lib/services/auth/auth_gate.dart b/lib/services/auth/auth_gate.dart index 1e1c88f..ca32542 100644 --- a/lib/services/auth/auth_gate.dart +++ b/lib/services/auth/auth_gate.dart @@ -93,7 +93,7 @@ class AuthGate extends StatelessWidget { Constants.dbFieldUsersEmail: email, }); } catch (e) { - print("Error creating user document: $e"); + debugPrint("Error creating user document: $e"); } } @@ -105,7 +105,7 @@ class AuthGate extends StatelessWidget { await _checkUsersCollectionExists(Constants.dbCollectionLocations); return languagesExist && locationsExist; } catch (e) { - print(e.toString()); + debugPrint(e.toString()); return false; } } @@ -120,7 +120,7 @@ class AuthGate extends StatelessWidget { final snapshot = await collection.limit(1).get(); return snapshot.docs.isNotEmpty; } catch (e) { - print(e.toString()); + debugPrint(e.toString()); return false; } }