Skip to content

Conversation

@AlexV525
Copy link
Member

No description provided.

AlexV525 and others added 21 commits October 9, 2024 23:43
# Conflicts:
#	example/lib/customs/pickers/directory_file_asset_picker.dart
#	lib/src/delegates/asset_picker_builder_delegate.dart
#	lib/src/delegates/asset_picker_viewer_builder_delegate.dart
#	lib/src/widget/asset_picker_viewer.dart
We have `Asset` and `Path` generic abstractions, but we didn't consider the delegate's generic abstractions. They are necessary when building delegates that rely on custom data source providers.
### ✨ What's the context?

Current `AssetPickerConfig` only accept single `specialItemPosition` and `specialItemBuilder` which is is not suitable for cases where multiple special items is required.


### 🛠 Changes being made

- Added `specialItems` in `AssetPickerConfig` and which accept list of `specialItemPosition` and `specialItemBuilder`.
- Added `isPermissionLimited` param to `SpecialItemBuilder` typedef for case where special item is required to remove when `isPermissionLimited` is false. Example as below.
```dart
SpecialItem(
  itemPosition: SpecialItemPosition.append,
  itemBuilder: (
    BuildContext context,
    AssetPathEntity? path,
    int length,
    bool isPermissionLimited,
 ) {
    if (!isPermissionLimited) {
      return null;
    }
    return const Center(
      child: Text('Append Widget', textAlign: TextAlign.center),
    );
  },
)
```
- Removed unused `SpecialPosition.none` enum.

### ✨ Result
<img
src="https://github.com/user-attachments/assets/5f16edcf-f9f9-4411-b4d3-ea389839c934"
width="300" />

---------

Co-authored-by: yujune <[email protected]>
Co-authored-by: Alex Li <[email protected]>
Add `enableLivePhoto` flag to `AssetPickerConfig` to control Live Photo functionality

## Summary
This PR implements the feature requested in issue #716. It adds a new `enableLivePhoto` bool flag to `AssetPickerConfig` that controls whether Live Photo functionality is enabled throughout the picker.

## Changes Made
- [x] Added `enableLivePhoto` bool parameter to AssetPickerConfig (defaults to `true` for backward compatibility)
- [x] Passed `enableLivePhoto` from AssetPickerConfig to `DefaultAssetPickerBuilderDelegate`
- [x] Added `enableLivePhoto` field to `DefaultAssetPickerBuilderDelegate`
- [x] Updated `buildLivePhotoIndicator` call to check the `enableLivePhoto` flag before showing the indicator in the grid
- [x] Added `enableLivePhoto` to `DefaultAssetPickerViewerBuilderDelegate`
- [x] Updated `ImagePageBuilder` to accept enableLivePhoto parameter
- [x] Updated `_isLivePhoto` getter to check both `enableLivePhoto` flag and asset property
- [x] Updated `AssetPickerViewer.pushToViewer `to pass `enableLivePhoto` parameter
- [x] Added unit tests to verify the new flag works correctly
- [x] Added clarifying comment for `_isLivePhoto` getter
- [x] Fixed lint error in test_utils.dart (const → final)

## Behavior
- **When `enableLivePhoto` is `true` (default)**: All Live-Photo indicators and interactions work as before, maintaining full backward compatibility
- **When `enableLivePhoto` is `false`**: 
  - Live Photo indicators are hidden in the grid view
  - Live Photo video controller is not initialized in preview
  - No Live Photo widget is rendered in the image viewer

## Implementation Details
The flag is propagated through the entire component hierarchy:
1. `AssetPickerConfig` → `AssetPickerDelegate` → `DefaultAssetPickerBuilderDelegate`
2. `DefaultAssetPickerBuilderDelegate` → `AssetPickerViewer.pushToViewer` → `DefaultAssetPickerViewerBuilderDelegate`
3. `DefaultAssetPickerViewerBuilderDelegate` → `ImagePageBuilder`

This ensures that all Live-Photo-related functionality is consistently controlled by a single flag, making it easy for users to disable Live Photo features when needed while maintaining full backward compatibility.

---------

Co-authored-by: Alex Li <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: AlexV525 <[email protected]>
@AlexV525 AlexV525 requested a review from LeGoffMael as a code owner November 22, 2025 04:30
# Conflicts:
#	lib/src/delegates/asset_picker_builder_delegate.dart
#	lib/src/delegates/asset_picker_delegate.dart
#	lib/src/delegates/asset_picker_viewer_builder_delegate.dart
#	lib/src/widget/asset_picker.dart
@AlexV525 AlexV525 merged commit 1f3c524 into main Nov 22, 2025
7 checks passed
@AlexV525 AlexV525 deleted the feat/v10 branch November 22, 2025 17:32
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.

3 participants