Skip to content

Commit

Permalink
Merge pull request #192 from Piwigo/feature/fix_dependencies
Browse files Browse the repository at this point in the history
Fix flutter dependencies
  • Loading branch information
remi-martin authored Jun 28, 2024
2 parents 12a2192 + e1a3807 commit 919ac62
Show file tree
Hide file tree
Showing 35 changed files with 384 additions and 592 deletions.
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
/build/.last_build_id
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ android {
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
// Sets Java compatibility to Java 11
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.1.3" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion lib/components/appbars/root_search_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class _RootSearchAppBarState extends State<RootSearchAppBar> {
),
title: Text(
appStrings.tabBar_albums,
textScaleFactor: 1,
textScaler: TextScaler.linear(1),
style: Theme.of(context).appBarTheme.titleTextStyle,
),
),
Expand Down
5 changes: 2 additions & 3 deletions lib/components/appbars/settings_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
}

// In case 0%-100% of the expanded height is viewed
double scrollDelta =
(_expandedHeight - widget.scrollController.offset) / _expandedHeight;
double scrollDelta = (_expandedHeight - widget.scrollController.offset) / _expandedHeight;
double scrollPercent = (scrollDelta * 2 - 1);
return (1 - scrollPercent) * delta * basePadding + basePadding;
}
Expand All @@ -59,7 +58,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
),
title: Text(
appStrings.tabBar_preferences,
textScaleFactor: 1,
textScaler: TextScaler.linear(1),
style: Theme.of(context).appBarTheme.titleTextStyle,
),
),
Expand Down
56 changes: 17 additions & 39 deletions lib/components/cards/image_details_card.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dart:io';
import 'dart:ui' as ui show Codec, FrameInfo, Image;
import 'dart:ui' as ui show Image;

import 'package:auto_size_text/auto_size_text.dart';
import 'package:extended_text/extended_text.dart';
Expand All @@ -17,8 +17,7 @@ import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';

