Skip to content

chore: Use photoviewer as auto route page#432

Merged
PartyDonut merged 1 commit intodevelopfrom
chore/convert-photo-viewer-screen-to-auto-route
Aug 3, 2025
Merged

chore: Use photoviewer as auto route page#432
PartyDonut merged 1 commit intodevelopfrom
chore/convert-photo-viewer-screen-to-auto-route

Conversation

@PartyDonut
Copy link
Copy Markdown
Collaborator

Pull Request Description

Use routes for viewing photo/album items

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Aug 3, 2025

Reviewer's Guide

This PR replaces manual navigation for viewing photo/album items with a fully integrated auto_route solution by defining a new PhotoViewerRoute, annotating the PhotoViewerScreen for auto_route, and updating all navigation calls to use context.navigateTo or context.router.push with the generated route.

Sequence diagram for navigation to PhotoViewerScreen using auto_route

sequenceDiagram
    actor User
    participant UI as FolderDetailScreen/LibraryViews/PhotoAlbumExtension
    participant Context
    participant AutoRouter
    participant PhotoViewerScreen

    User->>UI: Selects a photo/album item
    UI->>Context: context.navigateTo(PhotoViewerRoute(...))
    Context->>AutoRouter: Handles navigation
    AutoRouter->>PhotoViewerScreen: Instantiates with args
    PhotoViewerScreen-->>User: Displays photo viewer
Loading

Class diagram for the new PhotoViewerRoute and PhotoViewerScreen integration

classDiagram
    class PhotoViewerRoute {
        +List<PhotoModel>? items
        +String? selected
        +Future<List<PhotoModel>>? loadingItems
        +Key? key
    }
    class PhotoViewerRouteArgs {
        +List<PhotoModel>? items
        +String? selected
        +Future<List<PhotoModel>>? loadingItems
        +Key? key
    }
    class PhotoViewerScreen {
        +List<PhotoModel>? items
        +String? selected
        +Future<List<PhotoModel>>? loadingItems
        +Key? key
    }
    PhotoViewerRoute --> PhotoViewerRouteArgs
    PhotoViewerRouteArgs --> PhotoViewerScreen : used by
    PhotoViewerRoute --> PhotoViewerScreen : builds
    PhotoViewerScreen <|-- _PhotoViewerScreenState
Loading

File-Level Changes

Change Details Files
Introduce PhotoViewerRoute and integrate into auto_route setup
  • Define PhotoViewerRoute and its args class in auto_router.gr.dart
  • Add PhotoViewerRoute entry to the router in auto_router.dart
  • Annotate PhotoViewerScreen with @RoutePage and @QueryParam for selected ID
  • Add dart:async import and adjust import prefixes in generated router
lib/routes/auto_router.gr.dart
lib/routes/auto_router.dart
lib/screens/photo_viewer/photo_viewer_screen.dart
Replace manual Navigator/PageTransition usage with auto_route navigation
  • Remove page_transition imports across multiple files
  • Use context.navigateTo(PhotoViewerRoute(...)) or context.router.push for photo viewer
  • Update navigation calls in folder_detail_screen, library_views, library_search_provider, and play_item_helpers
lib/screens/details_screens/folder_detail_screen.dart
lib/screens/library_search/widgets/library_views.dart
lib/providers/library_search_provider.dart
lib/util/item_base_model/play_item_helpers.dart
Update PhotoViewerScreen internals for routing parameters
  • Replace indexOfSelected parameter with selected ID queryParam
  • Compute currentPage from selected ID and clamp to valid range
  • Initialize ExtendedPageController with currentPage and update cacheNeighbors call
lib/screens/photo_viewer/photo_viewer_screen.dart
Minor code maintenance and guard fixes
  • Guard fullScreenHelper.closeFullScreen with context.mounted in controls
  • Reorder and clean up imports in photos_model
  • Renumber auto_route import prefixes for consistency
lib/screens/photo_viewer/photo_viewer_controls.dart
lib/models/items/photos_model.dart
lib/routes/auto_router.gr.dart

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
Copy Markdown
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 @PartyDonut - I've reviewed your changes - here's some feedback:

  • You’re mixing context.navigateTo(...) and context.router.push(...); consider consolidating on one (e.g. always using context.router.push) for consistent auto_route navigation.
  • Rather than using rawQueryParams for the selectedId on '/album', you might define it as a path parameter (e.g. '/album/:selectedId') so the route and URLs are more intuitive and easier to deep-link.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You’re mixing context.navigateTo(...) and context.router.push(...); consider consolidating on one (e.g. always using context.router.push) for consistent auto_route navigation.
- Rather than using rawQueryParams for the selectedId on '/album', you might define it as a path parameter (e.g. '/album/:selectedId') so the route and URLs are more intuitive and easier to deep-link.

## Individual Comments

### Comment 1
<location> `lib/screens/photo_viewer/photo_viewer_controls.dart:133` </location>
<code_context>
   @override
   void dispose() {
     timerController.dispose();
-    fullScreenHelper.closeFullScreen(ref);
+    if (context.mounted) {
+      fullScreenHelper.closeFullScreen(ref);
+    }
</code_context>

<issue_to_address>
Checking context.mounted before calling closeFullScreen may be unnecessary.

Since closeFullScreen only uses ref and not BuildContext, you can remove the context.mounted check for clarity if widget lifecycle is not involved.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    if (context.mounted) {
      fullScreenHelper.closeFullScreen(ref);
    }
=======
    fullScreenHelper.closeFullScreen(ref);
>>>>>>> REPLACE

</suggested_fix>

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.

Comment on lines 133 to 135
timerController.dispose();
fullScreenHelper.closeFullScreen(ref);
if (context.mounted) {
fullScreenHelper.closeFullScreen(ref);
}
windowManager.removeListener(this);
super.dispose();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: Checking context.mounted before calling closeFullScreen may be unnecessary.

Since closeFullScreen only uses ref and not BuildContext, you can remove the context.mounted check for clarity if widget lifecycle is not involved.

Suggested change
fullScreenHelper.closeFullScreen(ref);
if (context.mounted) {
fullScreenHelper.closeFullScreen(ref);
}
windowManager.removeListener(this);
super.dispose();
fullScreenHelper.closeFullScreen(ref);

@PartyDonut PartyDonut merged commit 7628321 into develop Aug 3, 2025
1 check passed
@PartyDonut PartyDonut deleted the chore/convert-photo-viewer-screen-to-auto-route branch August 3, 2025 11:56
Julien9969 pushed a commit to Julien9969/Fladder that referenced this pull request Sep 7, 2025
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
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.

1 participant