feat: deliver RSchedule service login exams and elastic glass navigation

This commit is contained in:
Codex
2026-10-13 17:06:50 +08:00
parent 9193fd8e43
commit 8f20a341c4
35 changed files with 1742 additions and 453 deletions
+102
View File
@@ -0,0 +1,102 @@
import 'dart:async';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
class FakeSchoolPlatform extends WebViewPlatform {
late FakeSchoolWeb web;
late FakeSchoolDelegate delegate;
final cookies = FakeSchoolCookies();
@override
PlatformWebViewController createPlatformWebViewController(
PlatformWebViewControllerCreationParams params,
) => web = FakeSchoolWeb(params);
@override
PlatformNavigationDelegate createPlatformNavigationDelegate(
PlatformNavigationDelegateCreationParams params,
) => delegate = FakeSchoolDelegate(params);
@override
PlatformWebViewCookieManager createPlatformCookieManager(
PlatformWebViewCookieManagerCreationParams params,
) => cookies;
}
class FakeSchoolWeb extends PlatformWebViewController {
FakeSchoolWeb(super.params) : super.implementation();
final loads = <String>[];
String? url;
Future<Object> Function(String)? javascript;
@override
Future<void> setJavaScriptMode(JavaScriptMode mode) async {}
@override
Future<void> setPlatformNavigationDelegate(
PlatformNavigationDelegate handler,
) async {}
@override
Future<void> loadRequest(LoadRequestParams params) async {
url = params.uri.toString();
loads.add(url!);
}
@override
Future<String?> currentUrl() async => url;
@override
Future<Object> runJavaScriptReturningResult(String script) =>
javascript?.call(script) ?? Future.value(false);
@override
Future<void> clearCache() async {}
@override
Future<void> clearLocalStorage() async {}
@override
Future<void> loadHtmlString(String html, {String? baseUrl}) async {
url = 'about:blank';
loads.add('about:blank');
}
}
class FakeSchoolDelegate extends PlatformNavigationDelegate {
FakeSchoolDelegate(super.params) : super.implementation();
late PageEventCallback started, finished;
late WebResourceErrorCallback resourceError;
late NavigationRequestCallback navigation;
@override
Future<void> setOnNavigationRequest(
NavigationRequestCallback callback,
) async {
navigation = callback;
}
@override
Future<void> setOnPageStarted(PageEventCallback callback) async {
started = callback;
}
@override
Future<void> setOnPageFinished(PageEventCallback callback) async {
finished = callback;
}
@override
Future<void> setOnWebResourceError(WebResourceErrorCallback callback) async {
resourceError = callback;
}
@override
Future<void> setOnHttpError(HttpResponseErrorCallback callback) async {}
}
class FakeSchoolCookies extends PlatformWebViewCookieManager {
FakeSchoolCookies()
: super.implementation(const PlatformWebViewCookieManagerCreationParams());
Completer<bool>? clearing;
bool fail = false;
@override
Future<bool> clearCookies() => fail
? Future.error(StateError('native cookies'))
: clearing?.future ?? Future.value(true);
}
Future<void> flushSchoolEvents() async {
for (var i = 0; i < 12; i++) {
await Future<void>.delayed(Duration.zero);
}
}