Skip to content

Commit 919ac62

Browse files
authored
Merge pull request #192 from Piwigo/feature/fix_dependencies
Fix flutter dependencies
2 parents 12a2192 + e1a3807 commit 919ac62

35 files changed

Lines changed: 384 additions & 592 deletions

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ GeneratedPluginRegistrant.java
99
# Remember to never publicly share your keystore.
1010
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
1111
key.properties
12+
/build/.last_build_id

android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ android {
3434
compileOptions {
3535
// Flag to enable support for the new language APIs
3636
coreLibraryDesugaringEnabled true
37-
// Sets Java compatibility to Java 8
38-
sourceCompatibility JavaVersion.VERSION_1_8
39-
targetCompatibility JavaVersion.VERSION_1_8
37+
// Sets Java compatibility to Java 11
38+
sourceCompatibility JavaVersion.VERSION_11
39+
targetCompatibility JavaVersion.VERSION_11
4040
}
4141

4242
kotlinOptions {
43-
jvmTarget = '1.8'
43+
jvmTarget = '11'
4444
}
4545

4646
sourceSets {

android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pluginManagement {
1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
2121
id "com.android.application" version "7.1.3" apply false
22-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
22+
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
2323
}
2424

2525
include ":app"

lib/components/appbars/root_search_app_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class _RootSearchAppBarState extends State<RootSearchAppBar> {
104104
),
105105
title: Text(
106106
appStrings.tabBar_albums,
107-
textScaleFactor: 1,
107+
textScaler: TextScaler.linear(1),
108108
style: Theme.of(context).appBarTheme.titleTextStyle,
109109
),
110110
),

lib/components/appbars/settings_app_bar.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
3333
}
3434

3535
// In case 0%-100% of the expanded height is viewed
36-
double scrollDelta =
37-
(_expandedHeight - widget.scrollController.offset) / _expandedHeight;
36+
double scrollDelta = (_expandedHeight - widget.scrollController.offset) / _expandedHeight;
3837
double scrollPercent = (scrollDelta * 2 - 1);
3938
return (1 - scrollPercent) * delta * basePadding + basePadding;
4039
}
@@ -59,7 +58,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
5958
),
6059
title: Text(
6160
appStrings.tabBar_preferences,
62-
textScaleFactor: 1,
61+
textScaler: TextScaler.linear(1),
6362
style: Theme.of(context).appBarTheme.titleTextStyle,
6463
),
6564
),

lib/components/cards/image_details_card.dart

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:io';
2-
import 'dart:ui' as ui show Codec, FrameInfo, Image;
2+
import 'dart:ui' as ui show Image;
33

44
import 'package:auto_size_text/auto_size_text.dart';
55
import 'package:extended_text/extended_text.dart';
@@ -17,8 +17,7 @@ import 'package:provider/provider.dart';
1717
import 'package:video_player/video_player.dart';
1818

