From b08b5d0abef7b3b5b33a3460e8be57a676c15564 Mon Sep 17 00:00:00 2001 From: nyne Date: Wed, 6 Nov 2024 17:43:36 +0800 Subject: [PATCH 01/10] update action --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26b1ba3..8254751 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: {} jobs: Build_MacOS: - runs-on: macos-13 + runs-on: macos-15 steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 @@ -12,7 +12,7 @@ jobs: channel: "stable" flutter-version-file: pubspec.yaml architecture: x64 - - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app + - run: sudo xcode-select --switch /Applications/Xcode_16.0.app - run: flutter pub get # Step 1: Decode and install the certificate - name: Decode and install certificate @@ -38,12 +38,12 @@ jobs: # Step 4: Attach and upload artifacts (optional) - name: Upload DMG - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: venera.dmg path: dist/venera.dmg Build_IOS: - runs-on: macos-13 + runs-on: macos-15 steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 @@ -51,7 +51,7 @@ jobs: channel: "stable" flutter-version-file: pubspec.yaml architecture: x64 - - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app + - run: sudo xcode-select --switch /Applications/Xcode_16.0.app - run: flutter pub get - run: flutter build ios --release --no-codesign - run: | From 22f2ac99ade4b6a49acd100b698346496614190e Mon Sep 17 00:00:00 2001 From: nyne Date: Wed, 6 Nov 2024 18:06:20 +0800 Subject: [PATCH 02/10] fix http --- lib/network/app_dio.dart | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/network/app_dio.dart b/lib/network/app_dio.dart index dbbc7bc..b57cc0a 100644 --- a/lib/network/app_dio.dart +++ b/lib/network/app_dio.dart @@ -218,14 +218,14 @@ class RHttpAdapter implements HttpClientAdapter { rhttp.ClientSettings settings; RHttpAdapter(this.settings) { - settings.copyWith( + settings = settings.copyWith( redirectSettings: const rhttp.RedirectSettings.limited(5), timeoutSettings: const rhttp.TimeoutSettings( connectTimeout: Duration(seconds: 15), keepAliveTimeout: Duration(seconds: 60), keepAlivePing: Duration(seconds: 30), ), - httpVersionPref: rhttp.HttpVersionPref.http1_1, + throwOnStatusCode: false, ); } @@ -275,12 +275,7 @@ class RHttpAdapter implements HttpClientAdapter { var data = res.body; if(headers['content-encoding']?.contains('gzip') ?? false) { // rhttp does not support gzip decoding - var buffer = []; - await for (var chunk in data) { - buffer.addAll(chunk); - } - data = Stream.value(Uint8List.fromList(gzip.decode(buffer))); - buffer.clear(); + data = gzip.decoder.bind(data).map((data) => Uint8List.fromList(data)); } return ResponseBody( data, From 5234de434a199d3058f427df469393780bd05873 Mon Sep 17 00:00:00 2001 From: nyne Date: Wed, 6 Nov 2024 22:08:23 +0800 Subject: [PATCH 03/10] improve network log --- lib/network/app_dio.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/network/app_dio.dart b/lib/network/app_dio.dart index b57cc0a..b190994 100644 --- a/lib/network/app_dio.dart +++ b/lib/network/app_dio.dart @@ -196,12 +196,6 @@ class AppDio with DioMixin { : rhttp.ProxySettings.proxy(proxy!), )); } - Log.info( - "Network", - "${options?.method ?? 'GET'} $path\n" - "Headers: ${options?.headers}\n" - "Data: $data\n", - ); return super.request( path, data: data, @@ -238,6 +232,12 @@ class RHttpAdapter implements HttpClientAdapter { Stream? requestStream, Future? cancelFuture, ) async { + Log.info( + "Network", + "${options.method} ${options.uri}\n" + "Headers: ${options.headers}\n" + "Data: ${options.data}\n", + ); var res = await rhttp.Rhttp.request( method: switch (options.method) { 'GET' => rhttp.HttpMethod.get, From e51a58ba4f0668391bfc513e3485de7dfcebca0b Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 08:49:32 +0800 Subject: [PATCH 04/10] fix deleting files when canceling a task --- lib/network/download.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/network/download.dart b/lib/network/download.dart index f0c3748..1bb4ab8 100644 --- a/lib/network/download.dart +++ b/lib/network/download.dart @@ -90,7 +90,7 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin { var local = LocalManager().find(id, comicType); if (path != null) { if (local == null) { - Directory(path!).deleteIgnoreError(); + Directory(path!).deleteIgnoreError(recursive: true); } else if (chapters != null) { for (var c in chapters!) { var dir = Directory(FilePath.join(path!, c)); From 5d43f5c556c36f0cf83d5c1ed396198d9437eff9 Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 08:59:49 +0800 Subject: [PATCH 05/10] fix favorites page --- assets/translation.json | 8 +++- lib/pages/favorites/favorite_actions.dart | 1 - lib/pages/favorites/favorites_page.dart | 3 +- lib/pages/favorites/local_favorites_page.dart | 7 +-- pubspec.lock | 44 ++++++++++++++++--- pubspec.yaml | 2 +- 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/assets/translation.json b/assets/translation.json index 0df06c2..0545744 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -169,7 +169,9 @@ "minAppVersion @version is required": "需要最低App版本 @version", "Remove": "移除", "Long press to zoom": "长按缩放", - "Updates Available": "更新可用" + "Updates Available": "更新可用", + "Unselected": "未选择", + "Long press and drag to reorder.": "长按并拖动以重新排序。" }, "zh_TW": { "Home": "首頁", @@ -341,6 +343,8 @@ "minAppVersion @version is required": "需要最低App版本 @version", "Remove": "移除", "Long press to zoom": "長按縮放", - "Updates Available": "更新可用" + "Updates Available": "更新可用", + "Unselected": "未選擇", + "Long press and drag to reorder.": "長按並拖動以重新排序。" } } \ No newline at end of file diff --git a/lib/pages/favorites/favorite_actions.dart b/lib/pages/favorites/favorite_actions.dart index a51f091..2b625d6 100644 --- a/lib/pages/favorites/favorite_actions.dart +++ b/lib/pages/favorites/favorite_actions.dart @@ -6,7 +6,6 @@ Future newFolder() async { context: App.rootContext, builder: (context) { var controller = TextEditingController(); - var folders = LocalFavoritesManager().folderNames; String? error; return StatefulBuilder(builder: (context, setState) { diff --git a/lib/pages/favorites/favorites_page.dart b/lib/pages/favorites/favorites_page.dart index f069923..042058e 100644 --- a/lib/pages/favorites/favorites_page.dart +++ b/lib/pages/favorites/favorites_page.dart @@ -152,7 +152,8 @@ class _FavoritesPageState extends State { } else { var favoriteData = getFavoriteDataOrNull(folder!); if (favoriteData == null) { - return const Center(child: Text("Unknown source")); + folder = null; + return buildBody(); } else { return NetworkFavoritePage(favoriteData, key: Key(folder!)); } diff --git a/lib/pages/favorites/local_favorites_page.dart b/lib/pages/favorites/local_favorites_page.dart index 0497042..62230c8 100644 --- a/lib/pages/favorites/local_favorites_page.dart +++ b/lib/pages/favorites/local_favorites_page.dart @@ -15,10 +15,8 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { late List comics; void updateComics() { - print(comics.length); setState(() { comics = LocalFavoritesManager().getAllComics(widget.folder); - print(comics.length); }); } @@ -107,7 +105,9 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { }, ).then( (value) { - setState(() {}); + if(mounted) { + setState(() {}); + } }, ); }), @@ -199,6 +199,7 @@ class _ReorderComicsPageState extends State<_ReorderComicsPage> { var comicSource = e.type.comicSource; return ComicTile( key: Key(e.hashCode.toString()), + enableLongPressed: false, comic: Comic( e.name, e.coverPath, diff --git a/pubspec.lock b/pubspec.lock index fdf85c8..0c55483 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -345,10 +345,10 @@ packages: dependency: "direct main" description: name: flutter_reorderable_grid_view - sha256: "40abcc5bff228ebff119326502e7357ee6399956b60b80b17385e9770b7458c0" + sha256: "93a2b9e279bf40b9333428a67e70e520ca1528554984eb6f6304538400897e64" url: "https://pub.dev" source: hosted - version: "5.0.1" + version: "5.3.2" flutter_rust_bridge: dependency: transitive description: @@ -638,10 +638,42 @@ packages: dependency: transitive description: name: screen_retriever - sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90" + sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c" url: "https://pub.dev" source: hosted - version: "0.1.9" + version: "0.2.0" + screen_retriever_linux: + dependency: transitive + description: + name: screen_retriever_linux + sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_macos: + dependency: transitive + description: + name: screen_retriever_macos + sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_platform_interface: + dependency: transitive + description: + name: screen_retriever_platform_interface + sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_windows: + dependency: transitive + description: + name: screen_retriever_windows + sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13" + url: "https://pub.dev" + source: hosted + version: "0.2.0" scrollable_positioned_list: dependency: "direct main" description: @@ -868,10 +900,10 @@ packages: dependency: "direct main" description: name: window_manager - sha256: ab8b2a7f97543d3db2b506c9d875e637149d48ee0c6a5cb5f5fd6e0dac463792 + sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059" url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "0.4.3" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 119c78f..06018c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,7 +39,7 @@ dependencies: url: https://github.com/venera-app/flutter.widgets ref: 09e756b1f1b04e6298318d99ec20a787fb360f59 path: packages/scrollable_positioned_list - flutter_reorderable_grid_view: 5.0.1 + flutter_reorderable_grid_view: 5.3.2 yaml: any uuid: ^4.5.1 desktop_webview_window: From 5a14ea48c1e784b90e59d3bfc880b8e9df6827be Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 09:02:03 +0800 Subject: [PATCH 06/10] fix changing search target in search result page --- lib/pages/search_result_page.dart | 39 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/pages/search_result_page.dart b/lib/pages/search_result_page.dart index 19d2105..1d67e5f 100644 --- a/lib/pages/search_result_page.dart +++ b/lib/pages/search_result_page.dart @@ -42,7 +42,7 @@ class _SearchResultPageState extends State { void search([String? text]) { if (text != null) { - if(suggestionsController.entry != null) { + if (suggestionsController.entry != null) { suggestionsController.remove(); } setState(() { @@ -135,20 +135,24 @@ class _SearchResultPageState extends State { onChanged: onChanged, action: buildAction(), ), - loadPage: source!.searchPageData!.loadPage == null ? null : (i) { - return source.searchPageData!.loadPage!( - text, - i, - options, - ); - }, - loadNext: source.searchPageData!.loadNext == null ? null : (i) { - return source.searchPageData!.loadNext!( - text, - i, - options, - ); - }, + loadPage: source!.searchPageData!.loadPage == null + ? null + : (i) { + return source.searchPageData!.loadPage!( + text, + i, + options, + ); + }, + loadNext: source.searchPageData!.loadNext == null + ? null + : (i) { + return source.searchPageData!.loadNext!( + text, + i, + options, + ); + }, ); } @@ -424,6 +428,11 @@ class _SearchSettingsDialogState extends State<_SearchSettingsDialog> { setState(() { searchTarget = e.key; options.clear(); + final searchOptions = ComicSource.find(searchTarget)! + .searchPageData! + .searchOptions ?? + []; + options = searchOptions.map((e) => e.defaultValue).toList(); onChanged(); }); }, From 082aa3631629191377a475e9813f19528f7d4178 Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 09:31:57 +0800 Subject: [PATCH 07/10] improve reader; fix #21 --- assets/translation.json | 8 ++++++-- lib/foundation/appdata.dart | 1 + lib/pages/reader/gesture.dart | 18 +++++++++++++++++- lib/pages/reader/images.dart | 10 ++++++++-- lib/pages/settings/reader.dart | 8 ++++++++ lib/pages/settings/setting_components.dart | 4 ++++ 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/assets/translation.json b/assets/translation.json index 0545744..47b6225 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -171,7 +171,9 @@ "Long press to zoom": "长按缩放", "Updates Available": "更新可用", "Unselected": "未选择", - "Long press and drag to reorder.": "长按并拖动以重新排序。" + "Long press and drag to reorder.": "长按并拖动以重新排序。", + "Limit image width": "限制图片宽度", + "When using Continuous(Top to Bottom) mode": "当使用连续(从上到下)模式" }, "zh_TW": { "Home": "首頁", @@ -345,6 +347,8 @@ "Long press to zoom": "長按縮放", "Updates Available": "更新可用", "Unselected": "未選擇", - "Long press and drag to reorder.": "長按並拖動以重新排序。" + "Long press and drag to reorder.": "長按並拖動以重新排序。", + "Limit image width": "限制圖片寬度", + "When using Continuous(Top to Bottom) mode": "當使用連續(從上到下)模式" } } \ No newline at end of file diff --git a/lib/foundation/appdata.dart b/lib/foundation/appdata.dart index 817aa96..eae041e 100644 --- a/lib/foundation/appdata.dart +++ b/lib/foundation/appdata.dart @@ -113,6 +113,7 @@ class _Settings with ChangeNotifier { 'downloadThreads': 5, 'enableLongPressToZoom': true, 'checkUpdateOnStart': true, + 'limitImageWidth': true, }; operator [](String key) { diff --git a/lib/pages/reader/gesture.dart b/lib/pages/reader/gesture.dart index 9c04e34..a97e17e 100644 --- a/lib/pages/reader/gesture.dart +++ b/lib/pages/reader/gesture.dart @@ -22,6 +22,8 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> { _DragListener? dragListener; + int fingers = 0; + @override void initState() { _tapGestureRecognizer = TapGestureRecognizer() @@ -38,6 +40,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> { return Listener( behavior: HitTestBehavior.translucent, onPointerDown: (event) { + fingers++; _lastTapPointer = event.pointer; _lastTapMoveDistance = Offset.zero; _tapGestureRecognizer.addPointer(event); @@ -46,7 +49,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> { _dragInProgress = false; } Future.delayed(_kLongPressMinTime, () { - if (_lastTapPointer == event.pointer) { + if (_lastTapPointer == event.pointer && fingers == 1) { if(_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) { onLongPressedDown(event.position); _longPressInProgress = true; @@ -67,6 +70,19 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> { } }, onPointerUp: (event) { + fingers--; + if (_longPressInProgress) { + onLongPressedUp(event.position); + } + if(_dragInProgress) { + dragListener?.onEnd?.call(); + _dragInProgress = false; + } + _lastTapPointer = null; + _lastTapMoveDistance = null; + }, + onPointerCancel: (event) { + fingers--; if (_longPressInProgress) { onLongPressedUp(event.position); } diff --git a/lib/pages/reader/images.dart b/lib/pages/reader/images.dart index 578b893..11be666 100644 --- a/lib/pages/reader/images.dart +++ b/lib/pages/reader/images.dart @@ -471,18 +471,24 @@ class _ContinuousModeState extends State<_ContinuousMode> }, child: widget, ); + var width = MediaQuery.of(context).size.width; + var height = MediaQuery.of(context).size.height; + if(appdata.settings['limitImageWidth'] && width / height > 0.7) { + width = height * 0.7; + } return PhotoView.customChild( backgroundDecoration: BoxDecoration( color: context.colorScheme.surface, ), + childSize: Size(width, height), minScale: 1.0, maxScale: 2.5, strictScale: true, controller: photoViewController, child: SizedBox( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, + width: width, + height: height, child: widget, ), ); diff --git a/lib/pages/settings/reader.dart b/lib/pages/settings/reader.dart index e8cb88d..a597736 100644 --- a/lib/pages/settings/reader.dart +++ b/lib/pages/settings/reader.dart @@ -61,6 +61,14 @@ class _ReaderSettingsState extends State { widget.onChanged?.call('enableLongPressToZoom'); }, ).toSliver(), + _SwitchSetting( + title: 'Limit image width'.tl, + subtitle: 'When using Continuous(Top to Bottom) mode'.tl, + settingKey: 'limitImageWidth', + onChanged: () { + widget.onChanged?.call('limitImageWidth'); + }, + ).toSliver(), ], ); } diff --git a/lib/pages/settings/setting_components.dart b/lib/pages/settings/setting_components.dart index 677c98f..9a95270 100644 --- a/lib/pages/settings/setting_components.dart +++ b/lib/pages/settings/setting_components.dart @@ -5,6 +5,7 @@ class _SwitchSetting extends StatefulWidget { required this.title, required this.settingKey, this.onChanged, + this.subtitle, }); final String title; @@ -13,6 +14,8 @@ class _SwitchSetting extends StatefulWidget { final VoidCallback? onChanged; + final String? subtitle; + @override State<_SwitchSetting> createState() => _SwitchSettingState(); } @@ -24,6 +27,7 @@ class _SwitchSettingState extends State<_SwitchSetting> { return ListTile( title: Text(widget.title), + subtitle: widget.subtitle == null ? null : Text(widget.subtitle!), trailing: Switch( value: appdata.settings[widget.settingKey], onChanged: (value) { From 26fa41f503c2c31a6976ec828e814908f0b2a8f3 Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 09:41:14 +0800 Subject: [PATCH 08/10] improve translation --- assets/translation.json | 16 ++++++++++++++-- lib/pages/search_page.dart | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/assets/translation.json b/assets/translation.json index 47b6225..92f5bb0 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -173,7 +173,13 @@ "Unselected": "未选择", "Long press and drag to reorder.": "长按并拖动以重新排序。", "Limit image width": "限制图片宽度", - "When using Continuous(Top to Bottom) mode": "当使用连续(从上到下)模式" + "When using Continuous(Top to Bottom) mode": "当使用连续(从上到下)模式", + "Open link": "打开链接", + "Open comic": "打开漫画", + "Move To First": "移动到最前", + "Cancel": "取消", + "Paused": "已暂停", + "Pause": "暂停" }, "zh_TW": { "Home": "首頁", @@ -349,6 +355,12 @@ "Unselected": "未選擇", "Long press and drag to reorder.": "長按並拖動以重新排序。", "Limit image width": "限制圖片寬度", - "When using Continuous(Top to Bottom) mode": "當使用連續(從上到下)模式" + "When using Continuous(Top to Bottom) mode": "當使用連續(從上到下)模式", + "Open link": "打開鏈接", + "Open comic": "打開漫畫", + "Move To First": "移動到最前", + "Cancel": "取消", + "Paused": "已暫停", + "Pause": "暫停" } } \ No newline at end of file diff --git a/lib/pages/search_page.dart b/lib/pages/search_page.dart index c16a61e..6bfc070 100644 --- a/lib/pages/search_page.dart +++ b/lib/pages/search_page.dart @@ -369,6 +369,9 @@ class _SearchPageState extends State { ), trailing: const Icon(Icons.arrow_right), onTap: () { + setState(() { + suggestions.clear(); + }); handleAppLink(Uri.parse(controller.text)); }, ); From 99bbea80dc69109611a837166a3b2cd0d802944f Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 09:56:10 +0800 Subject: [PATCH 09/10] update version code --- lib/foundation/app.dart | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/foundation/app.dart b/lib/foundation/app.dart index e1456b6..ef843d6 100644 --- a/lib/foundation/app.dart +++ b/lib/foundation/app.dart @@ -10,7 +10,7 @@ export "widget_utils.dart"; export "context.dart"; class _App { - final version = "1.0.2"; + final version = "1.0.3"; bool get isAndroid => Platform.isAndroid; diff --git a/pubspec.yaml b/pubspec.yaml index 06018c7..30c4f5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: venera description: "A comic app." publish_to: 'none' -version: 1.0.2+102 +version: 1.0.3+103 environment: sdk: '>=3.5.0 <4.0.0' From a9a22ace14810c3b3422597d21f977f0fa3bd7df Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 10:20:50 +0800 Subject: [PATCH 10/10] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index abe4797..db004f5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![License](https://img.shields.io/github/license/venera-app/venera)](https://github.com/venera-app/venera/blob/master/LICENSE) [![Download](https://img.shields.io/github/v/release/venera-app/venera)](https://github.com/venera-app/venera/releases) [![stars](https://img.shields.io/github/stars/venera-app/venera)](https://github.com/venera-app/venera/stargazers) +[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/+Ws-IpmUutzkxMjhl) A comic reader that support reading local and network comics.