Commit 764c66bb authored by huqu's avatar huqu

fix bugs

parent 9474420e
......@@ -45,6 +45,18 @@ class DeviceSubtitleBO extends Equatable {
);
}
String toSubTitle() {
final parts = <String>[
if (text.isNotEmpty) text,
if (voltage.isNotEmpty) voltage,
if (powerDisplay.isNotEmpty) powerDisplay,
if (temperature.isNotEmpty) temperature,
if (statusText.isNotEmpty) statusText,
if (wifiSignal.isNotEmpty) wifiSignal,
];
return parts.join('·');
}
@override
List<Object?> get props =>
[text, voltage, powerDisplay, temperature, statusText, wifiSignal];
......
......@@ -56,6 +56,8 @@ class AppRouter extends $AppRouter {
AutoRoute(page: ReportDeviceListRoute.page),
// InspectionTopologyRoute / InspectionTopologyView(巡检拓扑页)
AutoRoute(page: InspectionTopologyRoute.page),
// HelpRoute / HelpView(帮助页)
AutoRoute(page: HelpRoute.page),
// AboutRoute / AboutView(关于页)
AutoRoute(page: AboutRoute.page),
];
......
......@@ -30,6 +30,7 @@ import 'package:smart_hotel_app/views/home/inspection_topology/inspection_topolo
import 'package:smart_hotel_app/views/layout/default_view.dart' as _i4;
import 'package:smart_hotel_app/views/login/login_view.dart' as _i11;
import 'package:smart_hotel_app/views/profile/about/about_view.dart' as _i3;
import 'package:smart_hotel_app/views/profile/help/help_view.dart' as _i25;
import 'package:smart_hotel_app/views/profile/index/index_view.dart' as _i12;
import 'package:smart_hotel_app/views/report/device/device_list_view.dart'
as _i13;
......@@ -69,6 +70,12 @@ abstract class $AppRouter extends _i22.RootStackRouter {
child: const _i2.AbnormalListView(),
);
},
HelpRoute.name: (routeData) {
return _i22.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i25.HelpView(),
);
},
AboutRoute.name: (routeData) {
return _i22.AutoRoutePage<dynamic>(
routeData: routeData,
......@@ -282,6 +289,20 @@ class AbnormalListRoute extends _i22.PageRouteInfo<void> {
}
/// generated route for
/// [_i25.HelpView]
class HelpRoute extends _i22.PageRouteInfo<void> {
const HelpRoute({List<_i22.PageRouteInfo>? children})
: super(
HelpRoute.name,
initialChildren: children,
);
static const String name = 'HelpRoute';
static const _i22.PageInfo<void> page = _i22.PageInfo<void>(name);
}
/// generated route for
/// [_i3.AboutView]
class AboutRoute extends _i22.PageRouteInfo<void> {
const AboutRoute({List<_i22.PageRouteInfo>? children})
......
import 'package:flutter/material.dart';
class DealUtils {
/// 去除多余0
......@@ -5,4 +7,58 @@ class DealUtils {
return value.replaceAll(RegExp(r'\.?0+$'), '');
}
/// 设备图标
static IconData deviceIcon(String deviceTypeIcon) {
if (deviceTypeIcon.isEmpty) return Icons.devices_other;
switch (deviceTypeIcon) {
case 'aircon':
return Icons.air_outlined;
case 'light':
return Icons.light_outlined;
case 'tv':
return Icons.tv_outlined;
case 'curtain':
return Icons.blinds_outlined;
case 'switch':
return Icons.power_settings_new;
case 'breaker':
return Icons.power;
case 'gateway':
return Icons.wifi;
case 'sensor':
return Icons.sensors;
case 'current':
return Icons.electric_bolt;
case 'voltage':
return Icons.speed;
case 'power':
return Icons.electric_meter;
default:
return Icons.devices_other;
}
}
/// 设备图标
// static String deviceIcon(String deviceTypeIcon) {
// switch (deviceTypeIcon) {
// case 'air-vent':
// return 'lib/assets/icon/device_air_bg.png';
// case 'lightbulb':
// return 'lib/assets/icon/device_light_bg.png';
// case 'tv':
// return 'lib/assets/icon/device_tv_bg.png';
// case 'panel-top':
// return 'lib/assets/icon/device_panel_bg.png';
// case 'zap':
// return 'lib/assets/icon/device_zap_bg.png';
// case 'wifi':
// return 'lib/assets/icon/device_wifi_bg.png';
// case 'meeting':
// return 'lib/assets/icon/device_meeting_bg.png';
// }
// }
}
\ No newline at end of file
......@@ -78,7 +78,7 @@ class AlarmInfoBlock extends StatelessWidget {
SizedBox(width: 20.w),
Expanded(
child: Text(
displayValue,
displayValue.isNotEmpty ? displayValue : '--',
style: TextStyle(
fontSize: 24.sp,
color: valueColor ?? const Color.fromRGBO(100, 116, 139, 1),
......
......@@ -58,6 +58,7 @@ class DeviceCubit extends Cubit<DeviceState> {
powerData: powerData,
tempData: tempData,
timeLabels: timeLabels,
deviceTypeIcon: basic.deviceTypeIcon,
);
}
......
......@@ -12,6 +12,7 @@ class DeviceInfo extends Equatable {
final List<int> powerData;
final List<int> tempData;
final List<String> timeLabels;
final String deviceTypeIcon;
const DeviceInfo({
required this.deviceName,
......@@ -25,6 +26,7 @@ class DeviceInfo extends Equatable {
required this.powerData,
required this.tempData,
required this.timeLabels,
required this.deviceTypeIcon,
});
@override
......@@ -40,6 +42,7 @@ class DeviceInfo extends Equatable {
powerData,
tempData,
timeLabels,
deviceTypeIcon,
];
}
......
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
import 'package:smart_hotel_app/views/home/device/cubit/device_state.dart';
class StateInfoBlock extends StatelessWidget {
......@@ -27,7 +28,7 @@ class StateInfoBlock extends StatelessWidget {
color: const Color.fromRGBO(219, 234, 254, 1),
),
child: Icon(
Icons.power,
DealUtils.deviceIcon(deviceInfo.deviceTypeIcon),
color: const Color.fromRGBO(59, 130, 246, 1),
size: 38.sp,
),
......
......@@ -64,6 +64,7 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
onlineDeviceCount: dashboard.statistics.onlineDeviceCount,
alerts: dashboard.alerts.take(5).toList(),
equipmentList: dashboard.devices
.where((d) => !d.deviceName.contains('分控'))
.map((d) => _mapDeviceToEquipment(d))
.toList(),
));
......@@ -71,7 +72,7 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
EquipmentItem _mapDeviceToEquipment(DeviceItemBO d) {
return EquipmentItem(
icon: _mapDeviceIcon(d.deviceTypeIcon),
icon: DealUtils.deviceIcon(d.deviceTypeIcon),
title: d.deviceLocation + d.deviceName,
subtitle: _buildDeviceSubtitle(d),
// status: d.onlineStatus == '1' ? d.runStatusText : '离线',
......@@ -80,23 +81,6 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
);
}
IconData _mapDeviceIcon(String icon) {
switch (icon) {
case 'ac':
return Icons.air_outlined;
case 'light':
return Icons.light_outlined;
case 'tv':
return Icons.tv_outlined;
case 'curtain':
return Icons.blinds_outlined;
case 'wifi':
return Icons.wifi;
default:
return Icons.devices_other;
}
}
String _buildDeviceSubtitle(DeviceItemBO d) {
return [
if (d.roomName.isNotEmpty) d.roomName,
......
......@@ -122,9 +122,10 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
voltageAlarmTitle: alert.alertTitle,
voltageAlarmLocation: location,
voltageValue: alert.voltage,
normalVoltage: '',
alertContent: alert.alertContent,
voltageWaitTime: alert.waitingDurationDesc,
voltageAlarmLevel: alert.alertLevelText,
alertCategory: alert.alertCategory,
),
]);
}
......
......@@ -31,11 +31,6 @@ class EquipmentListBlock extends StatelessWidget {
decoration: BoxDecoration(
color: const Color.fromRGBO(229, 241, 255, 1.0),
borderRadius: BorderRadius.circular(8.r),
// border: Border.all(
// color: const Color.fromRGBO(66, 165, 245, 1.0),
// width: 2.w,
// style: BorderStyle.solid,
// ),
),
child: Icon(
item.icon,
......
......@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart';
import 'package:smart_hotel_app/views/home/index/cubit/home_index_cubit.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart';
......@@ -12,9 +13,10 @@ class VoltageOperateBlock extends StatelessWidget {
final String voltageAlarmTitle;
final String voltageAlarmLocation;
final String voltageValue;
final String normalVoltage;
final String alertContent;
final String voltageWaitTime;
final String voltageAlarmLevel;
final String alertCategory;
const VoltageOperateBlock({
super.key,
......@@ -22,9 +24,10 @@ class VoltageOperateBlock extends StatelessWidget {
required this.voltageAlarmTitle,
required this.voltageAlarmLocation,
required this.voltageValue,
required this.normalVoltage,
required this.alertContent,
required this.voltageWaitTime,
required this.voltageAlarmLevel,
required this.alertCategory,
});
@override
......@@ -53,13 +56,14 @@ class VoltageOperateBlock extends StatelessWidget {
color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(12.r),
),
child: Image.asset('lib/assets/icon/thermostat_bg.png',
width: 16.w, height: 32.h),
child: Icon(DealUtils.deviceIcon(alertCategory), size: 40.w,
color: const Color.fromRGBO(73, 149, 234, 1.0)),
),
SizedBox(width: 16.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4.h,
children: [
Text(
voltageAlarmTitle,
......@@ -69,7 +73,6 @@ class VoltageOperateBlock extends StatelessWidget {
color: Colors.black,
),
),
SizedBox(height: 4.h),
Text(
voltageAlarmLocation,
style: TextStyle(
......@@ -84,7 +87,7 @@ class VoltageOperateBlock extends StatelessWidget {
voltageAlarmLevel,
style: TextStyle(
fontSize: 24.sp,
color: voltageAlarmLevel=="置顶" ?
color: voltageAlarmLevel == "置顶" ?
const Color.fromRGBO(255, 100, 101, 1.0) :
const Color.fromRGBO(255, 204, 21, 1.0),
),
......@@ -96,7 +99,7 @@ class VoltageOperateBlock extends StatelessWidget {
width: double.infinity,
margin: EdgeInsets.only(left: 80.w, bottom: 20.h),
child: Text(
'电压${voltageValue} (正常≤${normalVoltage}V)·$voltageWaitTime',
'电压$voltageValue ${'($alertContent)'}·$voltageWaitTime',
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0),
......
......@@ -61,7 +61,7 @@ class InspectionCubit extends Cubit<InspectionState> {
return {
DeviceStatusTab.total: total,
DeviceStatusTab.on: runStatus.normal,
DeviceStatusTab.off: 0,
// DeviceStatusTab.off: 0,
DeviceStatusTab.offline: runStatus.offline,
DeviceStatusTab.alarm: runStatus.warning,
DeviceStatusTab.fault: runStatus.fault,
......
......@@ -2,8 +2,9 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:smart_hotel_app/models/bo/inspection_device_bo.dart';
import 'package:smart_hotel_app/models/bo/inspection_room_bo.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
enum DeviceStatusTab { total, on, off, offline, alarm, fault }
enum DeviceStatusTab { total, on, /*off, */offline, alarm, fault }
extension DeviceStatusTabRunStatus on DeviceStatusTab {
/// 映射为接口 runStatus 入参:
......@@ -14,8 +15,8 @@ extension DeviceStatusTabRunStatus on DeviceStatusTab {
return null;
case DeviceStatusTab.on:
return 'online';
case DeviceStatusTab.off:
return 'offline';
// case DeviceStatusTab.off:
// return 'offline';
case DeviceStatusTab.offline:
return 'offline';
case DeviceStatusTab.alarm:
......@@ -50,7 +51,7 @@ class InspectionDevice {
factory InspectionDevice.fromInspectionDeviceBO(InspectionDeviceBO bo) {
return InspectionDevice(
id: bo.deviceId.toString(),
icon: _mapIcon(bo.deviceCategory),
icon: DealUtils.deviceIcon(bo.deviceTypeIcon),
name: bo.deviceName,
type: bo.deviceTypeName,
location: bo.roomName,
......@@ -60,32 +61,6 @@ class InspectionDevice {
);
}
static IconData _mapIcon(String iconType) {
switch (iconType) {
case 'curtain':
return Icons.blinds_outlined;
case 'gateway':
return Icons.wifi;
case 'sensor':
return Icons.thermostat;
case 'camera':
return Icons.videocam;
case 'lamp':
return Icons.light;
case 'air_conditioner':
case 'ac':
return Icons.ac_unit;
case 'socket':
return Icons.kitchen;
case 'alarm':
return Icons.smoke_free;
case 'door_sensor':
return Icons.sensor_door;
default:
return Icons.devices_other;
}
}
static Color _mapStatusColor(String runStatus) {
switch (runStatus) {
case 'normal':
......@@ -126,7 +101,7 @@ class InspectionState extends Equatable {
this.tabCounts = const {
DeviceStatusTab.total: 0,
DeviceStatusTab.on: 0,
DeviceStatusTab.off: 0,
// DeviceStatusTab.off: 0,
DeviceStatusTab.offline: 0,
DeviceStatusTab.alarm: 0,
DeviceStatusTab.fault: 0,
......
......@@ -31,11 +31,6 @@ class DeviceListItem extends StatelessWidget {
decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(8.r),
// border: Border.all(
// color: const Color.fromRGBO(66, 165, 245, 1.0),
// width: 1.w,
// style: BorderStyle.solid,
// ),
),
child: Icon(
device.icon,
......
......@@ -258,8 +258,8 @@ class FilterPanel extends StatelessWidget {
return '总计';
case DeviceStatusTab.on:
return '开启';
case DeviceStatusTab.off:
return '关闭';
// case DeviceStatusTab.off:
// return '关闭';
case DeviceStatusTab.offline:
return '离线';
case DeviceStatusTab.alarm:
......@@ -275,8 +275,8 @@ class FilterPanel extends StatelessWidget {
return const Color.fromRGBO(66, 165, 245, 1.0);
case DeviceStatusTab.on:
return const Color.fromRGBO(26, 188, 156, 1.0);
case DeviceStatusTab.off:
return const Color.fromRGBO(200, 208, 220, 1.0);
// case DeviceStatusTab.off:
// return const Color.fromRGBO(200, 208, 220, 1.0);
case DeviceStatusTab.offline:
return const Color.fromRGBO(100, 116, 139, 1.0);
case DeviceStatusTab.alarm:
......
......@@ -23,7 +23,7 @@ class RememberPasswordRow extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
SizedBox(
width: 40.w,
height: 40.w,
child: Transform.scale(
......@@ -31,12 +31,12 @@ class RememberPasswordRow extends StatelessWidget {
child: Checkbox(
value: value,
onChanged: onChanged,
activeColor: Color(0xFF4A90E2),
activeColor: const Color(0xFF4A90E2),
checkColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.w),
),
side: BorderSide(color: Color(0xFF4A90E2)),
side: const BorderSide(color: Color(0xFF4A90E2)),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
......@@ -45,23 +45,23 @@ class RememberPasswordRow extends StatelessWidget {
Text(
'记住密码',
style: TextStyle(
color: Color(0xFF0A0D14),
color: const Color(0xFF0A0D14),
fontSize: 24.sp,
),
),
],
),
),
GestureDetector(
onTap: onForgotPassword,
child: Text(
'忘记密码?',
style: TextStyle(
color: Color(0xFF0A0D14),
fontSize: 24.sp,
),
),
),
// GestureDetector(
// onTap: onForgotPassword,
// child: Text(
// '忘记密码?',
// style: TextStyle(
// color: Color(0xFF0A0D14),
// fontSize: 24.sp,
// ),
// ),
// ),
],
);
}
......
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@RoutePage()
class HelpView extends StatelessWidget {
const HelpView({super.key});
Widget _buildSectionTitle(String title) {
return Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Text(
title,
style: TextStyle(
fontSize: 30.sp,
fontWeight: FontWeight.w600,
color: const Color.fromRGBO(15, 23, 42, 1),
),
),
);
}
Widget _buildSubTitle(String title) {
return Padding(
padding: EdgeInsets.only(top: 16.h, bottom: 10.h),
child: Text(
title,
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.w600,
color: const Color.fromRGBO(15, 23, 42, 1),
),
),
);
}
Widget _buildBodyText(String text) {
return Padding(
padding: EdgeInsets.only(bottom: 8.h),
child: Text(
text,
style: TextStyle(
fontSize: 26.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
height: 1.6,
),
),
);
}
Widget _buildFeatureItem(int index, String title, String description) {
return Padding(
padding: EdgeInsets.only(bottom: 12.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: RichText(
text: TextSpan(
style: TextStyle(
fontSize: 26.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
height: 1.6,
),
children: [
TextSpan(
text: '$index.$title:',
style: const TextStyle(
fontWeight: FontWeight.w600,
color: Color.fromRGBO(15, 23, 42, 1),
),
),
TextSpan(text: description),
],
),
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromRGBO(242, 243, 245, 1),
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios,
color: Color.fromRGBO(100, 116, 139, 1)),
onPressed: () => context.maybePop(),
),
title: Text(
'帮助',
style: TextStyle(
color: const Color.fromRGBO(15, 23, 42, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w600,
),
),
centerTitle: true,
),
body: SingleChildScrollView(
padding: EdgeInsets.all(28.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(28.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24.r),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildBodyText('欢迎使用本帮助文档,将引导您快速上手,并解决使用过程中遇到的常见问题。'),
SizedBox(height: 20.h),
_buildSectionTitle('一、快速入门'),
_buildSubTitle('1.1 登录与认证'),
_buildBodyText('账号登录:使用系统分配的账号和密码登录。'),
_buildBodyText('若忘记账号密码,请联系系统管理员。'),
_buildSubTitle('1.2 首页概览'),
_buildBodyText('顶部状态栏:实时显示当前待处理告警数、进行中的变更单。'),
_buildBodyText('快捷入口:一键跳转至告警中心、告警详情。'),
SizedBox(height: 20.h),
_buildSectionTitle('二、核心功能详解'),
_buildFeatureItem(1, '数据看板', '实时汇总房间、设备、人员、能耗及告警数据,提供多维度运营分析与可视化展示。'),
_buildFeatureItem(2, '人员管理', '支持入住登记、退房办理、换房调配及人员信息维护,实现全生命周期管理。'),
_buildFeatureItem(3, '房间管理', '统一管理房间资源、入住状态、床位情况及设备配置,提高房间利用效率。'),
_buildFeatureItem(4, '设备管理', '支持设备接入、绑定、配置、监控及远程运维,实现设备全流程管理。'),
_buildFeatureItem(5, '环境监测', '实时监测温度、湿度、氧气及二氧化碳浓度,保障室内环境安全舒适。'),
_buildFeatureItem(6, '智能控制', '支持空调等设备远程控制、参数调整及定时任务配置,提升管理效率。'),
_buildFeatureItem(7, '联动策略', '基于环境数据和业务规则自动触发设备联动,实现智能化场景控制。'),
_buildFeatureItem(8, '能耗分析', '统计设备和房间能耗数据,提供趋势分析、异常识别及节能优化建议。'),
_buildFeatureItem(9, '告警预警', '对环境异常、设备故障及能耗异常进行实时告警,并支持闭环处理。'),
_buildFeatureItem(10, '权限管理', '支持用户、角色和权限分级管理,实现系统功能与数据安全管控。'),
],
),
),
],
),
),
);
}
}
\ No newline at end of file
......@@ -32,8 +32,8 @@ class ProfileHeaderBlock extends StatelessWidget {
Row(
children: [
ClipOval(
child: Image.network(
'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face',
child: Image.asset(
'lib/assets/icon/user_head.jpg',
width: 100.r,
height: 100.r,
fit: BoxFit.cover,
......
......@@ -74,6 +74,7 @@ class ProfileMenuBlock extends StatelessWidget {
context.pushRoute(const AbnormalListRoute());
break;
case '帮助':
context.pushRoute(const HelpRoute());
break;
case '关于':
context.pushRoute(const AboutRoute());
......
......@@ -49,7 +49,7 @@ class DeviceListCubit extends Cubit<DeviceListState> {
deviceId: row.deviceId,
name: row.deviceName,
room: row.roomNumber.isNotEmpty ? row.roomNumber : row.deviceLocation,
type: deviceTypeFromName(row.deviceTypeName),
type: DeviceTypeEnum.all,
online: row.onlineStatus == '1',
status: row.statusTag.text.isNotEmpty
? row.statusTag.text
......@@ -57,6 +57,7 @@ class DeviceListCubit extends Cubit<DeviceListState> {
color: row.statusTag.color,
lastUpdate: row.subtitle.text,
deviceTypeIcon: row.deviceTypeIcon,
subTitle: row.subtitle.toSubTitle(),
);
}).toList();
}
......
......@@ -21,21 +21,6 @@ String? deviceTypeIdFromEnum(DeviceTypeEnum type) {
}
}
/// 根据 API 的 deviceTypeName 匹配 DeviceTypeEnum
DeviceTypeEnum deviceTypeFromName(String typeName) {
final name = typeName.toLowerCase();
if (name.contains('空开') || name.contains('airswitch') || name.contains('breaker')) {
return DeviceTypeEnum.smartBreaker;
}
if (name.contains('客控') || name.contains('guest')) {
return DeviceTypeEnum.guestControl;
}
if (name.contains('网络') || name.contains('network')) {
return DeviceTypeEnum.network;
}
return DeviceTypeEnum.smartBreaker; // fallback
}
class DeviceInfo extends Equatable {
final int deviceId;
final String name;
......@@ -46,6 +31,7 @@ class DeviceInfo extends Equatable {
final String lastUpdate;
final String color;
final String deviceTypeIcon;
final String subTitle;
const DeviceInfo({
this.deviceId = 0,
......@@ -57,11 +43,12 @@ class DeviceInfo extends Equatable {
this.lastUpdate = '',
this.color = '',
this.deviceTypeIcon = '',
this.subTitle = '',
});
@override
List<Object?> get props => [deviceId, name, room, type, online,
status, lastUpdate, color, deviceTypeIcon];
status, lastUpdate, color, deviceTypeIcon, subTitle];
}
class DeviceListState extends Equatable {
......
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
import 'package:smart_hotel_app/views/report/device/cubit/device_list_state.dart';
class DeviceCard extends StatelessWidget {
......@@ -10,36 +11,6 @@ class DeviceCard extends StatelessWidget {
required this.device,
});
IconData _getIconForType(String deviceTypeIcon) {
switch (deviceTypeIcon) {
case 'ac':
return Icons.air_outlined;
case 'light':
return Icons.light_outlined;
case 'tv':
return Icons.tv_outlined;
case 'curtain':
return Icons.blinds_outlined;
case 'wifi':
return Icons.wifi;
default:
return Icons.devices_other;
}
}
String _getTypeLabel(DeviceTypeEnum type) {
switch (type) {
case DeviceTypeEnum.smartBreaker:
return '智能空开';
case DeviceTypeEnum.guestControl:
return '客控设备';
case DeviceTypeEnum.network:
return '网络设备';
default:
return '其他';
}
}
@override
Widget build(BuildContext context) {
return Container(
......@@ -59,7 +30,7 @@ class DeviceCard extends StatelessWidget {
color: const Color.fromRGBO(229, 241, 255, 1),
),
child: Icon(
_getIconForType(device.deviceTypeIcon),
DealUtils.deviceIcon(device.deviceTypeIcon),
color: const Color.fromRGBO(73, 149, 234, 1),
size: 36.sp,
),
......@@ -78,18 +49,8 @@ class DeviceCard extends StatelessWidget {
color: const Color.fromRGBO(31, 41, 55, 1),
),
),
Row(
spacing: 16.w,
children: [
Text(
_getTypeLabel(device.type),
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(107, 114, 128, 1),
),
),
Text(
'房间 ${device.room}',
device.subTitle,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(107, 114, 128, 1),
......@@ -97,9 +58,8 @@ class DeviceCard extends StatelessWidget {
),
],
),
],
),
),
SizedBox(width: 20.w),
Text(
device.status,
style: TextStyle(
......
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
class RoomDetailCard extends StatelessWidget {
final RoomDetailListBO room;
......@@ -30,7 +31,7 @@ class RoomDetailCard extends StatelessWidget {
borderRadius: BorderRadius.circular(12.r),
),
child: Icon(
Icons.meeting_room_outlined,
Icons.house,
color: const Color.fromRGBO(59, 130, 246, 1),
size: 32.sp,
),
......@@ -72,10 +73,10 @@ class RoomDetailCard extends StatelessWidget {
label: '通电中',
isActive: room.statusTags.powerSupplyStatus,
),
// _StatusTag(
// label: 'wifi正常',
// isActive: room.statusTags.wifiNormalStatus,
// ),
_StatusTag(
label: 'wifi正常',
isActive: room.statusTags.wifiNormalStatus,
),
],
),
],
......@@ -158,23 +159,6 @@ class _DeviceControl extends StatelessWidget {
const _DeviceControl({required this.device});
IconData _icon() {
switch (device.deviceTypeIcon) {
case 'ac':
return Icons.air_outlined;
case 'light':
return Icons.light_outlined;
case 'tv':
return Icons.tv_outlined;
case 'curtain':
return Icons.blinds_outlined;
case 'wifi':
return Icons.wifi;
default:
return Icons.devices_other;
}
}
@override
Widget build(BuildContext context) {
return Container(
......@@ -186,7 +170,7 @@ class _DeviceControl extends StatelessWidget {
child: Row(
children: [
Icon(
_icon(),
DealUtils.deviceIcon(device.deviceTypeIcon),
color: const Color.fromRGBO(59, 130, 246, 1),
size: 40.sp,
),
......
......@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart';
import 'package:smart_hotel_app/repositories/room_repository.dart';
import 'package:smart_hotel_app/services/room_service.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
import 'package:smart_hotel_app/views/service/room/cubit/service_room_state.dart';
class ServiceRoomCubit extends Cubit<ServiceRoomState> {
......@@ -45,7 +46,7 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
name: d.deviceName.contains('-')
? d.deviceName.split('-').last
: d.deviceName,
icon: _mapDeviceIcon(d.deviceTypeIcon),
icon: DealUtils.deviceIcon(d.deviceTypeIcon),
isOn: d.powerStatus == '1' || d.powerStatus == 'on',
statusText: _buildDeviceStatusText(d),
);
......@@ -65,7 +66,7 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
name: c.deviceName.contains('-')
? c.deviceName.split('-').last
: c.deviceName,
icon: _mapDeviceIcon(iconMap[c.deviceId] ?? ''),
icon: DealUtils.deviceIcon(iconMap[c.deviceId] ?? ''),
isOn: c.powerOn,
detailText: c.currentParamDisplay.isNotEmpty ? c.currentParamDisplay : null,
deviceTypeName: c.deviceTypeName,
......@@ -128,26 +129,6 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
}
}
IconData _mapDeviceIcon(String deviceTypeIcon) {
final icon = deviceTypeIcon.toLowerCase();
if (icon.contains('air-vent')) {
return Icons.air_outlined;
}
if (icon.contains('lightbulb')) {
return Icons.light_outlined;
}
if (icon.contains('tv')) {
return Icons.tv_outlined;
}
if (icon.contains('panel-top')) {
return Icons.curtains_closed_outlined;
}
if (icon.contains('wifi')) {
return Icons.wifi;
}
return Icons.devices_other;
}
/// 房间总电源开关
Future<void> toggleMainPowerForSwitch(bool value) async {
if (state.isPoweringOn || state.isPoweringOff) return;
......
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