mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	* Fixes double video auto initialize issue and placeholder for video controller * WIP unravel stack index * Refactors video player controller format fixing video format Working format * Fixes hide on pause * Got hiding when tapped working * Hides controls when video starts and fixes placeholder for memory card Remove prints * Fixes show controls with microtask * fix LivePhotos not playing * removes unused function callbacks and moves wakelock * Update motion video * Fixing motion photo playing * Renames to isPlayingVideo * Fixes playing video on change * pause on dispose * fixing issues with sync between controls * Adds gallery app bar * Switches to memoized * Fixes pause * Revert "Switches to memoized" This reverts commit 234e6741dea05aa0b967dde746f1d625f15bed94. * uses stateful widget * Fixes double video play by using provider and new chewie video player wip format Fixes motion photos format --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
import 'package:hooks_riverpod/hooks_riverpod.dart';
 | 
						|
import 'package:immich_mobile/shared/models/asset.dart';
 | 
						|
import 'package:immich_mobile/shared/providers/db.provider.dart';
 | 
						|
import 'package:isar/isar.dart';
 | 
						|
import 'package:riverpod_annotation/riverpod_annotation.dart';
 | 
						|
 | 
						|
part 'asset_stack.provider.g.dart';
 | 
						|
 | 
						|
class AssetStackNotifier extends StateNotifier<List<Asset>> {
 | 
						|
  final Asset _asset;
 | 
						|
  final Ref _ref;
 | 
						|
 | 
						|
  AssetStackNotifier(
 | 
						|
    this._asset,
 | 
						|
    this._ref,
 | 
						|
  ) : super([]) {
 | 
						|
    fetchStackChildren();
 | 
						|
  }
 | 
						|
 | 
						|
  void fetchStackChildren() async {
 | 
						|
    if (mounted) {
 | 
						|
      state = await _ref.read(assetStackProvider(_asset).future);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  void removeChild(int index) {
 | 
						|
    if (index < state.length) {
 | 
						|
      state.removeAt(index);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
final assetStackStateProvider = StateNotifierProvider.autoDispose
 | 
						|
    .family<AssetStackNotifier, List<Asset>, Asset>(
 | 
						|
  (ref, asset) => AssetStackNotifier(asset, ref),
 | 
						|
);
 | 
						|
 | 
						|
final assetStackProvider =
 | 
						|
    FutureProvider.autoDispose.family<List<Asset>, Asset>((ref, asset) async {
 | 
						|
  // Guard [local asset]
 | 
						|
  if (asset.remoteId == null) {
 | 
						|
    return [];
 | 
						|
  }
 | 
						|
 | 
						|
  return await ref
 | 
						|
      .watch(dbProvider)
 | 
						|
      .assets
 | 
						|
      .filter()
 | 
						|
      .isArchivedEqualTo(false)
 | 
						|
      .isTrashedEqualTo(false)
 | 
						|
      .stackParentIdEqualTo(asset.remoteId)
 | 
						|
      .sortByFileCreatedAtDesc()
 | 
						|
      .findAll();
 | 
						|
});
 | 
						|
 | 
						|
@riverpod
 | 
						|
int assetStackIndex(AssetStackIndexRef ref, Asset asset) {
 | 
						|
  return -1;
 | 
						|
}
 |