feat: 增加请求弹窗和拒绝说明

This commit is contained in:
2026-07-15 21:40:00 +08:00
parent 839a980b45
commit f1457e68eb
13 changed files with 645 additions and 5 deletions

View File

@@ -102,6 +102,9 @@ class _ControllerHomeState extends State<ControllerHome> {
_controller!.onTargetOffline = (message) {
_onTargetOffline(message);
};
_controller!.onConnectionRejected = (message) {
_onConnectionRejected(message);
};
_controller!.onRemoteStream = (renderer) {
setState(() => _renderer = renderer);
renderer.addListener(_onRendererUpdate);
@@ -147,6 +150,20 @@ class _ControllerHomeState extends State<ControllerHome> {
setState(() => _connected = false);
}
/// 被控端拒绝连接请求:提示用户并复位到连接设置面板。
Future<void> _onConnectionRejected(String message) async {
final scaffoldCtx = _scaffoldKey.currentState?.context;
if (mounted && scaffoldCtx != null) {
ScaffoldMessenger.of(scaffoldCtx).showSnackBar(
SnackBar(
content: Text(message),
duration: const Duration(seconds: 3),
),
);
}
setState(() => _connected = false);
}
Future<void> _disconnect() async {
await _controller?.disconnect();
_controller = null;