Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings screen redesign #2396

Merged
merged 8 commits into from
Jan 24, 2025
Merged

Settings screen redesign #2396

merged 8 commits into from
Jan 24, 2025

Conversation

Mozart299
Copy link
Contributor

@Mozart299 Mozart299 commented Jan 23, 2025

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Summary by CodeRabbit

  • User Interface Changes

    • Simplified profile page, reducing tabs from 3 to 1
    • Focused solely on settings functionality
    • Removed exposure and devices tabs
  • Settings Enhancements

    • Transitioned to a stateful settings widget for better state management
    • Added scrollable settings view
    • Introduced logout button and account deletion option
    • Included app version information
  • User Experience

    • Improved layout responsiveness
    • Enhanced plugin registration with error handling
    • Integrated package_info_plus plugin for app version retrieval

Copy link

coderabbitai bot commented Jan 23, 2025

📝 Walkthrough

Walkthrough

The pull request introduces significant changes to the mobile application's profile page, simplifying its structure. The ProfilePage now features only one tab, with the "Exposure" and "Devices" tabs removed. The SettingsWidget has been transformed from a stateless to a stateful widget, enabling internal state management and adding new functionalities such as logout confirmation and account deletion dialogs. Additionally, the layout has been made responsive, enhancing user interaction options.

Changes

File Change Summary
mobile-v3/lib/src/app/profile/pages/profile_page.dart Reduced DefaultTabController length from 3 to 1; commented out "Exposure" and "Devices" tabs.
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart Changed SettingsWidget to a stateful widget; added state management, logout confirmation dialog, delete account dialog, responsive layout, and new UI elements.
mobile-v3/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java Added registration for PackageInfoPlugin with error handling in registerWith method.
mobile-v3/ios/Runner/GeneratedPluginRegistrant.m Included package_info_plus plugin registration with conditional compilation.
mobile-v3/pubspec.yaml Added package_info_plus: ^8.1.3 dependency.

Possibly related PRs

Suggested Labels

ready for review

Suggested Reviewers

  • Baalmart
  • Codebmk

Poem

In the realm of code, where tabs once roamed free,
We've trimmed the branches of complexity's tree 🌳
One settings page, sleek and refined,
A digital canvas, elegantly designed 🖥️
Simplicity reigns, with scrolls so light! 📱


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
mobile-v3/lib/src/app/profile/pages/profile_page.dart (2)

30-30: Clean implementation of profile page simplification.

The reduction to a single tab aligns well with the PR objectives. The commented-out code should be removed rather than left as comments.

Consider removing the commented-out code for better maintainability:

-                          // Tab(
-                          //     height: 60,
-                          //     icon: TabIcon(
-                          //         image: "assets/profile/exposure.svg",
-                          //         label: "Exposure")),
-                          // Tab(
-                          //     height: 60,
-                          //     icon: TabIcon(
-                          //         image: "assets/profile/places.svg",
-                          //         label: "Places")),
-                          // Tab(
-                          //     height: 60,
-                          //     icon: TabIcon(
-                          //         image: "assets/profile/devices.svg",
-                          //         label: "Devices")),

Also applies to: 124-138


147-149: Remove commented-out widgets from TabBarView.

For consistency with the tab removal, the commented-out widgets should be removed rather than left as comments.

-                        // ExposureWidget(),
-                        // Container(child: Text("devices")),
-                        // DevicesWidget(),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5ed5b and a2586bb.

📒 Files selected for processing (2)
  • mobile-v3/lib/src/app/profile/pages/profile_page.dart (3 hunks)
  • mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (1 hunks)
🔇 Additional comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

10-18: Well-structured responsive layout implementation!

Good use of MediaQuery for screen-size-based calculations and SingleChildScrollView for content accessibility.


21-69: Replace print statements with actual functionality.

The settings tiles are well-structured, but the onChanged handlers only contain print statements. These should be replaced with actual functionality implementations.

Would you like assistance in implementing the actual functionality for these settings?

