diff --git a/.vscode/launch.json b/.vscode/launch.json index 1545fd0..ed1fb1f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -30,5 +30,15 @@ "full" ] }, + { + "name": "Flutter (Full Dev Flavor)", + "type": "dart", + "request": "launch", + "program": "lib/main.dart", + "args": [ + "--flavor", + "full-dev" + ] + }, ] } \ No newline at end of file diff --git a/lib/ui/core/word_display.dart b/lib/ui/core/word_display.dart index cc25ef3..dfd2fa6 100644 --- a/lib/ui/core/word_display.dart +++ b/lib/ui/core/word_display.dart @@ -16,6 +16,8 @@ import "package:ciyue/ui/core/tags_list.dart"; import "package:ciyue/viewModels/ai_explanation.dart"; import "package:ciyue/viewModels/wordbook.dart"; import "package:dict_reader/dict_reader.dart"; +import "package:flutter/foundation.dart"; +import "package:flutter/gestures.dart"; import "package:flutter/material.dart"; import "package:flutter/services.dart"; import "package:flutter_inappwebview/flutter_inappwebview.dart"; @@ -410,6 +412,7 @@ class _WebviewAndroidState extends State { algorithmicDarkeningAllowed: !isLightTheme, resourceCustomSchemes: ["entry", "sound"], transparentBackground: true, + horizontalScrollBarEnabled: , webViewAssetLoader: WebViewAssetLoader( domain: "ciyue.internal", httpAllowed: true, @@ -468,6 +471,13 @@ class _WebviewAndroidState extends State { ), initialSettings: webviewSettings, contextMenu: contextMenu, + gestureRecognizers: { + // Flutter inappwebview scroll not working inside the NestedScrollView TabBarView + // https://stackoverflow.com/a/67345391 + Factory( + () => VerticalDragGestureRecognizer(), + ), + }, onLoadResourceWithCustomScheme: onLoadResourceWithCustomSchemeWarpper(widget.dictId), shouldOverrideUrlLoading: @@ -475,15 +485,17 @@ class _WebviewAndroidState extends State { onWebViewCreated: (controller) async { webViewController = controller; - controller.addJavaScriptHandler( - handlerName: "WebViewHeight", - callback: (args) { - double newHeight = args[0].toDouble(); - setState(() { - height = newHeight; - }); - }, - ); + if (widget.isExpansion) { + controller.addJavaScriptHandler( + handlerName: "WebViewHeight", + callback: (args) { + double newHeight = args[0].toDouble(); + setState(() { + height = newHeight; + }); + }, + ); + } }, onPageCommitVisible: (controller, url) async { controller.evaluateJavascript(source: """ @@ -833,7 +845,6 @@ class WordDisplay extends StatelessWidget { List validDictIds = const [], }) { return TabBarView( - physics: const NeverScrollableScrollPhysics(), children: [ if (settings.aiExplainWord) AIExplainView(