Skip to content

Commit

Permalink
Merge pull request #197 from Piwigo/develop
Browse files Browse the repository at this point in the history
Release 2.3.1
  • Loading branch information
remi-martin authored Jul 13, 2024
2 parents 74609ca + 714792e commit 2ac26cb
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 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
5 changes: 4 additions & 1 deletion lib/views/album/album_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,20 @@ class _AlbumPageState extends State<AlbumPage> {
}

void _onWillPop(bool pop) {
if (pop) return;
if (_selectedList.isNotEmpty) {
setState(() {
_selectedList.clear();
});
} else {
Navigator.of(context).pop();
}
}

@override
Widget build(BuildContext context) {
return PopScope(
canPop: _selectedList.isEmpty,
canPop: false,
onPopInvoked: _onWillPop,
child: Scaffold(
body: SafeArea(
Expand Down
5 changes: 4 additions & 1 deletion lib/views/image/image_favorites_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ class _ImageFavoritesPageState extends State<ImageFavoritesPage> {
bool get _hasNonFavorites => _selectedList.where((image) => !image.favorite).isNotEmpty;

void _onWillPop(bool pop) async {
if (pop) return;
if (_selectedList.isNotEmpty) {
setState(() {
_selectedList.clear();
});
} else {
Navigator.of(context).pop();
}
}

Expand Down Expand Up @@ -141,7 +144,7 @@ class _ImageFavoritesPageState extends State<ImageFavoritesPage> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: _selectedList.isEmpty,
canPop: false,
onPopInvoked: _onWillPop,
child: Scaffold(
body: SafeArea(
Expand Down
3 changes: 2 additions & 1 deletion lib/views/image/image_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class _ImagePageState extends State<ImagePage> {
/// * If overlay is hidden, show it.
/// * Otherwise, close the page.
void _onWillPop(bool pop) {
if (pop) return;
if (!_showOverlay) {
setState(() {
_showOverlay = true;
Expand Down Expand Up @@ -282,7 +283,7 @@ class _ImagePageState extends State<ImagePage> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: !_showOverlay,
canPop: false,
onPopInvoked: _onWillPop,
child: Scaffold(
backgroundColor: Colors.black,
Expand Down
5 changes: 4 additions & 1 deletion lib/views/image/image_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ class _ImageSearchPageState extends State<ImageSearchPage> {
bool get _hasNonFavorites => _selectedList.where((image) => !image.favorite).isNotEmpty;

void _onWillPop(bool pop) {
if (pop) return;
if (_selectedList.isNotEmpty) {
setState(() {
_selectedList.clear();
});
} else {
Navigator.of(context).pop();
}
}

Expand Down Expand Up @@ -148,7 +151,7 @@ class _ImageSearchPageState extends State<ImageSearchPage> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: _selectedList.isEmpty,
canPop: false,
onPopInvoked: _onWillPop,
child: Scaffold(
body: SafeArea(
Expand Down
5 changes: 4 additions & 1 deletion lib/views/image/image_tags_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ class _ImageTagsPageState extends State<ImageTagsPage> {
bool get _hasNonFavorites => _selectedList.where((image) => !image.favorite).isNotEmpty;

void _onWillPop(bool pop) {
if (pop) return null;
if (_selectedList.isNotEmpty) {
setState(() {
_selectedList.clear();
});
} else {
Navigator.of(context).pop();
}
}

Expand Down Expand Up @@ -143,7 +146,7 @@ class _ImageTagsPageState extends State<ImageTagsPage> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: _selectedList.isEmpty,
canPop: false,
onPopInvoked: _onWillPop,
child: Scaffold(
body: SafeArea(
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 2ac26cb

Please sign in to comment.