Files
TTSTDConnect/flutter_sender/lib/features/control/control_toolbar.dart
T
tongtong f87ef59d98 feat(receiver): 授权开关与按需投屏,新增 LocalSend 风格文件服务
- 新增 Prefs 持久化 + BootReceiver 开机自启,主开关打开后进入应用/开机自动准备待命

- Service 拆为待命/投屏两阶段:待命只维持广播与控制通道,不建编码器、不创建 VirtualDisplay

- 新增控制帧 msgType=8 Mirror:主控端请求投屏,被控端弹窗确认并校验屏幕录制权限后才开流

- 新增 MirrorRequestActivity 透明确认页(通知兜底 + 30s 超时自动拒绝)

- 投屏按本机真实分辨率(不强制横屏)适配,旋转/分辨率变化自动重建采集

- 新增 LocalSend 风格 HTTP 文件服务(53317,含 info/browse/download/upload/mirror),目录做根路径越权校验,主界面提供存储与通知权限申请

- 控制通道 msgType=7 增加 op=list 目录浏览;Rust/Dart 同步支持投屏请求并加工具栏按钮
2026-11-27 09:07:31 +08:00

114 lines
3.5 KiB
Dart

import 'package:flutter/material.dart';
class ControlToolbar extends StatelessWidget {
const ControlToolbar({super.key, required this.enabled, required this.onEvent});
final bool enabled;
final void Function(String type, Map<String, dynamic> payload) onEvent;
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Icon(Icons.gamepad),
const SizedBox(width: 8),
Text('远程控制', style: Theme.of(context).textTheme.titleSmall),
const Spacer(),
if (!enabled)
Text('连接后可用', style: Theme.of(context).textTheme.labelSmall),
],
),
const SizedBox(height: 10),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
_Action(
icon: Icons.touch_app,
label: '点击中心',
enabled: enabled,
onPressed: () => onEvent('touch', {
'action': 0,
'pointerId': 1,
'x': 960,
'y': 540,
'pressure': 800,
}),
),
_Action(
icon: Icons.arrow_back,
label: '返回',
enabled: enabled,
onPressed: () => onEvent('key', {'action': 0, 'keycode': 4, 'modifiers': 0}),
),
_Action(
icon: Icons.home,
label: '主页',
enabled: enabled,
onPressed: () => onEvent('key', {'action': 0, 'keycode': 3, 'modifiers': 0}),
),
_Action(
icon: Icons.mouse,
label: '滚轮向下',
enabled: enabled,
onPressed: () => onEvent('wheel', {'deltaX': 0, 'deltaY': -1, 'buttons': 0}),
),
_Action(
icon: Icons.content_paste,
label: '发送剪贴板',
enabled: enabled,
onPressed: () => onEvent('clipboard', {'text': 'TTSTD Connect'}),
),
_Action(
icon: Icons.screen_share,
label: '请求投屏',
enabled: enabled,
onPressed: () => onEvent('requestMirror', const {}),
),
_Action(
icon: Icons.stop_screen_share,
label: '停止投屏',
enabled: enabled,
onPressed: () => onEvent('stopMirror', const {}),
),
],
),
],
),
),
);
}
}
class _Action extends StatelessWidget {
const _Action({
required this.icon,
required this.label,
required this.enabled,
required this.onPressed,
});
final IconData icon;
final String label;
final bool enabled;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return OutlinedButton.icon(
onPressed: enabled ? onPressed : null,
icon: Icon(icon, size: 18),
label: Text(label),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
),
);
}
}