Skip to content

feat: added side navigation bar #69

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

Merged
merged 10 commits into from
Jun 26, 2025
Merged

Conversation

Vishveshwara
Copy link
Contributor

@Vishveshwara Vishveshwara commented Jun 20, 2025

Fixes #65

Screen Recording:

side.nav.bar.mp4

Summary by Sourcery

Add side navigation bar across the app by introducing a reusable CommonScaffold and AppDrawer, wire up named routes for display selection, settings, and about-us screens, and configure platform settings and dependencies to enable external URL launching and sharing.

New Features:

  • Introduce side navigation drawer (AppDrawer) and integrate it into app via CommonScaffold.
  • Add About Us and Settings screens accessible through the navigation drawer.
  • Register named routes in main.dart for navigation between screens.
  • Add share_plus dependency to support external sharing and URL-based drawer actions.

Enhancements:

  • Extract common scaffold layout into CommonScaffold widget to standardize app bar and drawer usage.
  • Update pubspec.yaml to include new icon assets, bump intl version, and add share_plus.
  • Update assets to include icons directory.

Build:

  • Update AndroidManifest.xml and iOS Info.plist to declare URL schemes and Custom Tabs intents for external link support.

Copy link
Contributor

sourcery-ai bot commented Jun 20, 2025

Reviewer's Guide

This PR centralizes app navigation by introducing a CommonScaffold and AppDrawer for a consistent side navigation experience, refactors the existing display selection screen to adopt this layout, adds new About Us and Settings screens with enforced portrait orientation, configures named routes in main.dart, integrates URL launching and sharing via share_plus, and updates platform manifests and dependencies to support external links and new assets.

Class diagram for CommonScaffold and AppDrawer integration

classDiagram
    class CommonScaffold {
      +String title
      +Widget? titleWidget
      +Widget body
      +int index
      +List<Widget>? actions
      +double? toolbarHeight
    }
    class AppDrawer {
      +int selectedIndex
    }
    CommonScaffold o-- AppDrawer : uses
Loading

Class diagram for AboutUsScreen and SettingsScreen

classDiagram
    class AboutUsScreen {
      +State createState()
    }
    class _AboutUsScreenState {
      +void initState()
      +void _setOrientation()
      +Widget build(BuildContext context)
    }
    AboutUsScreen -- _AboutUsScreenState

    class SettingsScreen {
      +State createState()
    }
    class SettingsScreenState {
      +String selectedLanguage
      +List<String> languages
      +void initState()
      +void _setOrientation()
      +Widget build(BuildContext context)
    }
    SettingsScreen -- SettingsScreenState
Loading

Class diagram for URL launcher helper

classDiagram
    class url_constant {
      +Future<void> openUrl(String url)
    }
Loading

File-Level Changes

Change Details Files
Introduce a reusable scaffold and side drawer for global navigation
  • Create CommonScaffold widget with AppBar and drawer integration
  • Implement AppDrawer with navigation items, external links, and sharing
  • Refactor DisplaySelectionScreen to use CommonScaffold
lib/view/widget/common_scaffold_widget.dart
lib/view/widget/navigation_drawer.dart
lib/view/display_selection_screen.dart
Add About Us and Settings screens with portrait orientation
  • Implement AboutUsScreen with CommonScaffold and URL launcher for links
  • Implement SettingsScreen with language dropdown and orientation lock
lib/view/about_us_screen.dart
lib/view/settings_screen.dart
Configure named routes and theme in main application entry
  • Define initialRoute and routes map for display, settings, and about screens
  • Set up ThemeData properties for consistent styling
lib/main.dart
Integrate external URL launching and sharing support
  • Add openUrl helper in url_constant.dart using url_launcher
  • Add share_plus dependency and integrate Share.share in drawer
lib/constants/url_constant.dart
pubspec.yaml
Update Android and iOS configuration for custom tabs and URL schemes
  • Add CustomTabsService and VIEW intents in AndroidManifest
  • Declare LSApplicationQueriesSchemes in Info.plist
android/app/src/main/AndroidManifest.xml
ios/Runner/Info.plist
Bump dependencies and include new icon assets
  • Upgrade intl to ^0.20.2 and add share_plus
  • Register assets/icons directory in pubspec
pubspec.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#65 Add pages similar to the badgemagic app: About us
#65 Add pages similar to the badgemagic app: Feedback/bug reports
#65 Add pages similar to the badgemagic app: License, github

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Vishveshwara - I've reviewed your changes - here's some feedback:

  • You might want to centralize the orientation-locking logic (currently duplicated in each screen’s initState) into a common mixin or widget to reduce boilerplate.
  • The drawer’s navigation uses Navigator.pushNamedAndRemoveUntil which clears the entire stack—consider pushReplacementNamed (or similar) if you want to preserve expected back-stack behavior.
  • There are several commented-out ListTile entries in the navigation drawer—removing or moving them to a feature branch will keep the code cleaner and more maintainable.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You might want to centralize the orientation-locking logic (currently duplicated in each screen’s initState) into a common mixin or widget to reduce boilerplate.
