diff --git a/lib/pages/guide/admission_guide_page.dart b/lib/pages/guide/admission_guide_page.dart index f8717a9..97cb4f7 100644 --- a/lib/pages/guide/admission_guide_page.dart +++ b/lib/pages/guide/admission_guide_page.dart @@ -3,10 +3,8 @@ import 'dart:io'; import 'package:ap_common/ap_common.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:nsysu_ap/config/constants.dart'; -import 'package:webview_windows/webview_windows.dart'; class AdmissionGuidePage extends StatefulWidget { @override @@ -17,15 +15,11 @@ class _AdmissionGuidePageState extends State { late ApLocalizations ap; InAppWebViewController? webViewController; - final WebviewController _windowsController = WebviewController(); @override void initState() { AnalyticsUtil.instance .setCurrentScreen('AdmissionGuidePage', 'admission_guide_page.dart'); - if (!kIsWeb && Platform.isWindows) { - initWindowsPlatformState(); - } super.initState(); } @@ -44,8 +38,6 @@ class _AdmissionGuidePageState extends State { if (await webViewController?.canGoBack() ?? false) { webViewController?.goBack(); } - } else if (Platform.isWindows) { - _windowsController.goBack(); } }, ), @@ -56,8 +48,6 @@ class _AdmissionGuidePageState extends State { if (await webViewController?.canGoForward() ?? false) { webViewController?.goForward(); } - } else if (Platform.isWindows) { - _windowsController.goForward(); } }, ), @@ -65,7 +55,11 @@ class _AdmissionGuidePageState extends State { ), body: Builder( builder: (BuildContext context) { - if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) { + if (!kIsWeb && + (Platform.isAndroid || + Platform.isIOS || + Platform.isMacOS || + Platform.isWindows)) { return InAppWebView( initialUrlRequest: URLRequest( url: WebUri(Constants.admissionGuideUrl), @@ -75,10 +69,6 @@ class _AdmissionGuidePageState extends State { //_windowsController.complete(webViewController); }, ); - } else if (Platform.isWindows) { - return Webview( - _windowsController, - ); } else { return HintContent( icon: ApIcon.apps, @@ -89,48 +79,4 @@ class _AdmissionGuidePageState extends State { ), ); } - - Future initWindowsPlatformState() async { - try { - await _windowsController.initialize(); - _windowsController.url.listen((String url) { - if (kDebugMode) { - print(url); - } - }); - - await _windowsController.setBackgroundColor(Colors.transparent); - await _windowsController - .setPopupWindowPolicy(WebviewPopupWindowPolicy.deny); - await _windowsController.loadUrl(Constants.admissionGuideUrl); - - if (!mounted) return; - setState(() {}); - } on PlatformException catch (e) { - WidgetsBinding.instance.addPostFrameCallback((_) { - showDialog( - context: context, - builder: (_) => AlertDialog( - title: const Text('Error'), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Code: ${e.code}'), - Text('Message: ${e.message}'), - ], - ), - actions: [ - TextButton( - child: const Text('Continue'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ), - ); - }); - } - } } diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index bbff311..c130af0 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -233,6 +233,7 @@ class HomePageState extends State { if (kIsWeb || Platform.isAndroid || Platform.isIOS || + Platform.isMacOS || Platform.isWindows) { _openPage( AdmissionGuidePage(), diff --git a/pubspec.lock b/pubspec.lock index 189e4e5..a14b55a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1738,14 +1738,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" - webview_windows: - dependency: "direct main" - description: - name: webview_windows - sha256: "47fcad5875a45db29dbb5c9e6709bf5c88dcc429049872701343f91ed7255730" - url: "https://pub.dev" - source: hosted - version: "0.4.0" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e41af51..69dc186 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,7 +33,6 @@ dependencies: cookie_jar: ^4.0.3 flutter_inappwebview: ^6.1.5 desktop_webview_window: ^0.2.3 - webview_windows: ^0.4.0 timeago: ^3.0.2 google_sign_in_dartio: ^0.3.0 json_annotation: ^4.6.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index d424aca..7662d0b 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -14,7 +14,6 @@ #include #include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopWebviewWindowPluginRegisterWithRegistrar( @@ -33,6 +32,4 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); - WebviewWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WebviewWindowsPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 74179d4..196b328 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -11,7 +11,6 @@ list(APPEND FLUTTER_PLUGIN_LIST printing share_plus url_launcher_windows - webview_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST