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

feat(mobile): Folder View for mobile #15047

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

arnolicious
Copy link
Contributor

General Idea

  • Folder navigation with one page per folder (like for example nextcloud app)
  • Shows subfolders and assets in that page
  • Nice to have: switch between List view and Tile view

Implementation Idea

My rough Idea was to have one single state representing the entire folder structure, since that can be derived from a single api call.
And then, whenever a folder gets navigated to, the assets for that specific folder could get fetched, and also saved in that state.

That way (I hope) you could navigate out and back in again without having to refetch the assets, since they would still be saved in state.

So far

Since I have basically no experience with complex Flutter projects or Flutter State Management, this is gonna be rough, but i've hacked together a somewhat functional prototype that fetches the folders and lets you navigate through them.

Asset loading is not yet implemented, since I am sure there are already plenty of basic improvements that could be made at this stage from more experience devs regarding the entire state and fetching logic.

import 'package:immich_mobile/entities/asset.entity.dart';

abstract interface class IFolderApiRepository {
Future<AsyncValue<List<String>>> getAllUniquePaths();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should just return the Future<List<String>> here. So that we don't add additional type dependency from riverpod library to the repository

final String path;
List<Asset>? assets;
final List<RecursiveFolder> subfolders;
final FolderService _folderService;
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it strange to include the FolderService here. I think the Model should serve solely as a way to represent the data structure and not include dependencies in its structure

page: FolderRoute.page,
guards: [_authGuard],
transitionsBuilder: TransitionsBuilders.slideLeft,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

I find using TransitionsBuilders.fadeIn is nicer here

fetchFolders();
}

Future<void> fetchFolders() async {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the AsyncValue's methods in this function to represent the loading/error states

@arnolicious
Copy link
Contributor Author

Thanks for the feedback Alex, I implemented your suggested fixes as well as I could.

I have now tried to implement the loading of assets by creating a new Provider, however something is not working yet.
I think the problem is the passing from the current folder to the provider, so that it can return the correct assets.
There's only a empty list returned, and re-navigating to a previously visited folder also doesn't trigger the provider to refetch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants