Commit 53839dd5 authored by 张宏's avatar 张宏
parents 08cc8142 65c9e3b0
This diff is collapsed.
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:laki_icu_app/models/bo/monitoring_bo.dart';
import 'package:laki_icu_app/utils/bluetooth/index.dart';
typedef OnMenuItemTap = Function(String menuId);
......@@ -77,15 +78,57 @@ class MonitoringBottomMenu extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 图标
Container(
StreamBuilder<BluetoothConnectionStatus>(
stream: appBluetoothManager.stateStream,
initialData: appBluetoothManager.status,
builder: (context, snapshot) {
final status = snapshot.data;
final isActive =
status == BluetoothConnectionStatus.connectedReady ||
status == BluetoothConnectionStatus.active;
return SizedBox(
width: 167.w,
height: 62.h,
child: AnimatedContainer(
duration: const Duration(milliseconds: 180),
padding: EdgeInsets.symmetric(
horizontal: isActive ? 7.w : 0,
vertical: isActive ? 4.h : 0,
),
decoration: isActive
? BoxDecoration(
color: const Color(0xFF063D36)
.withValues(alpha: 0.22),
borderRadius: BorderRadius.circular(32.r),
boxShadow: [
BoxShadow(
color: const Color(0xFF39FF88)
.withValues(alpha: 0.18),
blurRadius: 12.w,
spreadRadius: 1.w,
),
],
)
: null,
child: ColorFiltered(
colorFilter: isActive
? const ColorFilter.mode(
Color(0xFF8DFFCB),
BlendMode.srcATop,
)
: const ColorFilter.mode(
Colors.transparent,
BlendMode.dst,
),
child: Image.asset(
item.iconPath,
fit: BoxFit.contain,
),
),
),
);
},
),
],
),
......
......@@ -522,6 +522,9 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
try {
await _bluetoothManager.connectToDevice(device);
if (!_bluetoothManager.isConnected) {
throw StateError('蓝牙连接未就绪');
}
await _storageService.saveBoundBluetoothDevice(
deviceId: device.remoteId,
deviceName: device.name,
......@@ -620,7 +623,11 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
'deviceId=$deviceId isConnected=${_bluetoothManager.isConnected}',
);
if (!isClosed) {
emit(state.copyWith(bluetoothMessage: '蓝牙设备已自动连接'));
emit(state.copyWith(
bluetoothMessage: _bluetoothManager.isConnected
? '蓝牙设备已自动连接'
: '蓝牙自动连接未就绪,等待重试',
));
}
} catch (e) {
debugPrint(
......@@ -1074,9 +1081,6 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
_mcuReportChangedSub?.cancel();
_webrtcService.dispose();
_p2pVideoService.dispose();
return Future.wait([
_disposeMqttClient(),
_bluetoothManager.release(),
]).then((_) => super.close());
return _disposeMqttClient().then((_) => super.close());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment