diff --git a/android/app/build.gradle b/android/app/build.gradle index bc9c6cf..7ce7ead 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { @@ -81,7 +78,6 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "androidx.window:window:1.0.0" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' } diff --git a/android/build.gradle b/android/build.gradle index d1b666a..b42eb3a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.1.3' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/android/settings.gradle b/android/settings.gradle index 44e62bc..08fcadc 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,11 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +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 +} + +include ":app" \ No newline at end of file diff --git a/lib/network/upload.dart b/lib/network/upload.dart index 9471efe..3b47584 100644 --- a/lib/network/upload.dart +++ b/lib/network/upload.dart @@ -85,8 +85,7 @@ Future> uploadPhotos( if (url == null) return []; String? username = await storage.read(key: Preferences.usernameKey); String? password = await storage.read(key: Preferences.passwordKey); - UploadNotifier uploadNotifier = - App.appKey.currentContext!.read(); + UploadNotifier uploadNotifier = App.appKey.currentContext!.read(); int nbError = 0; // Creates Upload Item list for the upload notifier @@ -106,8 +105,7 @@ Future> uploadPhotos( App.navigatorKey.currentState?.popAndPushNamed(UploadStatusPage.routeName); // Iterate on each item - await Future.wait(List>.generate(items.length, (index) async { - UploadItem item = items[index]; + for (UploadItem item in items) { try { // Upload image Response? response = await uploadChunk( @@ -152,7 +150,7 @@ Future> uploadPhotos( uploadNotifier.itemUploadCompleted(item, error: true); nbError++; } - })); + } // Send notifications showUploadNotification(nbError, result.length); @@ -202,10 +200,8 @@ Future uploadChunk({ // Filter fields if (info['name'] != '' && info['name'] != null) fields['name'] = info['name']; - if (info['comment'] != '' && info['comment'] != null) - fields['comment'] = info['comment']; - if (info['tag_ids']?.isNotEmpty ?? false) - fields['tag_ids'] = info['tag_ids'].join(','); + if (info['comment'] != '' && info['comment'] != null) fields['comment'] = info['comment']; + if (info['tag_ids']?.isNotEmpty ?? false) fields['tag_ids'] = info['tag_ids'].join(','); if (info['level'] != -1) fields['level'] = info['level']; // Create dio client @@ -247,8 +243,7 @@ Future uploadCompleted(List imageId, int categoryId) async { }); try { - Response response = - await ApiClient.post(data: formData, queryParameters: queries); + Response response = await ApiClient.post(data: formData, queryParameters: queries); if (response.statusCode == 200) { return true; } @@ -270,8 +265,7 @@ Future communityUploadCompleted(List imageId, int categoryId) async { 'category_id': categoryId, }); try { - Response response = - await ApiClient.post(data: formData, queryParameters: queries); + Response response = await ApiClient.post(data: formData, queryParameters: queries); if (response.statusCode == 200) { return true; } diff --git a/lib/views/image/image_page.dart b/lib/views/image/image_page.dart index 7769f95..d327d18 100644 --- a/lib/views/image/image_page.dart +++ b/lib/views/image/image_page.dart @@ -82,11 +82,9 @@ class _ImagePageState extends State { void initState() { _imageList = widget.images.sublist(0); _album = widget.album; - _imagePage = - ((_imageList.length - 1) / Settings.defaultElementPerPage).floor(); + _imagePage = ((_imageList.length - 1) / Settings.defaultElementPerPage).floor(); - final ImageModel? startImage = - _imageList.firstWhere((image) => image.id == widget.startId); + final ImageModel? startImage = _imageList.firstWhere((image) => image.id == widget.startId); if (startImage != null) { _page = _imageList.indexOf(startImage); if (_imageList.last == startImage) { @@ -117,9 +115,7 @@ class _ImagePageState extends State { systemNavigationBarColor: Colors.black.withOpacity(0.001), statusBarColor: Colors.black.withOpacity(0.001), statusBarIconBrightness: - App.appKey.currentContext?.read().isDark ?? false - ? Brightness.light - : Brightness.dark, + App.appKey.currentContext?.read().isDark ?? false ? Brightness.light : Brightness.dark, )); super.dispose(); } @@ -129,8 +125,7 @@ class _ImagePageState extends State { Future _loadMoreImages() async { if (_album.id == -1) return; if (_album.nbImages <= _imageList.length) return; - ApiResponse> result = - await fetchImages(_album.id, _imagePage + 1); + ApiResponse> result = await fetchImages(_album.id, _imagePage + 1); if (result.hasError || !result.hasData) return; setState(() { _imagePage += 1; @@ -145,10 +140,8 @@ class _ImagePageState extends State { if (serverUrl == null) return {}; // Get server cookies - List cookies = - await ApiClient.cookieJar.loadForRequest(Uri.parse(serverUrl)); - String cookiesStr = - cookies.map((cookie) => '${cookie.name}=${cookie.value}').join('; '); + List cookies = await ApiClient.cookieJar.loadForRequest(Uri.parse(serverUrl)); + String cookiesStr = cookies.map((cookie) => '${cookie.name}=${cookie.value}').join('; '); // Get HTTP Basic id SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -354,9 +347,7 @@ class _ImagePageState extends State { style: TextStyle(fontSize: 16.0, color: Colors.white), ), ), - if (MediaQuery.of(context).orientation == - Orientation.landscape) - ..._actions, + if (MediaQuery.of(context).orientation == Orientation.landscape) ..._actions, if (widget.isAdmin) PopupMenuButton( position: PopupMenuPosition.under, @@ -385,9 +376,7 @@ class _ImagePageState extends State { _onLike, ), child: PopupListItem( - icon: !_currentImage.favorite - ? Icons.favorite_border - : Icons.favorite, + icon: !_currentImage.favorite ? Icons.favorite_border : Icons.favorite, text: !_currentImage.favorite ? appStrings.imageOptions_addFavorites : appStrings.imageOptions_removeFavorites, @@ -495,10 +484,7 @@ class _ImagePageState extends State { imageUrl = image.elementUrl; imageUrl = HtmlUnescape().convert(imageUrl); } else { - imageUrl = image - .getDerivativeFromString(Preferences.getImageFullScreenSize) - ?.url ?? - ''; + imageUrl = image.getDerivativeFromString(Preferences.getImageFullScreenSize)?.url ?? ''; } // ApiClient.cookieJar.loadForRequest(Uri.parse(imageUrl)); @@ -520,10 +506,8 @@ class _ImagePageState extends State { child: IconButton( color: Colors.white, style: ButtonStyle( - backgroundColor: MaterialStateProperty.resolveWith( - (states) => Colors.black.withOpacity(0.5)), - shape: MaterialStateProperty.resolveWith( - (states) => CircleBorder()), + backgroundColor: MaterialStateProperty.resolveWith((states) => Colors.black.withOpacity(0.5)), + shape: MaterialStateProperty.resolveWith((states) => CircleBorder()), ), onPressed: () { Navigator.of(context).pushNamed( @@ -562,6 +546,7 @@ class _ImagePageState extends State { debugPrint("$o\n$s"); return const Icon(Icons.broken_image_outlined); }, + filterQuality: FilterQuality.medium, ); }, ); @@ -601,14 +586,11 @@ class _ImagePageState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _pagination, - if (MediaQuery.of(context).orientation == - Orientation.portrait) + if (MediaQuery.of(context).orientation == Orientation.portrait) SizedBox( height: 56.0, child: Row( - children: _actions - .map((action) => Expanded(child: action)) - .toList(), + children: _actions.map((action) => Expanded(child: action)).toList(), ), ), ], @@ -667,8 +649,7 @@ class _ImagePageState extends State { duration: _overlayAnimationDuration, curve: _overlayAnimationCurve, child: Builder(builder: (context) { - if (_currentImage.comment == null || _currentImage.comment!.isEmpty) - return const SizedBox(); + if (_currentImage.comment == null || _currentImage.comment!.isEmpty) return const SizedBox(); return GestureDetector( behavior: HitTestBehavior.opaque, onTap: _showImageDetails, diff --git a/pubspec.yaml b/pubspec.yaml index 4bc3198..7b8761f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 2.2.3+223 environment: - sdk: ">=2.17.6 <3.0.0" + sdk: ">=3.0.0 <4.0.0" + flutter: 3.22.2 dependencies: flutter: @@ -24,15 +25,18 @@ dependencies: auto_size_text: ^3.0.0 # Text that auto-sizes (image thumbnail title) cupertino_icons: ^1.0.2 # iOS style icons (might be useless) font_awesome_flutter: ^10.1.0 # Font awesome icons (might be useless) - flutter_slidable: ^2.0.0 # Album card's sliding cations + flutter_slidable: ^3.0.1 # Album card's sliding cations drag_select_grid_view: ^0.6.1 # Drag to select image grid - rounded_loading_button: ^2.1.0 # Loading button animation + rounded_loading_button: # Loading button animation + git: + url: https://github.com/scopendo/flutter_rounded_loading_button # A custom fork that can work with the latest flutter SDK + ref: dd4b76a modal_bottom_sheet: ^3.0.0-pre # Custom modals (might be useless) cached_network_image: ^3.2.2 # Better cache for images (used for album's thumbnail) flutter_speed_dial: ^6.1.0+1 # Speed dial pull_to_refresh: ^2.0.0 # Top and bottom refresh gestures photo_view: ^0.14.0 # Zoom on fullscreen photos - extended_text: ^11.0.0 # Text overflow on left side + extended_text: ^13.0.0 # Text overflow on left side flutter_easyloading: ^3.0.5 # Show loading dialog # Storage @@ -64,7 +68,7 @@ dependencies: # Translations flutter_localizations: sdk: flutter - intl: ^0.18.0 # Used for translations + intl: ^0.19.0 # Used for translations html_unescape: ^2.0.0 dev_dependencies: