From 397eaefe9e7ce70181955dfd5d0308c10d636561 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:38:24 +0800 Subject: [PATCH 01/24] Update url_launcher --- app/lib/url_launcher_util.dart | 4 ++++ app/lib/widget/connect.dart | 2 +- app/lib/widget/gps_map.dart | 2 +- app/lib/widget/handler/enhance_handler.dart | 2 +- app/lib/widget/home_app_bar.dart | 2 +- app/lib/widget/people_browser.dart | 2 +- app/lib/widget/settings.dart | 2 +- app/lib/widget/shared_album_info_dialog.dart | 2 +- app/lib/widget/sign_in.dart | 2 +- app/pubspec.lock | 16 ++++++++-------- 10 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 app/lib/url_launcher_util.dart diff --git a/app/lib/url_launcher_util.dart b/app/lib/url_launcher_util.dart new file mode 100644 index 00000000..ef63602d --- /dev/null +++ b/app/lib/url_launcher_util.dart @@ -0,0 +1,4 @@ +import 'package:url_launcher/url_launcher_string.dart'; + +Future launch(String url) => + launchUrlString(url, mode: LaunchMode.externalApplication); diff --git a/app/lib/widget/connect.dart b/app/lib/widget/connect.dart index a7b2b98d..130ec954 100644 --- a/app/lib/widget/connect.dart +++ b/app/lib/widget/connect.dart @@ -22,8 +22,8 @@ import 'package:nc_photos/platform/features.dart' as features; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/string_extension.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/use_case/ls_single_file.dart'; -import 'package:url_launcher/url_launcher.dart'; class ConnectArguments { ConnectArguments(this.account); diff --git a/app/lib/widget/gps_map.dart b/app/lib/widget/gps_map.dart index 79fc2535..269e728b 100644 --- a/app/lib/widget/gps_map.dart +++ b/app/lib/widget/gps_map.dart @@ -4,8 +4,8 @@ import 'package:latlong2/latlong.dart'; import 'package:nc_photos/mobile/platform.dart' if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform; import 'package:nc_photos/pref.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:tuple/tuple.dart'; -import 'package:url_launcher/url_launcher.dart'; enum GpsMapProvider { // the order must not be changed diff --git a/app/lib/widget/handler/enhance_handler.dart b/app/lib/widget/handler/enhance_handler.dart index 8d239208..ef5d5374 100644 --- a/app/lib/widget/handler/enhance_handler.dart +++ b/app/lib/widget/handler/enhance_handler.dart @@ -20,11 +20,11 @@ import 'package:nc_photos/platform/k.dart' as platform_k; import 'package:nc_photos/pref.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/selectable.dart'; import 'package:nc_photos/widget/settings.dart'; import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:nc_photos_plugin/nc_photos_plugin.dart'; -import 'package:url_launcher/url_launcher.dart'; class EnhanceHandler { const EnhanceHandler({ diff --git a/app/lib/widget/home_app_bar.dart b/app/lib/widget/home_app_bar.dart index d20dadf7..eb5f41b1 100644 --- a/app/lib/widget/home_app_bar.dart +++ b/app/lib/widget/home_app_bar.dart @@ -7,9 +7,9 @@ import 'package:nc_photos/event/event.dart'; import 'package:nc_photos/help_utils.dart' as help_utils; import 'package:nc_photos/pref.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/account_picker_dialog.dart'; import 'package:nc_photos/widget/settings.dart'; -import 'package:url_launcher/url_launcher.dart'; /// AppBar for home screens class HomeSliverAppBar extends StatelessWidget { diff --git a/app/lib/widget/people_browser.dart b/app/lib/widget/people_browser.dart index 31a73fd4..6db9c45e 100644 --- a/app/lib/widget/people_browser.dart +++ b/app/lib/widget/people_browser.dart @@ -18,9 +18,9 @@ import 'package:nc_photos/iterable_extension.dart'; import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/person_browser.dart'; -import 'package:url_launcher/url_launcher.dart'; class PeopleBrowserArguments { PeopleBrowserArguments(this.account); diff --git a/app/lib/widget/settings.dart b/app/lib/widget/settings.dart index 442d810e..0e359e21 100644 --- a/app/lib/widget/settings.dart +++ b/app/lib/widget/settings.dart @@ -19,6 +19,7 @@ import 'package:nc_photos/pref.dart'; import 'package:nc_photos/service.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/fancy_option_picker.dart'; import 'package:nc_photos/widget/gps_map.dart'; import 'package:nc_photos/widget/home.dart'; @@ -28,7 +29,6 @@ import 'package:nc_photos/widget/share_folder_picker.dart'; import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:screen_brightness/screen_brightness.dart'; import 'package:tuple/tuple.dart'; -import 'package:url_launcher/url_launcher.dart'; class SettingsArguments { SettingsArguments(this.account); diff --git a/app/lib/widget/shared_album_info_dialog.dart b/app/lib/widget/shared_album_info_dialog.dart index c02f9ac7..d0429471 100644 --- a/app/lib/widget/shared_album_info_dialog.dart +++ b/app/lib/widget/shared_album_info_dialog.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:nc_photos/app_localizations.dart'; import 'package:nc_photos/help_utils.dart' as help_utils; import 'package:nc_photos/pref.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:nc_photos/url_launcher_util.dart'; class SharedAlbumInfoDialog extends StatefulWidget { const SharedAlbumInfoDialog({ diff --git a/app/lib/widget/sign_in.dart b/app/lib/widget/sign_in.dart index 776f433c..c61122ec 100644 --- a/app/lib/widget/sign_in.dart +++ b/app/lib/widget/sign_in.dart @@ -10,10 +10,10 @@ import 'package:nc_photos/pref.dart'; import 'package:nc_photos/pref_util.dart' as pref_util; import 'package:nc_photos/string_extension.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/connect.dart'; import 'package:nc_photos/widget/home.dart'; import 'package:nc_photos/widget/root_picker.dart'; -import 'package:url_launcher/url_launcher.dart'; class SignIn extends StatefulWidget { static const routeName = "/sign-in"; diff --git a/app/pubspec.lock b/app/pubspec.lock index 1c456dd9..982d5155 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1101,56 +1101,56 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.17" + version: "6.1.4" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.17" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.1.0" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.12" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" uuid: dependency: transitive description: From ee6767f7511d029f37905604ae8bddc5a5ceb9dc Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:40:15 +0800 Subject: [PATCH 02/24] Update mime --- app/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 982d5155..0cc97670 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -634,7 +634,7 @@ packages: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" mocktail: dependency: transitive description: From 68f8433dd33e3232698dfc009b15a3e51ebfce3f Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:42:51 +0800 Subject: [PATCH 03/24] Update path_provider --- app/pubspec.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 0cc97670..8ece1d78 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -718,49 +718,49 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.11" path_provider_android: dependency: transitive description: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.16" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.10" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.7" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.7" pedantic: dependency: transitive description: From e1db2fe943207c0fd86427cb32a3cd2ca1a37ec9 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:46:17 +0800 Subject: [PATCH 04/24] Update device_info_plus --- app/pubspec.lock | 4 ++-- app/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 8ece1d78..4440578c 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -233,7 +233,7 @@ packages: name: device_info_plus url: "https://pub.dartlang.org" source: hosted - version: "3.2.1" + version: "4.0.0" device_info_plus_linux: dependency: transitive description: @@ -247,7 +247,7 @@ packages: name: device_info_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "2.2.3" device_info_plus_platform_interface: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 8df51584..8ed151f6 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -39,7 +39,7 @@ dependencies: collection: ^1.15.0 connectivity_plus: ^2.0.2 devicelocale: ^0.5.0 - device_info_plus: ^3.1.0 + device_info_plus: ^4.0.0 draggable_scrollbar: git: url: https://gitlab.com/nc-photos/flutter-draggable-scrollbar From 9713416ee6f31568220ef42a3d6f2292e34043f9 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:52:40 +0800 Subject: [PATCH 05/24] Update flutter_map --- app/lib/widget/gps_map.dart | 11 +++++------ app/pubspec.lock | 16 ++++++++-------- app/pubspec.yaml | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/lib/widget/gps_map.dart b/app/lib/widget/gps_map.dart index 269e728b..0a2b9a72 100644 --- a/app/lib/widget/gps_map.dart +++ b/app/lib/widget/gps_map.dart @@ -88,15 +88,14 @@ class _OsmGpsMap extends StatelessWidget { enableScrollWheel: false, interactiveFlags: InteractiveFlag.none, ), + nonRotatedChildren: [ + AttributionWidget.defaultWidget( + source: "OpenStreetMap contributors", + ), + ], layers: [ TileLayerOptions( urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png", - attributionBuilder: (_) { - return const Text( - "© OpenStreetMap contributors", - style: TextStyle(color: Colors.black), - ); - }, ), MarkerLayerOptions( markers: [ diff --git a/app/pubspec.lock b/app/pubspec.lock index 4440578c..dfbe3fd5 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -410,7 +410,7 @@ packages: name: flutter_map url: "https://pub.dartlang.org" source: hosted - version: "0.14.0" + version: "1.1.1" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -789,6 +789,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + polylabel: + dependency: transitive + description: + name: polylabel + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" pool: dependency: transitive description: @@ -1067,13 +1074,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.13" - transparent_image: - dependency: transitive - description: - name: transparent_image - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" tuple: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 8ed151f6..3f62469f 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -55,7 +55,7 @@ dependencies: url: https://gitlab.com/nc-photos/flutter_background_service.git ref: v0.2.6-nc-photos-2 flutter_bloc: ^7.0.0 - flutter_map: ^0.14.0 + flutter_map: ^1.1.1 flutter_staggered_grid_view: git: url: https://gitlab.com/nc-photos/flutter_staggered_grid_view From a271edc1b45fd80b48c74f300b7c8367dc0fdb78 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:53:41 +0800 Subject: [PATCH 06/24] Update kiwi --- app/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index dfbe3fd5..92b92bb9 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -557,7 +557,7 @@ packages: name: kiwi url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "4.0.2" latlong2: dependency: transitive description: From 3ec9e8157e5d5b0621b1ddd885af939fd441bb98 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 17:55:27 +0800 Subject: [PATCH 07/24] Update rxdart --- app/pubspec.lock | 4 ++-- app/pubspec.yaml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 92b92bb9..da564443 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -846,12 +846,12 @@ packages: source: hosted version: "3.0.1+1" rxdart: - dependency: "direct main" + dependency: transitive description: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.3" + version: "0.27.4" screen_brightness: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 3f62469f..ea27be5e 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -84,7 +84,6 @@ dependencies: page_view_indicators: ^2.0.0 path: ^1.8.0 path_provider: ^2.0.6 - rxdart: ^0.27.2 screen_brightness: ^0.1.1 shared_preferences: ^2.0.8 # android/ios only From 62c0d3c1f8abeb0bf17746c9fd9d2df20610486e Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 18:04:52 +0800 Subject: [PATCH 08/24] Update shared_preferences --- app/pubspec.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index da564443..c1a61553 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -893,35 +893,35 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "2.0.15" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.10" + version: "2.0.12" shared_preferences_ios: dependency: transitive description: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: @@ -935,14 +935,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.1.1" shelf: dependency: transitive description: From 9048123118e58f916b84bde17a29079ed4024c73 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 18:05:59 +0800 Subject: [PATCH 09/24] Update battery_plus --- app/pubspec.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index c1a61553..2a02038b 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -44,7 +44,7 @@ packages: name: battery_plus url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" battery_plus_linux: dependency: transitive description: @@ -58,7 +58,7 @@ packages: name: battery_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" battery_plus_platform_interface: dependency: transitive description: @@ -79,7 +79,7 @@ packages: name: battery_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.2" bloc: dependency: "direct main" description: From a9ab10508e01eb7c22832003f09106cecfe29d20 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 18:08:09 +0800 Subject: [PATCH 10/24] Update synchronized --- app/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 2a02038b..4c3fc22e 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1045,7 +1045,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.0+2" term_glyph: dependency: transitive description: From f55f68b593acdf48e15f80c347d7eb1a6d4c29ee Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 19:28:02 +0800 Subject: [PATCH 11/24] Update xml --- app/lib/iterable_extension.dart | 8 ++++++++ app/pubspec.lock | 6 +++--- app/pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/lib/iterable_extension.dart b/app/lib/iterable_extension.dart index 24e039b9..3be61377 100644 --- a/app/lib/iterable_extension.dart +++ b/app/lib/iterable_extension.dart @@ -84,6 +84,14 @@ extension IterableExtension on Iterable { } } +extension IterableFlattenExtension on Iterable> { + /// Flattens an [Iterable] of [Iterable] values of type [T] to a [Iterable] of + /// values of type [T]. + /// + /// This function originated in the xml package + Iterable flatten() => expand((values) => values); +} + class _ComputeAllMessage { const _ComputeAllMessage(this.callback, this.data); diff --git a/app/pubspec.lock b/app/pubspec.lock index 4c3fc22e..d63c13e2 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -226,7 +226,7 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.3" + version: "0.7.4" device_info_plus: dependency: "direct main" description: @@ -774,7 +774,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "5.0.0" platform: dependency: transitive description: @@ -1296,7 +1296,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.1" + version: "6.1.0" yaml: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index ea27be5e..b05c840b 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -99,7 +99,7 @@ dependencies: visibility_detector: ^0.3.3 wakelock: ^0.5.2 woozy_search: ^2.0.3 - xml: ^5.0.2 + xml: ^6.1.0 dev_dependencies: test: any From 1cab879cd6b5e9a3ad88e8c64b75fde60a250f0f Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Jul 2022 22:52:18 +0800 Subject: [PATCH 12/24] Update flutter_lints --- app/analysis_options.yaml | 7 + app/lib/api/api.dart | 122 +++++++++--------- app/lib/event/native_event.dart | 2 +- app/lib/mobile/android/download.dart | 2 +- app/lib/service.dart | 2 +- app/lib/web/google_gps_map.dart | 4 +- app/lib/widget/album_browser_mixin.dart | 4 +- app/lib/widget/album_importer.dart | 6 +- app/lib/widget/dir_picker.dart | 4 +- app/lib/widget/draggable.dart | 2 +- app/lib/widget/draggable_item_list_mixin.dart | 2 +- .../widget/photo_date_time_edit_dialog.dart | 12 +- app/lib/widget/settings.dart | 2 +- app/lib/widget/share_album_dialog.dart | 2 +- app/lib/widget/shared_file_viewer.dart | 4 +- app/lib/widget/slideshow_dialog.dart | 4 +- app/lib/widget/trashbin_viewer.dart | 6 +- app/lib/widget/viewer.dart | 2 +- app/pubspec.lock | 12 +- app/pubspec.yaml | 4 +- 20 files changed, 110 insertions(+), 95 deletions(-) diff --git a/app/analysis_options.yaml b/app/analysis_options.yaml index f9b30346..41026582 100644 --- a/app/analysis_options.yaml +++ b/app/analysis_options.yaml @@ -1 +1,8 @@ include: package:flutter_lints/flutter.yaml + +linter: + rules: + depend_on_referenced_packages: false + prefer_interpolation_to_compose_strings: false + no_leading_underscores_for_local_identifiers: false + use_build_context_synchronously: false diff --git a/app/lib/api/api.dart b/app/lib/api/api.dart index ca5bb83c..a644b527 100644 --- a/app/lib/api/api.dart +++ b/app/lib/api/api.dart @@ -31,10 +31,10 @@ class Response { class Api { Api(this._account); - _Files files() => _Files(this); - _Ocs ocs() => _Ocs(this); - _Systemtags systemtags() => _Systemtags(this); - _SystemtagsRelations systemtagsRelations() => _SystemtagsRelations(this); + ApiFiles files() => ApiFiles(this); + ApiOcs ocs() => ApiOcs(this); + ApiSystemtags systemtags() => ApiSystemtags(this); + ApiSystemtagsRelations systemtagsRelations() => ApiSystemtagsRelations(this); static String getAuthorizationHeaderValue(Account account) { final auth = @@ -108,8 +108,8 @@ class Api { bool _isHttpStatusGood(int status) => status ~/ 100 == 2; -class _Files { - _Files(this._api); +class ApiFiles { + ApiFiles(this._api); final Api _api; @@ -447,26 +447,26 @@ class _Files { static final _log = Logger("api.api._Files"); } -class _Ocs { - _Ocs(this._api); +class ApiOcs { + ApiOcs(this._api); - _OcsDav dav() => _OcsDav(this); - _OcsFacerecognition facerecognition() => _OcsFacerecognition(this); - _OcsFilesSharing filesSharing() => _OcsFilesSharing(this); + ApiOcsDav dav() => ApiOcsDav(this); + ApiOcsFacerecognition facerecognition() => ApiOcsFacerecognition(this); + ApiOcsFilesSharing filesSharing() => ApiOcsFilesSharing(this); final Api _api; } -class _OcsDav { - _OcsDav(this._ocs); +class ApiOcsDav { + ApiOcsDav(this._ocs); - _OcsDavDirect direct() => _OcsDavDirect(this); + ApiOcsDavDirect direct() => ApiOcsDavDirect(this); - final _Ocs _ocs; + final ApiOcs _ocs; } -class _OcsDavDirect { - _OcsDavDirect(this._dav); +class ApiOcsDavDirect { + ApiOcsDavDirect(this._dav); Future post({ required int fileId, @@ -490,23 +490,23 @@ class _OcsDavDirect { } } - final _OcsDav _dav; + final ApiOcsDav _dav; static final _log = Logger("api.api._OcsDavDirect"); } -class _OcsFacerecognition { - _OcsFacerecognition(this._ocs); +class ApiOcsFacerecognition { + ApiOcsFacerecognition(this._ocs); - _OcsFacerecognitionPersons persons() => _OcsFacerecognitionPersons(this); - _OcsFacerecognitionPerson person(String name) => - _OcsFacerecognitionPerson(this, name); + ApiOcsFacerecognitionPersons persons() => ApiOcsFacerecognitionPersons(this); + ApiOcsFacerecognitionPerson person(String name) => + ApiOcsFacerecognitionPerson(this, name); - final _Ocs _ocs; + final ApiOcs _ocs; } -class _OcsFacerecognitionPersons { - _OcsFacerecognitionPersons(this._facerecognition); +class ApiOcsFacerecognitionPersons { + ApiOcsFacerecognitionPersons(this._facerecognition); Future get() async { try { @@ -526,23 +526,23 @@ class _OcsFacerecognitionPersons { } } - final _OcsFacerecognition _facerecognition; + final ApiOcsFacerecognition _facerecognition; static final _log = Logger("api.api._OcsFacerecognitionPersons"); } -class _OcsFacerecognitionPerson { - _OcsFacerecognitionPerson(this._facerecognition, this._name); +class ApiOcsFacerecognitionPerson { + ApiOcsFacerecognitionPerson(this._facerecognition, this._name); - _OcsFacerecognitionPersonFaces faces() => - _OcsFacerecognitionPersonFaces(this); + ApiOcsFacerecognitionPersonFaces faces() => + ApiOcsFacerecognitionPersonFaces(this); - final _OcsFacerecognition _facerecognition; + final ApiOcsFacerecognition _facerecognition; final String _name; } -class _OcsFacerecognitionPersonFaces { - _OcsFacerecognitionPersonFaces(this._person); +class ApiOcsFacerecognitionPersonFaces { + ApiOcsFacerecognitionPersonFaces(this._person); Future get() async { try { @@ -562,24 +562,24 @@ class _OcsFacerecognitionPersonFaces { } } - final _OcsFacerecognitionPerson _person; + final ApiOcsFacerecognitionPerson _person; static final _log = Logger("api.api._OcsFacerecognitionPersonFaces"); } -class _OcsFilesSharing { - _OcsFilesSharing(this._ocs); +class ApiOcsFilesSharing { + ApiOcsFilesSharing(this._ocs); - _OcsFilesSharingShares shares() => _OcsFilesSharingShares(this); - _OcsFilesSharingShare share(String shareId) => - _OcsFilesSharingShare(this, shareId); - _OcsFilesSharingSharees sharees() => _OcsFilesSharingSharees(this); + ApiOcsFilesSharingShares shares() => ApiOcsFilesSharingShares(this); + ApiOcsFilesSharingShare share(String shareId) => + ApiOcsFilesSharingShare(this, shareId); + ApiOcsFilesSharingSharees sharees() => ApiOcsFilesSharingSharees(this); - final _Ocs _ocs; + final ApiOcs _ocs; } -class _OcsFilesSharingShares { - _OcsFilesSharingShares(this._filesSharing); +class ApiOcsFilesSharingShares { + ApiOcsFilesSharingShares(this._filesSharing); /// Get Shares from a specific file or folder /// @@ -652,19 +652,19 @@ class _OcsFilesSharingShares { } } - final _OcsFilesSharing _filesSharing; + final ApiOcsFilesSharing _filesSharing; static final _log = Logger("api.api._OcsFilesSharingShares"); } -class _OcsFilesSharingShare { - _OcsFilesSharingShare(this._filesSharing, this._shareId); +class ApiOcsFilesSharingShare { + ApiOcsFilesSharingShare(this._filesSharing, this._shareId); /// Remove the given share /// /// See: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html#delete-share /// * The type of share ID is listed as int in the document, however, the - /// share ID returned in [_OcsFilesSharingShares.get] is actually a string. To + /// share ID returned in [ApiOcsFilesSharingShares.get] is actually a string. To /// keep it consistent, we'll use string instead Future delete() async { try { @@ -681,14 +681,14 @@ class _OcsFilesSharingShare { } } - final _OcsFilesSharing _filesSharing; + final ApiOcsFilesSharing _filesSharing; final String _shareId; static final _log = Logger("api.api._OcsFilesSharingShare"); } -class _OcsFilesSharingSharees { - _OcsFilesSharingSharees(this._filesSharing); +class ApiOcsFilesSharingSharees { + ApiOcsFilesSharingSharees(this._filesSharing); /// Get all sharees matching a search term /// @@ -720,13 +720,13 @@ class _OcsFilesSharingSharees { } } - final _OcsFilesSharing _filesSharing; + final ApiOcsFilesSharing _filesSharing; static final _log = Logger("api.api._OcsFilesSharingSharees"); } -class _Systemtags { - const _Systemtags(this.api); +class ApiSystemtags { + const ApiSystemtags(this.api); Future propfind({ id, @@ -791,17 +791,17 @@ class _Systemtags { static final _log = Logger("api.api._Systemtags"); } -class _SystemtagsRelations { - const _SystemtagsRelations(this.api); +class ApiSystemtagsRelations { + const ApiSystemtagsRelations(this.api); - _SystemtagsRelationsFiles files(int fileId) => - _SystemtagsRelationsFiles(this, fileId); + ApiSystemtagsRelationsFiles files(int fileId) => + ApiSystemtagsRelationsFiles(this, fileId); final Api api; } -class _SystemtagsRelationsFiles { - const _SystemtagsRelationsFiles(this.systemtagsRelations, this.fileId); +class ApiSystemtagsRelationsFiles { + const ApiSystemtagsRelationsFiles(this.systemtagsRelations, this.fileId); /// List systemtags associated with a file /// @@ -864,7 +864,7 @@ class _SystemtagsRelationsFiles { } } - final _SystemtagsRelations systemtagsRelations; + final ApiSystemtagsRelations systemtagsRelations; final int fileId; static final _log = Logger("api.api._SystemtagsRelationsFiles"); diff --git a/app/lib/event/native_event.dart b/app/lib/event/native_event.dart index 1fcaa54f..f8bca097 100644 --- a/app/lib/event/native_event.dart +++ b/app/lib/event/native_event.dart @@ -25,7 +25,7 @@ class NativeEventListener { _subscription = null; } - static late final _mappedStream = + static final _mappedStream = NativeEvent.stream.whereType().map((ev) { switch (ev.event) { case FileExifUpdatedEvent._id: diff --git a/app/lib/mobile/android/download.dart b/app/lib/mobile/android/download.dart index 086376be..e3bac793 100644 --- a/app/lib/mobile/android/download.dart +++ b/app/lib/mobile/android/download.dart @@ -12,7 +12,7 @@ class DownloadEvent { static const _downloadCancelChannel = EventChannel( "com.nkming.nc_photos/download_event/action_download_cancel"); - static late final _cancelStream = _downloadCancelChannel + static final _cancelStream = _downloadCancelChannel .receiveBroadcastStream() .map((data) => DownloadCancelEvent( data["notificationId"], diff --git a/app/lib/service.dart b/app/lib/service.dart index de454242..038ed9fb 100644 --- a/app/lib/service.dart +++ b/app/lib/service.dart @@ -210,7 +210,7 @@ class _L10n { } } - static late final _inst = _L10n._(); + static final _inst = _L10n._(); late AppLocalizations _l10n; static final _log = Logger("service._L10n"); diff --git a/app/lib/web/google_gps_map.dart b/app/lib/web/google_gps_map.dart index 5248dc6e..5507ed1a 100644 --- a/app/lib/web/google_gps_map.dart +++ b/app/lib/web/google_gps_map.dart @@ -1,9 +1,9 @@ // ignore: avoid_web_libraries_in_flutter import 'dart:html'; -import 'package:/nc_photos/mobile/ui_hack.dart' if (dart.library.html) 'dart:ui' - as ui; import 'package:flutter/widgets.dart'; +import 'package:nc_photos/mobile/ui_hack.dart' if (dart.library.html) 'dart:ui' + as ui; import 'package:tuple/tuple.dart'; class GoogleGpsMap extends StatefulWidget { diff --git a/app/lib/widget/album_browser_mixin.dart b/app/lib/widget/album_browser_mixin.dart index 865c0c43..ff5e1340 100644 --- a/app/lib/widget/album_browser_mixin.dart +++ b/app/lib/widget/album_browser_mixin.dart @@ -231,11 +231,11 @@ mixin AlbumBrowserMixin )(); } catch (e, stackTrace) { _log.shout( - "[_onAddToCollectionPressed] Failed while ImportPendingSharedAlbum: ${logFilename(album.albumFile?.path)}", + "[_onAddToCollectionPressed] Failed while _onAddToCollectionPressed: ${logFilename(album.albumFile?.path)}", e, stackTrace); } - if (newAlbum != null) { + if (newAlbum != null && mounted) { album_browser_util.pushReplacement(context, account, newAlbum!); } } diff --git a/app/lib/widget/album_importer.dart b/app/lib/widget/album_importer.dart index 1c537548..6bea7450 100644 --- a/app/lib/widget/album_importer.dart +++ b/app/lib/widget/album_importer.dart @@ -178,7 +178,7 @@ class _AlbumImporterState extends State { icon: AnimatedSwitcher( duration: k.animationDurationShort, transitionBuilder: (child, animation) => - ScaleTransition(child: child, scale: animation), + ScaleTransition(scale: animation, child: child), child: Icon( isPicked ? Icons.check_box : Icons.check_box_outline_blank, key: ValueKey(isPicked), @@ -218,7 +218,9 @@ class _AlbumImporterState extends State { // make sure we dismiss the dialog in any cases Navigator.of(context).pop(); } - Navigator.of(context).pop(); + if (mounted) { + Navigator.of(context).pop(); + } } Future _createAllAlbums(BuildContext context) async { diff --git a/app/lib/widget/dir_picker.dart b/app/lib/widget/dir_picker.dart index ad6bc295..74d9b683 100644 --- a/app/lib/widget/dir_picker.dart +++ b/app/lib/widget/dir_picker.dart @@ -95,11 +95,11 @@ class DirPickerState extends State { duration: k.animationDurationNormal, // see AnimatedSwitcher.defaultLayoutBuilder layoutBuilder: (currentChild, previousChildren) => Stack( + alignment: Alignment.topLeft, children: [ ...previousChildren, if (currentChild != null) currentChild, ], - alignment: Alignment.topLeft, ), // needed to prevent background color overflowing the parent bound, see: // https://github.com/flutter/flutter/issues/86584 @@ -171,7 +171,7 @@ class DirPickerState extends State { icon: AnimatedSwitcher( duration: k.animationDurationShort, transitionBuilder: (child, animation) => - ScaleTransition(child: child, scale: animation), + ScaleTransition(scale: animation, child: child), child: Icon( iconData, key: ValueKey(pickState), diff --git a/app/lib/widget/draggable.dart b/app/lib/widget/draggable.dart index 8621eb9f..5a9b29a7 100644 --- a/app/lib/widget/draggable.dart +++ b/app/lib/widget/draggable.dart @@ -57,11 +57,11 @@ class Draggable extends StatelessWidget { ), ), ), - child: child, childWhenDragging: Opacity( opacity: .25, child: child, ), + child: child, ), ), if (onDropBefore != null || onDropAfter != null) diff --git a/app/lib/widget/draggable_item_list_mixin.dart b/app/lib/widget/draggable_item_list_mixin.dart index 7e314504..21c909b2 100644 --- a/app/lib/widget/draggable_item_list_mixin.dart +++ b/app/lib/widget/draggable_item_list_mixin.dart @@ -44,13 +44,13 @@ mixin DraggableItemListMixin on State { final item = _items[index]; return my.Draggable( data: item, - child: item.buildWidget(context), feedback: item.buildDragFeedbackWidget(context), onDropBefore: item.onDropBefore, onDropAfter: item.onDropAfter, onDragStarted: item.onDragStarted, onDragEndedAny: item.onDragEndedAny, feedbackSize: Size(_maxCrossAxisExtent * .65, _maxCrossAxisExtent * .65), + child: item.buildWidget(context), ); } diff --git a/app/lib/widget/photo_date_time_edit_dialog.dart b/app/lib/widget/photo_date_time_edit_dialog.dart index 62c1dc57..a1e89c13 100644 --- a/app/lib/widget/photo_date_time_edit_dialog.dart +++ b/app/lib/widget/photo_date_time_edit_dialog.dart @@ -33,6 +33,7 @@ class _PhotoDateTimeEditDialogState extends State { Row( children: [ Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().dateYearInputHint, @@ -51,10 +52,10 @@ class _PhotoDateTimeEditDialogState extends State { }, initialValue: "${widget.initialDateTime.year}", ), - flex: 1, ), const SizedBox(width: 4), Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().dateMonthInputHint, @@ -72,10 +73,10 @@ class _PhotoDateTimeEditDialogState extends State { initialValue: widget.initialDateTime.month.toString().padLeft(2, "0"), ), - flex: 1, ), const SizedBox(width: 4), Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().dateDayInputHint, @@ -93,7 +94,6 @@ class _PhotoDateTimeEditDialogState extends State { initialValue: widget.initialDateTime.day.toString().padLeft(2, "0"), ), - flex: 1, ), ], ), @@ -105,6 +105,7 @@ class _PhotoDateTimeEditDialogState extends State { Row( children: [ Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().timeHourInputHint, @@ -122,10 +123,10 @@ class _PhotoDateTimeEditDialogState extends State { initialValue: widget.initialDateTime.hour.toString().padLeft(2, "0"), ), - flex: 1, ), const SizedBox(width: 4), Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().timeMinuteInputHint, @@ -144,12 +145,11 @@ class _PhotoDateTimeEditDialogState extends State { .toString() .padLeft(2, "0"), ), - flex: 1, ), const SizedBox(width: 4), const Flexible( - child: SizedBox(), flex: 1, + child: SizedBox(), ), ], ), diff --git a/app/lib/widget/settings.dart b/app/lib/widget/settings.dart index 0e359e21..c62abc67 100644 --- a/app/lib/widget/settings.dart +++ b/app/lib/widget/settings.dart @@ -1504,6 +1504,6 @@ enum _Experiment { sharedAlbum, } -late final _enabledExperiments = [ +final _enabledExperiments = [ _Experiment.sharedAlbum, ]; diff --git a/app/lib/widget/share_album_dialog.dart b/app/lib/widget/share_album_dialog.dart index 19b2a8ab..5b7b6e40 100644 --- a/app/lib/widget/share_album_dialog.dart +++ b/app/lib/widget/share_album_dialog.dart @@ -100,6 +100,7 @@ class _ShareAlbumDialogState extends State { ); } return SimpleDialogOption( + onPressed: isProcessing ? () {} : () => _onShareItemPressed(share), child: ListTile( title: Text(share.displayName), subtitle: Text(share.shareWith.toString()), @@ -108,7 +109,6 @@ class _ShareAlbumDialogState extends State { child: trailing, ), ), - onPressed: isProcessing ? () {} : () => _onShareItemPressed(share), ); } diff --git a/app/lib/widget/shared_file_viewer.dart b/app/lib/widget/shared_file_viewer.dart index 6584a62f..9a79dd17 100644 --- a/app/lib/widget/shared_file_viewer.dart +++ b/app/lib/widget/shared_file_viewer.dart @@ -226,7 +226,9 @@ class _SharedFileViewerState extends State { } } } finally { - Navigator.of(context).pop(); + if (mounted) { + Navigator.of(context).pop(); + } } } else { setState(() { diff --git a/app/lib/widget/slideshow_dialog.dart b/app/lib/widget/slideshow_dialog.dart index a933df14..5ceef56b 100644 --- a/app/lib/widget/slideshow_dialog.dart +++ b/app/lib/widget/slideshow_dialog.dart @@ -73,6 +73,7 @@ class _SlideshowDialogState extends State { Row( children: [ Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().timeMinuteInputHint, @@ -98,12 +99,12 @@ class _SlideshowDialogState extends State { initialValue: widget.duration.inMinutes.toString().padLeft(2, "0"), ), - flex: 1, ), const SizedBox(width: 4), const Text(":"), const SizedBox(width: 4), Flexible( + flex: 1, child: TextFormField( decoration: InputDecoration( hintText: L10n.global().timeSecondInputHint, @@ -130,7 +131,6 @@ class _SlideshowDialogState extends State { .toString() .padLeft(2, "0"), ), - flex: 1, ), ], ), diff --git a/app/lib/widget/trashbin_viewer.dart b/app/lib/widget/trashbin_viewer.dart index 2fd409d5..f68e4d13 100644 --- a/app/lib/widget/trashbin_viewer.dart +++ b/app/lib/widget/trashbin_viewer.dart @@ -172,7 +172,9 @@ class _TrashbinViewerState extends State { content: Text(L10n.global().restoreSuccessNotification), duration: k.snackBarDurationNormal, )); - Navigator.of(context).pop(); + if (mounted) { + Navigator.of(context).pop(); + } } catch (e, stacktrace) { _log.shout("Failed while restore trashbin: ${logFilename(file.path)}", e, stacktrace); @@ -314,7 +316,7 @@ class _TrashbinViewerState extends State { shouldCleanupAlbum: false, isRemoveOpened: true, ); - if (count > 0) { + if (count > 0 && mounted) { Navigator.of(context).pop(); } } diff --git a/app/lib/widget/viewer.dart b/app/lib/widget/viewer.dart index b043b4b9..7997e67c 100644 --- a/app/lib/widget/viewer.dart +++ b/app/lib/widget/viewer.dart @@ -599,7 +599,7 @@ class _ViewerState extends State isRemoveOpened: true, isMoveToTrash: true, ); - if (count > 0) { + if (count > 0 && mounted) { Navigator.of(context).pop(); } } diff --git a/app/pubspec.lock b/app/pubspec.lock index d63c13e2..f3809f4f 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -398,7 +398,7 @@ packages: name: flutter_lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" flutter_localizations: dependency: "direct main" description: flutter @@ -571,7 +571,7 @@ packages: name: lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" lists: dependency: transitive description: @@ -839,12 +839,12 @@ packages: source: hosted version: "2.1.0" quiver: - dependency: transitive + dependency: "direct main" description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "3.0.1+1" + version: "3.1.0" rxdart: dependency: transitive description: @@ -1152,12 +1152,12 @@ packages: source: hosted version: "3.0.1" uuid: - dependency: transitive + dependency: "direct main" description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.5" + version: "3.0.6" vector_math: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index b05c840b..f77fcd41 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -84,6 +84,7 @@ dependencies: page_view_indicators: ^2.0.0 path: ^1.8.0 path_provider: ^2.0.6 + quiver: ^3.1.0 screen_brightness: ^0.1.1 shared_preferences: ^2.0.8 # android/ios only @@ -91,6 +92,7 @@ dependencies: synchronized: ^3.0.0 tuple: ^2.0.0 url_launcher: ^6.0.3 + uuid: ^3.0.6 video_player: git: url: https://gitlab.com/nc-photos/flutter-plugins @@ -104,7 +106,7 @@ dependencies: dev_dependencies: test: any bloc_test: any - flutter_lints: ^1.0.4 + flutter_lints: ^2.0.1 # flutter_test: # sdk: flutter # integration_test: From ef1521296d88239b1a7dc7d5d8b29fb5959e2666 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 00:29:23 +0800 Subject: [PATCH 13/24] Update google maps --- app/pubspec.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index f3809f4f..2fdc5703 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -464,14 +464,14 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.8" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.2.0" hashcodes: dependency: transitive description: From b5c99954387a042201d433f36eb2069297fe7f14 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 00:34:47 +0800 Subject: [PATCH 14/24] Update wakelock --- app/pubspec.lock | 2 +- app/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 2fdc5703..bd4e2cc2 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1212,7 +1212,7 @@ packages: name: wakelock url: "https://pub.dartlang.org" source: hosted - version: "0.5.6" + version: "0.6.2" wakelock_macos: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index f77fcd41..7451cedb 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -99,7 +99,7 @@ dependencies: ref: video_player-v2.2.6-nc-photos-2 path: packages/video_player/video_player visibility_detector: ^0.3.3 - wakelock: ^0.5.2 + wakelock: ^0.6.2 woozy_search: ^2.0.3 xml: ^6.1.0 From bfaf99553bb3aeb3608c49ec5f0620d1ea015c55 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 01:15:47 +0800 Subject: [PATCH 15/24] Update screen_brightness --- app/pubspec.lock | 15 +++++++++++---- app/pubspec.yaml | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index bd4e2cc2..d02ef1e2 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -858,28 +858,35 @@ packages: name: screen_brightness url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.2.1" screen_brightness_android: dependency: transitive description: name: screen_brightness_android url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "0.1.0" screen_brightness_ios: dependency: transitive description: name: screen_brightness_ios url: "https://pub.dartlang.org" source: hosted - version: "0.0.5" + version: "0.1.0" + screen_brightness_macos: + dependency: transitive + description: + name: screen_brightness_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0+1" screen_brightness_platform_interface: dependency: transitive description: name: screen_brightness_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "0.1.0" sembast: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 7451cedb..84cfce32 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -85,7 +85,7 @@ dependencies: path: ^1.8.0 path_provider: ^2.0.6 quiver: ^3.1.0 - screen_brightness: ^0.1.1 + screen_brightness: ^0.2.1 shared_preferences: ^2.0.8 # android/ios only sqflite: ^2.0.0 From c83458a86658689939a864bc17d60ff98bdef178 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 02:26:28 +0800 Subject: [PATCH 16/24] Update connectivity_plus --- app/pubspec.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index d02ef1e2..379178b9 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -156,42 +156,42 @@ packages: name: connectivity_plus url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.3.5" connectivity_plus_linux: dependency: transitive description: name: connectivity_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" connectivity_plus_macos: dependency: transitive description: name: connectivity_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "1.2.4" connectivity_plus_platform_interface: dependency: transitive description: name: connectivity_plus_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" connectivity_plus_web: dependency: transitive description: name: connectivity_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.1.0+1" + version: "1.2.2" connectivity_plus_windows: dependency: transitive description: name: connectivity_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.2" convert: dependency: transitive description: From 3bf4fae19df8c9b34a77d2a711da8ae5a701ef27 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 02:36:59 +0800 Subject: [PATCH 17/24] Update native_device_orientation --- app/pubspec.lock | 2 +- app/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 379178b9..63c72f0d 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -655,7 +655,7 @@ packages: name: native_device_orientation url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.4" nc_photos_plugin: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 84cfce32..5ef70d79 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -78,7 +78,7 @@ dependencies: memory_info: ^0.0.2 mime: ^1.0.1 mutex: ^3.0.0 - native_device_orientation: 1.1.0 + native_device_orientation: ^1.1.0 nc_photos_plugin: path: ../plugin page_view_indicators: ^2.0.0 From bd855ec139cf85d49dee85a8ee4e76dfaf755cc8 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 01:12:40 +0800 Subject: [PATCH 18/24] Update transitive dependencies --- app/pubspec.lock | 60 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 63c72f0d..daea7e39 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "40.0.0" + version: "41.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.2.0" android_intent_plus: dependency: "direct main" description: @@ -30,7 +30,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.1" async: dependency: transitive description: @@ -198,28 +198,28 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" coverage: dependency: transitive description: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.3.2" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" csslib: dependency: transitive description: name: csslib url: "https://pub.dartlang.org" source: hosted - version: "0.17.1" + version: "0.17.2" dbus: dependency: transitive description: @@ -363,7 +363,7 @@ packages: name: flutter_blurhash url: "https://pub.dartlang.org" source: hosted - version: "0.6.0" + version: "0.7.0" flutter_cache_manager: dependency: transitive description: @@ -377,7 +377,7 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "5.1.1" + version: "5.3.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: @@ -417,7 +417,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" flutter_staggered_grid_view: dependency: "direct main" description: @@ -450,14 +450,14 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.0" google_maps_flutter: dependency: "direct main" description: @@ -499,14 +499,14 @@ packages: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.2.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" idb_shim: dependency: "direct main" description: @@ -690,14 +690,14 @@ packages: name: octo_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.0" page_view_indicators: dependency: "direct main" description: @@ -802,7 +802,7 @@ packages: name: pool url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.5.1" positioned_tap_detector_2: dependency: transitive description: @@ -830,14 +830,14 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "6.0.2" + version: "6.0.3" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" quiver: dependency: "direct main" description: @@ -956,28 +956,28 @@ packages: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" shelf_static: dependency: transitive description: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" sky_engine: dependency: transitive description: flutter @@ -1010,14 +1010,14 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.0.1+1" + version: "2.2.1+1" stack_trace: dependency: transitive description: @@ -1094,7 +1094,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" unicode: dependency: transitive description: @@ -1212,7 +1212,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "7.5.0" + version: "8.3.0" wakelock: dependency: "direct main" description: @@ -1261,14 +1261,14 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" win32: dependency: transitive description: @@ -1310,7 +1310,7 @@ packages: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" sdks: dart: ">=2.17.0 <3.0.0" flutter: ">=3.0.0" From 2de1fe54d97db34944531ca0e61c6ae482bc58d4 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 13:59:09 +0800 Subject: [PATCH 19/24] Update bloc --- app/lib/app_init.dart | 16 ----- app/lib/bloc/album_search.dart | 26 +++---- app/lib/bloc/app_password_exchange.dart | 25 ++++--- app/lib/bloc/list_album.dart | 41 ++++++----- app/lib/bloc/list_album_share_outlier.dart | 26 +++---- app/lib/bloc/list_face.dart | 21 +++--- app/lib/bloc/list_favorite.dart | 23 +++--- app/lib/bloc/list_importable_album.dart | 24 ++++--- app/lib/bloc/list_person.dart | 21 +++--- app/lib/bloc/list_share.dart | 21 +++--- app/lib/bloc/list_sharee.dart | 21 +++--- app/lib/bloc/list_sharing.dart | 42 ++++++----- app/lib/bloc/list_tag.dart | 21 +++--- app/lib/bloc/ls_dir.dart | 21 +++--- app/lib/bloc/ls_trashbin.dart | 27 ++++---- app/lib/bloc/scan_account_dir.dart | 81 +++++++++++----------- app/lib/bloc/search_suggestion.dart | 28 ++++---- app/lib/main.dart | 19 ++++- app/pubspec.lock | 13 +++- app/pubspec.yaml | 5 +- 20 files changed, 286 insertions(+), 236 deletions(-) diff --git a/app/lib/app_init.dart b/app/lib/app_init.dart index 3e8644ef..6cd16181 100644 --- a/app/lib/app_init.dart +++ b/app/lib/app_init.dart @@ -1,7 +1,6 @@ import 'package:equatable/equatable.dart'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/foundation.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:kiwi/kiwi.dart'; import 'package:logging/logging.dart'; import 'package:nc_photos/app_db.dart'; @@ -46,7 +45,6 @@ Future initAppLaunch() async { await _initPref(); await _initAccountPrefs(); await _initDeviceInfo(); - _initBloc(); _initEquatable(); if (features.isSupportSelfSignedCert) { _initSelfSignedCertManager(); @@ -135,10 +133,6 @@ Future _initDeviceInfo() async { } } -void _initBloc() { - Bloc.observer = _BlocObserver(); -} - void _initKiwi() { final kiwi = KiwiContainer(); kiwi.registerInstance(EventBus()); @@ -180,13 +174,3 @@ void _initVisibilityDetector() { final _log = Logger("app_init"); var _hasInitedInThisIsolate = false; - -class _BlocObserver extends BlocObserver { - @override - onChange(BlocBase bloc, Change change) { - super.onChange(bloc, change); - _log.finer("${bloc.runtimeType} $change"); - } - - static final _log = Logger("app_init._BlocObserver"); -} diff --git a/app/lib/bloc/album_search.dart b/app/lib/bloc/album_search.dart index b70550f3..ade714e5 100644 --- a/app/lib/bloc/album_search.dart +++ b/app/lib/bloc/album_search.dart @@ -55,20 +55,22 @@ class AlbumSearchBlocSuccess extends AlbumSearchBlocState { } class AlbumSearchBloc extends Bloc { - AlbumSearchBloc() : super(const AlbumSearchBlocInit()); + AlbumSearchBloc() : super(const AlbumSearchBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(AlbumSearchBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + AlbumSearchBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is AlbumSearchBlocSearchEvent) { - yield* _onEventSearch(event); + await _onEventSearch(event, emit); } else if (event is AlbumSearchBlocUpdateItemsEvent) { - yield* _onEventUpdateItems(event); + await _onEventUpdateItems(event, emit); } } - Stream _onEventSearch( - AlbumSearchBlocSearchEvent ev) async* { + Future _onEventSearch( + AlbumSearchBlocSearchEvent ev, Emitter emit) async { final matches = _albums .where((element) => element.name.toLowerCase().contains(ev.phrase.toLowerCase())) @@ -82,16 +84,16 @@ class AlbumSearchBloc extends Bloc { return a.name.compareTo(b.name); } }); - yield AlbumSearchBlocSuccess(matches); + emit(AlbumSearchBlocSuccess(matches)); _lastSearch = ev; } - Stream _onEventUpdateItems( - AlbumSearchBlocUpdateItemsEvent ev) async* { + Future _onEventUpdateItems(AlbumSearchBlocUpdateItemsEvent ev, + Emitter emit) async { _albums = ev.albums; if (_lastSearch != null) { // search again - yield* _onEventSearch(_lastSearch!); + await _onEventSearch(_lastSearch!, emit); } } diff --git a/app/lib/bloc/app_password_exchange.dart b/app/lib/bloc/app_password_exchange.dart index fb363dcb..08e962f4 100644 --- a/app/lib/bloc/app_password_exchange.dart +++ b/app/lib/bloc/app_password_exchange.dart @@ -60,27 +60,30 @@ class AppPasswordExchangeBlocFailure extends AppPasswordExchangeBlocState { class AppPasswordExchangeBloc extends Bloc { - AppPasswordExchangeBloc() : super(const AppPasswordExchangeBlocInit()); + AppPasswordExchangeBloc() : super(const AppPasswordExchangeBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(AppPasswordExchangeBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent(AppPasswordExchangeBlocEvent event, + Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is AppPasswordExchangeBlocConnect) { - yield* _exchangePassword(event.account); + await _onEventConnect(event, emit); } } - Stream _exchangePassword( - Account account) async* { + Future _onEventConnect(AppPasswordExchangeBlocConnect ev, + Emitter emit) async { + final account = ev.account; try { final appPwd = await api_util.exchangePassword(account); - yield AppPasswordExchangeBlocSuccess(appPwd); + emit(AppPasswordExchangeBlocSuccess(appPwd)); } on InvalidBaseUrlException catch (e) { _log.warning("[_exchangePassword] Invalid base url"); - yield AppPasswordExchangeBlocFailure(e); + emit(AppPasswordExchangeBlocFailure(e)); } on HandshakeException catch (e) { _log.info("[_exchangePassword] Self-signed cert"); - yield AppPasswordExchangeBlocFailure(e); + emit(AppPasswordExchangeBlocFailure(e)); } catch (e, stacktrace) { if (e is ApiException && e.response.statusCode == 401) { // wrong password, normal @@ -90,7 +93,7 @@ class AppPasswordExchangeBloc _log.shout("[_exchangePassword] Failed while exchanging password", e, stacktrace); } - yield AppPasswordExchangeBlocFailure(e); + emit(AppPasswordExchangeBlocFailure(e)); } } diff --git a/app/lib/bloc/list_album.dart b/app/lib/bloc/list_album.dart index 7e1b6471..b9d89f8c 100644 --- a/app/lib/bloc/list_album.dart +++ b/app/lib/bloc/list_album.dart @@ -137,6 +137,8 @@ class ListAlbumBloc extends Bloc { }, logTag: "ListAlbumBloc.refresh", ); + + on(_onEvent); } static bool require(DiContainer c) => true; @@ -160,16 +162,6 @@ class ListAlbumBloc extends Bloc { } } - @override - mapEventToState(ListAlbumBlocEvent event) async* { - _log.info("[mapEventToState] $event"); - if (event is ListAlbumBlocQuery) { - yield* _onEventQuery(event); - } else if (event is _ListAlbumBlocExternalEvent) { - yield* _onExternalEvent(event); - } - } - @override close() { _albumUpdatedListener.end(); @@ -182,31 +174,42 @@ class ListAlbumBloc extends Bloc { return super.close(); } - Stream _onEventQuery(ListAlbumBlocQuery ev) async* { - yield ListAlbumBlocLoading(ev.account, state.items); + Future _onEvent( + ListAlbumBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); + if (event is ListAlbumBlocQuery) { + await _onEventQuery(event, emit); + } else if (event is _ListAlbumBlocExternalEvent) { + await _onExternalEvent(event, emit); + } + } + + Future _onEventQuery( + ListAlbumBlocQuery ev, Emitter emit) async { + emit(ListAlbumBlocLoading(ev.account, state.items)); bool hasContent = state.items.isNotEmpty; if (!hasContent) { // show something instantly on first load final cacheState = await _queryOffline(ev); - yield ListAlbumBlocLoading(ev.account, cacheState.items); + emit(ListAlbumBlocLoading(ev.account, cacheState.items)); hasContent = cacheState.items.isNotEmpty; } final newState = await _queryOnline(ev); if (newState is ListAlbumBlocFailure) { - yield ListAlbumBlocFailure( + emit(ListAlbumBlocFailure( ev.account, newState.items.isNotEmpty ? newState.items : state.items, - newState.exception); + newState.exception)); } else { - yield newState; + emit(newState); } } - Stream _onExternalEvent( - _ListAlbumBlocExternalEvent ev) async* { - yield ListAlbumBlocInconsistent(state.account, state.items); + Future _onExternalEvent( + _ListAlbumBlocExternalEvent ev, Emitter emit) async { + emit(ListAlbumBlocInconsistent(state.account, state.items)); } void _onAlbumUpdatedEvent(AlbumUpdatedEvent ev) { diff --git a/app/lib/bloc/list_album_share_outlier.dart b/app/lib/bloc/list_album_share_outlier.dart index f927764f..9906a75e 100644 --- a/app/lib/bloc/list_album_share_outlier.dart +++ b/app/lib/bloc/list_album_share_outlier.dart @@ -180,23 +180,25 @@ class ListAlbumShareOutlierBloc extends Bloc(_onEvent); + } static bool require(DiContainer c) => DiContainer.has(c, DiType.shareeRepo); - @override - mapEventToState(ListAlbumShareOutlierBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent(ListAlbumShareOutlierBlocEvent event, + Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListAlbumShareOutlierBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery( - ListAlbumShareOutlierBlocQuery ev) async* { + Future _onEventQuery(ListAlbumShareOutlierBlocQuery ev, + Emitter emit) async { try { assert(ev.album.provider is AlbumStaticProvider); - yield ListAlbumShareOutlierBlocLoading(ev.account, state.items); + emit(ListAlbumShareOutlierBlocLoading(ev.account, state.items)); final albumShares = await () async { var temp = (ev.album.shares ?? []) @@ -222,14 +224,14 @@ class ListAlbumShareOutlierBloc extends Bloc { - ListFaceBloc() : super(ListFaceBlocInit()); + ListFaceBloc() : super(ListFaceBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(ListFaceBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListFaceBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListFaceBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListFaceBlocQuery ev) async* { + Future _onEventQuery( + ListFaceBlocQuery ev, Emitter emit) async { try { - yield ListFaceBlocLoading(ev.account, state.items); - yield ListFaceBlocSuccess(ev.account, await _query(ev)); + emit(ListFaceBlocLoading(ev.account, state.items)); + emit(ListFaceBlocSuccess(ev.account, await _query(ev))); } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListFaceBlocFailure(ev.account, state.items, e); + emit(ListFaceBlocFailure(ev.account, state.items, e)); } } diff --git a/app/lib/bloc/list_favorite.dart b/app/lib/bloc/list_favorite.dart index 9c9234f2..dd00c271 100644 --- a/app/lib/bloc/list_favorite.dart +++ b/app/lib/bloc/list_favorite.dart @@ -71,7 +71,9 @@ class ListFavoriteBloc ListFavoriteBloc(this._c) : assert(require(_c)), assert(ListFavorite.require(_c)), - super(const ListFavoriteBlocInit()); + super(const ListFavoriteBlocInit()) { + on(_onEvent); + } static bool require(DiContainer c) => true; @@ -90,24 +92,25 @@ class ListFavoriteBloc } } - @override - mapEventToState(ListFavoriteBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListFavoriteBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListFavoriteBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListFavoriteBlocQuery ev) async* { + Future _onEventQuery( + ListFavoriteBlocQuery ev, Emitter emit) async { List? cache; try { - yield ListFavoriteBlocLoading(ev.account, state.items); + emit(ListFavoriteBlocLoading(ev.account, state.items)); cache = await _queryOffline(ev); if (cache != null) { - yield ListFavoriteBlocLoading(ev.account, cache); + emit(ListFavoriteBlocLoading(ev.account, cache)); } final remote = await _queryOnline(ev); - yield ListFavoriteBlocSuccess(ev.account, remote); + emit(ListFavoriteBlocSuccess(ev.account, remote)); if (cache != null) { CacheFavorite(_c)(ev.account, remote, cache: cache) @@ -118,7 +121,7 @@ class ListFavoriteBloc } } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListFavoriteBlocFailure(ev.account, cache ?? state.items, e); + emit(ListFavoriteBlocFailure(ev.account, cache ?? state.items, e)); } } diff --git a/app/lib/bloc/list_importable_album.dart b/app/lib/bloc/list_importable_album.dart index 63bdc1b2..2c8ad2a1 100644 --- a/app/lib/bloc/list_importable_album.dart +++ b/app/lib/bloc/list_importable_album.dart @@ -89,21 +89,23 @@ class ListImportableAlbumBloc ListImportableAlbumBloc(this._c) : assert(require(_c)), assert(ListAlbum.require(_c)), - super(ListImportableAlbumBlocInit()); + super(ListImportableAlbumBlocInit()) { + on(_onEvent); + } static bool require(DiContainer c) => DiContainer.has(c, DiType.fileRepo); - @override - mapEventToState(ListImportableAlbumBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent(ListImportableAlbumBlocEvent event, + Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListImportableAlbumBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery( - ListImportableAlbumBlocQuery ev) async* { - yield const ListImportableAlbumBlocLoading([]); + Future _onEventQuery(ListImportableAlbumBlocQuery ev, + Emitter emit) async { + emit(const ListImportableAlbumBlocLoading([])); try { final albums = (await ListAlbum(_c)(ev.account) .where((event) => event is Album) @@ -128,15 +130,15 @@ class ListImportableAlbumBloc products.add(ev); // don't emit events too frequently if (++count >= 5) { - yield ListImportableAlbumBlocLoading(products); + emit(ListImportableAlbumBlocLoading(products)); } } } } - yield ListImportableAlbumBlocSuccess(products); + emit(ListImportableAlbumBlocSuccess(products)); } catch (e) { _log.severe("[_onEventQuery] Exception while request", e); - yield ListImportableAlbumBlocFailure(state.items, e); + emit(ListImportableAlbumBlocFailure(state.items, e)); } } diff --git a/app/lib/bloc/list_person.dart b/app/lib/bloc/list_person.dart index 54d5b2c2..6dcf2d42 100644 --- a/app/lib/bloc/list_person.dart +++ b/app/lib/bloc/list_person.dart @@ -70,7 +70,9 @@ class ListPersonBlocFailure extends ListPersonBlocState { /// List all people recognized in an account class ListPersonBloc extends Bloc { - ListPersonBloc() : super(ListPersonBlocInit()); + ListPersonBloc() : super(ListPersonBlocInit()) { + on(_onEvent); + } static ListPersonBloc of(Account account) { final name = bloc_util.getInstNameForAccount("ListPersonBloc", account); @@ -86,21 +88,22 @@ class ListPersonBloc extends Bloc { } } - @override - mapEventToState(ListPersonBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListPersonBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListPersonBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListPersonBlocQuery ev) async* { + Future _onEventQuery( + ListPersonBlocQuery ev, Emitter emit) async { try { - yield ListPersonBlocLoading(ev.account, state.items); - yield ListPersonBlocSuccess(ev.account, await _query(ev)); + emit(ListPersonBlocLoading(ev.account, state.items)); + emit(ListPersonBlocSuccess(ev.account, await _query(ev))); } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListPersonBlocFailure(ev.account, state.items, e); + emit(ListPersonBlocFailure(ev.account, state.items, e)); } } diff --git a/app/lib/bloc/list_share.dart b/app/lib/bloc/list_share.dart index 806ab50a..9fc4fb31 100644 --- a/app/lib/bloc/list_share.dart +++ b/app/lib/bloc/list_share.dart @@ -73,23 +73,26 @@ class ListShareBlocFailure extends ListShareBlocState { /// List all shares from a given file class ListShareBloc extends Bloc { - ListShareBloc() : super(ListShareBlocInit()); + ListShareBloc() : super(ListShareBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(ListShareBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListShareBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListShareBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListShareBlocQuery ev) async* { + Future _onEventQuery( + ListShareBlocQuery ev, Emitter emit) async { try { - yield ListShareBlocLoading(ev.account, ev.file, state.items); - yield ListShareBlocSuccess(ev.account, ev.file, await _query(ev)); + emit(ListShareBlocLoading(ev.account, ev.file, state.items)); + emit(ListShareBlocSuccess(ev.account, ev.file, await _query(ev))); } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListShareBlocFailure(ev.account, ev.file, state.items, e); + emit(ListShareBlocFailure(ev.account, ev.file, state.items, e)); } } diff --git a/app/lib/bloc/list_sharee.dart b/app/lib/bloc/list_sharee.dart index 6e1ecf1e..d701a67f 100644 --- a/app/lib/bloc/list_sharee.dart +++ b/app/lib/bloc/list_sharee.dart @@ -70,7 +70,9 @@ class ListShareeBlocFailure extends ListShareeBlocState { /// List all sharees of this account class ListShareeBloc extends Bloc { - ListShareeBloc() : super(ListShareeBlocInit()); + ListShareeBloc() : super(ListShareeBlocInit()) { + on(_onEvent); + } static ListShareeBloc of(Account account) { final name = bloc_util.getInstNameForAccount("ListShareeBloc", account); @@ -86,21 +88,22 @@ class ListShareeBloc extends Bloc { } } - @override - mapEventToState(ListShareeBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListShareeBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListShareeBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListShareeBlocQuery ev) async* { + Future _onEventQuery( + ListShareeBlocQuery ev, Emitter emit) async { try { - yield ListShareeBlocLoading(ev.account, state.items); - yield ListShareeBlocSuccess(ev.account, await _query(ev)); + emit(ListShareeBlocLoading(ev.account, state.items)); + emit(ListShareeBlocSuccess(ev.account, await _query(ev))); } catch (e, stackTrace) { _log.shout("[_onEventQuery] Exception while request", e, stackTrace); - yield ListShareeBlocFailure(ev.account, state.items, e); + emit(ListShareeBlocFailure(ev.account, state.items, e)); } } diff --git a/app/lib/bloc/list_sharing.dart b/app/lib/bloc/list_sharing.dart index 1c66b6bb..1d908f26 100644 --- a/app/lib/bloc/list_sharing.dart +++ b/app/lib/bloc/list_sharing.dart @@ -166,6 +166,8 @@ class ListSharingBloc extends Bloc { }, logTag: "ListSharingBloc.refresh", ); + + on(_onEvent); } static bool require(DiContainer c) => @@ -196,48 +198,50 @@ class ListSharingBloc extends Bloc { return super.close(); } - @override - mapEventToState(ListSharingBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListSharingBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListSharingBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } else if (event is _ListSharingBlocShareRemoved) { - yield* _onEventShareRemoved(event); + await _onEventShareRemoved(event, emit); } else if (event is _ListSharingBlocPendingSharedAlbumMoved) { - yield* _onEventPendingSharedAlbumMoved(event); + await _onEventPendingSharedAlbumMoved(event, emit); } } - Stream _onEventQuery(ListSharingBlocQuery ev) async* { + Future _onEventQuery( + ListSharingBlocQuery ev, Emitter emit) async { try { - yield ListSharingBlocLoading(ev.account, state.items); - yield ListSharingBlocSuccess(ev.account, await _query(ev)); + emit(ListSharingBlocLoading(ev.account, state.items)); + emit(ListSharingBlocSuccess(ev.account, await _query(ev))); } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListSharingBlocFailure(ev.account, state.items, e); + emit(ListSharingBlocFailure(ev.account, state.items, e)); } } - Stream _onEventShareRemoved( - _ListSharingBlocShareRemoved ev) async* { + Future _onEventShareRemoved(_ListSharingBlocShareRemoved ev, + Emitter emit) async { if (state is! ListSharingBlocSuccess && state is! ListSharingBlocFailure) { return; } final newItems = state.items.where((i) => !ev.shares.contains(i.share)).toList(); // i love hacks :) - yield (state as dynamic).copyWith( + emit((state as dynamic).copyWith( items: newItems, - ) as ListSharingBlocState; + ) as ListSharingBlocState); } - Stream _onEventPendingSharedAlbumMoved( - _ListSharingBlocPendingSharedAlbumMoved ev) async* { + Future _onEventPendingSharedAlbumMoved( + _ListSharingBlocPendingSharedAlbumMoved ev, + Emitter emit) async { if (state.items.isEmpty) { return; } try { - yield ListSharingBlocLoading(ev.account, state.items); + emit(ListSharingBlocLoading(ev.account, state.items)); final items = List.of(state.items); items.removeWhere( @@ -250,11 +254,11 @@ class ListSharingBloc extends Bloc { items.add(ListSharingAlbum(s, newAlbum)); } - yield ListSharingBlocSuccess(ev.account, items); + emit(ListSharingBlocSuccess(ev.account, items)); } catch (e, stackTrace) { _log.severe("[_onEventPendingSharedAlbumMoved] Exception while request", e, stackTrace); - yield ListSharingBlocFailure(ev.account, state.items, e); + emit(ListSharingBlocFailure(ev.account, state.items, e)); } } diff --git a/app/lib/bloc/list_tag.dart b/app/lib/bloc/list_tag.dart index 795ac64c..f2b11db5 100644 --- a/app/lib/bloc/list_tag.dart +++ b/app/lib/bloc/list_tag.dart @@ -67,7 +67,9 @@ class ListTagBloc extends Bloc { ListTagBloc(this._c) : assert(require(_c)), assert(ListTag.require(_c)), - super(const ListTagBlocInit()); + super(const ListTagBlocInit()) { + on(_onEvent); + } static bool require(DiContainer c) => true; @@ -85,21 +87,22 @@ class ListTagBloc extends Bloc { } } - @override - mapEventToState(ListTagBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + ListTagBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is ListTagBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(ListTagBlocQuery ev) async* { + Future _onEventQuery( + ListTagBlocQuery ev, Emitter emit) async { try { - yield ListTagBlocLoading(ev.account, state.items); - yield ListTagBlocSuccess(ev.account, await _query(ev)); + emit(ListTagBlocLoading(ev.account, state.items)); + emit(ListTagBlocSuccess(ev.account, await _query(ev))); } catch (e, stackTrace) { _log.severe("[_onEventQuery] Exception while request", e, stackTrace); - yield ListTagBlocFailure(ev.account, state.items, e); + emit(ListTagBlocFailure(ev.account, state.items, e)); } } diff --git a/app/lib/bloc/ls_dir.dart b/app/lib/bloc/ls_dir.dart index 9eb7af6a..6b915eec 100644 --- a/app/lib/bloc/ls_dir.dart +++ b/app/lib/bloc/ls_dir.dart @@ -148,23 +148,26 @@ class LsDirBlocFailure extends LsDirBlocState { /// A bloc that return all directories under a dir recursively class LsDirBloc extends Bloc { - LsDirBloc(this.fileRepo) : super(LsDirBlocInit()); + LsDirBloc(this.fileRepo) : super(LsDirBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(LsDirBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + LsDirBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is LsDirBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } } - Stream _onEventQuery(LsDirBlocQuery ev) async* { + Future _onEventQuery( + LsDirBlocQuery ev, Emitter emit) async { try { - yield LsDirBlocLoading(ev.account, ev.root, state.items); - yield LsDirBlocSuccess(ev.account, ev.root, await _query(ev)); + emit(LsDirBlocLoading(ev.account, ev.root, state.items)); + emit(LsDirBlocSuccess(ev.account, ev.root, await _query(ev))); } catch (e) { _log.severe("[_onEventQuery] Exception while request", e); - yield LsDirBlocFailure(ev.account, ev.root, state.items, e); + emit(LsDirBlocFailure(ev.account, ev.root, state.items, e)); } } diff --git a/app/lib/bloc/ls_trashbin.dart b/app/lib/bloc/ls_trashbin.dart index a32b1901..18aeb83d 100644 --- a/app/lib/bloc/ls_trashbin.dart +++ b/app/lib/bloc/ls_trashbin.dart @@ -106,6 +106,8 @@ class LsTrashbinBloc extends Bloc { }, logTag: "LsTrashbinBloc.refresh", ); + + on(_onEvent); } static LsTrashbinBloc of(Account account) { @@ -122,29 +124,30 @@ class LsTrashbinBloc extends Bloc { } } - @override - mapEventToState(LsTrashbinBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent( + LsTrashbinBlocEvent event, Emitter emit) async { + _log.info("[_onEvent] $event"); if (event is LsTrashbinBlocQuery) { - yield* _onEventQuery(event); + await _onEventQuery(event, emit); } else if (event is _LsTrashbinBlocExternalEvent) { - yield* _onExternalEvent(event); + await _onExternalEvent(event, emit); } } - Stream _onEventQuery(LsTrashbinBlocQuery ev) async* { + Future _onEventQuery( + LsTrashbinBlocQuery ev, Emitter emit) async { try { - yield LsTrashbinBlocLoading(ev.account, state.items); - yield LsTrashbinBlocSuccess(ev.account, await _query(ev)); + emit(LsTrashbinBlocLoading(ev.account, state.items)); + emit(LsTrashbinBlocSuccess(ev.account, await _query(ev))); } catch (e) { _log.severe("[_onEventQuery] Exception while request", e); - yield LsTrashbinBlocFailure(ev.account, state.items, e); + emit(LsTrashbinBlocFailure(ev.account, state.items, e)); } } - Stream _onExternalEvent( - _LsTrashbinBlocExternalEvent ev) async* { - yield LsTrashbinBlocInconsistent(state.account, state.items); + Future _onExternalEvent(_LsTrashbinBlocExternalEvent ev, + Emitter emit) async { + emit(LsTrashbinBlocInconsistent(state.account, state.items)); } void _onFileRemovedEvent(FileRemovedEvent ev) { diff --git a/app/lib/bloc/scan_account_dir.dart b/app/lib/bloc/scan_account_dir.dart index 00620a2b..3703b849 100644 --- a/app/lib/bloc/scan_account_dir.dart +++ b/app/lib/bloc/scan_account_dir.dart @@ -117,6 +117,19 @@ class ScanAccountDirBloc _accountPrefUpdatedEventListener.begin(); _nativeFileExifUpdatedListener?.begin(); + + on(_onEvent, transformer: ((events, mapper) { + return events.asyncExpand(mapper).distinct((a, b) { + // only handle ScanAccountDirBlocQuery + final r = a is ScanAccountDirBlocQuery && + b is ScanAccountDirBlocQuery && + a == b; + if (r) { + _log.fine("[on] Skip identical ScanAccountDirBlocQuery event"); + } + return r; + }); + })); } static ScanAccountDirBloc of(Account account) { @@ -134,31 +147,6 @@ class ScanAccountDirBloc } } - @override - transformEvents(Stream events, transitionFn) { - return super.transformEvents(events.distinct((a, b) { - // only handle ScanAccountDirBlocQuery - final r = a is ScanAccountDirBlocQuery && - b is ScanAccountDirBlocQuery && - a == b; - if (r) { - _log.fine( - "[transformEvents] Skip identical ScanAccountDirBlocQuery event"); - } - return r; - }), transitionFn); - } - - @override - mapEventToState(ScanAccountDirBlocEvent event) async* { - _log.info("[mapEventToState] $event"); - if (event is ScanAccountDirBlocQueryBase) { - yield* _onEventQuery(event); - } else if (event is _ScanAccountDirBlocExternalEvent) { - yield* _onExternalEvent(event); - } - } - @override close() { _fileRemovedEventListener.end(); @@ -175,9 +163,20 @@ class ScanAccountDirBloc return super.close(); } - Stream _onEventQuery( - ScanAccountDirBlocQueryBase ev) async* { - yield ScanAccountDirBlocLoading(state.files); + Future _onEvent(ScanAccountDirBlocEvent event, + Emitter emit) async { + _log.info("[_onEvent] $event"); + if (event is ScanAccountDirBlocQueryBase) { + await _onEventQuery(event, emit); + } else if (event is _ScanAccountDirBlocExternalEvent) { + await _onExternalEvent(event, emit); + } + } + + Future _onEventQuery(ScanAccountDirBlocQueryBase ev, + Emitter emit) async { + _log.info("[_onEventQuery] $ev"); + emit(ScanAccountDirBlocLoading(state.files)); final hasContent = state.files.isNotEmpty; final stopwatch = Stopwatch()..start(); @@ -186,16 +185,16 @@ class ScanAccountDirBloc "[_onEventQuery] Elapsed time (_queryOffline): ${stopwatch.elapsedMilliseconds}ms"); if (!hasContent) { // show something instantly on first load - yield ScanAccountDirBlocLoading( - cacheFiles.where((f) => file_util.isSupportedFormat(f)).toList()); + emit(ScanAccountDirBlocLoading( + cacheFiles.where((f) => file_util.isSupportedFormat(f)).toList())); } - yield* _queryOnline(ev, cacheFiles); + await _queryOnline(ev, emit, cacheFiles); } - Stream _onExternalEvent( - _ScanAccountDirBlocExternalEvent ev) async* { - yield ScanAccountDirBlocInconsistent(state.files); + Future _onExternalEvent(_ScanAccountDirBlocExternalEvent ev, + Emitter emit) async { + emit(ScanAccountDirBlocInconsistent(state.files)); } void _onFileRemovedEvent(FileRemovedEvent ev) { @@ -335,8 +334,8 @@ class ScanAccountDirBloc return files; } - Stream _queryOnline( - ScanAccountDirBlocQueryBase ev, List cache) async* { + Future _queryOnline(ScanAccountDirBlocQueryBase ev, + Emitter emit, List cache) async { // 1st pass: scan for new files var files = []; final cacheMap = FileForwardCacheManager.prepareFileMap(cache); @@ -350,17 +349,17 @@ class ScanAccountDirBloc if (event is ExceptionEvent) { _log.shout("[_queryOnline] Exception while request (1st pass)", event.error, event.stackTrace); - yield ScanAccountDirBlocFailure( + emit(ScanAccountDirBlocFailure( cache.isEmpty ? files : cache.where((f) => file_util.isSupportedFormat(f)).toList(), - event.error); + event.error)); return; } files.addAll(event); if (cache.isEmpty) { // only emit partial results if there's no cache - yield ScanAccountDirBlocLoading(files); + emit(ScanAccountDirBlocLoading(files)); } } _log.info( @@ -376,7 +375,7 @@ class ScanAccountDirBloc // if cache is empty, we have already emitted the results in the loop if (cache.isNotEmpty || files.isEmpty) { // emit results from remote - yield ScanAccountDirBlocLoading(files); + emit(ScanAccountDirBlocLoading(files)); } files = await _queryOnlinePass2(ev, cacheMap, files); @@ -385,7 +384,7 @@ class ScanAccountDirBloc _log.shout( "[_queryOnline] Failed while _queryOnlinePass2", e, stackTrace); } - yield ScanAccountDirBlocSuccess(files); + emit(ScanAccountDirBlocSuccess(files)); } Future> _queryOnlinePass2(ScanAccountDirBlocQueryBase ev, diff --git a/app/lib/bloc/search_suggestion.dart b/app/lib/bloc/search_suggestion.dart index e0ac20a0..69d0da10 100644 --- a/app/lib/bloc/search_suggestion.dart +++ b/app/lib/bloc/search_suggestion.dart @@ -66,21 +66,23 @@ class SearchSuggestionBloc extends Bloc> { SearchSuggestionBloc({ required this.itemToKeywords, - }) : super(SearchSuggestionBlocInit()); + }) : super(SearchSuggestionBlocInit()) { + on(_onEvent); + } - @override - mapEventToState(SearchSuggestionBlocEvent event) async* { - _log.info("[mapEventToState] $event"); + Future _onEvent(SearchSuggestionBlocEvent event, + Emitter> emit) async { + _log.info("[_onEvent] $event"); if (event is SearchSuggestionBlocSearchEvent) { - yield* _onEventSearch(event); + await _onEventSearch(event, emit); } else if (event is SearchSuggestionBlocUpdateItemsEvent) { - yield* _onEventUpdateItems(event); + await _onEventUpdateItems(event, emit); } } - Stream> _onEventSearch( - SearchSuggestionBlocSearchEvent ev) async* { - yield SearchSuggestionBlocLoading(state.results); + Future _onEventSearch(SearchSuggestionBlocSearchEvent ev, + Emitter> emit) async { + emit(SearchSuggestionBlocLoading(state.results)); // doesn't work with upper case final results = _search.search(ev.phrase.toCaseInsensitiveString()); if (kDebugMode) { @@ -106,12 +108,12 @@ class SearchSuggestionBloc ) .map((e) => e.item2) .toList(); - yield SearchSuggestionBlocSuccess(matches); + emit(SearchSuggestionBlocSuccess(matches)); _lastSearch = ev; } - Stream> _onEventUpdateItems( - SearchSuggestionBlocUpdateItemsEvent ev) async* { + Future _onEventUpdateItems(SearchSuggestionBlocUpdateItemsEvent ev, + Emitter> emit) async { _search.setEntries([]); for (final a in ev.items) { for (final k in itemToKeywords(a)) { @@ -120,7 +122,7 @@ class SearchSuggestionBloc } if (_lastSearch != null) { // search again - yield* _onEventSearch(_lastSearch!); + await _onEventSearch(_lastSearch!, emit); } } diff --git a/app/lib/main.dart b/app/lib/main.dart index 657c4ed4..20fee5bc 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,5 +1,8 @@ +import 'package:bloc/bloc.dart'; +import 'package:bloc_concurrency/bloc_concurrency.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:logging/logging.dart'; import 'package:nc_photos/app_init.dart' as app_init; import 'package:nc_photos/platform/k.dart' as platform_k; import 'package:nc_photos/widget/my_app.dart'; @@ -12,5 +15,19 @@ void main() async { // reset orientation override just in case, see #59 SystemChrome.setPreferredOrientations([]); } - runApp(const MyApp()); + BlocOverrides.runZoned( + () => runApp(const MyApp()), + blocObserver: _BlocObserver(), + eventTransformer: sequential(), + ); +} + +class _BlocObserver extends BlocObserver { + @override + onChange(BlocBase bloc, Change change) { + super.onChange(bloc, change); + _log.finer("${bloc.runtimeType} $change"); + } + + static final _log = Logger("main._BlocObserver"); } diff --git a/app/pubspec.lock b/app/pubspec.lock index daea7e39..2a7ba624 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -86,14 +86,21 @@ packages: name: bloc url: "https://pub.dartlang.org" source: hosted - version: "7.2.1" + version: "8.0.3" + bloc_concurrency: + dependency: "direct main" + description: + name: bloc_concurrency + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" bloc_test: dependency: "direct dev" description: name: bloc_test url: "https://pub.dartlang.org" source: hosted - version: "8.5.0" + version: "9.0.3" boolean_selector: dependency: transitive description: @@ -356,7 +363,7 @@ packages: name: flutter_bloc url: "https://pub.dartlang.org" source: hosted - version: "7.3.3" + version: "8.0.1" flutter_blurhash: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 5ef70d79..5a33e483 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -34,7 +34,8 @@ dependencies: ref: android_intent_plus-v3.1.1-nc-photos-1 path: packages/android_intent_plus battery_plus: ^2.1.3 - bloc: ^7.0.0 + bloc: ^8.0.0 + bloc_concurrency: ^0.2.0 cached_network_image: ^3.2.1 collection: ^1.15.0 connectivity_plus: ^2.0.2 @@ -54,7 +55,7 @@ dependencies: git: url: https://gitlab.com/nc-photos/flutter_background_service.git ref: v0.2.6-nc-photos-2 - flutter_bloc: ^7.0.0 + flutter_bloc: ^8.0.0 flutter_map: ^1.1.1 flutter_staggered_grid_view: git: From 98adf40ba61800ba6500e26b09a68e61ea201c97 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 16:23:14 +0800 Subject: [PATCH 20/24] update transitive --- app/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 2a7ba624..9c577e76 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -648,7 +648,7 @@ packages: name: mocktail url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" mutex: dependency: "direct main" description: From fe62c5f86aada7c3d3ed56a37590609ffc27bf2a Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 16:33:24 +0800 Subject: [PATCH 21/24] Update device_info_plus_windows --- app/pubspec.lock | 12 ++++++------ app/pubspec.yaml | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 9c577e76..d09f906e 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -233,7 +233,7 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.4" + version: "0.7.6" device_info_plus: dependency: "direct main" description: @@ -270,12 +270,12 @@ packages: source: hosted version: "2.1.0" device_info_plus_windows: - dependency: transitive + dependency: "direct overridden" description: name: device_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.0" devicelocale: dependency: "direct main" description: @@ -335,7 +335,7 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "2.0.1" file: dependency: transitive description: @@ -767,7 +767,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.1.0" pedantic: dependency: transitive description: @@ -1282,7 +1282,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.7.0" wkt_parser: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 5a33e483..41172e1d 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -104,6 +104,11 @@ dependencies: woozy_search: ^2.0.3 xml: ^6.1.0 +dependency_overrides: + # the dependency of device_info_plus_windows was set incorrectly in + # device_info_plus, this is a workaround until it's fixed in upstream + device_info_plus_windows: ^3.0.0 + dev_dependencies: test: any bloc_test: any From 292e880b7391a9d14f0e17f734da7d8edcda389b Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 16:34:10 +0800 Subject: [PATCH 22/24] Update battery_plus_linux --- app/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index d09f906e..1b9b83a5 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -51,7 +51,7 @@ packages: name: battery_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.1.2" battery_plus_macos: dependency: transitive description: From 1c502c5ace44f25344ca2e3d9a5b5836b6d30606 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 19:15:16 +0800 Subject: [PATCH 23/24] Update video_player --- app/pubspec.lock | 54 +++++++++++++++++++++++------------------------- app/pubspec.yaml | 11 +++++----- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 1b9b83a5..b1266603 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -322,13 +322,6 @@ packages: url: "https://gitlab.com/nc-photos/exifdart.git" source: git version: "1.2.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" ffi: dependency: transitive description: @@ -434,11 +427,6 @@ packages: url: "https://gitlab.com/nc-photos/flutter_staggered_grid_view" source: git version: "0.4.0" - flutter_test: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" flutter_typeahead: dependency: "direct main" description: @@ -1182,30 +1170,40 @@ packages: video_player: dependency: "direct main" description: - path: "packages/video_player/video_player" - ref: "video_player-v2.2.6-nc-photos-2" - resolved-ref: "176a4e719a376c8f686a0ed73900b171cf92ebf0" + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.5" + video_player_android: + dependency: "direct overridden" + description: + path: "packages/video_player/video_player_android" + ref: "video_player-v2.4.5-nc-photos-1" + resolved-ref: fade05907d60e1076c270cd41a5f2b842c4a4d00 url: "https://gitlab.com/nc-photos/flutter-plugins" source: git - version: "2.2.6" + version: "2.3.6" + video_player_avfoundation: + dependency: transitive + description: + name: video_player_avfoundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.5" video_player_platform_interface: dependency: transitive description: - path: "packages/video_player/video_player_platform_interface" - ref: "video_player-v2.2.6-nc-photos-2" - resolved-ref: "176a4e719a376c8f686a0ed73900b171cf92ebf0" - url: "https://gitlab.com/nc-photos/flutter-plugins" - source: git - version: "4.2.0" + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.3" video_player_web: dependency: transitive description: - path: "packages/video_player/video_player_web" - ref: "video_player-v2.2.6-nc-photos-2" - resolved-ref: "176a4e719a376c8f686a0ed73900b171cf92ebf0" - url: "https://gitlab.com/nc-photos/flutter-plugins" - source: git - version: "2.0.4" + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.10" visibility_detector: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 41172e1d..020218aa 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -94,11 +94,7 @@ dependencies: tuple: ^2.0.0 url_launcher: ^6.0.3 uuid: ^3.0.6 - video_player: - git: - url: https://gitlab.com/nc-photos/flutter-plugins - ref: video_player-v2.2.6-nc-photos-2 - path: packages/video_player/video_player + video_player: 2.4.5 visibility_detector: ^0.3.3 wakelock: ^0.6.2 woozy_search: ^2.0.3 @@ -108,6 +104,11 @@ dependency_overrides: # the dependency of device_info_plus_windows was set incorrectly in # device_info_plus, this is a workaround until it's fixed in upstream device_info_plus_windows: ^3.0.0 + video_player_android: + git: + url: https://gitlab.com/nc-photos/flutter-plugins + ref: video_player-v2.4.5-nc-photos-1 + path: packages/video_player/video_player_android dev_dependencies: test: any From ac01e35e89ca21a9825cd08257620f80ca912823 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Jul 2022 19:22:02 +0800 Subject: [PATCH 24/24] Update transitive dependencies --- app/pubspec.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index b1266603..01eae0bf 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -37,7 +37,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" battery_plus: dependency: "direct main" description: @@ -212,7 +212,7 @@ packages: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "1.5.0" crypto: dependency: transitive description: @@ -587,7 +587,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: @@ -998,7 +998,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" sqflite: dependency: "direct main" description: @@ -1040,7 +1040,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" synchronized: dependency: "direct main" description: @@ -1054,28 +1054,28 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test: dependency: "direct dev" description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.21.1" + version: "1.21.4" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.13" + version: "0.4.16" tuple: dependency: "direct main" description: @@ -1217,7 +1217,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "8.3.0" + version: "9.0.0" wakelock: dependency: "direct main" description: