Skip to content

Commit ccb7dad

Browse files
committed
Fixed dependencies, added default language, updated upload notification unsuccessful
1 parent f33737e commit ccb7dad

5 files changed

Lines changed: 88 additions & 95 deletions

File tree

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.5.31'
2+
ext.kotlin_version = '1.6.21'
33
repositories {
44
google()
55
jcenter()

android/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
org.gradle.jvmargs=-Xmx1536M
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
android.jetifier.blacklist=bcprov-jdk15on

lib/main.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,25 @@ class MyApp extends StatelessWidget {
5454
final themeProvider = Provider.of<ThemeNotifier>(context);
5555
return MaterialApp(
5656
title: "Piwigo NG",
57+
// localeListResolutionCallback: (locales, supportedLocales) {
58+
// debugPrint('device locales=$locales supported locales=$supportedLocales');
59+
//
60+
// for (Locale locale in locales) {
61+
// if (supportedLocales.contains(locale)) {
62+
// return locale;
63+
// }
64+
// }
65+
//
66+
// return Locale('en', 'US');
67+
// },
5768
localizationsDelegates: [
5869
AppLocalizations.delegate,
5970
GlobalMaterialLocalizations.delegate,
6071
GlobalWidgetsLocalizations.delegate,
6172
GlobalCupertinoLocalizations.delegate,
6273
],
6374
supportedLocales: AppLocalizations.supportedLocales,
75+
locale: Locale('en', 'US'),
6476
theme: light,
6577
// theme: themeProvider.darkTheme ? dark : light,
6678
initialRoute: '/',

lib/services/upload/Uploader.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ class Uploader {
2323

2424
Uploader(this.mainContext);
2525

26-
Future<void> _showUploadNotification(Map<String, dynamic> downloadStatus) async {
26+
Future<void> showUploadNotification(Map<String, dynamic> downloadStatus) async {
2727
final android = AndroidNotificationDetails(
2828
'channel id',
2929
'channel name',
3030
channelDescription: 'channel description',
3131
priority: Priority.high,
32-
importance: Importance.max
32+
importance: Importance.max,
3333
);
3434
final platform = NotificationDetails(android: android);
35+
print(downloadStatus);
3536
final isSuccess = downloadStatus['isSuccess'];
3637

3738
await API.localNotification.show(
@@ -95,6 +96,7 @@ class Uploader {
9596
uploadStatusProvider.reset();
9697
ScaffoldMessenger.of(context).hideCurrentSnackBar();
9798
ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(context, appStrings(context).uploadError_title));
99+
result['isSuccess'] = false;
98100
}
99101

100102
try {
@@ -106,7 +108,7 @@ class Uploader {
106108
debugPrint(e.message);
107109
}
108110

109-
await _showUploadNotification(result);
111+
await showUploadNotification(result);
110112
}
111113

112114
Future<XFile> testCompressAndGetFile(XFile file) async {

lib/views/RootCategoryViewPage.dart

Lines changed: 69 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
4040
_searchController.addListener(() {
4141
setState(() {
4242
_isSearching = _searchController.text.length > 0;
43-
_getData();
43+
//_getData();
4444
});
4545
});
4646
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -87,46 +87,75 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
8787
),
8888
];
8989
},
90-
body: Builder(builder: (context) {
91-
if(_isSearching) {
92-
return FutureBuilder<Map<String,dynamic>>(
93-
key: UniqueKey(),
94-
future: _imagesFuture,
95-
builder: (BuildContext context, AsyncSnapshot imagesSnapshot) {
96-
if(imagesSnapshot.hasData){
97-
print("Images: ${imagesSnapshot.data}");
98-
if(imagesSnapshot.data['stat'] == 'fail') {
90+
body: RefreshIndicator(
91+
displacement: 20,
92+
notificationPredicate: (notification) {
93+
return notification.metrics.atEdge;
94+
},
95+
onRefresh: () {
96+
_getData();
97+
return Future.delayed(Duration(milliseconds: 1000));
98+
},
99+
child: Builder(builder: (context) {
100+
if(_isSearching) {
101+
return FutureBuilder<Map<String,dynamic>>(
102+
key: UniqueKey(),
103+
future: _imagesFuture,
104+
builder: (BuildContext context, AsyncSnapshot imagesSnapshot) {
105+
if(imagesSnapshot.hasData){
106+
if(imagesSnapshot.data['stat'] == 'fail') {
107+
return Center(
108+
child: Text(appStrings(context).categoryImageList_noDataError),
109+
);
110+
}
111+
var images = imagesSnapshot.data['result']['images'];
112+
var nbImages = images.length;
113+
return Column(
114+
children: [
115+
_imageGrid(images),
116+
Center(
117+
child: Container(
118+
padding: EdgeInsets.all(10),
119+
child: Text(appStrings(context).imageCount(nbImages), style: TextStyle(fontSize: 20, color: _theme.textTheme.bodyText2.color, fontWeight: FontWeight.w300,),),
120+
),
121+
),
122+
],
123+
);
124+
} else {
99125
return Center(
100-
child: Text(appStrings(context).categoryImageList_noDataError),
126+
child: CircularProgressIndicator(),
101127
);
102128
}
103-
var images = imagesSnapshot.data['result']['images'];
104-
var nbImages = images.length;
105-
return RefreshIndicator(
106-
displacement: 20,
107-
notificationPredicate: (notification) {
108-
return notification.metrics.atEdge;
109-
},
110-
onRefresh: () {
111-
setState(() {
112-
print("refresh");
113-
});
114-
return Future.delayed(Duration(milliseconds: 1000));
115-
},
116-
child: SingleChildScrollView(
117-
physics: NeverScrollableScrollPhysics(),
118-
child: Column(
119-
children: [
120-
_imageGrid(images),
121-
Center(
122-
child: Container(
123-
padding: EdgeInsets.all(10),
124-
child: Text(appStrings(context).imageCount(nbImages), style: TextStyle(fontSize: 20, color: _theme.textTheme.bodyText2.color, fontWeight: FontWeight.w300)),
125-
),
126-
),
127-
],
129+
},
130+
);
131+
}
132+
return FutureBuilder<Map<String,dynamic>>(
133+
key: UniqueKey(),
134+
future: _albumsFuture, // Albums of the list
135+
builder: (BuildContext context, AsyncSnapshot albumSnapshot) {
136+
if(albumSnapshot.hasData){
137+
if(albumSnapshot.data['stat'] == 'fail') {
138+
return Container(
139+
padding: EdgeInsets.all(10),
140+
child: Text(albumSnapshot.data['result']),
141+
); //appStrings(context).categoryMainEmpty
142+
}
143+
var albums = albumSnapshot.data['result']['categories'];
144+
int nbPhotos = 0;
145+
albums.forEach((cat) => nbPhotos+=cat["total_nb_images"]);
146+
albums.removeWhere((category) => (
147+
category["id"].toString() == _rootCategory
148+
));
149+
return Column(
150+
children: [
151+
_albumGrid(albums),
152+
Center(
153+
child: Container(
154+
padding: EdgeInsets.all(10),
155+
child: Text(appStrings(context).imageCount(nbPhotos), style: TextStyle(fontSize: 20, color: _theme.textTheme.bodyText2.color, fontWeight: FontWeight.w300,),),
156+
),
128157
),
129-
),
158+
],
130159
);
131160
} else {
132161
return Center(
@@ -135,59 +164,8 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
135164
}
136165
},
137166
);
138-
}
139-
return FutureBuilder<Map<String,dynamic>>(
140-
key: UniqueKey(),
141-
future: _albumsFuture, // Albums of the list
142-
builder: (BuildContext context, AsyncSnapshot albumSnapshot) {
143-
if(albumSnapshot.hasData){
144-
//print(albumSnapshot.data);
145-
if(albumSnapshot.data['stat'] == 'fail') {
146-
return Container(
147-
padding: EdgeInsets.all(10),
148-
child: Text(albumSnapshot.data['result']),
149-
); //appStrings(context).categoryMainEmtpy
150-
}
151-
var albums = albumSnapshot.data['result']['categories'];
152-
int nbPhotos = 0;
153-
albums.forEach((cat) => nbPhotos+=cat["total_nb_images"]);
154-
albums.removeWhere((category) => (
155-
category["id"].toString() == _rootCategory
156-
));
157-
return RefreshIndicator(
158-
displacement: 20,
159-
notificationPredicate: (notification) {
160-
return notification.metrics.atEdge;
161-
},
162-
onRefresh: () {
163-
setState(() {
164-
print("refresh");
165-
});
166-
return Future.delayed(Duration(milliseconds: 1000));
167-
},
168-
child: SingleChildScrollView(
169-
physics: NeverScrollableScrollPhysics(),
170-
child: Column(
171-
children: [
172-
_albumGrid(albums),
173-
Center(
174-
child: Container(
175-
padding: EdgeInsets.all(10),
176-
child: Text(appStrings(context).imageCount(nbPhotos), style: TextStyle(fontSize: 20, color: _theme.textTheme.bodyText2.color, fontWeight: FontWeight.w300)),
177-
),
178-
),
179-
],
180-
),
181-
),
182-
);
183-
} else {
184-
return Center(
185-
child: CircularProgressIndicator(),
186-
);
187-
}
188-
},
189-
);
190-
}),
167+
}),
168+
),
191169
),
192170
),
193171
floatingActionButton: widget.isAdmin ? FloatingActionButton(
@@ -199,7 +177,7 @@ class _RootCategoryViewPageState extends State<RootCategoryViewPage> with Single
199177
}
200178
).whenComplete(() {
201179
setState(() {
202-
print('refresh');
180+
_getData();
203181
});
204182
});
205183
},

0 commit comments

Comments
 (0)