import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import '/features/core/abstracts/base_view_model.dart'; import '/features/core/services/logging_service.dart'; import '/features/core/services/navigation_service.dart'; import '/features/home/data/models/image_model.dart'; import '/features/home/services/image_cache_manager_service.dart'; import '/features/home/services/images_service.dart'; import '/features/home/views/image_carousel/image_carousel_view.dart'; import '/locator.dart'; class GalleryViewModel extends BaseViewModel { GalleryViewModel({ required ImagesService imagesService, required NavigationService navigationService, required ImageCacheManagerService imageCacheManagerService, required LoggingService loggingService, }) : _imagesService = imagesService, _navigationService = navigationService, _imageCacheManagerService = imageCacheManagerService, _loggingService = loggingService; final ImagesService _imagesService; final NavigationService _navigationService; final ImageCacheManagerService _imageCacheManagerService; final LoggingService _loggingService; final ValueNotifier _isDisplayingPressingPrompt = ValueNotifier(true); ValueListenable get isDisplayingPressingPrompt => _isDisplayingPressingPrompt; @override Future initialise(bool Function() mounted, [arguments]) async { super.initialise(mounted, arguments); } @override Future dispose() async { super.dispose(); } void onPromptPressed() => _isDisplayingPressingPrompt.value = false; Iterable get imageModels => _imagesService.imageModels; void pushImageCarouselView(BuildContext context, {required ImageModel imageModel}) => _navigationService.pushImageCarouselView( context, imageCarouselViewArguments: ImageCarouselViewArguments( imageIndexKey: imageModel.imageIndex, ), ); static GalleryViewModel get locate => Locator.locate(); double? downloadProgressValue({required DownloadProgress progress}) => progress.totalSize != null ? progress.downloaded / progress.totalSize! : null; }