Comment on lines 71 to 93
// Logout Button
Padding(
padding: EdgeInsets.symmetric(vertical: screenHeight * 0.05),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
minimumSize: Size.fromHeight(screenHeight * 0.07),
),
onPressed: () {
print("Logout tapped");
},
child: const Text(
"Log out",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Implement actual logout functionality.

The logout button is well-styled but lacks actual implementation. This is a critical user flow that needs proper implementation.

Consider implementing proper logout flow:

  1. Show confirmation dialog
  2. Clear user session
  3. Navigate to login screen

Would you like me to provide a code example for this implementation?

Comment on lines 95 to 111
// Delete Account Section
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * 0.3),
child: InkWell(
onTap: () {
print("Delete Account tapped");
},
child: Text(
"Delete Account",
style: TextStyle(
color: Colors.red.shade300,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safety measures for account deletion.

The delete account functionality needs additional safety measures to prevent accidental deletions.

Consider implementing:

  1. Double confirmation dialog
  2. Password re-entry requirement
  3. Clear warning about data loss
  4. Actual account deletion logic

Would you like me to provide a code example for this implementation?

Comment on lines 115 to 149
// App Info
Center(
child: Column(
children: [
SvgPicture.asset(
"assets/images/shared/logo.svg",
height: screenHeight * 0.05,
),
SizedBox(height: screenHeight * 0.01),
const Text(
"3.40.1(1)",
style: TextStyle(
color: Colors.grey,
fontSize: 12,
),
),
SizedBox(height: screenHeight * 0.01),
const Text(
"A PROJECT BY",
style: TextStyle(
color: Colors.grey,
fontSize: 12,
),
),
Text(
"Makerere University".toUpperCase(),
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white,
),
),
],
),
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use dynamic version number instead of hardcoding.

The app info section looks good, but the version number should be retrieved dynamically.

Consider using Flutter's package_info_plus to get the version number:

final packageInfo = await PackageInfo.fromPlatform();
final version = packageInfo.version;
final buildNumber = packageInfo.buildNumber;

@Mozart299 Mozart299 requested a review from Baalmart January 23, 2025 12:39
…ion display and logout/delete account functionality
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (1)

121-121: Remove debug print statements.

Remove print statements used for debugging before merging to production.

-                print("Location setting: $value");
+                // Handle location setting change
-                print("Notifications setting: $value");
+                // Handle notifications setting change

Also applies to: 136-136

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2586bb and 4bfd629.

⛔ Files ignored due to path filters (1)
  • mobile-v3/pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • mobile-v3/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java (1 hunks)
  • mobile-v3/ios/Runner/GeneratedPluginRegistrant.m (2 hunks)
  • mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (1 hunks)
  • mobile-v3/pubspec.yaml (1 hunks)
🔇 Additional comments (8)
mobile-v3/ios/Runner/GeneratedPluginRegistrant.m (1)

21-25: LGTM! Package registration looks good.

The package_info_plus plugin is properly registered following iOS conventions.

Also applies to: 38-38

mobile-v3/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java (1)

33-37: LGTM! Package registration looks good.

The package_info_plus plugin is properly registered following Android conventions.

mobile-v3/pubspec.yaml (1)

59-59: LGTM! Dependency addition looks good.

The package_info_plus dependency is properly specified with a version constraint.

mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (5)

44-46: Implement actual logout logic.

The logout functionality is incomplete with only navigation logic.


87-89: Implement actual account deletion logic.

The account deletion functionality is incomplete with only navigation logic.


147-147: Implement feedback, story, and terms handlers.

The handlers for "Send Feedback", "Our Story", and "Terms and Privacy Policy" are using print statements instead of actual implementations.

Would you like me to provide implementation examples for these handlers?

Also applies to: 156-156, 165-165


104-246: LGTM! Responsive layout implementation looks good.

The UI implementation uses MediaQuery appropriately for responsive design, and the widget hierarchy is well-structured.


4-4: ⚠️ Potential issue

Update package import.

The import statement uses the old package_info package instead of package_info_plus.

-import 'package:package_info/package_info.dart';
+import 'package:package_info_plus/package_info_plus.dart';

Likely invalid or redundant comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

31-53: ⚠️ Potential issue

Implement actual logout logic.

While the confirmation dialog is well implemented, the actual logout logic is still missing. Please implement:

  1. Clear user session/tokens
  2. Clean up any cached data
  3. Proper navigation handling

55-97: ⚠️ Potential issue

Add error handling and implement account deletion logic.

While the UI flow is well implemented, please address:

  1. Add error handling for invalid passwords
  2. Implement actual account deletion logic
  3. Show loading state during deletion
🧹 Nitpick comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

121-122: Replace print statements with proper logging.

Debug print statements should be replaced with proper logging for better debugging and monitoring in production.

Consider using a logging package like logging or your app's logging system:

-                print("Location setting: $value");
+                log.info('Location setting updated: $value');

Also applies to: 136-137, 147-148, 156-157, 165-166


104-244: Well-implemented responsive layout!

The UI implementation properly uses MediaQuery for responsive layout and maintains consistent spacing. The settings tiles are well-organized with clear visual hierarchy.

However, consider adding error boundaries to handle potential widget rendering errors gracefully.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bfd629 and 0af7a80.

📒 Files selected for processing (1)
  • mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (1 hunks)
🔇 Additional comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

6-22: Well-structured state management implementation!

The transition to StatefulWidget with proper state initialization is appropriate for managing settings state.


24-29: Excellent implementation of dynamic version retrieval!

The version management implementation correctly uses PackageInfo.fromPlatform() as suggested.

…ss; update SettingsWidget state creation method
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

30-52: ⚠️ Potential issue

Implement actual logout functionality.

The logout confirmation dialog UI is well-implemented, but the actual logout logic is missing.

Consider implementing:

onPressed: () async {
  await AuthService.logout();  // Clear tokens, user session
  await SecureStorage.clearAll();  // Clear secure storage
  Navigator.of(context).pushReplacementNamed('/login');
},

54-96: ⚠️ Potential issue

Enhance account deletion security measures.

While the password confirmation is a good start, the account deletion flow needs additional security measures.

Consider implementing:

onPressed: () async {
  try {
    final isValid = await AuthService.validatePassword(
      passwordController.text
    );
    if (!isValid) {
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(content: Text('Invalid password'))
      );
      return;
    }
    await UserService.deleteAccount();
    await AuthService.logout();
    Navigator.of(context).pushReplacementNamed('/login');
  } catch (e) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Error: ${e.toString()}'))
    );
  }
},
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0af7a80 and 1f461ab.

