mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-02-06 15:10:20 +00:00
feat: Replace desktop_webview_window with tao&wry , from tauri
This commit is contained in:
142
lib/common/rust/api/webview_api.dart
Normal file
142
lib/common/rust/api/webview_api.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// @generated by `flutter_rust_bridge`@ 2.11.1.
|
||||
|
||||
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
||||
|
||||
import '../frb_generated.dart';
|
||||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
|
||||
part 'webview_api.freezed.dart';
|
||||
|
||||
// These functions are ignored because they are not marked as `pub`: `handle_command`, `load_app_icon`, `run_webview_loop`, `send_command`
|
||||
// These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `UserEvent`, `WebViewCommand`, `WebViewInstance`
|
||||
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`
|
||||
|
||||
/// Create a new WebView window and return its ID
|
||||
String webviewCreate({required WebViewConfiguration config}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewCreate(config: config);
|
||||
|
||||
/// Navigate to a URL
|
||||
void webviewNavigate({required String id, required String url}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewNavigate(id: id, url: url);
|
||||
|
||||
/// Go back in history
|
||||
void webviewGoBack({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewGoBack(id: id);
|
||||
|
||||
/// Go forward in history
|
||||
void webviewGoForward({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewGoForward(id: id);
|
||||
|
||||
/// Reload the current page
|
||||
void webviewReload({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewReload(id: id);
|
||||
|
||||
/// Stop loading
|
||||
void webviewStop({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewStop(id: id);
|
||||
|
||||
/// Execute JavaScript in the WebView
|
||||
void webviewExecuteScript({required String id, required String script}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewExecuteScript(
|
||||
id: id,
|
||||
script: script,
|
||||
);
|
||||
|
||||
/// Set window visibility
|
||||
void webviewSetVisibility({required String id, required bool visible}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewSetVisibility(
|
||||
id: id,
|
||||
visible: visible,
|
||||
);
|
||||
|
||||
/// Close the WebView window
|
||||
void webviewClose({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewClose(id: id);
|
||||
|
||||
/// Set window size
|
||||
void webviewSetWindowSize({
|
||||
required String id,
|
||||
required int width,
|
||||
required int height,
|
||||
}) => RustLib.instance.api.crateApiWebviewApiWebviewSetWindowSize(
|
||||
id: id,
|
||||
width: width,
|
||||
height: height,
|
||||
);
|
||||
|
||||
/// Set window position
|
||||
void webviewSetWindowPosition({
|
||||
required String id,
|
||||
required int x,
|
||||
required int y,
|
||||
}) => RustLib.instance.api.crateApiWebviewApiWebviewSetWindowPosition(
|
||||
id: id,
|
||||
x: x,
|
||||
y: y,
|
||||
);
|
||||
|
||||
/// Get the current navigation state
|
||||
WebViewNavigationState webviewGetState({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewGetState(id: id);
|
||||
|
||||
/// Check if the WebView is closed
|
||||
bool webviewIsClosed({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewIsClosed(id: id);
|
||||
|
||||
/// Poll for events from the WebView (non-blocking)
|
||||
List<WebViewEvent> webviewPollEvents({required String id}) =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewPollEvents(id: id);
|
||||
|
||||
/// Get a list of all active WebView IDs
|
||||
List<String> webviewListAll() =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebviewListAll();
|
||||
|
||||
/// WebView window configuration
|
||||
@freezed
|
||||
sealed class WebViewConfiguration with _$WebViewConfiguration {
|
||||
const WebViewConfiguration._();
|
||||
const factory WebViewConfiguration({
|
||||
required String title,
|
||||
required int width,
|
||||
required int height,
|
||||
String? userDataFolder,
|
||||
required bool enableDevtools,
|
||||
required bool transparent,
|
||||
String? userAgent,
|
||||
}) = _WebViewConfiguration;
|
||||
static Future<WebViewConfiguration> default_() =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebViewConfigurationDefault();
|
||||
}
|
||||
|
||||
@freezed
|
||||
sealed class WebViewEvent with _$WebViewEvent {
|
||||
const WebViewEvent._();
|
||||
|
||||
const factory WebViewEvent.navigationStarted({required String url}) =
|
||||
WebViewEvent_NavigationStarted;
|
||||
const factory WebViewEvent.navigationCompleted({required String url}) =
|
||||
WebViewEvent_NavigationCompleted;
|
||||
const factory WebViewEvent.titleChanged({required String title}) =
|
||||
WebViewEvent_TitleChanged;
|
||||
const factory WebViewEvent.webMessage({required String message}) =
|
||||
WebViewEvent_WebMessage;
|
||||
const factory WebViewEvent.windowClosed() = WebViewEvent_WindowClosed;
|
||||
const factory WebViewEvent.error({required String message}) =
|
||||
WebViewEvent_Error;
|
||||
}
|
||||
|
||||
/// Navigation state of the WebView
|
||||
@freezed
|
||||
sealed class WebViewNavigationState with _$WebViewNavigationState {
|
||||
const WebViewNavigationState._();
|
||||
const factory WebViewNavigationState({
|
||||
required String url,
|
||||
required String title,
|
||||
required bool canGoBack,
|
||||
required bool canGoForward,
|
||||
required bool isLoading,
|
||||
}) = _WebViewNavigationState;
|
||||
static Future<WebViewNavigationState> default_() =>
|
||||
RustLib.instance.api.crateApiWebviewApiWebViewNavigationStateDefault();
|
||||
}
|
||||
Reference in New Issue
Block a user