1919
class ImageDetailsCard extends StatelessWidget {
20-
const ImageDetailsCard({Key? key, required this.image, this.onRemove})
21-
: super(key: key);
20+
const ImageDetailsCard({Key? key, required this.image, this.onRemove}) : super(key: key);
2221

2322
final ImageModel image;
2423
final Function()? onRemove;
@@ -57,9 +56,7 @@ class ImageDetailsCard extends StatelessWidget {
5756
child: ClipRRect(
5857
borderRadius: BorderRadius.circular(5.0),
5958
child: Builder(builder: (context) {
60-
final String? imageUrl = image
61-
.getDerivativeFromString(Preferences.getImageThumbnailSize)
62-
?.url;
59+
final String? imageUrl = image.getDerivativeFromString(Preferences.getImageThumbnailSize)?.url;
6360
return ImageNetworkDisplay(
6461
imageUrl: imageUrl,
6562
);
@@ -91,10 +88,7 @@ class ImageDetailsCard extends StatelessWidget {
9188
children: [
9289
Flexible(
9390
child: Text(
94-
image.file
95-
.replaceAll('', '\u200B')
96-
.split(path.extension(image.file))
97-
.first,
91+
image.file.replaceAll('', '\u200B').split(path.extension(image.file)).first,
9892
maxLines: 1,
9993
overflow: TextOverflow.ellipsis,
10094
style: Theme.of(context).textTheme.bodySmall,
@@ -112,13 +106,11 @@ class ImageDetailsCard extends StatelessWidget {
112106
const Spacer(),
113107
if (image.dateAvailable != null)
114108
Builder(builder: (context) {
115-
LocaleNotifier localeNotifier =
116-
Provider.of<LocaleNotifier>(context, listen: false);
109+
LocaleNotifier localeNotifier = Provider.of<LocaleNotifier>(context, listen: false);
117110
String date =
118-
DateFormat.yMMMMd(localeNotifier.locale.languageCode)
119-
.format(DateTime.parse(image.dateAvailable!));
120-
String time = DateFormat.Hms(localeNotifier.locale.languageCode)
121-
.format(DateTime.parse(image.dateAvailable!));
111+
DateFormat.yMMMMd(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
112+
String time =
113+
DateFormat.Hms(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
122114
return AutoSizeText(
123115
"$date $time",
124116
maxLines: 1,
@@ -150,8 +142,7 @@ class ImageDetailsCard extends StatelessWidget {
150142
}
151143

152144
class LocalImageDetailsCard extends StatefulWidget {
153-
const LocalImageDetailsCard(
154-
{Key? key, required this.image, this.onRemove, this.isDuplicate = false})
145+
const LocalImageDetailsCard({Key? key, required this.image, this.onRemove, this.isDuplicate = false})
155146
: super(key: key);
156147

157148
final File image;
@@ -214,17 +205,12 @@ class _LocalImageDetailsCardState extends State<LocalImageDetailsCard> {
214205
fit: StackFit.expand,
215206
children: [
216207
LayoutBuilder(builder: (context, constraints) {
217-
List<String>? mimeType =
218-
mime(widget.image.path.split('/').last)?.split('/');
208+
List<String>? mimeType = mime(widget.image.path.split('/').last)?.split('/');
219209

220210
if (mimeType?.first == 'image') {
221211
_checkMemory();
222-
double? cacheWidth = constraints.maxWidth.isInfinite
223-
? constraints.maxWidth
224-
: null;
225-
double? cacheHeight = constraints.maxHeight.isInfinite
226-
? constraints.maxHeight
227-
: null;
212+
double? cacheWidth = constraints.maxWidth.isInfinite ? constraints.maxWidth : null;
213+
double? cacheHeight = constraints.maxHeight.isInfinite ? constraints.maxHeight : null;
228214
return Image.file(
229215
widget.image,
230216
fit: BoxFit.cover,
@@ -327,8 +313,7 @@ class _LocalImageDetailsCardState extends State<LocalImageDetailsCard> {
327313
}
328314

329315
class LocalVideoDetailsCard extends StatefulWidget {
330-
const LocalVideoDetailsCard(
331-
{Key? key, required this.video, this.onRemove, this.isDuplicate = false})
316+
const LocalVideoDetailsCard({Key? key, required this.video, this.onRemove, this.isDuplicate = false})
332317
: super(key: key);
333318

334319
final File video;
@@ -361,9 +346,7 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
361346
final Duration duration = _controller.value.duration;
362347
int hours = duration.inHours;
363348
int minutes = (duration - Duration(hours: hours)).inMinutes;
364-
int seconds =
365-
(duration - Duration(hours: hours) - Duration(minutes: minutes))
366-
.inSeconds;
349+
int seconds = (duration - Duration(hours: hours) - Duration(minutes: minutes)).inSeconds;
367350
return '${hours > 0 ? '$hours:' : ''}${minutes < 10 ? '0$minutes' : '$minutes'}:${seconds < 10 ? '0$seconds' : '$seconds'}';
368351
}
369352

@@ -433,17 +416,12 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
433416
bottom: 2.0,
434417
left: 2.0,
435418
child: Container(
436-
padding: const EdgeInsets.symmetric(
437-
horizontal: 4, vertical: 2),
419+
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
438420
decoration: BoxDecoration(
439-
borderRadius: BorderRadius.circular(5),
440-
color: AppColors.black.withOpacity(0.7)),
421+
borderRadius: BorderRadius.circular(5), color: AppColors.black.withOpacity(0.7)),
441422
child: Text(
442423
_duration,
443-
style: TextStyle(
444-
color: AppColors.white,
445-
fontSize: 10,
446-
fontWeight: FontWeight.bold),
424+
style: TextStyle(color: AppColors.white, fontSize: 10, fontWeight: FontWeight.bold),
447425
),
448426
),
449427
),

lib/components/dialogs/confirm_dialog.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ class ConfirmDialog extends StatelessWidget {
2727
actions: [
2828
TextButton(
2929
style: ButtonStyle(
30-
foregroundColor: MaterialStateColor.resolveWith(
31-
(states) =>
32-
Theme.of(context).textTheme.bodySmall?.color ??
33-
AppColors.disabled,
30+
foregroundColor: WidgetStateColor.resolveWith(
31+
(states) => Theme.of(context).textTheme.bodySmall?.color ?? AppColors.disabled,
3432
),
35-
overlayColor: MaterialStateColor.resolveWith(
33+
overlayColor: WidgetStateColor.resolveWith(
3634
(states) => AppColors.accent.withOpacity(0.3),
3735
),
3836
),
@@ -43,10 +41,10 @@ class ConfirmDialog extends StatelessWidget {
4341
),
4442
TextButton(
4543
style: ButtonStyle(
46-
foregroundColor: MaterialStateColor.resolveWith(
44+
foregroundColor: WidgetStateColor.resolveWith(
4745
(states) => confirmColor ?? AppColors.accent,
4846
),
49-
overlayColor: MaterialStateColor.resolveWith(
47+
overlayColor: WidgetStateColor.resolveWith(
5048
(states) => AppColors.accent.withOpacity(0.3),
5149
),
5250
),

lib/components/modals/move_or_copy_modal.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class MoveOrCopyModal extends StatefulWidget {
2626
}
2727

2828
class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
29-
final ScrollController _scrollController = ScrollController();
3029
late final Future<ApiResponse<List<AlbumModel>>> _albumFuture;
3130
late final List<int> _disabledAlbums;
3231

@@ -39,8 +38,7 @@ class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
3938
_disabledAlbums = [
4039
if (widget.album != null) widget.album!.id,
4140
if (parentAlbums.length == 1 || widget.isImage) 0,
42-
if (!widget.isImage && parentAlbums.length > 1)
43-
int.parse(parentAlbums[parentAlbums.length - 2]),
41+
if (!widget.isImage && parentAlbums.length > 1) int.parse(parentAlbums[parentAlbums.length - 2]),
4442
];
4543

4644
super.initState();
@@ -213,9 +211,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
213211
child: Text(
214212
"${List.generate(widget.index, (index) => '.').join()}${widget.index > 0 ? ' ' : ''}${widget.album.name}",
215213
overflow: TextOverflow.ellipsis,
216-
style: _disabled
217-
? Theme.of(context).textTheme.bodySmall
218-
: Theme.of(context).textTheme.bodyMedium,
214+
style: _disabled ? Theme.of(context).textTheme.bodySmall : Theme.of(context).textTheme.bodyMedium,
219215
),
220216
),
221217
),
@@ -235,9 +231,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
235231
child: Text(
236232
appStrings.albumCount(widget.album.nbCategories),
237233
style: TextStyle(
238-
color: Theme.of(context)
239-
.primaryColor
240-
.withOpacity(0.7),
234+
color: Theme.of(context).primaryColor.withOpacity(0.7),
241235
fontSize: 14,
242236
),
243237
),

lib/network/albums.dart

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
2727
);
2828

2929
if (response.statusCode == 200) {
30-
List<dynamic> jsonAlbums =
31-
tryParseJson(response.data)['result']['categories'];
30+
List<dynamic> jsonAlbums = tryParseJson(response.data)['result']['categories'];
3231
List<AlbumModel> albums = List<AlbumModel>.from(jsonAlbums.map(
3332
(album) {
34-
bool canUpload =
35-
appPreferences.getBool(Preferences.isAdminKey) ?? false;
33+
bool canUpload = appPreferences.getBool(Preferences.isAdminKey) ?? false;
3634
album['can_upload'] = canUpload;
3735
return AlbumModel.fromJson(album);
3836
},
@@ -47,8 +45,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
4745
}
4846
if (communityResult.hasData) {
4947
for (AlbumModel communityAlbum in communityResult.data) {
50-
int index =
51-
albums.indexWhere((album) => album.id == communityAlbum.id);
48+
int index = albums.indexWhere((album) => album.id == communityAlbum.id);
5249
if (index >= 0) {
5350
AlbumModel newAlbum = albums.elementAt(index);
5451
newAlbum.canUpload = true;
@@ -65,7 +62,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
6562
data: albums,
6663
);
6764
}
68-
} on DioError catch (e) {
65+
} on DioException catch (e) {
6966
debugPrint(e.message);
7067
} catch (e) {
7168
debugPrint("$e");
@@ -86,8 +83,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchCommunityAlbums(int albumID) async {
8683
);
8784

8885
if (response.statusCode == 200) {
89-
List<dynamic> jsonAlbums =
90-
json.decode(response.data)['result']['categories'];
86+
List<dynamic> jsonAlbums = json.decode(response.data)['result']['categories'];
9187
List<AlbumModel> albums = List<AlbumModel>.from(jsonAlbums.map(
9288
(album) => AlbumModel.fromJson(album),
9389
));
@@ -96,7 +92,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchCommunityAlbums(int albumID) async {
9692
data: albums,
9793
);
9894
}
99-
} on DioError catch (e) {
95+
} on DioException catch (e) {
10096
debugPrint(e.message);
10197
} catch (e) {
10298
debugPrint("$e");
@@ -129,7 +125,7 @@ Future<ApiResponse<List<AlbumModel>>> getAlbumTree([int? startId]) async {
129125
data: albums,
130126
);
131127
}
132-
} on DioError catch (e) {
128+
} on DioException catch (e) {
133129
debugPrint(e.message);
134130
} catch (e) {
135131
debugPrint("$e");
@@ -164,7 +160,7 @@ Future<ApiResponse<bool>> addAlbum({
164160
}
165161
return ApiResponse(data: true);
166162
}
167-
} on DioError catch (e) {
163+
} on DioException catch (e) {
168164
debugPrint(e.message);
169165
} catch (e) {
170166
debugPrint("$e");
@@ -197,7 +193,7 @@ Future<ApiResponse<bool>> moveAlbum(int catId, int parentCatId) async {
197193
}
198194
return ApiResponse(data: true);
199195
}
200-
} on DioError catch (e) {
196+
} on DioException catch (e) {
201197
debugPrint("${e.message}");
202198
} catch (e) {
203199
debugPrint("$e");
@@ -239,7 +235,7 @@ Future<ApiResponse<bool>> editAlbum({
239235
print(data);
240236
return ApiResponse(data: true);
241237
}
242-
} on DioError catch (e) {
238+
} on DioException catch (e) {
243239
debugPrint("${e.message}");
244240
} catch (e) {
245241
debugPrint("$e");
@@ -276,7 +272,7 @@ Future<ApiResponse<bool>> deleteAlbum(
276272
}
277273
return ApiResponse(data: true);
278274
}
279-
} on DioError catch (e) {
275+
} on DioException catch (e) {
280276
debugPrint("${e.message}");
281277
} catch (e) {
282278
debugPrint("$e");

lib/network/api_client.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import 'dart:convert';
22
import 'dart:io';
33

44
import 'package:cookie_jar/cookie_jar.dart';
5-
import 'package:dio/adapter.dart';
65
import 'package:dio/dio.dart';
6+
import 'package:dio/io.dart';
77
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
88
import 'package:flutter/foundation.dart';
99
import 'package:piwigo_ng/services/preferences_service.dart';
@@ -17,13 +17,9 @@ class ApiClient {
1717
..interceptors.add(CookieManager(cookieJar))
1818
..httpClientAdapter = sslHttpClientAdapter;
1919

20-
static HttpClientAdapter get sslHttpClientAdapter {
21-
return DefaultHttpClientAdapter()
22-
..onHttpClientCreate = (HttpClient client) {
23-
client.badCertificateCallback = piwigoSSLBypass;
24-
return client;
25-
};
26-
}
20+
static HttpClientAdapter get sslHttpClientAdapter => IOHttpClientAdapter(
21+
createHttpClient: () => HttpClient()..badCertificateCallback = piwigoSSLBypass,
22+
);
2723

2824
static bool piwigoSSLBypass(X509Certificate cert, String host, int port) {
2925
if (Preferences.getEnableSSL) {
@@ -138,8 +134,7 @@ class ApiClient {
138134
class SSLHttpOverrides extends HttpOverrides {
139135
@override
140136
HttpClient createHttpClient(SecurityContext? context) {
141-
return super.createHttpClient(context)
142-
..badCertificateCallback = ApiClient.piwigoSSLBypass;
137+
return super.createHttpClient(context)..badCertificateCallback = ApiClient.piwigoSSLBypass;
143138
}
144139
}
145140

0 commit comments

Comments
 (0)