- Flutter 桌面端通过 dart:ffi 调用 Rust Core cdylib - 实现 ECDH P-256 密钥协商、HKDF 子密钥派生、AES-256-GCM 控制帧 - Android 被控端用派生密钥做控制帧加密与媒体包 MAC - 新增 libopus JNI 骨架,默认回退 MediaCodec - 新增 aosp/zhanxun/neutral 签名变体与系统 sharedUserId - 本机独立信令服务与设置页开关 - 新增 .gitignore 排除所有编译产物与打包目录
125 lines
3.8 KiB
Dart
125 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/models.dart';
|
|
|
|
class ConnectBar extends StatelessWidget {
|
|
const ConnectBar({
|
|
super.key,
|
|
required this.phase,
|
|
required this.device,
|
|
required this.onConnect,
|
|
required this.onDisconnect,
|
|
});
|
|
|
|
final ConnectionPhase phase;
|
|
final DeviceInfo? device;
|
|
final VoidCallback onConnect;
|
|
final VoidCallback onDisconnect;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final connected = phase.isConnected;
|
|
final busy = phase.isBusy;
|
|
final discovered = phase != ConnectionPhase.idle;
|
|
final handshaken = phase == ConnectionPhase.probing ||
|
|
phase == ConnectionPhase.direct ||
|
|
phase == ConnectionPhase.relaying;
|
|
final color = switch (phase) {
|
|
ConnectionPhase.direct || ConnectionPhase.relaying => theme.colorScheme.primary,
|
|
ConnectionPhase.failed => theme.colorScheme.error,
|
|
_ => theme.colorScheme.outline,
|
|
};
|
|
|
|
return Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 10,
|
|
height: 10,
|
|
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(phase.label, style: theme.textTheme.titleSmall),
|
|
Text(
|
|
device == null ? '请从左侧选择一台设备' : '${device!.name} · ${device!.ip}',
|
|
style: theme.textTheme.bodySmall,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
FilledButton.icon(
|
|
onPressed: device == null || busy ? null : (connected ? onDisconnect : onConnect),
|
|
icon: Icon(connected ? Icons.link_off : Icons.play_arrow),
|
|
label: Text(connected ? '断开' : '连接'),
|
|
),
|
|
],
|
|
),
|
|
if (busy) ...[
|
|
const SizedBox(height: 12),
|
|
const LinearProgressIndicator(),
|
|
],
|
|
const SizedBox(height: 12),
|
|
Row(
|
|
children: [
|
|
_StepDone(active: discovered, label: '发现'),
|
|
_StepDivider(active: handshaken),
|
|
_StepDone(active: handshaken, label: '握手'),
|
|
_StepDivider(active: connected),
|
|
_StepDone(active: connected, label: '媒体'),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StepDone extends StatelessWidget {
|
|
const _StepDone({required this.active, required this.label});
|
|
|
|
final bool active;
|
|
final String label;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(active ? Icons.task_alt : Icons.radio_button_unchecked,
|
|
size: 16, color: active ? theme.colorScheme.primary : theme.colorScheme.outline),
|
|
const SizedBox(width: 4),
|
|
Text(label, style: theme.textTheme.labelSmall),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StepDivider extends StatelessWidget {
|
|
const _StepDivider({required this.active});
|
|
|
|
final bool active;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
child: Divider(thickness: 2, color: active ? Theme.of(context).colorScheme.primary : null),
|
|
),
|
|
);
|
|
}
|
|
}
|