完善遥控权限、控制发送和急停反馈
This commit is contained in:
@@ -14,6 +14,8 @@ import '../../../../core/logging/i_logger_service.dart';
|
||||
import '../../../devices/domain/entities/device_entity.dart';
|
||||
import '../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../../data/models/running_status_model.dart';
|
||||
import 'remote_control_link_feedback.dart';
|
||||
import 'permission_request_feedback.dart';
|
||||
import '../bloc/remote_control_cubit.dart';
|
||||
|
||||
class TopStatusBar extends StatelessWidget {
|
||||
@@ -83,41 +85,37 @@ class TopStatusBar extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 2. 控制状态 (对应 StatusChipLeft)
|
||||
StatusChip(
|
||||
text: remoteState.hasPermission
|
||||
? AppLocalizations.of(
|
||||
context,
|
||||
).translate('remote_control.controlling')
|
||||
: AppLocalizations.of(
|
||||
context,
|
||||
).translate('remote_control.not_controlling'),
|
||||
color: remoteState.hasPermission
|
||||
? const Color(0xFF1DB954)
|
||||
: Colors.red,
|
||||
icon: Icons.eighteen_mp,
|
||||
breathing: !remoteState.hasPermission,
|
||||
onTap: () {
|
||||
if (!remoteState.hasPermission) {
|
||||
// 🔥 点击后发起抢占:查权限 + 无权限则发 TCP switch_control
|
||||
debugPrint('🔑 [TopStatusBar] 👆 用户手动点击“未在控制”,请求抢占控制权');
|
||||
final targetDevice =
|
||||
_remoteControlCubit.state.targetDevice;
|
||||
if (targetDevice != null) {
|
||||
PermissionRequestFeedback(
|
||||
cubit: _remoteControlCubit,
|
||||
child: Tooltip(
|
||||
message: permissionStatusHint(context, remoteState),
|
||||
child: StatusChip(
|
||||
text: permissionStatusText(context, remoteState),
|
||||
color: remoteState.isPermissionRequestBusy
|
||||
? Colors.orange
|
||||
: remoteState.hasPermission
|
||||
? const Color(0xFF1DB954)
|
||||
: Colors.red,
|
||||
icon: Icons.eighteen_mp,
|
||||
breathing: !remoteState.hasPermission,
|
||||
onTap: () {
|
||||
if (remoteState.hasPermission || remoteState.isPermissionRequestBusy) return;
|
||||
_remoteControlCubit.requestControlPermissionS(
|
||||
targetDevice.deviceName,
|
||||
_remoteControlCubit.state.targetDevice?.deviceName ?? '',
|
||||
'app',
|
||||
source: '手动点击',
|
||||
grabControl: true,
|
||||
);
|
||||
} else {
|
||||
debugPrint('❌ [TopStatusBar] targetDevice 为空,无法请求权限');
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 3. 锁定状态 (对应 SmallFunctionButton)
|
||||
RemoteControlHeartbeatIndicator(
|
||||
heartbeats: _remoteControlCubit.serverHeartbeats,
|
||||
),
|
||||
_buildIconButton(
|
||||
remoteState.isLocked
|
||||
? "assets/svgs/remote_lock.svg"
|
||||
@@ -476,6 +474,7 @@ class TopStatusBar extends StatelessWidget {
|
||||
|
||||
// 🔥 新增:统一的业务逻辑分发方法
|
||||
void _handleSliderAction(String label, String action, BuildContext context) {
|
||||
RemoteControlLinkNotice.showIfDisconnected(context);
|
||||
debugPrint('🎯 [Slider 业务] label: $label, action: $action');
|
||||
|
||||
// 🔥 根据 label 区分不同的设备
|
||||
|
||||
Reference in New Issue
Block a user