- The drawer’s navigation uses Navigator.pushNamedAndRemoveUntil which clears the entire stack—consider pushReplacementNamed (or similar) if you want to preserve expected back-stack behavior.
- There are several commented-out ListTile entries in the navigation drawer—removing or moving them to a feature branch will keep the code cleaner and more maintainable.

## Individual Comments

### Comment 1
<location> `lib/view/widget/navigation_drawer.dart:166` </location>
<code_context>
+
+        Navigator.pop(context);
+
+        if (externalLink != null) {
+          openUrl(externalLink);
+        } else if (shareText != null) {
+          Share.share(shareText);
+        } else {
</code_context>

<issue_to_address>
External links are opened without checking if the URL is valid or can be launched.

Handle potential exceptions from openUrl to prevent unhandled errors, and consider notifying the user if the URL cannot be opened.

Suggested implementation:

```
        if (externalLink != null) {
          _handleExternalLink(context, externalLink);
        } else if (shareText != null) {
          Share.share(shareText);
        } else {

```

```
}

Future<void> _handleExternalLink(BuildContext context, String url) async {
  try {
    final uri = Uri.tryParse(url);
    if (uri != null && await canLaunchUrl(uri)) {
      await launchUrl(uri);
    } else {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Could not open the link.')),
      );
    }
  } catch (e) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('An error occurred while opening the link.')),
    );
  }
}

```

```
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:share_plus/share_plus.dart';

```
</issue_to_address>

### Comment 2
<location> `lib/constants/url_constant.dart:5` </location>
<code_context>
+
+Future<void> openUrl(String url) async {
+  final Uri uri = Uri.parse(url);
+  if (!await canLaunchUrl(uri)) {
+    throw 'Could not launch $url';
+  } else {
+    await launchUrl(uri);
</code_context>

<issue_to_address>
Throwing a string as an exception is not idiomatic in Dart.

Use Exception('Could not launch $url') instead for clearer error handling and stack traces.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
  if (!await canLaunchUrl(uri)) {
    throw 'Could not launch $url';
  } else {
    await launchUrl(uri);
  }
=======
  if (!await canLaunchUrl(uri)) {
    throw Exception('Could not launch $url');
  } else {
    await launchUrl(uri);
  }
>>>>>>> REPLACE

</suggested_fix>

### Comment 3
<location> `lib/view/about_us_screen.dart:66` </location>
<code_context>
+                      ),
+                      const SizedBox(height: 30),
+                      Text(
+                        "Magic ePaper is an app designed to control and update ePaper displays."
+                        "The goal is to provide tools for customizing and transferring images, text, and patterns to ePaper screens using NFC."
+                        "Data transfer from the smartphone to the ePaper hardware is done wirelessly via NFC. The project is built on top of custom firmware and display drivers for seamless communication and efficient image rendering.",
+                        textAlign: TextAlign.justify,
+                        style: GoogleFonts.sora(
</code_context>

<issue_to_address>
Text content is concatenated without spaces, which may result in missing spaces between sentences.

Add a space at the end of each string segment to ensure proper spacing when the text is rendered.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Vishveshwara
Copy link
Contributor Author

@AsCress @kienvo @Dhruv1797 can you please review this PR

Vishveshwara and others added 2 commits June 24, 2025 01:05
Exception handling for the url

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Copy link

@nope3472 nope3472 left a comment

Choose a reason for hiding this comment

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

1.Handle External Link Exceptions: External links are opened without checking if the URL is valid or can be launched.
2. Centralize Orientation-Locking Logic: The orientation-locking code is duplicated in each screen’s initState. Move this logic into a common mixin or widget to reduce repetition.

@Vishveshwara
Copy link
Contributor Author

Vishveshwara commented Jun 25, 2025

@Dhruv1797 can you please review this

Copy link
Collaborator

@AsCress AsCress left a comment

Choose a reason for hiding this comment

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

@Vishveshwara Too much commented out code. Do we need that to be present in the repo ?

@Vishveshwara
Copy link
Contributor Author

@Vishveshwara Too much commented out code. Do we need that to be present in the repo ?

I have just commented on some TODO actions, like adding the link of the app from the app Store.

@AsCress AsCress changed the title Feat: Added side navigation bar feat: added side navigation bar Jun 26, 2025
@AsCress AsCress merged commit 6d66a54 into fossasia:main Jun 26, 2025
3 checks passed
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.

Implement side navigation bar
4 participants