class ImageDetailsCard extends StatelessWidget {
const ImageDetailsCard({Key? key, required this.image, this.onRemove})
: super(key: key);
const ImageDetailsCard({Key? key, required this.image, this.onRemove}) : super(key: key);

final ImageModel image;
final Function()? onRemove;
Expand Down Expand Up @@ -57,9 +56,7 @@ class ImageDetailsCard extends StatelessWidget {
child: ClipRRect(
borderRadius: BorderRadius.circular(5.0),
child: Builder(builder: (context) {
final String? imageUrl = image
.getDerivativeFromString(Preferences.getImageThumbnailSize)
?.url;
final String? imageUrl = image.getDerivativeFromString(Preferences.getImageThumbnailSize)?.url;
return ImageNetworkDisplay(
imageUrl: imageUrl,
);
Expand Down Expand Up @@ -91,10 +88,7 @@ class ImageDetailsCard extends StatelessWidget {
children: [
Flexible(
child: Text(
image.file
.replaceAll('', '\u200B')
.split(path.extension(image.file))
.first,
image.file.replaceAll('', '\u200B').split(path.extension(image.file)).first,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall,
Expand All @@ -112,13 +106,11 @@ class ImageDetailsCard extends StatelessWidget {
const Spacer(),
if (image.dateAvailable != null)
Builder(builder: (context) {
LocaleNotifier localeNotifier =
Provider.of<LocaleNotifier>(context, listen: false);
LocaleNotifier localeNotifier = Provider.of<LocaleNotifier>(context, listen: false);
String date =
DateFormat.yMMMMd(localeNotifier.locale.languageCode)
.format(DateTime.parse(image.dateAvailable!));
String time = DateFormat.Hms(localeNotifier.locale.languageCode)
.format(DateTime.parse(image.dateAvailable!));
DateFormat.yMMMMd(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
String time =
DateFormat.Hms(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
return AutoSizeText(
"$date $time",
maxLines: 1,
Expand Down Expand Up @@ -150,8 +142,7 @@ class ImageDetailsCard extends StatelessWidget {
}

class LocalImageDetailsCard extends StatefulWidget {
const LocalImageDetailsCard(
{Key? key, required this.image, this.onRemove, this.isDuplicate = false})
const LocalImageDetailsCard({Key? key, required this.image, this.onRemove, this.isDuplicate = false})
: super(key: key);

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

if (mimeType?.first == 'image') {
_checkMemory();
double? cacheWidth = constraints.maxWidth.isInfinite
? constraints.maxWidth
: null;
double? cacheHeight = constraints.maxHeight.isInfinite
? constraints.maxHeight
: null;
double? cacheWidth = constraints.maxWidth.isInfinite ? constraints.maxWidth : null;
double? cacheHeight = constraints.maxHeight.isInfinite ? constraints.maxHeight : null;
return Image.file(
widget.image,
fit: BoxFit.cover,
Expand Down Expand Up @@ -327,8 +313,7 @@ class _LocalImageDetailsCardState extends State<LocalImageDetailsCard> {
}

class LocalVideoDetailsCard extends StatefulWidget {
const LocalVideoDetailsCard(
{Key? key, required this.video, this.onRemove, this.isDuplicate = false})
const LocalVideoDetailsCard({Key? key, required this.video, this.onRemove, this.isDuplicate = false})
: super(key: key);

final File video;
Expand Down Expand Up @@ -361,9 +346,7 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
final Duration duration = _controller.value.duration;
int hours = duration.inHours;
int minutes = (duration - Duration(hours: hours)).inMinutes;
int seconds =
(duration - Duration(hours: hours) - Duration(minutes: minutes))
.inSeconds;
int seconds = (duration - Duration(hours: hours) - Duration(minutes: minutes)).inSeconds;
return '${hours > 0 ? '$hours:' : ''}${minutes < 10 ? '0$minutes' : '$minutes'}:${seconds < 10 ? '0$seconds' : '$seconds'}';
}

Expand Down Expand Up @@ -433,17 +416,12 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
bottom: 2.0,
left: 2.0,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 2),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: AppColors.black.withOpacity(0.7)),
borderRadius: BorderRadius.circular(5), color: AppColors.black.withOpacity(0.7)),
child: Text(
_duration,
style: TextStyle(
color: AppColors.white,
fontSize: 10,
fontWeight: FontWeight.bold),
style: TextStyle(color: AppColors.white, fontSize: 10, fontWeight: FontWeight.bold),
),
),
),
Expand Down
12 changes: 5 additions & 7 deletions lib/components/dialogs/confirm_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ class ConfirmDialog extends StatelessWidget {
actions: [
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateColor.resolveWith(
(states) =>
Theme.of(context).textTheme.bodySmall?.color ??
AppColors.disabled,
foregroundColor: WidgetStateColor.resolveWith(
(states) => Theme.of(context).textTheme.bodySmall?.color ?? AppColors.disabled,
),
overlayColor: MaterialStateColor.resolveWith(
overlayColor: WidgetStateColor.resolveWith(
(states) => AppColors.accent.withOpacity(0.3),
),
),
Expand All @@ -43,10 +41,10 @@ class ConfirmDialog extends StatelessWidget {
),
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateColor.resolveWith(
foregroundColor: WidgetStateColor.resolveWith(
(states) => confirmColor ?? AppColors.accent,
),
overlayColor: MaterialStateColor.resolveWith(
overlayColor: WidgetStateColor.resolveWith(
(states) => AppColors.accent.withOpacity(0.3),
),
),
Expand Down
12 changes: 3 additions & 9 deletions lib/components/modals/move_or_copy_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class MoveOrCopyModal extends StatefulWidget {
}

class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
final ScrollController _scrollController = ScrollController();
late final Future<ApiResponse<List<AlbumModel>>> _albumFuture;
late final List<int> _disabledAlbums;

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

super.initState();
Expand Down Expand Up @@ -213,9 +211,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
child: Text(
"${List.generate(widget.index, (index) => '.').join()}${widget.index > 0 ? ' ' : ''}${widget.album.name}",
overflow: TextOverflow.ellipsis,
style: _disabled
? Theme.of(context).textTheme.bodySmall
: Theme.of(context).textTheme.bodyMedium,
style: _disabled ? Theme.of(context).textTheme.bodySmall : Theme.of(context).textTheme.bodyMedium,
),
),
),
Expand All @@ -235,9 +231,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
child: Text(
appStrings.albumCount(widget.album.nbCategories),
style: TextStyle(
color: Theme.of(context)
.primaryColor
.withOpacity(0.7),
color: Theme.of(context).primaryColor.withOpacity(0.7),
fontSize: 14,
),
),
Expand Down
26 changes: 11 additions & 15 deletions lib/network/albums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
);

if (response.statusCode == 200) {
List<dynamic> jsonAlbums =
tryParseJson(response.data)['result']['categories'];
List<dynamic> jsonAlbums = tryParseJson(response.data)['result']['categories'];
List<AlbumModel> albums = List<AlbumModel>.from(jsonAlbums.map(
(album) {
bool canUpload =
appPreferences.getBool(Preferences.isAdminKey) ?? false;
bool canUpload = appPreferences.getBool(Preferences.isAdminKey) ?? false;
album['can_upload'] = canUpload;
return AlbumModel.fromJson(album);
},
Expand All @@ -47,8 +45,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
}
if (communityResult.hasData) {
for (AlbumModel communityAlbum in communityResult.data) {
int index =
albums.indexWhere((album) => album.id == communityAlbum.id);
int index = albums.indexWhere((album) => album.id == communityAlbum.id);
if (index >= 0) {
AlbumModel newAlbum = albums.elementAt(index);
newAlbum.canUpload = true;
Expand All @@ -65,7 +62,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchAlbums(int albumID) async {
data: albums,
);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint(e.message);
} catch (e) {
debugPrint("$e");
Expand All @@ -86,8 +83,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchCommunityAlbums(int albumID) async {
);

if (response.statusCode == 200) {
List<dynamic> jsonAlbums =
json.decode(response.data)['result']['categories'];
List<dynamic> jsonAlbums = json.decode(response.data)['result']['categories'];
List<AlbumModel> albums = List<AlbumModel>.from(jsonAlbums.map(
(album) => AlbumModel.fromJson(album),
));
Expand All @@ -96,7 +92,7 @@ Future<ApiResponse<List<AlbumModel>>> fetchCommunityAlbums(int albumID) async {
data: albums,
);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint(e.message);
} catch (e) {
debugPrint("$e");
Expand Down Expand Up @@ -129,7 +125,7 @@ Future<ApiResponse<List<AlbumModel>>> getAlbumTree([int? startId]) async {
data: albums,
);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint(e.message);
} catch (e) {
debugPrint("$e");
Expand Down Expand Up @@ -164,7 +160,7 @@ Future<ApiResponse<bool>> addAlbum({
}
return ApiResponse(data: true);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint(e.message);
} catch (e) {
debugPrint("$e");
Expand Down Expand Up @@ -197,7 +193,7 @@ Future<ApiResponse<bool>> moveAlbum(int catId, int parentCatId) async {
}
return ApiResponse(data: true);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint("${e.message}");
} catch (e) {
debugPrint("$e");
Expand Down Expand Up @@ -239,7 +235,7 @@ Future<ApiResponse<bool>> editAlbum({
print(data);
return ApiResponse(data: true);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint("${e.message}");
} catch (e) {
debugPrint("$e");
Expand Down Expand Up @@ -276,7 +272,7 @@ Future<ApiResponse<bool>> deleteAlbum(
}
return ApiResponse(data: true);
}
} on DioError catch (e) {
} on DioException catch (e) {
debugPrint("${e.message}");
} catch (e) {
debugPrint("$e");
Expand Down
15 changes: 5 additions & 10 deletions lib/network/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:convert';
import 'dart:io';

import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/adapter.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:flutter/foundation.dart';
import 'package:piwigo_ng/services/preferences_service.dart';
Expand All @@ -17,13 +17,9 @@ class ApiClient {
..interceptors.add(CookieManager(cookieJar))
..httpClientAdapter = sslHttpClientAdapter;

static HttpClientAdapter get sslHttpClientAdapter {
return DefaultHttpClientAdapter()
..onHttpClientCreate = (HttpClient client) {
client.badCertificateCallback = piwigoSSLBypass;
return client;
};
}
static HttpClientAdapter get sslHttpClientAdapter => IOHttpClientAdapter(
createHttpClient: () => HttpClient()..badCertificateCallback = piwigoSSLBypass,
);

static bool piwigoSSLBypass(X509Certificate cert, String host, int port) {
if (Preferences.getEnableSSL) {
Expand Down Expand Up @@ -138,8 +134,7 @@ class ApiClient {
class SSLHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback = ApiClient.piwigoSSLBypass;
return super.createHttpClient(context)..badCertificateCallback = ApiClient.piwigoSSLBypass;
}
}

Expand Down
Loading

0 comments on commit 919ac62

Please sign in to comment.