📒 Files selected for processing (2)
  • mobile-v3/lib/src/app/profile/pages/profile_page.dart (4 hunks)
  • mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile-v3/lib/src/app/profile/pages/profile_page.dart
🔇 Additional comments (2)
mobile-v3/lib/src/app/profile/pages/widgets/settings_widget.dart (2)

6-28: Well-structured state management implementation!

The conversion to StatefulWidget and implementation of version info using package_info_plus is clean and follows best practices.


98-247: Clean and responsive layout implementation!

The use of MediaQuery for responsive sizing and proper widget organization creates a maintainable and scalable UI.

Comment on lines +142 to +166
SettingsTile(
iconPath: "assets/images/shared/feedback_icon.svg",
title: "Send Feedback",
onChanged: (value) {
print("Send Feedback tapped");
},
),

// Our Story
SettingsTile(
iconPath: "assets/images/shared/airqo_story_icon.svg",
title: "Our Story",
onChanged: (value) {
print("Our Story tapped");
},
),

// Terms and Privacy Policy
SettingsTile(
iconPath: "assets/images/shared/terms_and_privacy.svg",
title: "Terms and Privacy Policy",
onChanged: (value) {
print("Terms and Privacy Policy tapped");
},
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Implement navigation for information pages.

The feedback, story, and terms & privacy tiles need proper navigation implementation.

onChanged: (value) {
  Navigator.of(context).pushNamed('/feedback');  // or appropriate route
},

Comment on lines +111 to +124
// Location Setting
SettingsTile(
switchValue: _locationEnabled,
iconPath: "assets/images/shared/location_icon.svg",
title: "Location",
onChanged: (value) {
setState(() {
_locationEnabled = value;
});
print("Location setting: $value");
},
description:
"AirQo to use your precise location to locate the Air Quality of your nearest location",
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace print statements with proper logging.

Debug print statements should not be used in production code.

-                print("Location setting: $value");
+                log.info('Location permission ${value ? 'granted' : 'revoked'}');
+                // TODO: Implement actual location permission handling

Committable suggestion skipped: line range outside the PR's diff.

@Baalmart Baalmart merged commit 211c690 into staging Jan 24, 2025
31 checks passed
@Baalmart Baalmart deleted the settings-screen-redesign branch January 24, 2025 09:33
@Baalmart Baalmart mentioned this pull request Jan 24, 2025
1 task
@coderabbitai coderabbitai bot mentioned this pull request Jan 28, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants