优化ios
This commit is contained in:
@@ -142,12 +142,15 @@ class _BindDevicePageState extends State<BindDevicePage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 44,
|
||||
height: 48,
|
||||
child: OutlinedButton(
|
||||
onPressed: state.isSubmitting
|
||||
? null
|
||||
: () => Navigator.of(context).pop(),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: Color(0xFFE5E6EB),
|
||||
),
|
||||
@@ -158,7 +161,8 @@ class _BindDevicePageState extends State<BindDevicePage> {
|
||||
child: const Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontSize: 14,
|
||||
height: 1.0,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
),
|
||||
@@ -168,7 +172,7 @@ class _BindDevicePageState extends State<BindDevicePage> {
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 44,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: state.isSubmitting
|
||||
? null
|
||||
@@ -176,6 +180,9 @@ class _BindDevicePageState extends State<BindDevicePage> {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF165DFF),
|
||||
elevation: 0,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
@@ -192,7 +199,8 @@ class _BindDevicePageState extends State<BindDevicePage> {
|
||||
: const Text(
|
||||
'确定',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontSize: 14,
|
||||
height: 1.0,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -36,8 +36,15 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
|
||||
late DroneOsdDataSource _osdDataSource;
|
||||
StreamSubscription<DroneOsdEntity>? _stationOsdSubscription;
|
||||
|
||||
/// 静态缓存:跨页面实例保留上次的 host 数据
|
||||
static final Map<String, dynamic> _cachedHostData = {};
|
||||
|
||||
final ValueNotifier<Map<String, dynamic>> _stationHostData =
|
||||
ValueNotifier<Map<String, dynamic>>({});
|
||||
ValueNotifier<Map<String, dynamic>>(
|
||||
// 初始化时从缓存加载,进入页面立即显示
|
||||
Map<String, dynamic>.from(_cachedHostData),
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -73,47 +80,52 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
final hostData = data['data'] is Map ? (data['data'] as Map)['host'] : null;
|
||||
if (hostData == null || hostData is! Map) return;
|
||||
|
||||
final Map<String, dynamic> parsed = {};
|
||||
// 🔥 基于已有数据合并,只更新非 null 字段,避免 Type 2 消息覆盖已有值
|
||||
final Map<String, dynamic> merged = Map<String, dynamic>.from(_stationHostData.value);
|
||||
|
||||
parsed['environment_temperature'] =
|
||||
(hostData['environment_temperature'] as num?)?.toDouble();
|
||||
parsed['humidity'] = (hostData['humidity'] as num?)?.toDouble();
|
||||
parsed['wind_speed'] = (hostData['wind_speed'] as num?)?.toDouble();
|
||||
parsed['rainfall'] = hostData['rainfall']?.toString();
|
||||
parsed['cover_state'] = hostData['cover_state']?.toString();
|
||||
parsed['drone_in_dock'] = hostData['drone_in_dock']?.toString();
|
||||
parsed['temperature'] = (hostData['temperature'] as num?)?.toDouble();
|
||||
parsed['putter_state'] = hostData['putter_state']?.toString();
|
||||
parsed['supplement_light_state'] = hostData['supplement_light_state']
|
||||
?.toString();
|
||||
parsed['alarm_state'] = hostData['alarm_state']?.toString();
|
||||
parsed['emergency_stop_state'] = hostData['emergency_stop_state']
|
||||
?.toString();
|
||||
parsed['silent_mode'] = hostData['silent_mode']?.toString();
|
||||
parsed['mode_code'] = hostData['mode_code']?.toString();
|
||||
parsed['heading'] = (hostData['heading'] as num?)?.toDouble();
|
||||
parsed['height'] = (hostData['height'] as num?)?.toDouble();
|
||||
parsed['latitude'] = (hostData['latitude'] as num?)?.toDouble();
|
||||
parsed['longitude'] = (hostData['longitude'] as num?)?.toDouble();
|
||||
parsed['home_position_is_valid'] = hostData['home_position_is_valid']
|
||||
?.toString();
|
||||
parsed['battery_store_mode'] = hostData['battery_store_mode']?.toString();
|
||||
parsed['first_power_on'] = hostData['first_power_on']?.toString();
|
||||
parsed['drone_charge_state'] = hostData['drone_charge_state'];
|
||||
parsed['air_conditioner'] = hostData['air_conditioner'];
|
||||
parsed['network_state'] = hostData['network_state'];
|
||||
parsed['position_state'] = hostData['position_state'];
|
||||
parsed['storage'] = hostData['storage'];
|
||||
parsed['sub_device'] = hostData['sub_device'];
|
||||
parsed['alternate_land_point'] = hostData['alternate_land_point'];
|
||||
void _put(String key, dynamic value) {
|
||||
if (value != null) merged[key] = value;
|
||||
}
|
||||
|
||||
_put('environment_temperature', (hostData['environment_temperature'] as num?)?.toDouble());
|
||||
_put('humidity', (hostData['humidity'] as num?)?.toDouble());
|
||||
_put('wind_speed', (hostData['wind_speed'] as num?)?.toDouble());
|
||||
_put('rainfall', hostData['rainfall']?.toString());
|
||||
_put('cover_state', hostData['cover_state']?.toString());
|
||||
_put('drone_in_dock', hostData['drone_in_dock']?.toString());
|
||||
_put('temperature', (hostData['temperature'] as num?)?.toDouble());
|
||||
_put('putter_state', hostData['putter_state']?.toString());
|
||||
_put('supplement_light_state', hostData['supplement_light_state']?.toString());
|
||||
_put('alarm_state', hostData['alarm_state']?.toString());
|
||||
_put('emergency_stop_state', hostData['emergency_stop_state']?.toString());
|
||||
_put('silent_mode', hostData['silent_mode']?.toString());
|
||||
_put('mode_code', hostData['mode_code']?.toString());
|
||||
_put('heading', (hostData['heading'] as num?)?.toDouble());
|
||||
_put('height', (hostData['height'] as num?)?.toDouble());
|
||||
_put('latitude', (hostData['latitude'] as num?)?.toDouble());
|
||||
_put('longitude', (hostData['longitude'] as num?)?.toDouble());
|
||||
_put('home_position_is_valid', hostData['home_position_is_valid']?.toString());
|
||||
_put('battery_store_mode', hostData['battery_store_mode']?.toString());
|
||||
_put('first_power_on', hostData['first_power_on']?.toString());
|
||||
_put('drone_charge_state', hostData['drone_charge_state']);
|
||||
_put('air_conditioner', hostData['air_conditioner']);
|
||||
_put('network_state', hostData['network_state']);
|
||||
_put('position_state', hostData['position_state']);
|
||||
_put('storage', hostData['storage']);
|
||||
_put('sub_device', hostData['sub_device']);
|
||||
_put('alternate_land_point', hostData['alternate_land_point']);
|
||||
|
||||
if (hostData['air_conditioner'] is Map) {
|
||||
final ac = hostData['air_conditioner'] as Map;
|
||||
parsed['air_conditioner_state'] = ac['air_conditioner_state']?.toString();
|
||||
parsed['air_conditioner_switch_time'] = ac['switch_time']?.toString();
|
||||
_put('air_conditioner_state', ac['air_conditioner_state']?.toString());
|
||||
_put('air_conditioner_switch_time', ac['switch_time']?.toString());
|
||||
}
|
||||
|
||||
_stationHostData.value = Map<String, dynamic>.from(parsed);
|
||||
_stationHostData.value = merged;
|
||||
// 同步写入静态缓存
|
||||
_cachedHostData
|
||||
..clear()
|
||||
..addAll(merged);
|
||||
}
|
||||
|
||||
/// 🔥 页面重新激活时调用(从其他页面返回时)
|
||||
|
||||
Reference in New Issue
Block a user