Skip to content

Commit

Permalink
Merge pull request #195 from Piwigo/feature/download_or_share_images
Browse files Browse the repository at this point in the history
Resolve #190 "download or share images"
  • Loading branch information
remi-martin authored Jul 13, 2024
2 parents 7c1009f + e8c2cec commit 714792e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
12 changes: 6 additions & 6 deletions lib/components/lists/image_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ class _ImageGridViewState extends State<ImageGridView> {
void _onTapImage(ImageModel image) {
final bool selected = widget.selectedList.contains(image);
if (widget.selectedList.isNotEmpty && !selected) {
if (widget.onSelectImage != null) widget.onSelectImage!(image);
widget.onSelectImage?.call(image);
} else if (selected) {
if (widget.onDeselectImage != null) widget.onDeselectImage!(image);
widget.onDeselectImage?.call(image);
} else {
if (widget.onTapImage != null) widget.onTapImage!(image);
widget.onTapImage?.call(image);
}
}

void _onLongPressImage(ImageModel image) {
if (widget.selectedList.isEmpty) {
HapticFeedback.mediumImpact();
}
if (widget.selectedList.contains(image)) return;
setState(() {
if (widget.onSelectImage != null) widget.onSelectImage!(image);
widget.onSelectImage?.call(image);
});
}

Expand All @@ -69,8 +70,7 @@ class _ImageGridViewState extends State<ImageGridView> {
return ClipRRect(
borderRadius: index == widget.imageList.length - 1
? BorderRadius.only(
topRight: widget.imageList.length <
Settings.getImageCrossAxisCount(context)
topRight: widget.imageList.length < Settings.getImageCrossAxisCount(context)
? Radius.circular(10.0)
: Radius.zero,
bottomRight: Radius.circular(10.0),
Expand Down
9 changes: 7 additions & 2 deletions lib/network/images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:piwigo_ng/models/album_model.dart';
import 'package:piwigo_ng/models/image_model.dart';
import 'package:piwigo_ng/network/api_error.dart';
import 'package:piwigo_ng/network/upload.dart';
import 'package:piwigo_ng/services/chunked_uploader.dart';
import 'package:piwigo_ng/services/notification_service.dart';
import 'package:piwigo_ng/services/preferences_service.dart';
Expand Down Expand Up @@ -292,9 +292,14 @@ Future<XFile?> downloadImage(
ImageModel image,
) async {
String localPath = path.join(dirPath, image.file);
if (!await askMediaPermission()) return null;
try {
await ApiClient.download(
path: image.elementUrl,
path: 'action.php',
queryParameters: {
'id': image.id,
'part': 'e',
},
outputPath: localPath,
);
await ImageGallerySaver.saveFile(
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ dependencies:
flutter_easyloading: ^3.0.5 # Show loading dialog

# Storage
package_info_plus: ^3.1.2 # Get project info (version)
package_info_plus: ^8.0.0 # Get project info (version)
path_provider: ^2.0.11 # Get application documents
shared_preferences: ^2.0.15 # Base local storage
flutter_secure_storage: ^6.0.0 # Local storage secured for logins
image_picker: ^0.8.5+3 # Pick images from camera
file_picker: ^5.2.5 # Pick images and videos at a time for upload

# Device
device_info_plus: ^8.2.0 # Get device info (version)
device_info_plus: ^10.1.0 # Get device info (version)
flutter_local_notifications: ^17.2.0 # Throws notifications on download or upload
open_filex: ^4.3.2 # Open files with devices apps
open_filex: ^4.4.0 # Open files with devices apps
workmanager: ^0.5.0 # Background processes (auto upload)
image_gallery_saver: ^2.0.3 # Download images

# Utils
mime_type: ^1.0.0 # Check mime type of files (differentiate photos from videos)
video_player: ^2.4.7 # Read video files in fullscreen mode
chewie: ^1.5.0 # Video player with options
chewie: ^1.8.1 # Video player with options
flutter_image_compress: ^1.1.3 # Remove metadata
permission_handler: ^10.2.0 # Check and asks for permissions
share_plus: ^4.4.0 # Share files
share_plus: ^9.0.0 # Share files
flutter_cache_manager: ^3.3.0 # Handles network image cache
heic_to_jpg: ^0.2.0 # Convert heic files to jpg
provider: ^6.0.3 # Notifiers for theme and language changes
Expand Down

0 comments on commit 714792e

Please sign in to comment.