Skip to content

Commit 802b209

Browse files
committed
debug messages
1 parent 06623f4 commit 802b209

19 files changed

Lines changed: 1150 additions & 474 deletions

lib/api/CategoryAPI.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Future<Map<String,dynamic>> fetchAlbums(String albumID) async {
2424
};
2525
}
2626
} catch(e) {
27-
var error = e as DioError;
27+
//var error = e as DioError;
2828
return {
2929
'stat': 'fail',
30-
'result': error.message
30+
'result': e.toString(),
3131
};
3232
}
3333
}
@@ -84,14 +84,15 @@ Future<dynamic> addCategory(String catName, String catDesc, String parent) async
8484
};
8585
}
8686
}
87-
Future<dynamic> deleteCategory(String catId) async {
87+
Future<dynamic> deleteCategory(String catId, {String deletionMode = "delete_orphans"}) async {
8888
Map<String, String> queries = {
8989
"format": "json",
9090
"method": "pwg.categories.delete",
9191
};
9292
FormData formData = FormData.fromMap({
9393
"category_id": catId,
9494
"pwg_token": API.prefs.getString("pwg_token"),
95+
'photo_deletion_mode': deletionMode,
9596
});
9697
try {
9798
Response response = await API.dio.post('ws.php',

lib/constants/SettingsConstants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Constants {
3131
8: 'Admins',
3232
};
3333

34+
static double CONFIRM_DIALOG_MAX_WIDTH = 500.0;
35+
3436
static double PORTRAIT_IMAGE_COUNT_MIN = 1.0;
3537
static double PORTRAIT_IMAGE_COUNT_MAX = 6.0;
3638
static double LANDSCAPE_IMAGE_COUNT_MIN = 4.0;

lib/l10n/app_en.arb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
"deleteCategory_empty": "Delete Empty Album",
252252
"deleteCategory_noImages": "Keep Photos",
253253
"deleteCategory_orphanedImages": "Delete Orphans",
254-
"deleteCategory_allImages": "Delete {count} Photos",
254+
"deleteCategory_allImages": "{count, plural, =0{Delete Photos} =1{Delete Photo} other{Delete {count} Photos}}",
255255
"@deleteCategory_allImages" : {
256256
"placeholders": {
257257
"count": {}

lib/l10n/app_fr.arb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
},
189189
"deleteCategory_empty": "Effacer Album Vide",
190190
"deleteCategory_noImages": "Conserver les photos",
191-
"deleteCategory_orphanedImages": "Effacer Images Orphelines",
192-
"deleteCategory_allImages": "Effacer {count} photos",
191+
"deleteCategory_orphanedImages": "Effacer les images orphelines",
192+
"deleteCategory_allImages": "{count, plural, =0{Effacer les photos} =1{Effacer la photo} other{Effacer {count} photos}}",
193193
"@deleteCategory_allImages": {
194194
"placeholders": {
195195
"count": {}
@@ -757,5 +757,5 @@
757757
"settings_pwgForumURL": "http://fr.piwigo.org",
758758
"settings_acknowledgements": "Remerciements",
759759
"settings_privacy": "Politique de Confidentialité",
760-
"settings_privacyUrl": "&lang=en_EN"
760+
"settings_privacyUrl": "&lang=fr_FR"
761761
}

lib/services/ThemeProvider.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ThemeData light = ThemeData(
1111
bottomAppBarColor: Color(0xffeeeeee),
1212
focusColor: Color(0xffff7700),
1313
backgroundColor: Color(0xffffffff),
14-
// buttonColor: Color(0xcbff7700),
14+
bottomSheetTheme: BottomSheetThemeData(
15+
backgroundColor: Colors.black.withOpacity(0)),
1516
scaffoldBackgroundColor: Color(0xffeeeeee),
1617
cardColor: Color(0xffffffff),
1718
errorColor: Color(0xffff0e00),

lib/services/upload/Uploader.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class Uploader {
6868
}
6969

7070
print('new status');
71-
// createDio();
7271

7372
await _showUploadNotification(result);
7473
}

lib/views/CategoryViewPage.dart

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,12 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
9595
}
9696

9797
void _onEditSelection() async {
98-
showDialog(context: context,
99-
builder: (BuildContext context) {
100-
return EditImageSelectionDialog(
98+
Navigator.of(context).push(
99+
MaterialPageRoute(builder: (_) => EditImagesPage(
101100
catId: int.parse(widget.category),
102101
images: _selectedItems.values.toList(),
103-
);
104-
}
105-
).whenComplete(() {
106-
setState(() {
107-
_selectedItems.clear();
108-
_isEditMode = false;
109-
});
110-
});
102+
))
103+
);
111104
}
112105
void _onDownloadSelection() async {
113106
if (await confirmDownloadDialog(context,
@@ -205,6 +198,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
205198
}
206199
}
207200
void _onDeleteSelection() async {
201+
print(_imageDeletionMode());
208202
if(await confirmDeleteDialog(context,
209203
content: appStrings(context).deleteImageCount_title(_selectedItems.length),
210204
)) {
@@ -227,6 +221,38 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
227221
}
228222
}
229223

224+
void _onSelectAll() {
225+
setState(() {
226+
if(_selectedItems.length == imageList.length) {
227+
_selectedItems.clear();
228+
} else {
229+
imageList.forEach((image) {
230+
_selectedItems.putIfAbsent(image['id'], () => image);
231+
});
232+
}
233+
});
234+
}
235+
236+
int _imageDeletionMode() {
237+
int nbUnique = 0;
238+
_selectedItems.values.forEach((image) {
239+
print(image["categories"]);
240+
if(image["categories"].length == 1) nbUnique++;
241+
});
242+
if(nbUnique == 0) {
243+
print(appStrings(context).deleteCategory_allImages(_selectedItems.length));
244+
print(appStrings(context).removeSingleImage_title);
245+
return 0;
246+
}
247+
if(nbUnique == _selectedItems.length) {
248+
print(appStrings(context).deleteCategory_allImages(_selectedItems.length));
249+
return 1;
250+
}
251+
print(appStrings(context).deleteCategory_allImages(_selectedItems.length));
252+
print(appStrings(context).removeSingleImage_title);
253+
return 2;
254+
}
255+
230256
handleAlbumSnapshot(AsyncSnapshot albumSnapshot, int nbImages) {
231257
if(albumSnapshot.data['stat'] == 'fail') {
232258
return Center(child: Text(appStrings(context).categoryMainEmtpy));
@@ -251,6 +277,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
251277
Widget build(BuildContext context) {
252278
return Scaffold(
253279
resizeToAvoidBottomInset: true,
280+
extendBody: true,
254281
body: createListeners(
255282
NestedScrollView(
256283
controller: _controller,
@@ -287,13 +314,18 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
287314
Text("${_selectedPhotos()}", overflow: TextOverflow.fade, softWrap: true) :
288315
Text(widget.title),
289316
actions: [
317+
_isEditMode ? IconButton(
318+
onPressed: _onSelectAll,
319+
icon: _selectedItems.length == imageList.length ?
320+
Icon(Icons.check_circle) : Icon(Icons.circle_outlined),
321+
) : SizedBox(),
290322
_isEditMode ? IconButton(
291323
onPressed: closeEditMode,
292324
icon: Icon(Icons.cancel),
293325
) : widget.isAdmin? IconButton(
294326
onPressed: openEditMode,
295327
icon: Icon(Icons.touch_app_rounded),
296-
) : Container(),
328+
) : SizedBox(),
297329
],
298330
);
299331
}
@@ -414,7 +446,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
414446
builder: (context) => UploadGalleryViewPage(imageData: mediaList, category: widget.category)
415447
)).whenComplete(() {
416448
setState(() {
417-
API.uploader.createDio();
449+
// API.uploader.createDio();
418450
print('After upload'); // refresh
419451
});
420452
});
@@ -442,7 +474,7 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
442474
builder: (context) => UploadGalleryViewPage(imageData: mediaList, category: widget.category)
443475
)).whenComplete(() {
444476
setState(() {
445-
API.uploader.createDio();
477+
// API.uploader.createDio();
446478
print('After upload'); // refresh
447479
});
448480
});
@@ -481,9 +513,13 @@ class _CategoryViewPageState extends State<CategoryViewPage> with SingleTickerPr
481513
physics: NeverScrollableScrollPhysics(),
482514
itemBuilder: (BuildContext context, int index) {
483515
var album = albums[index];
484-
return AlbumListItem(album, isAdmin: widget.isAdmin, onClose: () {
485-
setState(() {});
486-
});
516+
return AlbumListItem(album,
517+
isAdmin: widget.isAdmin,
518+
onClose: () {
519+
setState(() {});
520+
},
521+
onOpen: closeEditMode,
522+
);
487523
},
488524
) : Center(),
489525
imageList.length > 0 ?

lib/views/ImageViewPage.dart

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,12 @@ class _ImageViewPageState extends State<ImageViewPage> {
7373
}
7474

7575
void _onEditImage() async {
76-
showDialog(context: context,
77-
builder: (BuildContext context) {
78-
return EditImageSelectionDialog(
79-
catId: int.parse(widget.category),
80-
images: [images[_page]],
81-
);
82-
}
83-
).whenComplete(() {
84-
setState(() {});
85-
});
76+
Navigator.of(context).push(
77+
MaterialPageRoute(builder: (_) => EditImagesPage(
78+
catId: int.parse(widget.category),
79+
images: [images[_page]],
80+
))
81+
);
8682
}
8783
void _onDownloadImage() async {
8884
if(await confirmDownloadDialog(context,

lib/views/PrivacyPolicyViewPage.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_dotenv/flutter_dotenv.dart';
23
import 'package:piwigo_ng/constants/SettingsConstants.dart';
34
import 'package:webview_flutter/webview_flutter.dart';
45

@@ -11,6 +12,7 @@ class PrivacyPolicyViewPage extends StatefulWidget {
1112
class _PrivacyPolicyViewPageState extends State<PrivacyPolicyViewPage> {
1213
bool _isLoading;
1314
double _loadingProgress;
15+
String _url;
1416

1517
@override
1618
void initState() {
@@ -20,24 +22,33 @@ class _PrivacyPolicyViewPageState extends State<PrivacyPolicyViewPage> {
2022
super.initState();
2123
}
2224

25+
NavigationDecision _navigation(NavigationRequest request) {
26+
if(request.url == 'https://github.com/Piwigo/Piwigo-Android') {
27+
return NavigationDecision.prevent;
28+
}
29+
if(request.url == 'https://github.com/Piwigo/Piwigo-Mobile') {
30+
return NavigationDecision.prevent;
31+
}
32+
}
33+
2334
@override
2435
Widget build(BuildContext context) {
25-
var _theme = Theme.of(context);
36+
_url = '${dotenv.env['PRIVACY_POLICIES']}${appStrings(context).settings_privacyUrl}';
2637
return Scaffold(
2738
appBar: AppBar(
2839
title: Text(appStrings(context).settings_privacy),
2940
centerTitle: true,
3041
leading: IconButton(
31-
icon: Icon(Icons.chevron_left, color: _theme.iconTheme.color),
42+
icon: Icon(Icons.chevron_left, color: Theme.of(context).iconTheme.color),
3243
onPressed: Navigator.of(context).pop,
3344
),
3445
),
3546
body: Stack(
3647
children: [
3748
WebView(
38-
initialUrl: appStrings(context).settings_privacyUrl,
49+
initialUrl: _url,
50+
navigationDelegate: _navigation,
3951
onProgress: (progress) {
40-
print('PageView progress $progress');
4152
setState(() {
4253
_loadingProgress = progress/100;
4354
});

lib/views/RootCategoryViewPage.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
6565
builder: (BuildContext context, AsyncSnapshot albumSnapshot) {
6666
if(albumSnapshot.hasData){
6767
if(albumSnapshot.data['stat'] == 'fail') {
68-
return Center(child: Text(appStrings(context).categoryMainEmtpy));
68+
return Container(
69+
padding: EdgeInsets.all(10),
70+
child: Text(albumSnapshot.data['result']),
71+
); //appStrings(context).categoryMainEmtpy
6972
}
7073
var albums = albumSnapshot.data['result']['categories'];
7174
int nbPhotos = 0;

0 commit comments

Comments
 (0)