mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-04-03 08:05:06 +08:00
Merge branch 'main' into flutter-3.19.6
This commit is contained in:
@@ -13,12 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:proxypin/ui/component/json/theme.dart';
|
||||
import 'package:proxypin/ui/component/utils.dart';
|
||||
|
||||
class JsonText extends StatefulWidget {
|
||||
class JsonText extends StatelessWidget {
|
||||
final ColorTheme colorTheme;
|
||||
final dynamic json;
|
||||
final String indent;
|
||||
@@ -26,37 +28,11 @@ class JsonText extends StatefulWidget {
|
||||
|
||||
const JsonText({super.key, required this.json, this.indent = ' ', required this.colorTheme, this.scrollController});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _JsonTextSate();
|
||||
}
|
||||
|
||||
class _JsonTextSate extends State<JsonText> {
|
||||
late ColorTheme colorTheme;
|
||||
late dynamic json;
|
||||
late String indent;
|
||||
late ScrollController? scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
colorTheme = widget.colorTheme;
|
||||
json = widget.json;
|
||||
indent = widget.indent;
|
||||
scrollController = trackingScroll(widget.scrollController);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var jsnParser = JsnParser(json, colorTheme, indent);
|
||||
var future = jsnParser.getLength() < 30
|
||||
? Future.value(jsnParser.getJsonTree())
|
||||
: compute((message) => message.getJsonTree(), jsnParser).catchError((error) => <Text>[Text(error.toString())]);
|
||||
var future =
|
||||
compute((message) => message.getJsonTree(), jsnParser).catchError((error) => <Text>[Text(error.toString())]);
|
||||
|
||||
return FutureBuilder(
|
||||
future: future,
|
||||
@@ -73,7 +49,7 @@ class _JsonTextSate extends State<JsonText> {
|
||||
height: MediaQuery.of(context).size.height - 160,
|
||||
child: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
controller: scrollController,
|
||||
controller: trackingScroll(),
|
||||
cacheExtent: 1000,
|
||||
itemBuilder: (context, index) => textList[index],
|
||||
itemCount: textList.length));
|
||||
@@ -84,6 +60,32 @@ class _JsonTextSate extends State<JsonText> {
|
||||
return Container();
|
||||
});
|
||||
}
|
||||
|
||||
///滚动条
|
||||
ScrollController trackingScroll() {
|
||||
var trackingScroll = TrackingScrollController();
|
||||
double offset = 0;
|
||||
trackingScroll.addListener(() {
|
||||
if (trackingScroll.offset < -10 || (trackingScroll.offset < 30 && trackingScroll.offset < offset)) {
|
||||
if (scrollController != null && scrollController!.offset >= 0) {
|
||||
scrollController?.jumpTo(scrollController!.offset - max((offset - trackingScroll.offset), 15));
|
||||
}
|
||||
}
|
||||
offset = trackingScroll.offset;
|
||||
});
|
||||
|
||||
if (Platform.isIOS) {
|
||||
scrollController?.addListener(() {
|
||||
if (scrollController!.offset >= scrollController!.position.maxScrollExtent) {
|
||||
scrollController?.jumpTo(scrollController!.position.maxScrollExtent);
|
||||
trackingScroll
|
||||
.jumpTo(trackingScroll.offset + (scrollController!.offset - scrollController!.position.maxScrollExtent));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return trackingScroll;
|
||||
}
|
||||
}
|
||||
|
||||
class JsnParser {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <flutter_desktop_context_menu/flutter_desktop_context_menu_plugin.h>
|
||||
#include <flutter_js/flutter_js_plugin.h>
|
||||
#include <proxy_manager/proxy_manager_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
@@ -31,9 +31,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) proxy_manager_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ProxyManagerPlugin");
|
||||
proxy_manager_plugin_register_with_registrar(proxy_manager_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
|
||||
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
||||
@@ -8,7 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_desktop_context_menu
|
||||
flutter_js
|
||||
proxy_manager
|
||||
screen_retriever
|
||||
screen_retriever_linux
|
||||
url_launcher_linux
|
||||
window_manager
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import flutter_desktop_context_menu
|
||||
import flutter_js
|
||||
import path_provider_foundation
|
||||
import proxy_manager
|
||||
import screen_retriever
|
||||
import screen_retriever_macos
|
||||
import share_plus
|
||||
import shared_preferences_foundation
|
||||
import url_launcher_macos
|
||||
@@ -26,7 +26,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ProxyManagerPlugin.register(with: registry.registrar(forPlugin: "ProxyManagerPlugin"))
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <flutter_js/flutter_js_plugin.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <proxy_manager/proxy_manager_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <win32audio/win32audio_plugin_c_api.h>
|
||||
@@ -31,8 +31,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
ProxyManagerPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ProxyManagerPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
||||
@@ -9,7 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_js
|
||||
permission_handler_windows
|
||||
proxy_manager
|
||||
screen_retriever
|
||||
screen_retriever_windows
|
||||
share_plus
|
||||
url_launcher_windows
|
||||
win32audio
|
||||
|
||||
Reference in New Issue
Block a user