Commit 59e6cf59 authored by huqu's avatar huqu

fix bugs

parent 1244f87e
...@@ -341,10 +341,10 @@ class AreaDeviceBO extends Equatable { ...@@ -341,10 +341,10 @@ class AreaDeviceBO extends Equatable {
class RoomStatusBO extends Equatable { class RoomStatusBO extends Equatable {
final int roomId; final int roomId;
final String roomNumber; final String roomNumber;
final String occupancyStatus; final String occupancyStatus;//房间有无人状态,0=无人 1=有人
final String roomStatus; final String roomStatus;//房间状态,0=无人 1=有人
final String cleanStatus; final String cleanStatus;//清洁灯状态,0=待清洁 2=已完成
final String devicePowerStatus; final String devicePowerStatus;//设备开关状态 0=关 1=开
const RoomStatusBO({ const RoomStatusBO({
required this.roomId, required this.roomId,
......
import 'dart:convert';
import '../repositories/inspection_device_repository.dart'; import '../repositories/inspection_device_repository.dart';
import '../models/bo/inspection_device_bo.dart'; import '../models/bo/inspection_device_bo.dart';
...@@ -37,9 +39,28 @@ class InspectionDeviceService { ...@@ -37,9 +39,28 @@ class InspectionDeviceService {
required int deviceId, required int deviceId,
required int inspectorId, required int inspectorId,
}) async { }) async {
List<Map<String, dynamic>> list = [
{
'name': '检查输入电压是否正常',
'value': '正常',
'status': 2,
},
{
'name': '确认设备是否正常运行',
'value': '正常',
'status': 2,
},
{
'name': '若异常,请联系电工',
'value': '正常',
'status': 2,
},
];
final result = await _repository.startInspection({ final result = await _repository.startInspection({
'deviceId': deviceId, 'deviceId': deviceId,
'inspectorId': inspectorId, 'inspectorId': inspectorId,
'remark': '巡检完成',//后端要先写死
'items_detail': jsonEncode(list),//后端要先写死
}); });
if (result.success && result.data != null) { if (result.success && result.data != null) {
return result.data!; return result.data!;
......
...@@ -52,7 +52,7 @@ class AbnormalDetailView extends StatelessWidget { ...@@ -52,7 +52,7 @@ class AbnormalDetailView extends StatelessWidget {
body: BlocBuilder<AbnormalCubit, AbnormalState>( body: BlocBuilder<AbnormalCubit, AbnormalState>(
builder: (context, state) { builder: (context, state) {
if (state.isLoading) { if (state.isLoading) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0)));
} }
if (state.error != null) { if (state.error != null) {
return Center( return Center(
...@@ -121,7 +121,7 @@ class AbnormalDetailView extends StatelessWidget { ...@@ -121,7 +121,7 @@ class AbnormalDetailView extends StatelessWidget {
height: 32.sp, height: 32.sp,
child: const CircularProgressIndicator( child: const CircularProgressIndicator(
strokeWidth: 3, strokeWidth: 3,
color: Color.fromRGBO(237, 245, 255, 1), color: Color.fromRGBO(66, 165, 245, 1.0),
), ),
) )
: Text( : Text(
......
...@@ -111,6 +111,19 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> { ...@@ -111,6 +111,19 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> {
state: pagingState, state: pagingState,
fetchNextPage: fetchNextPage, fetchNextPage: fetchNextPage,
builderDelegate: PagedChildBuilderDelegate<AlarmItem>( builderDelegate: PagedChildBuilderDelegate<AlarmItem>(
firstPageProgressIndicatorBuilder: (_) => const Center(
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
newPageProgressIndicatorBuilder: (_) => const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
),
firstPageErrorIndicatorBuilder: (_) => Center( firstPageErrorIndicatorBuilder: (_) => Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
......
...@@ -52,7 +52,7 @@ class DeviceDetailView extends StatelessWidget { ...@@ -52,7 +52,7 @@ class DeviceDetailView extends StatelessWidget {
body: BlocBuilder<DeviceCubit, DeviceState>( body: BlocBuilder<DeviceCubit, DeviceState>(
builder: (context, state) { builder: (context, state) {
if (state.isLoading) { if (state.isLoading) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0)));
} }
if (state.error != null) { if (state.error != null) {
return Center( return Center(
...@@ -120,7 +120,7 @@ class DeviceDetailView extends StatelessWidget { ...@@ -120,7 +120,7 @@ class DeviceDetailView extends StatelessWidget {
height: 32.sp, height: 32.sp,
child: const CircularProgressIndicator( child: const CircularProgressIndicator(
strokeWidth: 3, strokeWidth: 3,
color: Color.fromRGBO(237, 245, 255, 1), color: Color.fromRGBO(66, 165, 245, 1.0),
), ),
) )
: Text( : Text(
...@@ -157,7 +157,7 @@ class DeviceDetailView extends StatelessWidget { ...@@ -157,7 +157,7 @@ class DeviceDetailView extends StatelessWidget {
height: 32.sp, height: 32.sp,
child: const CircularProgressIndicator( child: const CircularProgressIndicator(
strokeWidth: 3, strokeWidth: 3,
color: Color.fromRGBO(100, 116, 139, 1), color: Color.fromRGBO(66, 165, 245, 1.0),
), ),
) )
: Text( : Text(
......
...@@ -2,17 +2,26 @@ import 'package:flutter/material.dart'; ...@@ -2,17 +2,26 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:smart_hotel_app/models/bo/alert_dashboard_bo.dart'; import 'package:smart_hotel_app/models/bo/alert_dashboard_bo.dart';
import 'package:smart_hotel_app/repositories/alert_dashboard_repository.dart'; import 'package:smart_hotel_app/repositories/alert_dashboard_repository.dart';
import 'package:smart_hotel_app/repositories/alert_detail_repository.dart';
import 'package:smart_hotel_app/services/alert_dashboard_service.dart'; import 'package:smart_hotel_app/services/alert_dashboard_service.dart';
import 'package:smart_hotel_app/services/alert_detail_service.dart';
import 'package:smart_hotel_app/views/home/index/cubit/home_index_state.dart'; import 'package:smart_hotel_app/views/home/index/cubit/home_index_state.dart';
class HomeIndexCubit extends Cubit<HomeIndexState> { class HomeIndexCubit extends Cubit<HomeIndexState> {
final AlertDashboardService _service; final AlertDashboardService _service;
final AlertDetailService _alertDetailService;
HomeIndexCubit({AlertDashboardService? service}) HomeIndexCubit({
: _service = service ?? AlertDashboardService? service,
AlertDetailService? alertDetailService,
}) : _service = service ??
AlertDashboardService( AlertDashboardService(
repository: AlertDashboardRepository(), repository: AlertDashboardRepository(),
), ),
_alertDetailService = alertDetailService ??
AlertDetailService(
repository: AlertDetailRepository(),
),
super(const HomeIndexState()) { super(const HomeIndexState()) {
loadDashboard(); loadDashboard();
} }
...@@ -31,6 +40,20 @@ class HomeIndexCubit extends Cubit<HomeIndexState> { ...@@ -31,6 +40,20 @@ class HomeIndexCubit extends Cubit<HomeIndexState> {
loadDashboard(); loadDashboard();
} }
/// 处理告警
Future<void> handleAlert(int alertId) async {
if (state.isHandlingAlert) return;
emit(state.copyWith(isHandlingAlert: true));
try {
await _alertDetailService.handleAlert(alertId: alertId);
emit(state.copyWith(isHandlingAlert: false));
await reloadDashboard();
} catch (e) {
emit(state.copyWith(isHandlingAlert: false, error: e.toString()));
rethrow;
}
}
void _emitFromDashboard(AlertDashboardBO dashboard) { void _emitFromDashboard(AlertDashboardBO dashboard) {
emit(state.copyWith( emit(state.copyWith(
isLoading: false, isLoading: false,
......
...@@ -19,7 +19,10 @@ class EquipmentItem { ...@@ -19,7 +19,10 @@ class EquipmentItem {
} }
class HomeIndexState extends Equatable { class HomeIndexState extends Equatable {
static const _nothing = Object();
final bool isLoading; final bool isLoading;
final bool isHandlingAlert;
final String? error; final String? error;
final int highAlarmCount; final int highAlarmCount;
final int mediumAlarmCount; final int mediumAlarmCount;
...@@ -29,6 +32,7 @@ class HomeIndexState extends Equatable { ...@@ -29,6 +32,7 @@ class HomeIndexState extends Equatable {
const HomeIndexState({ const HomeIndexState({
this.isLoading = false, this.isLoading = false,
this.isHandlingAlert = false,
this.error, this.error,
this.highAlarmCount = 0, this.highAlarmCount = 0,
this.mediumAlarmCount = 0, this.mediumAlarmCount = 0,
...@@ -39,7 +43,8 @@ class HomeIndexState extends Equatable { ...@@ -39,7 +43,8 @@ class HomeIndexState extends Equatable {
HomeIndexState copyWith({ HomeIndexState copyWith({
bool? isLoading, bool? isLoading,
String? error, bool? isHandlingAlert,
Object? error = _nothing,
int? highAlarmCount, int? highAlarmCount,
int? mediumAlarmCount, int? mediumAlarmCount,
int? onlineDeviceCount, int? onlineDeviceCount,
...@@ -48,7 +53,8 @@ class HomeIndexState extends Equatable { ...@@ -48,7 +53,8 @@ class HomeIndexState extends Equatable {
}) { }) {
return HomeIndexState( return HomeIndexState(
isLoading: isLoading ?? this.isLoading, isLoading: isLoading ?? this.isLoading,
error: error, isHandlingAlert: isHandlingAlert ?? this.isHandlingAlert,
error: identical(error, _nothing) ? this.error : error as String?,
highAlarmCount: highAlarmCount ?? this.highAlarmCount, highAlarmCount: highAlarmCount ?? this.highAlarmCount,
mediumAlarmCount: mediumAlarmCount ?? this.mediumAlarmCount, mediumAlarmCount: mediumAlarmCount ?? this.mediumAlarmCount,
onlineDeviceCount: onlineDeviceCount ?? this.onlineDeviceCount, onlineDeviceCount: onlineDeviceCount ?? this.onlineDeviceCount,
...@@ -60,6 +66,7 @@ class HomeIndexState extends Equatable { ...@@ -60,6 +66,7 @@ class HomeIndexState extends Equatable {
@override @override
List<Object?> get props => [ List<Object?> get props => [
isLoading, isLoading,
isHandlingAlert,
error, error,
highAlarmCount, highAlarmCount,
mediumAlarmCount, mediumAlarmCount,
......
...@@ -12,30 +12,30 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -12,30 +12,30 @@ class EquipmentListBlock extends StatelessWidget {
required this.equipmentList, required this.equipmentList,
}); });
Widget _buildEquipmentItem(EquipmentItem item) { Widget _buildEquipmentItem(EquipmentItem item, bool isLast) {
return Container( return Container(
padding: EdgeInsets.symmetric(vertical: 16.h), padding: EdgeInsets.symmetric(vertical: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: !isLast ? Border(
bottom: BorderSide( bottom: BorderSide(
color: const Color.fromRGBO(235, 235, 235, 1.0), color: const Color.fromRGBO(235, 235, 235, 1.0),
width: 1.w, width: 1.h,
), ),
), ) : null,
), ),
child: Row( child: Row(
children: [ children: [
Container( Container(
width: 64.w, width: 64.w,
height: 66.h, height: 53.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(229, 241, 255, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(8.r),
border: Border.all( // border: Border.all(
color: const Color.fromRGBO(66, 165, 245, 1.0), // color: const Color.fromRGBO(66, 165, 245, 1.0),
width: 2.w, // width: 2.w,
style: BorderStyle.solid, // style: BorderStyle.solid,
), // ),
), ),
child: Icon( child: Icon(
item.icon, item.icon,
...@@ -47,6 +47,7 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -47,6 +47,7 @@ class EquipmentListBlock extends StatelessWidget {
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 5.h,
children: [ children: [
Transform.translate( Transform.translate(
offset: Offset(0, 2.h), offset: Offset(0, 2.h),
...@@ -59,7 +60,6 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -59,7 +60,6 @@ class EquipmentListBlock extends StatelessWidget {
), ),
), ),
), ),
SizedBox(height: 4.h),
Text( Text(
item.subtitle, item.subtitle,
style: TextStyle( style: TextStyle(
...@@ -85,11 +85,12 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -85,11 +85,12 @@ class EquipmentListBlock extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return SizedBox(
width: double.infinity, width: double.infinity,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
spacing: 12.h,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
...@@ -111,21 +112,20 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -111,21 +112,20 @@ class EquipmentListBlock extends StatelessWidget {
Text( Text(
'查看全部', '查看全部',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 28.sp,
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
), ),
), ),
Icon( Icon(
Icons.chevron_right, Icons.chevron_right,
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 24.sp, size: 30.sp,
), ),
], ],
), ),
), ),
], ],
), ),
SizedBox(height: 12.h),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
...@@ -133,7 +133,13 @@ class EquipmentListBlock extends StatelessWidget { ...@@ -133,7 +133,13 @@ class EquipmentListBlock extends StatelessWidget {
), ),
padding: EdgeInsets.symmetric(horizontal: 20.w), padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Column( child: Column(
children: equipmentList.take(5).map((item) => _buildEquipmentItem(item)).toList(), // children: equipmentList.take(5).map((item) => _buildEquipmentItem(item)).toList(),
children: equipmentList.take(5).toList().asMap().entries.map((entry) {
int index = entry.key;
var item = entry.value;
bool isLast = index == equipmentList.take(5).length - 1;
return _buildEquipmentItem(item, isLast);
}).toList(),
), ),
), ),
], ],
......
...@@ -6,17 +6,37 @@ class TaskHeadBlock extends StatelessWidget { ...@@ -6,17 +6,37 @@ class TaskHeadBlock extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Stack(
width: double.infinity, clipBehavior: Clip.none,
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight), children: [
child: Text( Positioned(
'设备告警看板', left: -28.w,
style: TextStyle( right: -28.w,
fontSize: 28.sp, top: 0,
fontWeight: FontWeight.bold, child: Container(
color: const Color.fromRGBO(51, 51, 51, 1.0), height: 150.h,
color: Colors.white,
),
), ),
), Container(
height: 150.h,
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'设备告警看板',
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.bold,
color: const Color.fromRGBO(0, 0, 0, 1),
),
),
],
),
),
],
); );
} }
} }
\ No newline at end of file
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/repositories/alert_detail_repository.dart';
import 'package:smart_hotel_app/services/alert_detail_service.dart';
import 'package:smart_hotel_app/views/home/index/cubit/home_index_cubit.dart'; import 'package:smart_hotel_app/views/home/index/cubit/home_index_cubit.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart'; import 'package:smart_hotel_app/utils/toast_utils.dart';
...@@ -15,7 +13,6 @@ class TemperatureBlock extends StatelessWidget { ...@@ -15,7 +13,6 @@ class TemperatureBlock extends StatelessWidget {
final String currentCurrent; final String currentCurrent;
final String waitTime; final String waitTime;
final String alarmLevel; final String alarmLevel;
final AlertDetailService? alertDetailService;
const TemperatureBlock({ const TemperatureBlock({
super.key, super.key,
...@@ -27,7 +24,6 @@ class TemperatureBlock extends StatelessWidget { ...@@ -27,7 +24,6 @@ class TemperatureBlock extends StatelessWidget {
required this.currentCurrent, required this.currentCurrent,
required this.waitTime, required this.waitTime,
required this.alarmLevel, required this.alarmLevel,
this.alertDetailService,
}); });
@override @override
...@@ -49,7 +45,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -49,7 +45,7 @@ class TemperatureBlock extends StatelessWidget {
children: [ children: [
Container( Container(
width: 66.w, width: 66.w,
height: 68.h, height: 54.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
...@@ -57,13 +53,14 @@ class TemperatureBlock extends StatelessWidget { ...@@ -57,13 +53,14 @@ class TemperatureBlock extends StatelessWidget {
child: Icon( child: Icon(
Icons.thermostat_outlined, Icons.thermostat_outlined,
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 32.sp, size: 40.sp,
), ),
), ),
SizedBox(width: 16.w), SizedBox(width: 16.w),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 5.h,
children: [ children: [
Text( Text(
temperatureAlarmTitle, temperatureAlarmTitle,
...@@ -73,7 +70,6 @@ class TemperatureBlock extends StatelessWidget { ...@@ -73,7 +70,6 @@ class TemperatureBlock extends StatelessWidget {
color: const Color.fromRGBO(0, 0, 0, 1.0), color: const Color.fromRGBO(0, 0, 0, 1.0),
), ),
), ),
SizedBox(height: 4.h),
Text( Text(
temperatureAlarmLocation, temperatureAlarmLocation,
style: TextStyle( style: TextStyle(
...@@ -88,7 +84,9 @@ class TemperatureBlock extends StatelessWidget { ...@@ -88,7 +84,9 @@ class TemperatureBlock extends StatelessWidget {
alarmLevel, alarmLevel,
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: alarmLevel=="置顶" ? const Color.fromRGBO(255, 100, 101, 1.0) : const Color.fromRGBO(255, 204, 21, 1.0), color: alarmLevel == "置顶" ?
const Color.fromRGBO(255, 100, 101, 1.0) :
const Color.fromRGBO(255, 204, 21, 1.0),
), ),
), ),
], ],
...@@ -99,7 +97,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -99,7 +97,7 @@ class TemperatureBlock extends StatelessWidget {
padding: EdgeInsets.symmetric(vertical: 20.h), padding: EdgeInsets.symmetric(vertical: 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(20.r),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
...@@ -109,7 +107,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -109,7 +107,7 @@ class TemperatureBlock extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'$currentTemperature', currentTemperature,
style: TextStyle( style: TextStyle(
fontSize: 40.sp, fontSize: 40.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
...@@ -120,7 +118,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -120,7 +118,7 @@ class TemperatureBlock extends StatelessWidget {
Text( Text(
'当前温度', '当前温度',
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
...@@ -132,7 +130,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -132,7 +130,7 @@ class TemperatureBlock extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'${currentVoltage}', currentVoltage,
style: TextStyle( style: TextStyle(
fontSize: 40.sp, fontSize: 40.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
...@@ -143,7 +141,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -143,7 +141,7 @@ class TemperatureBlock extends StatelessWidget {
Text( Text(
'电压', '电压',
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
...@@ -155,7 +153,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -155,7 +153,7 @@ class TemperatureBlock extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'${currentCurrent}', currentCurrent,
style: TextStyle( style: TextStyle(
fontSize: 40.sp, fontSize: 40.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
...@@ -166,7 +164,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -166,7 +164,7 @@ class TemperatureBlock extends StatelessWidget {
Text( Text(
'电流', '电流',
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
...@@ -189,20 +187,20 @@ class TemperatureBlock extends StatelessWidget { ...@@ -189,20 +187,20 @@ class TemperatureBlock extends StatelessWidget {
), ),
SizedBox(width: 8.w), SizedBox(width: 8.w),
Text( Text(
'已等待$waitTime·', waitTime,
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
Text( // Text(
alarmLevel, // alarmLevel,
style: TextStyle( // style: TextStyle(
fontSize: 24.sp, // fontSize: 24.sp,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
color: const Color.fromRGBO(255, 77, 79, 1.0), // color: const Color.fromRGBO(255, 77, 79, 1.0),
), // ),
), // ),
], ],
), ),
GestureDetector( GestureDetector(
...@@ -216,7 +214,7 @@ class TemperatureBlock extends StatelessWidget { ...@@ -216,7 +214,7 @@ class TemperatureBlock extends StatelessWidget {
child: Text( child: Text(
'立即处理', '立即处理',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 28.sp,
color: Colors.white, color: Colors.white,
), ),
), ),
...@@ -239,7 +237,6 @@ class TemperatureBlock extends StatelessWidget { ...@@ -239,7 +237,6 @@ class TemperatureBlock extends StatelessWidget {
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
), ),
child: Container( child: Container(
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
...@@ -248,33 +245,42 @@ class TemperatureBlock extends StatelessWidget { ...@@ -248,33 +245,42 @@ class TemperatureBlock extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text(
temperatureAlarmTitle,
style: TextStyle(
fontSize: 30.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
GestureDetector( GestureDetector(
onTap: () => Navigator.of(dialogContext).pop(), onTap: () => Navigator.of(dialogContext).pop(),
child: Icon( child: Container(
Icons.close, margin: EdgeInsets.only(top: 20.h, right: 20.h),
color: const Color.fromRGBO(100, 116, 139, 1.0), padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 2.h),
size: 32.sp, decoration: BoxDecoration(
), shape: BoxShape.circle,
border: Border.all(
width: 2.w,
color: const Color.fromRGBO(100, 116, 139, 1.0),
),
),
child: Icon(
Icons.close,
color: const Color.fromRGBO(100, 116, 139, 1.0),
size: 32.sp,
),
)
), ),
], ],
), ),
SizedBox(height: 16.h), Text(
temperatureAlarmTitle,
style: TextStyle(
fontSize: 30.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(height: 20.h),
Container( Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric( margin: EdgeInsets.symmetric(horizontal: 40.w),
horizontal: 20.w, padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 30.h),
vertical: 20.h,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(242, 243, 245, 1), color: const Color.fromRGBO(242, 243, 245, 1),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
...@@ -302,26 +308,29 @@ class TemperatureBlock extends StatelessWidget { ...@@ -302,26 +308,29 @@ class TemperatureBlock extends StatelessWidget {
], ],
), ),
), ),
SizedBox(height: 20.h),
GestureDetector( GestureDetector(
onTap: () { behavior: HitTestBehavior.opaque,
onTap: () async {
Navigator.of(dialogContext).pop(); Navigator.of(dialogContext).pop();
_handleAlert(context); try {
await context.read<HomeIndexCubit>().handleAlert(alertId);
if (context.mounted) {
showToast('操作成功');
}
} catch (e) {
if (context.mounted) {
showToast('操作失败: $e');
}
}
}, },
child: Container( child: Container(
width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 30.h),
height: 72.h, child: Text(
decoration: BoxDecoration( '确认',
color: const Color.fromRGBO(66, 165, 245, 1.0), style: TextStyle(
borderRadius: BorderRadius.circular(12.r), fontSize: 28.sp,
), color: const Color.fromRGBO(73, 149, 234, 1.0),
child: Center( fontWeight: FontWeight.bold,
child: Text(
'确认',
style: TextStyle(
fontSize: 28.sp,
color: Colors.white,
),
), ),
), ),
), ),
...@@ -333,20 +342,4 @@ class TemperatureBlock extends StatelessWidget { ...@@ -333,20 +342,4 @@ class TemperatureBlock extends StatelessWidget {
}, },
); );
} }
Future<void> _handleAlert(BuildContext context) async {
try {
final service = alertDetailService ??
AlertDetailService(repository: AlertDetailRepository());
await service.handleAlert(alertId: alertId);
if (context.mounted) {
showToast('操作成功');
context.read<HomeIndexCubit>().reloadDashboard();
}
} catch (e) {
if (context.mounted) {
showToast('操作失败: $e');
}
}
}
} }
\ No newline at end of file
...@@ -2,9 +2,7 @@ import 'package:auto_route/auto_route.dart'; ...@@ -2,9 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/repositories/alert_detail_repository.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart'; import 'package:smart_hotel_app/routes/app_router.gr.dart';
import 'package:smart_hotel_app/services/alert_detail_service.dart';
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.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/views/home/index/cubit/home_index_cubit.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart'; import 'package:smart_hotel_app/utils/toast_utils.dart';
...@@ -17,7 +15,6 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -17,7 +15,6 @@ class VoltageOperateBlock extends StatelessWidget {
final String normalVoltage; final String normalVoltage;
final String voltageWaitTime; final String voltageWaitTime;
final String voltageAlarmLevel; final String voltageAlarmLevel;
final AlertDetailService? alertDetailService;
const VoltageOperateBlock({ const VoltageOperateBlock({
super.key, super.key,
...@@ -28,7 +25,6 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -28,7 +25,6 @@ class VoltageOperateBlock extends StatelessWidget {
required this.normalVoltage, required this.normalVoltage,
required this.voltageWaitTime, required this.voltageWaitTime,
required this.voltageAlarmLevel, required this.voltageAlarmLevel,
this.alertDetailService,
}); });
@override @override
...@@ -51,20 +47,20 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -51,20 +47,20 @@ class VoltageOperateBlock extends StatelessWidget {
children: [ children: [
Container( Container(
width: 64.w, width: 64.w,
height: 66.h, height: 54.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
border: Border.all( // border: Border.all(
color: const Color.fromRGBO(66, 165, 245, 1.0), // color: const Color.fromRGBO(66, 165, 245, 1.0),
width: 2.w, // width: 2.w,
style: BorderStyle.solid, // style: BorderStyle.solid,
), // ),
), ),
child: Icon( child: Icon(
Icons.thermostat_outlined, Icons.thermostat_outlined,
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 32.sp, size: 40.sp,
), ),
), ),
SizedBox(width: 16.w), SizedBox(width: 16.w),
...@@ -95,7 +91,9 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -95,7 +91,9 @@ class VoltageOperateBlock extends StatelessWidget {
voltageAlarmLevel, voltageAlarmLevel,
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: voltageAlarmLevel=="置顶" ? const Color.fromRGBO(255, 100, 101, 1.0) : const Color.fromRGBO(255, 204, 21, 1.0), color: voltageAlarmLevel=="置顶" ?
const Color.fromRGBO(255, 100, 101, 1.0) :
const Color.fromRGBO(255, 204, 21, 1.0),
), ),
), ),
], ],
...@@ -105,22 +103,23 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -105,22 +103,23 @@ class VoltageOperateBlock extends StatelessWidget {
width: double.infinity, width: double.infinity,
margin: EdgeInsets.only(left: 80.w, bottom: 20.h), margin: EdgeInsets.only(left: 80.w, bottom: 20.h),
child: Text( child: Text(
'电压${voltageValue}V (正常≤${normalVoltage}V)·已等待$voltageWaitTime', '电压${voltageValue}V (正常≤${normalVoltage}V)·$voltageWaitTime',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
), ),
Container( SizedBox(
width: double.infinity, width: double.infinity,
child: Row( child: Row(
spacing: 20.w,
children: [ children: [
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () => _showHandleDialog(context), onTap: () => _showHandleDialog(context),
child: Container( child: Container(
height: 88.h, padding: EdgeInsets.symmetric(vertical: 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
...@@ -137,14 +136,13 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -137,14 +136,13 @@ class VoltageOperateBlock extends StatelessWidget {
), ),
), ),
), ),
SizedBox(width: 20.w),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
context.pushRoute(AbnormalDetailRoute(alertId: alertId, alarmStatus: AlarmStatus.pending)); context.pushRoute(AbnormalDetailRoute(alertId: alertId, alarmStatus: AlarmStatus.pending));
}, },
child: Container( child: Container(
height: 88.h, padding: EdgeInsets.symmetric(vertical: 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
...@@ -244,9 +242,18 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -244,9 +242,18 @@ class VoltageOperateBlock extends StatelessWidget {
), ),
SizedBox(height: 20.h), SizedBox(height: 20.h),
GestureDetector( GestureDetector(
onTap: () { onTap: () async {
Navigator.of(dialogContext).pop(); Navigator.of(dialogContext).pop();
_handleAlert(context); try {
await context.read<HomeIndexCubit>().handleAlert(alertId);
if (context.mounted) {
showToast('操作成功');
}
} catch (e) {
if (context.mounted) {
showToast('操作失败: $e');
}
}
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
...@@ -273,20 +280,4 @@ class VoltageOperateBlock extends StatelessWidget { ...@@ -273,20 +280,4 @@ class VoltageOperateBlock extends StatelessWidget {
}, },
); );
} }
Future<void> _handleAlert(BuildContext context) async {
try {
final service = alertDetailService ??
AlertDetailService(repository: AlertDetailRepository());
await service.handleAlert(alertId: alertId);
if (context.mounted) {
showToast('操作成功');
context.read<HomeIndexCubit>().reloadDashboard();
}
} catch (e) {
if (context.mounted) {
showToast('操作失败: $e');
}
}
}
} }
\ No newline at end of file
...@@ -86,7 +86,7 @@ class _InspectionDetailBodyState extends State<_InspectionDetailBody> { ...@@ -86,7 +86,7 @@ class _InspectionDetailBodyState extends State<_InspectionDetailBody> {
return Scaffold( return Scaffold(
backgroundColor: const Color.fromRGBO(242, 243, 245, 1), backgroundColor: const Color.fromRGBO(242, 243, 245, 1),
appBar: _buildAppBar(context), appBar: _buildAppBar(context),
body: const Center(child: CircularProgressIndicator()), body: const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0))),
); );
} }
......
...@@ -24,6 +24,19 @@ class DeviceList extends StatelessWidget { ...@@ -24,6 +24,19 @@ class DeviceList extends StatelessWidget {
state: pagingState, state: pagingState,
fetchNextPage: fetchNextPage, fetchNextPage: fetchNextPage,
builderDelegate: PagedChildBuilderDelegate<InspectionDevice>( builderDelegate: PagedChildBuilderDelegate<InspectionDevice>(
firstPageProgressIndicatorBuilder: (_) => const Center(
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
newPageProgressIndicatorBuilder: (_) => const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
),
firstPageErrorIndicatorBuilder: (_) => Center( firstPageErrorIndicatorBuilder: (_) => Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
......
...@@ -87,7 +87,6 @@ class InspectionDeviceView extends StatelessWidget { ...@@ -87,7 +87,6 @@ class InspectionDeviceView extends StatelessWidget {
), ),
], ],
if (state.inspectionItems.isNotEmpty) ...[ if (state.inspectionItems.isNotEmpty) ...[
SizedBox(height: 20.h),
InspectionItemsCard( InspectionItemsCard(
items: state.inspectionItems, items: state.inspectionItems,
), ),
...@@ -104,22 +103,17 @@ class InspectionDeviceView extends StatelessWidget { ...@@ -104,22 +103,17 @@ class InspectionDeviceView extends StatelessWidget {
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: 88.h, height: 88.h,
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: const Color.fromRGBO(66, 165, 245, 1.0),
borderRadius: BorderRadius.circular(24.r), borderRadius: BorderRadius.circular(24.r),
border: Border.all(
color: const Color.fromRGBO(66, 165, 245, 1.0),
width: 2.w,
),
), ),
child: Center( child: Text(
child: Text( '巡检记录',
'巡检记录', style: TextStyle(
style: TextStyle( color: Colors.white,
color: const Color.fromRGBO(66, 165, 245, 1.0), fontSize: 32.sp,
fontSize: 32.sp, fontWeight: FontWeight.bold,
fontWeight: FontWeight.bold,
),
), ),
), ),
), ),
......
...@@ -45,25 +45,36 @@ class InspectionHistoryCard extends StatelessWidget { ...@@ -45,25 +45,36 @@ class InspectionHistoryCard extends StatelessWidget {
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
spacing: 12.w,
children: [ children: [
Container( Container(
width: 60.w, width: 80.w,
height: 60.h, height: 64.h,
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(242, 243, 245, 1.0), color: const Color.fromRGBO(229, 241, 255, 1.0),
borderRadius: BorderRadius.circular(8.r), borderRadius: BorderRadius.circular(8.r),
), ),
child: Icon( child: Container(
Icons.person, width: 44.w,
color: const Color.fromRGBO(100, 116, 139, 1.0), height: 44.h,
size: 32.sp, decoration: const BoxDecoration(
color: Color.fromRGBO(73, 149, 234, 1),
shape: BoxShape.circle,
),
child: Icon(
Icons.person,
color: Colors.white,
size: 40.sp,
),
), ),
), ),
SizedBox(width: 12.w),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4.h,
children: [ children: [
Text( Text(
item.inspectorName, item.inspectorName,
...@@ -73,19 +84,18 @@ class InspectionHistoryCard extends StatelessWidget { ...@@ -73,19 +84,18 @@ class InspectionHistoryCard extends StatelessWidget {
color: const Color.fromRGBO(10, 13, 20, 1.0), color: const Color.fromRGBO(10, 13, 20, 1.0),
), ),
), ),
SizedBox(height: 4.h),
Row( Row(
children: [ children: [
Icon( Icon(
Icons.access_time, Icons.access_time,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
size: 20.sp, size: 24.sp,
), ),
SizedBox(width: 4.w), SizedBox(width: 4.w),
Text( Text(
item.inspectionTime, item.inspectionTime,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
...@@ -96,23 +106,23 @@ class InspectionHistoryCard extends StatelessWidget { ...@@ -96,23 +106,23 @@ class InspectionHistoryCard extends StatelessWidget {
], ],
), ),
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 4.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(225, 245, 238, 1.0), color: const Color.fromRGBO(225, 245, 238, 1.0),
borderRadius: BorderRadius.circular(10.r), borderRadius: BorderRadius.circular(40.r),
), ),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
Icons.check, Icons.check,
color: const Color.fromRGBO(26, 188, 156, 1.0), color: const Color.fromRGBO(26, 188, 156, 1.0),
size: 20.sp, size: 24.sp,
), ),
SizedBox(width: 4.w), SizedBox(width: 4.w),
Text( Text(
item.result, item.result,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: const Color.fromRGBO(26, 188, 156, 1.0), color: const Color.fromRGBO(26, 188, 156, 1.0),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
...@@ -122,10 +132,10 @@ class InspectionHistoryCard extends StatelessWidget { ...@@ -122,10 +132,10 @@ class InspectionHistoryCard extends StatelessWidget {
), ),
], ],
), ),
SizedBox(height: 16.h), SizedBox(height: 20.h),
Container( Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(242, 243, 245, 1.0), color: const Color.fromRGBO(242, 243, 245, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
...@@ -133,12 +143,11 @@ class InspectionHistoryCard extends StatelessWidget { ...@@ -133,12 +143,11 @@ class InspectionHistoryCard extends StatelessWidget {
child: Text( child: Text(
item.remark, item.remark,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
), ),
SizedBox(height: 20.h),
], ],
); );
} }
......
...@@ -28,8 +28,7 @@ class InspectionItemsCard extends StatelessWidget { ...@@ -28,8 +28,7 @@ class InspectionItemsCard extends StatelessWidget {
'巡检项目', '巡检项目',
style: TextStyle( style: TextStyle(
fontSize: 26.sp, fontSize: 26.sp,
fontWeight: FontWeight.bold, color: const Color.fromRGBO(100, 116, 139, 1.0),
color: const Color.fromRGBO(10, 13, 20, 1.0),
), ),
), ),
SizedBox(height: 20.h), SizedBox(height: 20.h),
...@@ -66,23 +65,23 @@ class InspectionItemsCard extends StatelessWidget { ...@@ -66,23 +65,23 @@ class InspectionItemsCard extends StatelessWidget {
), ),
SizedBox(width: 12.w), SizedBox(width: 12.w),
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 4.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(225, 245, 238, 1.0), color: const Color.fromRGBO(225, 245, 238, 1.0),
borderRadius: BorderRadius.circular(10.r), borderRadius: BorderRadius.circular(40.r),
), ),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
Icons.check, Icons.check,
color: const Color.fromRGBO(26, 188, 156, 1.0), color: const Color.fromRGBO(26, 188, 156, 1.0),
size: 20.sp, size: 24.sp,
), ),
SizedBox(width: 4.w), SizedBox(width: 4.w),
Text( Text(
item.result, item.result,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: const Color.fromRGBO(26, 188, 156, 1.0), color: const Color.fromRGBO(26, 188, 156, 1.0),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
......
...@@ -83,18 +83,17 @@ class StartInspectionButton extends StatelessWidget { ...@@ -83,18 +83,17 @@ class StartInspectionButton extends StatelessWidget {
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: 88.h, height: 88.h,
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
borderRadius: BorderRadius.circular(24.r), borderRadius: BorderRadius.circular(24.r),
), ),
child: Center( child: Text(
child: Text( '开始巡检',
'开始巡检', style: TextStyle(
style: TextStyle( color: Colors.white,
color: Colors.white, fontSize: 32.sp,
fontSize: 32.sp, fontWeight: FontWeight.bold,
fontWeight: FontWeight.bold,
),
), ),
), ),
), ),
......
...@@ -49,7 +49,6 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> { ...@@ -49,7 +49,6 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> {
final total = final total =
context.read<InspectionHistoryCubit>().state.totalCount; context.read<InspectionHistoryCubit>().state.totalCount;
final nextKey = state.nextIntPageKey; final nextKey = state.nextIntPageKey;
if (nextKey == null) return null;
if ((nextKey - 1) * InspectionHistoryCubit.pageSize >= total) { if ((nextKey - 1) * InspectionHistoryCubit.pageSize >= total) {
return null; return null;
} }
...@@ -129,8 +128,7 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> { ...@@ -129,8 +128,7 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> {
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: color: const Color.fromRGBO(10, 13, 20, 1.0),
const Color.fromRGBO(10, 13, 20, 1.0),
), ),
), ),
], ],
...@@ -144,6 +142,19 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> { ...@@ -144,6 +142,19 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> {
fetchNextPage: fetchNextPage, fetchNextPage: fetchNextPage,
builderDelegate: builderDelegate:
PagedChildBuilderDelegate<InspectionRecord>( PagedChildBuilderDelegate<InspectionRecord>(
firstPageProgressIndicatorBuilder: (_) => const Center(
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
newPageProgressIndicatorBuilder: (_) => const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
),
firstPageErrorIndicatorBuilder: (_) => Center( firstPageErrorIndicatorBuilder: (_) => Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
......
...@@ -12,121 +12,132 @@ class InspectionRecordItem extends StatelessWidget { ...@@ -12,121 +12,132 @@ class InspectionRecordItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final resultColor = _getResultColor(record.result);
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(20.r), borderRadius: BorderRadius.circular(20.r),
), ),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.h), padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 28.h),
margin: EdgeInsets.only(bottom: 20.h), margin: EdgeInsets.only(bottom: 20.h),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Container(
children: [ width: 80.w,
Container( height: 64.h,
width: 60.w, decoration: BoxDecoration(
height: 60.h, color: const Color.fromRGBO(229, 241, 255, 1.0),
decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.r),
color: const Color.fromRGBO(242, 243, 245, 1.0), ),
borderRadius: BorderRadius.circular(8.r), child: Icon(
), record.icon,
child: Icon( color: const Color.fromRGBO(73, 149, 234, 1.0),
record.icon, size: 32.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), ),
size: 32.sp, ),
), SizedBox(width: 20.w),
), Expanded(
SizedBox(width: 12.w), child: Column(
Column( spacing: 10.h,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(
record.deviceName,
style: TextStyle(
fontSize: 26.sp,
fontWeight: FontWeight.bold,
color: const Color.fromRGBO(10, 13, 20, 1.0),
),
),
SizedBox(height: 8.h),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Icon(
Icons.person,
color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 18.sp,
),
SizedBox(width: 4.w),
Text( Text(
record.inspectorName, record.deviceName,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 26.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), fontWeight: FontWeight.bold,
color: const Color.fromRGBO(10, 13, 20, 1.0),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 4.h),
decoration: BoxDecoration(
color: resultColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(40.r),
),
child: Row(
children: [
Icon(
_getResultIcon(record.result),
color: resultColor,
size: 24.sp,
),
SizedBox(width: 4.w),
Text(
record.result,
style: TextStyle(
fontSize: 24.sp,
color: resultColor,
fontWeight: FontWeight.bold,
),
),
],
), ),
), ),
], ],
), ),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
spacing: 4.w,
children: [
Container(
width: 24.w,
height: 24.h,
decoration: const BoxDecoration(
color: Color.fromRGBO(73, 149, 234, 1),
shape: BoxShape.circle,
),
child: Icon(
Icons.person,
color: Colors.white,
size: 22.sp,
),
),
Text(
record.inspectorName,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0),
),
),
],
),
Row(
children: [
Icon(
Icons.access_time,
color: const Color.fromRGBO(100, 116, 139, 1.0),
size: 24.sp,
),
SizedBox(width: 4.w),
Text(
record.inspectionTime,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0),
),
),
],
),
],
)
], ],
), )
],
),
Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h),
decoration: BoxDecoration(
color: _getResultColor(record.result).withOpacity(0.1),
borderRadius: BorderRadius.circular(10.r),
border: Border.all(
color: _getResultColor(record.result),
width: 1.w,
),
),
child: Row(
children: [
Icon(
_getResultIcon(record.result),
color: _getResultColor(record.result),
size: 18.sp,
),
SizedBox(width: 4.w),
Text(
record.result,
style: TextStyle(
fontSize: 22.sp,
color: _getResultColor(record.result),
fontWeight: FontWeight.bold,
),
),
],
),
), ),
], ],
), ),
SizedBox(height: 12.h), SizedBox(height: 20.h),
Row(
children: [
Icon(
Icons.access_time,
color: const Color.fromRGBO(100, 116, 139, 1.0),
size: 20.sp,
),
SizedBox(width: 4.w),
Text(
record.inspectionTime,
style: TextStyle(
fontSize: 22.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0),
),
),
],
),
SizedBox(height: 16.h),
Container( Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(242, 243, 245, 1.0), color: const Color.fromRGBO(242, 243, 245, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
...@@ -134,23 +145,24 @@ class InspectionRecordItem extends StatelessWidget { ...@@ -134,23 +145,24 @@ class InspectionRecordItem extends StatelessWidget {
child: Text( child: Text(
record.remark, record.remark,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
), ),
SizedBox(height: 16.h), SizedBox(height: 20.h),
Divider( Divider(
color: const Color.fromRGBO(242, 243, 245, 1.0),
height: 1.h, height: 1.h,
thickness: 0.5,
color: const Color.fromRGBO(100, 116, 139, 0.2),
), ),
SizedBox(height: 16.h), SizedBox(height: 20.h),
Text( Text(
'巡检项目', '巡检项目',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: const Color.fromRGBO(71, 85, 105, 1.0), color: const Color.fromRGBO(100, 116, 139, 1.0),
), ),
), ),
SizedBox(height: 12.h), SizedBox(height: 12.h),
...@@ -182,27 +194,27 @@ class InspectionRecordItem extends StatelessWidget { ...@@ -182,27 +194,27 @@ class InspectionRecordItem extends StatelessWidget {
} }
Widget _buildItemTag(InspectionItemRecord item) { Widget _buildItemTag(InspectionItemRecord item) {
final resultColor = _getResultColor(item.result); final resultColor = _getResultColor(record.result);
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h), padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color.fromRGBO(209, 250, 229, 1.0), // resultColor.withValues(alpha: 0.18), color: resultColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(18.r), borderRadius: BorderRadius.circular(40.r),
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
spacing: 6.w,
children: [ children: [
Icon( Icon(
_getResultIcon(item.result), _getResultIcon(record.result),
color: resultColor, color: resultColor,
size: 18.sp, size: 24.sp,
), ),
SizedBox(width: 6.w),
Text( Text(
item.name, item.name,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: resultColor, color: resultColor,
), ),
), ),
......
...@@ -26,10 +26,10 @@ class StatisticsCard extends StatelessWidget { ...@@ -26,10 +26,10 @@ class StatisticsCard extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
_buildStatItem('总计', totalCount, const Color.fromRGBO(66, 165, 245, 1.0)), _buildStatItem('总计', totalCount, const Color.fromRGBO(73, 149, 234, 1.0)),
_buildStatItem('通过', passCount, const Color.fromRGBO(26, 188, 156, 1.0)), _buildStatItem('通过', passCount, const Color.fromRGBO(20, 184, 166, 1.0)),
_buildStatItem('警告', warningCount, const Color.fromRGBO(247, 184, 75, 1.0)), _buildStatItem('警告', warningCount, const Color.fromRGBO(250, 204, 21, 1.0)),
_buildStatItem('不通过', failCount, const Color.fromRGBO(239, 68, 68, 1.0)), _buildStatItem('不通过', failCount, const Color.fromRGBO(255, 100, 101, 1.0)),
], ],
), ),
); );
...@@ -37,6 +37,7 @@ class StatisticsCard extends StatelessWidget { ...@@ -37,6 +37,7 @@ class StatisticsCard extends StatelessWidget {
Widget _buildStatItem(String label, int count, Color color) { Widget _buildStatItem(String label, int count, Color color) {
return Column( return Column(
spacing: 5.h,
children: [ children: [
Text( Text(
count.toString(), count.toString(),
...@@ -46,7 +47,6 @@ class StatisticsCard extends StatelessWidget { ...@@ -46,7 +47,6 @@ class StatisticsCard extends StatelessWidget {
color: color, color: color,
), ),
), ),
SizedBox(height: 4.h),
Text( Text(
label, label,
style: TextStyle( style: TextStyle(
......
...@@ -55,7 +55,7 @@ class InspectionTopologyPage extends StatelessWidget { ...@@ -55,7 +55,7 @@ class InspectionTopologyPage extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
if (state.isLoading) { if (state.isLoading) {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(color: const Color.fromRGBO(66, 165, 245, 1.0)),
); );
} }
......
...@@ -33,7 +33,7 @@ class BtnLogin extends StatelessWidget { ...@@ -33,7 +33,7 @@ class BtnLogin extends StatelessWidget {
height: 40.w, height: 40.w,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 3.w, strokeWidth: 3.w,
color: Colors.white, color: const Color.fromRGBO(66, 165, 245, 1.0),
), ),
) )
: Text( : Text(
......
...@@ -16,14 +16,14 @@ class ProfileHeaderBlock extends StatelessWidget { ...@@ -16,14 +16,14 @@ class ProfileHeaderBlock extends StatelessWidget {
return Container( return Container(
width: double.infinity, width: double.infinity,
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only(left: 28.w, right: 28.w, top: ScreenUtil().statusBarHeight + 32.h, bottom: 32.h), padding: EdgeInsets.only(left: 28.w, right: 28.w, top: ScreenUtil().statusBarHeight + 20.h, bottom: 32.h),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'我的', '我的',
style: TextStyle( style: TextStyle(
fontSize: 36.sp, fontSize: 32.sp,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.black, color: Colors.black,
), ),
......
...@@ -115,6 +115,19 @@ class _ReportDeviceListBodyState extends State<_ReportDeviceListBody> { ...@@ -115,6 +115,19 @@ class _ReportDeviceListBodyState extends State<_ReportDeviceListBody> {
state: pagingState, state: pagingState,
fetchNextPage: fetchNextPage, fetchNextPage: fetchNextPage,
builderDelegate: PagedChildBuilderDelegate<DeviceInfo>( builderDelegate: PagedChildBuilderDelegate<DeviceInfo>(
firstPageProgressIndicatorBuilder: (_) => const Center(
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
newPageProgressIndicatorBuilder: (_) => const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(
color: Color.fromRGBO(66, 165, 245, 1.0),
),
),
),
firstPageErrorIndicatorBuilder: (_) => Center( firstPageErrorIndicatorBuilder: (_) => Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
......
...@@ -40,7 +40,7 @@ class ReportEnergyDetailView extends StatelessWidget { ...@@ -40,7 +40,7 @@ class ReportEnergyDetailView extends StatelessWidget {
body: BlocBuilder<EnergyCubit, EnergyState>( body: BlocBuilder<EnergyCubit, EnergyState>(
builder: (context, state) { builder: (context, state) {
if (state.isLoading) { if (state.isLoading) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0)));
} }
if (state.error != null) { if (state.error != null) {
return Center( return Center(
......
...@@ -51,9 +51,10 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt ...@@ -51,9 +51,10 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt
if (state.isLoading) { if (state.isLoading) {
return Container( return Container(
color: const Color.fromRGBO(242, 243, 245, 1), color: const Color.fromRGBO(242, 243, 245, 1),
child: const Center(child: CircularProgressIndicator()), child: const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0))),
); );
} }
if (state.error != null) { if (state.error != null) {
return Container( return Container(
color: const Color.fromRGBO(242, 243, 245, 1), color: const Color.fromRGBO(242, 243, 245, 1),
...@@ -79,6 +80,7 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt ...@@ -79,6 +80,7 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt
), ),
); );
} }
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
return SingleChildScrollView( return SingleChildScrollView(
...@@ -89,31 +91,16 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt ...@@ -89,31 +91,16 @@ class _ReportIndexViewState extends State<ReportIndexView> with AutoRouteAwareSt
child: Container( child: Container(
width: double.infinity, width: double.infinity,
color: const Color.fromRGBO(242, 243, 245, 1), color: const Color.fromRGBO(242, 243, 245, 1),
padding: EdgeInsets.only( padding: EdgeInsets.only(left: 28.w, right: 28.w, bottom: 15.h),
left: 28.w,
right: 28.w,
top: ScreenUtil().statusBarHeight),
child: Column( child: Column(
spacing: 15.h,
children: [ children: [
ReportHeaderBlock( const ReportHeaderBlock(),
reportHeader: state.reportHeader), ReportMetricsBlock(reportMetrics: state.reportMetrics),
SizedBox(height: 10.h), WeeklyPowerChart(weeklyPowerUsage: state.weeklyPowerUsage),
ReportMetricsBlock( RoomStatusDistribution(roomStatusDistribution: state.roomStatusDistribution),
reportMetrics: state.reportMetrics), DeviceOnlineRate(deviceOnlineRate: state.deviceOnlineRate),
SizedBox(height: 10.h), QuickActionsBlock(quickActions: state.quickActions),
WeeklyPowerChart(
weeklyPowerUsage: state.weeklyPowerUsage),
SizedBox(height: 10.h),
RoomStatusDistribution(
roomStatusDistribution:
state.roomStatusDistribution),
SizedBox(height: 10.h),
DeviceOnlineRate(
deviceOnlineRate: state.deviceOnlineRate),
SizedBox(height: 10.h),
QuickActionsBlock(
quickActions: state.quickActions),
SizedBox(height: 10.h),
], ],
), ),
), ),
......
...@@ -2,23 +2,39 @@ import 'package:flutter/material.dart'; ...@@ -2,23 +2,39 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class ReportHeaderBlock extends StatelessWidget { class ReportHeaderBlock extends StatelessWidget {
final Map<String, dynamic> reportHeader; const ReportHeaderBlock({super.key});
const ReportHeaderBlock({super.key, required this.reportHeader});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Stack(
width: double.infinity, clipBehavior: Clip.none,
padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 16.h), children: [
child: Text( Positioned(
reportHeader['title'] as String, left: -28.w,
style: TextStyle( right: -28.w,
fontSize: 36.sp, top: 0,
fontWeight: FontWeight.w500, child: Container(
color: const Color.fromRGBO(71, 71, 71, 1), height: 150.h,
color: Colors.white,
),
),
Container(
height: 150.h,
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
child: Row(
children: [
Text(
'经营概览看板',
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.bold,
color: const Color.fromRGBO(0, 0, 0, 1),
),
),
],
),
), ),
), ],
); );
} }
} }
\ No newline at end of file
...@@ -43,7 +43,7 @@ class ReportRoomDetailView extends StatelessWidget { ...@@ -43,7 +43,7 @@ class ReportRoomDetailView extends StatelessWidget {
), ),
centerTitle: true, centerTitle: true,
), ),
body: const Center(child: CircularProgressIndicator()), body: const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0))),
); );
} }
...@@ -126,7 +126,7 @@ class ReportRoomDetailView extends StatelessWidget { ...@@ -126,7 +126,7 @@ class ReportRoomDetailView extends StatelessWidget {
if (state.isLoading) if (state.isLoading)
const Padding( const Padding(
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: Center(child: CircularProgressIndicator()), child: Center(child: CircularProgressIndicator(color: const Color.fromRGBO(66, 165, 245, 1.0))),
), ),
...state.detailRooms.map((room) { ...state.detailRooms.map((room) {
return Padding( return Padding(
......
...@@ -44,7 +44,7 @@ class ServiceDeviceDetailView extends StatelessWidget { ...@@ -44,7 +44,7 @@ class ServiceDeviceDetailView extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
final cubit = context.read<ServiceDeviceCubit>(); final cubit = context.read<ServiceDeviceCubit>();
if (state.isLoading) { if (state.isLoading) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator(color: Color.fromRGBO(66, 165, 245, 1.0)));
} }
if (state.error != null) { if (state.error != null) {
return Center( return Center(
...@@ -68,33 +68,38 @@ class ServiceDeviceDetailView extends StatelessWidget { ...@@ -68,33 +68,38 @@ class ServiceDeviceDetailView extends StatelessWidget {
); );
} }
return SingleChildScrollView( return SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 28.w), padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 20.h),
child: Column( child: Container(
children: [ padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 40.h),
SizedBox(height: 20.h), decoration: BoxDecoration(
TemperatureControlBlock( color: Colors.white,
isOn: state.isOn, borderRadius: BorderRadius.circular(24.r),
targetTemperature: state.targetTemperature, ),
currentTemperature: state.currentTemperature, child: Column(
minTemperature: state.minTemperature, children: [
maxTemperature: state.maxTemperature, TemperatureControlBlock(
onTogglePower: cubit.togglePower, isOn: state.isOn,
onIncreaseTemperature: cubit.increaseTemperature, targetTemperature: state.targetTemperature,
onDecreaseTemperature: cubit.decreaseTemperature, currentTemperature: state.currentTemperature,
), minTemperature: state.minTemperature,
SizedBox(height: 20.h), maxTemperature: state.maxTemperature,
ModeSelectionBlock( onTogglePower: cubit.togglePower,
modeData: state.modeData, onIncreaseTemperature: cubit.increaseTemperature,
onSelectMode: cubit.selectMode, onDecreaseTemperature: cubit.decreaseTemperature,
), ),
SizedBox(height: 20.h), SizedBox(height: 20.h),
WindSpeedBlock( ModeSelectionBlock(
currentSpeed: state.currentSpeed, modeData: state.modeData,
speedOptions: state.speedOptions, onSelectMode: cubit.selectMode,
onSetWindSpeed: cubit.setWindSpeed, ),
), SizedBox(height: 20.h),
SizedBox(height: 20.h), WindSpeedBlock(
], currentSpeed: state.currentSpeed,
speedOptions: state.speedOptions,
onSetWindSpeed: cubit.setWindSpeed,
),
],
),
), ),
); );
}, },
......
...@@ -67,7 +67,7 @@ class _ModeSelectionBlockState extends State<ModeSelectionBlock> { ...@@ -67,7 +67,7 @@ class _ModeSelectionBlockState extends State<ModeSelectionBlock> {
Text( Text(
mode['name'] as String, mode['name'] as String,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: isSelected color: isSelected
? Colors.white ? Colors.white
: const Color.fromRGBO(107, 114, 128, 1), : const Color.fromRGBO(107, 114, 128, 1),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'dart:math' as math; import 'dart:math' as math;
class TemperatureControlBlock extends StatefulWidget { class TemperatureControlBlock extends StatefulWidget {
...@@ -29,83 +30,37 @@ class TemperatureControlBlock extends StatefulWidget { ...@@ -29,83 +30,37 @@ class TemperatureControlBlock extends StatefulWidget {
_TemperatureControlBlockState(); _TemperatureControlBlockState();
} }
class _TemperatureControlBlockState extends State<TemperatureControlBlock> class _TemperatureControlBlockState extends State<TemperatureControlBlock> {
with SingleTickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final progress = (widget.targetTemperature - widget.minTemperature) / final progress = (widget.targetTemperature - widget.minTemperature) /
(widget.maxTemperature - widget.minTemperature); (widget.maxTemperature - widget.minTemperature);
return Container( return Column(
width: double.infinity, children: [
padding: EdgeInsets.symmetric(vertical: 20.w), Row(
child: Column( mainAxisAlignment: MainAxisAlignment.end,
children: [
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.only(right: 20.w),
child: _buildPowerSwitch(),
),
),
SizedBox(height: 20.h),
_buildCircularTemperatureControl(progress),
SizedBox(height: 40.h),
_buildControlButtons(),
],
),
);
}
Widget _buildPowerSwitch() {
return GestureDetector(
onTap: () => widget.onTogglePower(!widget.isOn),
child: Container(
width: 88.w,
height: 48.h,
decoration: BoxDecoration(
gradient: widget.isOn
? const LinearGradient(
colors: [
Color.fromRGBO(96, 165, 250, 1),
Color.fromRGBO(59, 130, 246, 1),
],
)
: const LinearGradient(
colors: [
Color.fromRGBO(209, 213, 219, 1),
Color.fromRGBO(156, 163, 175, 1),
],
),
borderRadius: BorderRadius.circular(24.r),
),
child: Stack(
children: [ children: [
AnimatedAlign( FlutterSwitch(
duration: const Duration(milliseconds: 200), width: 80.w,
alignment: widget.isOn ? Alignment.centerRight : Alignment.centerLeft, height: 35.h,
child: Padding( valueFontSize: 20.sp,
padding: EdgeInsets.symmetric(horizontal: 4.w), toggleSize: 25.h,
child: Container( borderRadius: 20.r,
width: 40.w, padding: 4.w,
height: 40.h, value: widget.isOn,
decoration: BoxDecoration( activeColor: const Color.fromRGBO(80, 162, 255, 1),
color: Colors.white, inactiveColor: const Color.fromRGBO(210, 213, 218, 1),
shape: BoxShape.circle, onToggle: widget.onTogglePower,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
),
),
), ),
SizedBox(width: 20.w),
], ],
), ),
), SizedBox(height: 20.h),
_buildCircularTemperatureControl(progress),
SizedBox(height: 40.h),
_buildControlButtons(),
],
); );
} }
...@@ -138,40 +93,38 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock> ...@@ -138,40 +93,38 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock>
Text( Text(
'${widget.targetTemperature}', '${widget.targetTemperature}',
style: TextStyle( style: TextStyle(
fontSize: 100.sp, fontSize: 68.sp,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: widget.isOn color: widget.isOn
? const Color.fromRGBO(37, 99, 235, 1) ? const Color.fromRGBO(35, 89, 245, 1)
: const Color.fromRGBO(209, 213, 219, 1), : const Color.fromRGBO(209, 213, 219, 1),
), ),
), ),
SizedBox(height: 8.h),
Text( Text(
'°C', '°C',
style: TextStyle( style: TextStyle(
fontSize: 48.sp, fontSize: 36.sp,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: widget.isOn color: widget.isOn
? const Color.fromRGBO(59, 130, 246, 1) ? const Color.fromRGBO(35, 89, 245, 1)
: const Color.fromRGBO(209, 213, 219, 1), : const Color.fromRGBO(209, 213, 219, 1),
), ),
), ),
SizedBox(height: 20.h),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'当前室温 ', '当前室温 ',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 24.sp,
color: const Color.fromRGBO(156, 163, 175, 1), color: const Color.fromRGBO(100, 116, 139, 1),
), ),
), ),
Text( Text(
'${widget.currentTemperature}°C', '${widget.currentTemperature}°C',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 24.sp,
color: const Color.fromRGBO(107, 114, 128, 1), color: const Color.fromRGBO(100, 116, 139, 1),
), ),
), ),
], ],
...@@ -186,14 +139,14 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock> ...@@ -186,14 +139,14 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock>
child: Container( child: Container(
width: 64.w, width: 64.w,
height: 64.w, height: 64.w,
decoration: BoxDecoration( decoration: const BoxDecoration(
color: const Color.fromRGBO(37, 99, 235, 1), color: Color.fromRGBO(37, 99, 235, 1),
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: const Color.fromRGBO(37, 99, 235, 0.3), color: Color.fromRGBO(37, 99, 235, 0.3),
blurRadius: 10, blurRadius: 10,
offset: const Offset(0, 4), offset: Offset(0, 4),
), ),
], ],
), ),
...@@ -217,44 +170,43 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock> ...@@ -217,44 +170,43 @@ class _TemperatureControlBlockState extends State<TemperatureControlBlock>
Widget _buildControlButtons() { Widget _buildControlButtons() {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
spacing: 40.w,
children: [ children: [
GestureDetector( GestureDetector(
onTap: widget.onDecreaseTemperature, onTap: widget.onDecreaseTemperature,
child: Container( child: Container(
width: 140.w, width: 102.w,
height: 120.h, height: 82.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(229, 231, 235, 1), color: const Color.fromRGBO(224, 227, 232, 1),
borderRadius: BorderRadius.circular(40.r), borderRadius: BorderRadius.circular(26.r),
), ),
child: Icon( child: Icon(
Icons.remove, Icons.remove,
size: 48.sp, size: 70.sp,
color: const Color.fromRGBO(107, 114, 128, 1), color: const Color.fromRGBO(107, 114, 128, 1),
), ),
), ),
), ),
SizedBox(width: 40.w),
Text( Text(
'温度调节', '温度调节',
style: TextStyle( style: TextStyle(
fontSize: 32.sp, fontSize: 32.sp,
color: const Color.fromRGBO(107, 114, 128, 1), color: const Color.fromRGBO(100, 116, 139, 1),
), ),
), ),
SizedBox(width: 40.w),
GestureDetector( GestureDetector(
onTap: widget.onIncreaseTemperature, onTap: widget.onIncreaseTemperature,
child: Container( child: Container(
width: 140.w, width: 102.w,
height: 120.h, height: 82.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(229, 231, 235, 1), color: const Color.fromRGBO(224, 227, 232, 1),
borderRadius: BorderRadius.circular(40.r), borderRadius: BorderRadius.circular(26.r),
), ),
child: Icon( child: Icon(
Icons.add, Icons.add,
size: 48.sp, size: 70.sp,
color: const Color.fromRGBO(107, 114, 128, 1), color: const Color.fromRGBO(107, 114, 128, 1),
), ),
), ),
......
...@@ -58,7 +58,7 @@ class _WindSpeedBlockState extends State<WindSpeedBlock> { ...@@ -58,7 +58,7 @@ class _WindSpeedBlockState extends State<WindSpeedBlock> {
child: Text( child: Text(
speed, speed,
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 24.sp,
color: isSelected color: isSelected
? Colors.white ? Colors.white
: const Color.fromRGBO(107, 114, 128, 1), : const Color.fromRGBO(107, 114, 128, 1),
......
...@@ -89,10 +89,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> { ...@@ -89,10 +89,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
} }
/// 加载房间状态列表 /// 加载房间状态列表
Future<void> loadRooms({ Future<void> loadRooms({int? floorId, String? areaType}) async {
int? floorId,
String? areaType,
}) async {
emit(state.copyWith(isLoading: true, error: null)); emit(state.copyWith(isLoading: true, error: null));
try { try {
final roomStatuses = await _roomService.getRoomStatus( final roomStatuses = await _roomService.getRoomStatus(
...@@ -151,7 +148,11 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> { ...@@ -151,7 +148,11 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
'roomId': rs.roomId, 'roomId': rs.roomId,
'number': rs.roomNumber, 'number': rs.roomNumber,
'status': displayStatus, 'status': displayStatus,
'type': '客房', // 默认类型,后续可通过楼层areas信息扩展 'type': '客房',
'occupancyStatus': rs.occupancyStatus, // 0=无人 1=有人
'roomStatus': rs.roomStatus, // 0=无人 1=有人
'cleanStatus': rs.cleanStatus, // 0=待清洁 2=已完成
'devicePowerStatus': rs.devicePowerStatus, // 0=关 1=开
}; };
} }
...@@ -183,15 +184,8 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> { ...@@ -183,15 +184,8 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
} }
} }
void selectType(String? type) {
emit(state.copyWith(selectedType: type));
}
/// 加载非客房-相关楼层区域设备 /// 加载非客房-相关楼层区域设备
Future<void> loadAreaDevices({ Future<void> loadAreaDevices({required int floorId, required String areaType}) async {
required int floorId,
required String areaType,
}) async {
emit(state.copyWith(isLoadingAreaDevices: true, error: null)); emit(state.copyWith(isLoadingAreaDevices: true, error: null));
try { try {
final devices = await _roomService.getAreaDevices( final devices = await _roomService.getAreaDevices(
...@@ -210,8 +204,103 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> { ...@@ -210,8 +204,103 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
} }
} }
void selectRoom(String? room) { /// 选择房间
emit(state.copyWith(selectedRoom: room)); void selectRoom({String? room, int? roomId}) {
emit(state.copyWith(selectedRoom: room, selectedRoomId: roomId));
}
/// UI 层切换楼层(含取消选中、重置类型/房间/搜索、加载房间数据)
void toggleFloor(String floorName, int floorId) {
final isSameFloor = state.selectedFloor == floorName;
final newFloor = isSameFloor ? null : floorName;
// 计算新楼层的 areas
List<String> areas = state.areas;
if (newFloor != null) {
final matched = _floorAreasCache.where(
(f) => f.floorId.toString() == newFloor,
);
areas = matched.isNotEmpty ? matched.first.areas : <String>[];
}
emit(state.copyWith(
selectedFloor: newFloor,
selectedType: null,
selectedRoom: null,
selectedRoomId: null,
searchText: '',
areas: areas,
));
if (newFloor != null) {
loadRooms(floorId: floorId);
}
}
/// UI 层切换区域类型(含取消选中、重置房间、加载非客房设备)
void toggleType(String type) {
final newType = state.selectedType != type ? type : null;
emit(state.copyWith(
selectedType: newType,
selectedRoom: null,
selectedRoomId: null,
));
if (newType != null && newType != '客房') {
_loadAreaDevicesForCurrentFloor(newType);
}
}
/// 获取当前筛选条件下的房间列表
List<Map<String, dynamic>> getFilteredRooms() {
List<Map<String, dynamic>> allRooms;
if (state.selectedFloor == null) {
allRooms = [];
for (final floorMap in (state.floors ?? [])) {
final floorName = floorMap.values.first;
allRooms.addAll(getRoomsByFloor(floorName));
}
} else {
allRooms = getRoomsByFloor(state.selectedFloor!);
}
if (state.selectedType != null) {
allRooms =
allRooms.where((room) => room['type'] == state.selectedType).toList();
}
if (state.searchText.isEmpty) {
return allRooms;
}
return allRooms
.where((room) => (room['number'] as String)
.toLowerCase()
.contains(state.searchText.toLowerCase()))
.toList();
}
/// 获取当前选中房间的完整数据
Map<String, dynamic>? getSelectedRoomDetail() {
if (state.selectedRoom == null) return null;
return _findRoomByNumber(state.selectedRoom!);
}
/// 根据楼层标签获取楼层 ID
int? getFloorIdByLabel(String floorLabel) {
for (final floorMap in (state.floors ?? [])) {
if (floorMap.values.first == floorLabel) {
return floorMap.keys.first;
}
}
return null;
}
/// 根据当前选中楼层加载非客房区域设备
void _loadAreaDevicesForCurrentFloor(String areaType) {
if (state.selectedFloor == null) return;
final floorId = getFloorIdByLabel(state.selectedFloor!);
if (floorId == null) return;
loadAreaDevices(floorId: floorId, areaType: areaType);
} }
void setSearchText(String text) { void setSearchText(String text) {
...@@ -261,4 +350,10 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> { ...@@ -261,4 +350,10 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
} }
return null; return null;
} }
@override
Future<void> close() {
return super.close();
}
} }
...@@ -2,15 +2,18 @@ import 'package:equatable/equatable.dart'; ...@@ -2,15 +2,18 @@ import 'package:equatable/equatable.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart'; import 'package:smart_hotel_app/models/bo/room_bo.dart';
class ServiceIndexState extends Equatable { class ServiceIndexState extends Equatable {
/// copyWith sentinel: 区分「未传参」和「显式传 null」
static const _nothing = Object();
final int pendingCount; final int pendingCount;
final int occupiedRooms; final int occupiedRooms;
final int vacantRooms; final int vacantRooms;
// final List<String> floors;
final List<Map<int,String>>? floors; final List<Map<int,String>>? floors;
final List<String> areas; final List<String> areas;
final String? selectedFloor; final String? selectedFloor;
final String? selectedType; final String? selectedType;
final String? selectedRoom; final String? selectedRoom;
final int? selectedRoomId;
final String searchText; final String searchText;
final List<Map<String, dynamic>> rooms; final List<Map<String, dynamic>> rooms;
final List<AreaDeviceBO> areaDevices; final List<AreaDeviceBO> areaDevices;
...@@ -29,6 +32,7 @@ class ServiceIndexState extends Equatable { ...@@ -29,6 +32,7 @@ class ServiceIndexState extends Equatable {
this.selectedFloor, this.selectedFloor,
this.selectedType, this.selectedType,
this.selectedRoom, this.selectedRoom,
this.selectedRoomId,
this.searchText = '', this.searchText = '',
this.rooms = const [], this.rooms = const [],
this.areaDevices = const [], this.areaDevices = const [],
...@@ -43,18 +47,18 @@ class ServiceIndexState extends Equatable { ...@@ -43,18 +47,18 @@ class ServiceIndexState extends Equatable {
int? pendingCount, int? pendingCount,
int? occupiedRooms, int? occupiedRooms,
int? vacantRooms, int? vacantRooms,
// List<String>? floors,
List<Map<int,String>>? floors, List<Map<int,String>>? floors,
List<String>? areas, List<String>? areas,
String? selectedFloor, Object? selectedFloor = _nothing,
String? selectedType, Object? selectedType = _nothing,
String? selectedRoom, Object? selectedRoom = _nothing,
Object? selectedRoomId = _nothing,
String? searchText, String? searchText,
List<Map<String, dynamic>>? rooms, List<Map<String, dynamic>>? rooms,
List<AreaDeviceBO>? areaDevices, List<AreaDeviceBO>? areaDevices,
bool? isLoading, bool? isLoading,
bool? isLoadingAreaDevices, bool? isLoadingAreaDevices,
String? error, Object? error = _nothing,
bool? isPoweringOn, bool? isPoweringOn,
bool? isPoweringOff, bool? isPoweringOff,
}) { }) {
...@@ -64,15 +68,16 @@ class ServiceIndexState extends Equatable { ...@@ -64,15 +68,16 @@ class ServiceIndexState extends Equatable {
vacantRooms: vacantRooms ?? this.vacantRooms, vacantRooms: vacantRooms ?? this.vacantRooms,
floors: floors ?? this.floors, floors: floors ?? this.floors,
areas: areas ?? this.areas, areas: areas ?? this.areas,
selectedFloor: selectedFloor ?? this.selectedFloor, selectedFloor: identical(selectedFloor, _nothing) ? this.selectedFloor : selectedFloor as String?,
selectedType: selectedType ?? this.selectedType, selectedType: identical(selectedType, _nothing) ? this.selectedType : selectedType as String?,
selectedRoom: selectedRoom ?? this.selectedRoom, selectedRoom: identical(selectedRoom, _nothing) ? this.selectedRoom : selectedRoom as String?,
selectedRoomId: identical(selectedRoomId, _nothing) ? this.selectedRoomId : selectedRoomId as int?,
searchText: searchText ?? this.searchText, searchText: searchText ?? this.searchText,
rooms: rooms ?? this.rooms, rooms: rooms ?? this.rooms,
areaDevices: areaDevices ?? this.areaDevices, areaDevices: areaDevices ?? this.areaDevices,
isLoading: isLoading ?? this.isLoading, isLoading: isLoading ?? this.isLoading,
isLoadingAreaDevices: isLoadingAreaDevices ?? this.isLoadingAreaDevices, isLoadingAreaDevices: isLoadingAreaDevices ?? this.isLoadingAreaDevices,
error: error ?? this.error, error: identical(error, _nothing) ? this.error : error as String?,
isPoweringOn: isPoweringOn ?? this.isPoweringOn, isPoweringOn: isPoweringOn ?? this.isPoweringOn,
isPoweringOff: isPoweringOff ?? this.isPoweringOff, isPoweringOff: isPoweringOff ?? this.isPoweringOff,
); );
...@@ -88,6 +93,7 @@ class ServiceIndexState extends Equatable { ...@@ -88,6 +93,7 @@ class ServiceIndexState extends Equatable {
selectedFloor, selectedFloor,
selectedType, selectedType,
selectedRoom, selectedRoom,
selectedRoomId,
searchText, searchText,
rooms, rooms,
areaDevices, areaDevices,
......
...@@ -64,7 +64,7 @@ class _ServiceIndexViewState extends State<ServiceIndexView> with AutoRouteAware ...@@ -64,7 +64,7 @@ class _ServiceIndexViewState extends State<ServiceIndexView> with AutoRouteAware
occupiedCount: state.occupiedRooms, occupiedCount: state.occupiedRooms,
vacantCount: state.vacantRooms, vacantCount: state.vacantRooms,
), ),
RoomManagementBlock(), const RoomManagementBlock(),
SizedBox(height: 18.h), SizedBox(height: 18.h),
], ],
); );
......
...@@ -50,7 +50,7 @@ class AreaDeviceList extends StatelessWidget { ...@@ -50,7 +50,7 @@ class AreaDeviceList extends StatelessWidget {
return const Center( return const Center(
child: Padding( child: Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: CircularProgressIndicator(), child: CircularProgressIndicator(color: const Color.fromRGBO(66, 165, 245, 1.0)),
), ),
); );
} }
......
import 'dart:convert';
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
...@@ -8,256 +10,145 @@ import 'package:smart_hotel_app/views/service/index/cubit/service_index_state.da ...@@ -8,256 +10,145 @@ import 'package:smart_hotel_app/views/service/index/cubit/service_index_state.da
import 'package:smart_hotel_app/views/service/index/widget/area_device_list.dart'; import 'package:smart_hotel_app/views/service/index/widget/area_device_list.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart'; import 'package:smart_hotel_app/utils/toast_utils.dart';
class RoomManagementBlock extends StatefulWidget { class RoomManagementBlock extends StatelessWidget {
const RoomManagementBlock({super.key}); const RoomManagementBlock({super.key});
@override @override
State<RoomManagementBlock> createState() => _RoomManagementBlockState();
}
class _RoomManagementBlockState extends State<RoomManagementBlock> {
String? _selectedFloor;
String? _selectedType;
String? _selectedRoom;
int? _selectedRoomId;
String _searchText = '';
final TextEditingController _searchController = TextEditingController();
final ScrollController _scrollController = ScrollController();
List<Map<String, dynamic>> _getFilteredRooms(ServiceIndexCubit cubit) {
List<Map<String, dynamic>> allRooms;
if (_selectedFloor == null) {
allRooms = [];
for (final floorMap in (cubit.state.floors ?? [])) {
final floorName = floorMap.values.first;
allRooms.addAll(cubit.getRoomsByFloor(floorName));
}
} else {
allRooms = cubit.getRoomsByFloor(_selectedFloor!);
}
if (_selectedType != null) {
allRooms = allRooms
.where((room) => room['type'] == _selectedType)
.toList();
}
if (_searchText.isEmpty) {
return allRooms;
}
final filtered = allRooms
.where((room) =>
(room['number'] as String).toLowerCase().contains(_searchText.toLowerCase()))
.toList();
return filtered;
}
/// 加载非客房区域设备
void _loadAreaDevices(ServiceIndexCubit cubit) {
if (_selectedFloor == null) return;
// 从 floors 中找对应 floorId
int? floorId;
for (final floorMap in (cubit.state.floors ?? [])) {
if (floorMap.values.first == _selectedFloor) {
floorId = floorMap.keys.first;
break;
}
}
if (floorId == null) return;
cubit.loadAreaDevices(floorId: floorId, areaType: _selectedType!);
}
@override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cubit = context.read<ServiceIndexCubit>(); return BlocBuilder<ServiceIndexCubit, ServiceIndexState>(
return BlocListener<ServiceIndexCubit, ServiceIndexState>( builder: (context, state) {
listener: (context, state) { final cubit = context.read<ServiceIndexCubit>();
if (_selectedFloor != state.selectedFloor) { return Container(
setState(() { width: double.infinity,
_selectedFloor = state.selectedFloor; padding: EdgeInsets.all(28.w),
}); decoration: BoxDecoration(
} borderRadius: BorderRadius.circular(24.r),
}, color: Colors.white,
child: Container( boxShadow: [
width: double.infinity, BoxShadow(
padding: EdgeInsets.all(20.w), color: const Color.fromRGBO(0, 0, 0, 0.03),
decoration: BoxDecoration( blurRadius: 20.r,
borderRadius: BorderRadius.circular(24.r), offset: const Offset(0, 4),
color: Colors.white, ),
boxShadow: [ ],
BoxShadow(
color: const Color.fromRGBO(0, 0, 0, 0.03),
blurRadius: 20.r,
offset: const Offset(0, 4),
), ),
], child: Column(
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, _buildFloorSelector(state, cubit),
children: [ SizedBox(height: 24.h),
_buildFloorSelector(cubit), _buildTypeSelector(state, cubit),
SizedBox(height: 18.h), SizedBox(height: 24.h),
_buildTypeSelector(), if (state.selectedType == null || state.selectedType == '客房') ...[
SizedBox(height: 18.h), _buildSearchBox(state, cubit),
if (_selectedType == null || _selectedType == '客房') ...[ SizedBox(height: 32.h),
_buildSearchBox(), _buildLine(),
SizedBox(height: 32.h), SizedBox(height: 24.h),
_buildLine(), _buildRoomGrid(state, cubit),
SizedBox(height: 18.h), SizedBox(height: 24.h),
_buildRoomGrid(cubit), if (state.selectedRoom != null) ...[
SizedBox(height: 20.h), _buildLine(),
if (_selectedRoom != null) SizedBox(height: 24.h),
Padding( _buildRoomDetail(state, cubit),
padding: EdgeInsets.only(bottom: 15.h), SizedBox(height: 10.h),
child: Text( ],
'已选:$_selectedRoom号房', _buildBottomButtons(state, cubit, context),
style: TextStyle( ] else ...[
fontSize: 24.sp, _buildLine(),
color: const Color.fromRGBO(100, 116, 139, 1), SizedBox(height: 24.h),
), AreaDeviceList(
devices: state.areaDevices,
isLoading: state.isLoadingAreaDevices,
), ),
), ],
BlocBuilder<ServiceIndexCubit, ServiceIndexState>( ],
builder: (context, state) => _buildBottomButtons(cubit), ),
), );
] else ...[ },
_buildLine(),
SizedBox(height: 18.h),
BlocBuilder<ServiceIndexCubit, ServiceIndexState>(
builder: (context, state) => AreaDeviceList(
devices: state.areaDevices,
isLoading: state.isLoadingAreaDevices,
),
),
],
],
),
),
); );
} }
Widget _buildFloorSelector(ServiceIndexCubit cubit) { Widget _buildFloorSelector(ServiceIndexState state, ServiceIndexCubit cubit) {
final floors = cubit.state.floors; final floors = state.floors;
return SingleChildScrollView( return Row(
scrollDirection: Axis.horizontal, children: (floors ?? []).map((floorMap) {
child: Row( final floorName = floorMap.values.first;
children: (floors ?? []).map((floorMap) { final floorNameNew = floorName == '1' ? '一' :
final floorName = floorMap.values.first; floorName == '2' ? '二' :
final floorId = floorMap.keys.first; floorName == '3' ? '三' :
final isSelected = _selectedFloor == floorName; floorName == '4' ? '四' :
final displayFloor = floorName; floorName == '5' ? '五' :
return Padding( floorName == '6' ? '六' :
padding: EdgeInsets.only(right: 24.w), floorName == '7' ? '七' : '';
child: GestureDetector( final floorId = floorMap.keys.first;
onTap: () { final isSelected = state.selectedFloor == floorName;
setState(() { return Expanded(
if (_selectedFloor == floorName) { child: GestureDetector(
_selectedFloor = null; onTap: () => cubit.toggleFloor(floorName, floorId),
} else { child: Column(
_selectedFloor = floorName; children: [
} Text(
_selectedType = null; '$floorNameNew楼',
_searchController.clear(); style: TextStyle(
_searchText = ''; fontSize: 28.sp,
}); color: isSelected
// 切换楼层时重新请求接口 ? const Color.fromRGBO(80, 162, 255, 1)
if (_selectedFloor != null) { : const Color.fromRGBO(0, 0, 0, 1),
cubit.selectFloor(_selectedFloor); fontWeight:
cubit.loadRooms(floorId: floorId); isSelected ? FontWeight.bold : FontWeight.normal,
}
},
child: Column(
children: [
Text(
'$displayFloor楼',
style: TextStyle(
fontSize: 28.sp,
color: isSelected
? const Color.fromRGBO(80, 162, 255, 1)
: const Color.fromRGBO(0, 0, 0, 1),
fontWeight:
isSelected ? FontWeight.bold : FontWeight.normal,
),
), ),
SizedBox(height: 4.h), ),
Container( SizedBox(height: 4.h),
width: 50.w, Container(
height: 3.h, width: 50.w,
decoration: BoxDecoration( height: 3.h,
color: isSelected decoration: BoxDecoration(
? const Color.fromRGBO(80, 162, 255, 1) color: isSelected
: Colors.transparent, ? const Color.fromRGBO(80, 162, 255, 1)
borderRadius: BorderRadius.circular(2.r), : Colors.transparent,
), borderRadius: BorderRadius.circular(2.r),
), ),
], ),
), ],
), ),
); ),
}).toList(), );
), }).toList(),
); );
} }
Widget _buildTypeSelector() { Widget _buildTypeSelector(ServiceIndexState state, ServiceIndexCubit cubit) {
final cubit = context.read<ServiceIndexCubit>();
final types = cubit.state.areas.isNotEmpty
? cubit.state.areas
: [];
return Row( return Row(
children: types.asMap().entries.map((entry) { children: state.areas.asMap().entries.map((entry) {
final index = entry.key;
final type = entry.value; final type = entry.value;
final isSelected = _selectedType == type; final isSelected = state.selectedType == type;
return Container( return GestureDetector(
width: 100.w, onTap: () => cubit.toggleType(type),
child: Padding( child: Container(
padding: alignment: Alignment.center,
EdgeInsets.only(right: index < types.length - 1 ? 10.w : 0), width: 110.w,
child: GestureDetector( height: 45.h,
onTap: () { margin: EdgeInsets.only(right: 10.w),
setState(() { decoration: BoxDecoration(
if (_selectedType == type) { borderRadius: BorderRadius.circular(8.r),
_selectedType = null; border: Border.all(
} else { color: isSelected
_selectedType = type; ? const Color.fromRGBO(73, 149, 234, 0.5)
} : Colors.transparent,
_selectedRoom = null; width: 1.w,
_selectedRoomId = null; ),
}); color: isSelected
// 非客房类型时,加载区域设备数据 ? const Color.fromRGBO(73, 149, 234, 0.2)
if (_selectedType != null && _selectedType != '客房') { : const Color.fromRGBO(238, 238, 238, 1),
_loadAreaDevices(cubit); ),
} child: Text(type,
}, style: TextStyle(
child: Container( fontSize: 24.sp,
padding: EdgeInsets.symmetric(vertical: 8.h), color: isSelected
decoration: BoxDecoration( ? const Color.fromRGBO(73, 149, 234, 1)
borderRadius: BorderRadius.circular(8.r), : const Color.fromRGBO(100, 116, 139, 1),
border: Border.all( fontWeight:
color: isSelected isSelected ? FontWeight.bold : FontWeight.normal,
? const Color.fromRGBO(73, 149, 234, 0.5)
: Colors.transparent,
width: 1.w,
),
color: isSelected
? const Color.fromRGBO(73, 149, 234, 0.2)
: const Color.fromRGBO(238, 238, 238, 1),
),
child: Center(
child: Text(
type,
style: TextStyle(
fontSize: 24.sp,
color: isSelected
? const Color.fromRGBO(73, 149, 234, 1)
: const Color.fromRGBO(100, 116, 139, 1),
fontWeight:
isSelected ? FontWeight.bold : FontWeight.normal,
),
),
),
), ),
), ),
), ),
...@@ -266,10 +157,10 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -266,10 +157,10 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
); );
} }
Widget _buildSearchBox() { Widget _buildSearchBox(ServiceIndexState state, ServiceIndexCubit cubit) {
return Container( return Container(
height: 80.h, height: 80.h,
padding: EdgeInsets.symmetric(horizontal: 16.w), padding: EdgeInsets.symmetric(horizontal: 20.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(86.r), borderRadius: BorderRadius.circular(86.r),
color: Colors.white, color: Colors.white,
...@@ -279,35 +170,17 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -279,35 +170,17 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
), ),
), ),
child: Row( child: Row(
spacing: 20.w,
children: [ children: [
Icon( Icon(
Icons.search, Icons.search,
color: const Color.fromRGBO(153, 153, 153, 1), color: const Color.fromRGBO(100, 116, 139, 1),
size: 37.sp, size: 46.sp,
), ),
SizedBox(width: 26.w),
Expanded( Expanded(
child: TextField( child: _SearchBox(
controller: _searchController, selectedFloor: state.selectedFloor,
onChanged: (value) { onChanged: (value) => cubit.setSearchText(value),
setState(() {
_searchText = value;
});
},
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
decoration: InputDecoration(
hintText: '输入房号快速查找,如301...',
hintStyle: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 16.h),
isCollapsed: true,
),
), ),
), ),
], ],
...@@ -316,21 +189,60 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -316,21 +189,60 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
} }
Widget _buildLine() { Widget _buildLine() {
return Container( return Divider(
height: 1.h, height: 0.5.h,
color: const Color.fromRGBO(100, 116, 139, 1), color: const Color.fromRGBO(100, 116, 139, 0.2),
thickness: 0.5,
); );
} }
String _buildFilterLabel() { Widget _buildRoomDetail(ServiceIndexState state, ServiceIndexCubit cubit) {
final floorPart = _selectedFloor?.replaceAll('楼', '') ?? ''; final room = cubit.getSelectedRoomDetail();
return floorPart.isNotEmpty ? '客房${floorPart}楼·左右滑动选择' : '左右滑动选择'; if (room == null) return const SizedBox.shrink();
final items = [
('房间有无人', room['occupancyStatus'] == '1' ? '有人' : '无人'),
('房间状态', room['occupancyStatus'] == '1' ? '入住' : '空闲'),
('清洁灯', room['cleanStatus'] == '2' ? '已完成' : '待清洁'),
('设备开关', room['devicePowerStatus'] == '1' ? '开' : '关'),
];
return Column(
children: items.map((item) {
return Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item.$1,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
Text(
item.$2,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(73, 149, 234, 1),
fontWeight: FontWeight.w500,
),
),
],
),
);
}).toList(),
);
} }
Widget _buildRoomGrid(ServiceIndexCubit cubit) { Widget _buildRoomGrid(ServiceIndexState state, ServiceIndexCubit cubit) {
final filteredRooms = _getFilteredRooms(cubit); final filteredRooms = cubit.getFilteredRooms();
const crossAxisCount = 12; const crossAxisCount = 12;
final floorPart = state.selectedFloor?.replaceAll('楼', '') ?? '';
final filterLabel = floorPart.isNotEmpty ? '客房$floorPart楼·左右滑动选择' : '左右滑动选择';
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...@@ -338,7 +250,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -338,7 +250,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
_buildFilterLabel(), filterLabel,
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1), color: const Color.fromRGBO(100, 116, 139, 1),
...@@ -353,20 +265,20 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -353,20 +265,20 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
), ),
], ],
), ),
SizedBox(height: 10.h), SizedBox(height: 18.h),
if (filteredRooms.isEmpty) if (filteredRooms.isEmpty)
Container( Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 40.h), padding: EdgeInsets.symmetric(vertical: 40.h),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.r), borderRadius: BorderRadius.circular(8.r),
color: const Color.fromRGBO(245, 245, 245, 1), color: const Color.fromRGBO(245, 245, 245, 1),
), ),
child: Center( child: Center(
child: Text( child: Text(
'未找到匹配的房间', '未找到匹配的房间',
style: TextStyle( style: TextStyle(
fontSize: 15.sp, fontSize: 24.sp,
color: const Color.fromRGBO(153, 153, 153, 1), color: const Color.fromRGBO(153, 153, 153, 1),
), ),
), ),
...@@ -375,25 +287,23 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -375,25 +287,23 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
else else
SingleChildScrollView( SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
controller: _scrollController,
child: SizedBox( child: SizedBox(
width: (120.w + 12.w) * crossAxisCount, width: (120.w + 12.w) * crossAxisCount,
child: GridView.builder( child: GridView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
gridDelegate: gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount, crossAxisCount: crossAxisCount,
crossAxisSpacing: 12, crossAxisSpacing: 12.w,
mainAxisSpacing: 12, mainAxisSpacing: 12.h,
childAspectRatio: 1, childAspectRatio: 1,
), ),
itemCount: filteredRooms.length, itemCount: filteredRooms.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final room = filteredRooms[index]; final room = filteredRooms[index];
final isSelected = _selectedRoom == room['number']; final isSelected = state.selectedRoom == room['number'];
return _buildRoomItem(room, isSelected); return _buildRoomItem(room, isSelected, cubit);
}, },
), ),
), ),
...@@ -402,20 +312,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -402,20 +312,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
); );
} }
Widget _buildRoomItem(Map<String, dynamic> room, bool isSelected) { Widget _buildRoomItem(Map<String, dynamic> room, bool isSelected, ServiceIndexCubit cubit) {
final status = room['status'] as String; final status = room['status'] as String;
Color backgroundColor; Color backgroundColor;
Color borderColor; Color borderColor;
Color textColor; Color textColor;
Color statusTextColor;
switch (status) { switch (status) {
case '入住': case '入住':
backgroundColor = const Color.fromRGBO(220, 236, 255, 1); backgroundColor = const Color.fromRGBO(229, 241, 255, 1);
borderColor = isSelected borderColor = isSelected
? const Color.fromRGBO(64, 158, 255, 1) ? const Color.fromRGBO(73, 149, 234, 1)
: Colors.transparent; : Colors.transparent;
textColor = const Color.fromRGBO(100, 116, 139, 1); textColor = const Color.fromRGBO(73, 149, 234, 1);
statusTextColor = const Color.fromRGBO(73, 149, 234, 1);
break; break;
case '待清洁': case '待清洁':
backgroundColor = const Color.fromRGBO(238, 238, 238, 1); backgroundColor = const Color.fromRGBO(238, 238, 238, 1);
...@@ -423,7 +331,6 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -423,7 +331,6 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
? const Color.fromRGBO(64, 158, 255, 1) ? const Color.fromRGBO(64, 158, 255, 1)
: Colors.transparent; : Colors.transparent;
textColor = const Color.fromRGBO(100, 116, 139, 1); textColor = const Color.fromRGBO(100, 116, 139, 1);
statusTextColor = const Color.fromRGBO(73, 149, 234, 1);
break; break;
case '空闲': case '空闲':
default: default:
...@@ -432,37 +339,37 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -432,37 +339,37 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
? const Color.fromRGBO(64, 158, 255, 1) ? const Color.fromRGBO(64, 158, 255, 1)
: Colors.transparent; : Colors.transparent;
textColor = const Color.fromRGBO(100, 116, 139, 1); textColor = const Color.fromRGBO(100, 116, 139, 1);
statusTextColor = const Color.fromRGBO(73, 149, 234, 1);
} }
return GestureDetector( return GestureDetector(
onTap: () { onTap: () => cubit.selectRoom(
setState(() { room: room['number'] as String,
_selectedRoom = room['number'] as String; roomId: room['roomId'] as int?,
_selectedRoomId = room['roomId'] as int?; ),
});
},
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(16.r),
color: backgroundColor, color: backgroundColor,
border: Border.all( border: Border.all(
color: borderColor, color: borderColor,
width: isSelected ? 3.w : 0, width: isSelected ? 1.w : 0,
), ),
), ),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
spacing: 6.h,
children: [ children: [
Text( Text(
room['number'] as String, room['number'] as String,
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
color: textColor, color: textColor,
), ),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
SizedBox(height: 6.h),
Builder( Builder(
builder: (context) { builder: (context) {
if (status == '入住') { if (status == '入住') {
...@@ -470,7 +377,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -470,7 +377,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
'入住', '入住',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: statusTextColor, color: const Color.fromRGBO(73, 149, 234, 1),
), ),
); );
} else if (status == '待清洁') { } else if (status == '待清洁') {
...@@ -484,7 +391,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -484,7 +391,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
' ', ' ',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: statusTextColor, color: const Color.fromRGBO(73, 149, 234, 1),
), ),
); );
} }
...@@ -496,17 +403,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -496,17 +403,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
); );
} }
Widget _buildBottomButtons(ServiceIndexCubit cubit) { Widget _buildBottomButtons(ServiceIndexState state, ServiceIndexCubit cubit, BuildContext context) {
final isRoomSelected = _selectedRoom != null; final isRoomSelected = state.selectedRoom != null;
final isProcessing = cubit.state.isPoweringOn || cubit.state.isPoweringOff; final isProcessing = state.isPoweringOn || state.isPoweringOff;
return Row( return Row(
spacing: 16.w,
children: [ children: [
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromRGBO(73, 149, 234, 1), backgroundColor: const Color.fromRGBO(73, 149, 234, 1),
disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1), disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1),
minimumSize: Size(double.infinity, 88.h), minimumSize: Size(double.infinity, 70.h),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
...@@ -516,7 +424,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -516,7 +424,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
onPressed: isRoomSelected && !isProcessing onPressed: isRoomSelected && !isProcessing
? () async { ? () async {
try { try {
await cubit.powerOnRoom(_selectedRoom!); await cubit.powerOnRoom(state.selectedRoom!);
if (context.mounted) { if (context.mounted) {
showToast('送电成功'); showToast('送电成功');
} }
...@@ -536,19 +444,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -536,19 +444,18 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
), ),
), ),
), ),
SizedBox(width: 16.w),
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromRGBO(229, 241, 255, 1), backgroundColor: const Color.fromRGBO(229, 241, 255, 1),
disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1), disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1),
minimumSize: Size(double.infinity, 88.h), minimumSize: Size(double.infinity, 70.h),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
side: const BorderSide( side: BorderSide(
color: Color.fromRGBO(73, 149, 234, 1), color: const Color.fromRGBO(73, 149, 234, 1),
width: 1, width: 1.w,
), ),
), ),
elevation: 0, elevation: 0,
...@@ -556,7 +463,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -556,7 +463,7 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
onPressed: isRoomSelected && !isProcessing onPressed: isRoomSelected && !isProcessing
? () async { ? () async {
try { try {
await cubit.powerOffRoom(_selectedRoom!); await cubit.powerOffRoom(state.selectedRoom!);
if (context.mounted) { if (context.mounted) {
showToast('断电成功'); showToast('断电成功');
} }
...@@ -576,24 +483,23 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -576,24 +483,23 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
), ),
), ),
), ),
SizedBox(width: 16.w),
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromRGBO(100, 116, 139, 0.2), backgroundColor: const Color.fromRGBO(100, 116, 139, 0.2),
disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1), disabledBackgroundColor: const Color.fromRGBO(204, 204, 204, 1),
minimumSize: Size(double.infinity, 88.h), minimumSize: Size(double.infinity, 70.h),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
), ),
elevation: 0, elevation: 0,
), ),
onPressed: (isRoomSelected && _selectedRoomId != null) onPressed: (isRoomSelected && state.selectedRoomId != null)
? () { ? () {
context.pushRoute(ServiceRoomDetailRoute( context.pushRoute(ServiceRoomDetailRoute(
roomId: _selectedRoomId!, roomId: state.selectedRoomId!,
roomNumber: _selectedRoom, roomNumber: state.selectedRoom,
)); ));
} }
: null, : null,
...@@ -610,3 +516,58 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> { ...@@ -610,3 +516,58 @@ class _RoomManagementBlockState extends State<RoomManagementBlock> {
); );
} }
} }
/// 搜索框 — 独立 StatefulWidget 管理 TextEditingController
class _SearchBox extends StatefulWidget {
final String? selectedFloor;
final ValueChanged<String> onChanged;
const _SearchBox({required this.selectedFloor, required this.onChanged});
@override
State<_SearchBox> createState() => _SearchBoxState();
}
class _SearchBoxState extends State<_SearchBox> {
final TextEditingController _controller = TextEditingController();
String? _lastFloor;
@override
void didUpdateWidget(covariant _SearchBox oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.selectedFloor != _lastFloor && widget.selectedFloor != null) {
_controller.clear();
}
_lastFloor = widget.selectedFloor;
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return TextField(
controller: _controller,
onChanged: widget.onChanged,
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
decoration: InputDecoration(
hintText: '输入房号快速查找,如301...',
hintStyle: TextStyle(
fontSize: 26.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 16.h),
isCollapsed: true,
),
);
}
}
...@@ -6,7 +6,6 @@ class ServiceHeadBlock extends StatelessWidget { ...@@ -6,7 +6,6 @@ class ServiceHeadBlock extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
return Stack( return Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: [ children: [
...@@ -21,7 +20,7 @@ class ServiceHeadBlock extends StatelessWidget { ...@@ -21,7 +20,7 @@ class ServiceHeadBlock extends StatelessWidget {
), ),
Container( Container(
height: 150.h, height: 150.h,
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight, left: 20.w, right: 20.w), padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
...@@ -31,26 +30,31 @@ class ServiceHeadBlock extends StatelessWidget { ...@@ -31,26 +30,31 @@ class ServiceHeadBlock extends StatelessWidget {
fontSize: 32.sp, fontSize: 32.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: const Color.fromRGBO(0, 0, 0, 1), color: const Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'FZLTXH',
), ),
), ),
Container( Container(
width: 64.w, width: 64.w,
height: 64.w, height: 64.h,
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(229, 241, 255, 1),
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( border: Border.all(
color: const Color.fromRGBO(73, 149, 234, 1), color: const Color.fromRGBO(73, 149, 234, 1),
width: 1.w, width: 2.w,
), ),
), ),
child: CircleAvatar( child: Container(
radius: 40.w, width: 40.w,
backgroundColor: Colors.white, height: 40.h,
decoration: const BoxDecoration(
color: Color.fromRGBO(73, 149, 234, 1),
shape: BoxShape.circle,
),
child: Icon( child: Icon(
Icons.person, Icons.person,
color: const Color.fromRGBO(73, 149, 234, 1), color: Colors.white,
size: 48.sp, size: 28.sp,
), ),
), ),
), ),
...@@ -60,4 +64,5 @@ class ServiceHeadBlock extends StatelessWidget { ...@@ -60,4 +64,5 @@ class ServiceHeadBlock extends StatelessWidget {
], ],
); );
} }
} }
...@@ -18,64 +18,40 @@ class ServiceStatsBlock extends StatelessWidget { ...@@ -18,64 +18,40 @@ class ServiceStatsBlock extends StatelessWidget {
return Container( return Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.only(top: 20.w, bottom: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
decoration: BoxDecoration( child: Row(
// borderRadius: BorderRadius.circular(24.r), spacing: 12.w,
color: Color.fromRGBO(242, 243, 245, 1.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Text( _buildStatCard(
// '服务概览', '待响应',
// style: TextStyle( '$pendingCount',
// fontSize: 28.sp, const Color.fromRGBO(73, 149, 234, 1),
// fontWeight: FontWeight.bold, ),
// color: const Color.fromRGBO(31, 41, 55, 1), _buildStatCard(
// ), '入住中',
// ), '$occupiedCount',
// SizedBox(height: 20.h), const Color.fromRGBO(20, 184, 166, 1),
Row( ),
children: [ _buildStatCard(
_buildStatCard( '空闲可清洁',
'待响应需求', '$vacantCount',
'$pendingCount', const Color.fromRGBO(10, 13, 20, 1),
const Color.fromRGBO(239, 68, 68, 1),
Icons.warning_amber_rounded,
),
SizedBox(width: 12.w),
_buildStatCard(
'入住中',
'$occupiedCount',
const Color.fromRGBO(34, 197, 94, 1),
Icons.meeting_room_outlined,
),
SizedBox(width: 12.w),
_buildStatCard(
'空闲可清洁',
'$vacantCount',
const Color.fromRGBO(59, 130, 246, 1),
Icons.cleaning_services_outlined,
),
],
), ),
], ],
), ),
); );
} }
Widget _buildStatCard( Widget _buildStatCard(String label, String value, Color color) {
String label, String value, Color color, IconData icon) {
return Expanded( return Expanded(
child: Container( child: Container(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.symmetric(vertical: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.withOpacity(0.08), color: Colors.white,
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(24.r),
), ),
child: Column( child: Column(
spacing: 5.h,
children: [ children: [
// Icon(icon, color: color, size: 28.sp),
SizedBox(height: 8.h),
Text( Text(
value, value,
style: TextStyle( style: TextStyle(
...@@ -84,12 +60,11 @@ class ServiceStatsBlock extends StatelessWidget { ...@@ -84,12 +60,11 @@ class ServiceStatsBlock extends StatelessWidget {
color: color, color: color,
), ),
), ),
SizedBox(height: 4.h),
Text( Text(
label, label,
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: const Color.fromRGBO(107, 114, 128, 1), color: const Color.fromRGBO(100, 116, 139, 1),
), ),
), ),
], ],
......
...@@ -55,7 +55,7 @@ class ServiceRoomDetailView extends StatelessWidget { ...@@ -55,7 +55,7 @@ class ServiceRoomDetailView extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
if (state.isLoading) { if (state.isLoading) {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(color: const Color.fromRGBO(66, 165, 245, 1.0)),
); );
} }
...@@ -117,7 +117,7 @@ class ServiceRoomDetailView extends StatelessWidget { ...@@ -117,7 +117,7 @@ class ServiceRoomDetailView extends StatelessWidget {
onDeviceToggle: (index, value) => onDeviceToggle: (index, value) =>
cubit.toggleControlDevice(index, value), cubit.toggleControlDevice(index, value),
onDeviceTap: (index, device) { onDeviceTap: (index, device) {
if (device.name == '空调' || device.name?.contains('空调') == true) { if (device.name.contains('空调')) {
context.pushRoute(ServiceDeviceDetailRoute(deviceId: device.deviceId)); context.pushRoute(ServiceDeviceDetailRoute(deviceId: device.deviceId));
} }
}, },
......
...@@ -49,7 +49,7 @@ class DeviceControlCard extends StatelessWidget { ...@@ -49,7 +49,7 @@ class DeviceControlCard extends StatelessWidget {
color: const Color.fromRGBO(10, 13, 20, 1.0), color: const Color.fromRGBO(10, 13, 20, 1.0),
), ),
), ),
SizedBox(height: 20.h), SizedBox(height: 30.h),
...controlDevices.asMap().entries.map((entry) { ...controlDevices.asMap().entries.map((entry) {
final index = entry.key; final index = entry.key;
final device = entry.value; final device = entry.value;
...@@ -71,10 +71,11 @@ class DeviceControlCard extends StatelessWidget { ...@@ -71,10 +71,11 @@ class DeviceControlCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Row(
spacing: 16.w,
children: [ children: [
Container( Container(
width: 64.w, width: 64.w,
height: 64.h, height: 53.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
...@@ -85,7 +86,6 @@ class DeviceControlCard extends StatelessWidget { ...@@ -85,7 +86,6 @@ class DeviceControlCard extends StatelessWidget {
size: 36.sp, size: 36.sp,
), ),
), ),
SizedBox(width: 16.w),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...@@ -109,27 +109,24 @@ class DeviceControlCard extends StatelessWidget { ...@@ -109,27 +109,24 @@ class DeviceControlCard extends StatelessWidget {
], ],
), ),
FlutterSwitch( FlutterSwitch(
width: 48.0, width: 80.w,
height: 25.0, height: 35.h,
valueFontSize: 20.sp,
toggleSize: 25.h,
borderRadius: 20.r,
padding: 4.w,
value: mainPowerOn, value: mainPowerOn,
showOnOff: false, activeColor: const Color.fromRGBO(80, 162, 255, 1),
onToggle: onMainPowerToggle inactiveColor: const Color.fromRGBO(210, 213, 218, 1),
onToggle: onMainPowerToggle,
), ),
// FlutterSwitch(
// value: mainPowerOn,
// onToggle: onMainPowerToggle,
// activeColor: const Color.fromRGBO(59, 130, 246, 1),
// inactiveColor: const Color.fromRGBO(209, 213, 219, 1),
// width: 50.w,
// height: 28.h,
// // toggleSize: 26,
// ),
], ],
), ),
SizedBox(height: 20.h), SizedBox(height: 30.h),
Divider( Divider(
color: const Color.fromRGBO(242, 243, 245, 1.0), height: 0.5.h,
thickness: 1.h, color: const Color.fromRGBO(100, 116, 139, 0.2),
thickness: 0.5,
), ),
], ],
); );
...@@ -147,65 +144,47 @@ class DeviceControlCard extends StatelessWidget { ...@@ -147,65 +144,47 @@ class DeviceControlCard extends StatelessWidget {
color: Colors.transparent, color: Colors.transparent,
child: InkWell( child: InkWell(
onTap: onDeviceTap != null ? () => onDeviceTap!(index, device) : null, onTap: onDeviceTap != null ? () => onDeviceTap!(index, device) : null,
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Icon(
children: [ device.icon,
Icon( color: const Color.fromRGBO(66, 165, 245, 1.0),
device.icon, size: 36.sp,
color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 36.sp,
),
SizedBox(width: 8.w),
Text(
device.name,
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.bold,
color: const Color.fromRGBO(10, 13, 20, 1.0),
),
),
],
), ),
if (device.detailText != null) ...[ SizedBox(width: 8.w),
SizedBox(height: 8.h), Text(
Text( device.name,
device.detailText!, style: TextStyle(
style: TextStyle( fontSize: 28.sp,
fontSize: 24.sp, fontWeight: FontWeight.bold,
color: const Color.fromRGBO(100, 116, 139, 1.0), color: const Color.fromRGBO(10, 13, 20, 1.0),
),
), ),
], ),
], ],
), ),
), ),
), ),
), ),
FlutterSwitch( FlutterSwitch(
width: 48.0, width: 80.w,
height: 25.0, height: 35.h,
valueFontSize: 20.sp,
toggleSize: 25.h,
borderRadius: 20.r,
padding: 4.w,
value: device.isOn, value: device.isOn,
showOnOff: false, activeColor: const Color.fromRGBO(80, 162, 255, 1),
inactiveColor: const Color.fromRGBO(210, 213, 218, 1),
onToggle: (value) => onDeviceToggle(index, value), onToggle: (value) => onDeviceToggle(index, value),
), ),
// FlutterSwitch(
// value: device.isOn,
// onToggle: (value) => onDeviceToggle(index, value),
// activeColor: const Color.fromRGBO(66, 165, 245, 1.0),
// inactiveColor: const Color.fromRGBO(200, 208, 220, 1.0),
// width: 60.w,
// height: 30.h,
// toggleSize: 26,
// ),
], ],
), ),
if (index < controlDevices.length - 1) ...[ if (index < controlDevices.length - 1) ...[
SizedBox(height: 20.h), SizedBox(height: 30.h),
Divider( Divider(
color: const Color.fromRGBO(242, 243, 245, 1.0), height: 0.5.h,
thickness: 1.h, color: const Color.fromRGBO(100, 116, 139, 0.2),
thickness: 0.5,
), ),
], ],
], ],
......
...@@ -4,59 +4,59 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; ...@@ -4,59 +4,59 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
class RoomBottomButtons extends StatelessWidget { class RoomBottomButtons extends StatelessWidget {
final VoidCallback? onPowerOn; final VoidCallback? onPowerOn;
final VoidCallback? onPowerOff; final VoidCallback? onPowerOff;
final VoidCallback? onDeviceControl; // final VoidCallback? onDeviceControl;
final bool isProcessing; final bool isProcessing;
const RoomBottomButtons({ const RoomBottomButtons({
super.key, super.key,
this.onPowerOn, this.onPowerOn,
this.onPowerOff, this.onPowerOff,
this.onDeviceControl, // this.onDeviceControl,
this.isProcessing = false, this.isProcessing = false,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
spacing: 12.w,
children: [ children: [
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (onPowerOn != null && !isProcessing) ? onPowerOn : null, onTap: (onPowerOn != null && !isProcessing) ? onPowerOn : null,
child: Container( child: Container(
height: 88.h, height: 70.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: (onPowerOn != null && !isProcessing) color: (onPowerOn != null && !isProcessing)
? const Color.fromRGBO(66, 165, 245, 1.0) ? const Color.fromRGBO(73, 149, 234, 1)
: const Color.fromRGBO(204, 204, 204, 1), : const Color.fromRGBO(204, 204, 204, 1),
borderRadius: BorderRadius.circular(20.r), borderRadius: BorderRadius.circular(16.r),
), ),
child: Center( child: Center(
child: Text( child: Text(
'送电', '送电',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 32.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
), ),
), ),
), ),
), ),
), ),
), ),
SizedBox(width: 12.w),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (onPowerOff != null && !isProcessing) ? onPowerOff : null, onTap: (onPowerOff != null && !isProcessing) ? onPowerOff : null,
child: Container( child: Container(
height: 88.h, height: 70.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: const Color.fromRGBO(229, 241, 255, 1),
borderRadius: BorderRadius.circular(20.r), borderRadius: BorderRadius.circular(16.r),
border: Border.all( border: Border.all(
color: (onPowerOff != null && !isProcessing) color: (onPowerOff != null && !isProcessing)
? const Color.fromRGBO(66, 165, 245, 1.0) ? const Color.fromRGBO(73, 149, 234, 1)
: const Color.fromRGBO(204, 204, 204, 1), : const Color.fromRGBO(204, 204, 204, 1),
width: 2.w, width: 1.w,
), ),
), ),
child: Center( child: Center(
...@@ -66,37 +66,36 @@ class RoomBottomButtons extends StatelessWidget { ...@@ -66,37 +66,36 @@ class RoomBottomButtons extends StatelessWidget {
color: (onPowerOff != null && !isProcessing) color: (onPowerOff != null && !isProcessing)
? const Color.fromRGBO(66, 165, 245, 1.0) ? const Color.fromRGBO(66, 165, 245, 1.0)
: const Color.fromRGBO(100, 116, 139, 1), : const Color.fromRGBO(100, 116, 139, 1),
fontSize: 32.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
),
),
),
),
),
),
SizedBox(width: 12.w),
Expanded(
child: GestureDetector(
onTap: onDeviceControl,
child: Container(
height: 88.h,
decoration: BoxDecoration(
color: const Color.fromRGBO(200, 208, 220, 1.0),
borderRadius: BorderRadius.circular(20.r),
),
child: Center(
child: Text(
'设备控制',
style: TextStyle(
color: const Color.fromRGBO(100, 116, 139, 1.0),
fontSize: 32.sp,
fontWeight: FontWeight.bold,
), ),
), ),
), ),
), ),
), ),
), ),
// Expanded(
// child: GestureDetector(
// onTap: onDeviceControl,
// child: Container(
// height: 70.h,
// decoration: BoxDecoration(
// color: const Color.fromRGBO(100, 116, 139, 0.2),
// borderRadius: BorderRadius.circular(16.r),
// ),
// child: Center(
// child: Text(
// '设备控制',
// style: TextStyle(
// color: const Color.fromRGBO(100, 116, 139, 1.0),
// fontSize: 28.sp,
// fontWeight: FontWeight.w500,
// ),
// ),
// ),
// ),
// ),
// ),
], ],
); );
} }
......
...@@ -20,6 +20,7 @@ class RoomDeviceStatusCard extends StatelessWidget { ...@@ -20,6 +20,7 @@ class RoomDeviceStatusCard extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h), padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 20.h,
children: [ children: [
Text( Text(
'房间设备状态', '房间设备状态',
...@@ -29,7 +30,6 @@ class RoomDeviceStatusCard extends StatelessWidget { ...@@ -29,7 +30,6 @@ class RoomDeviceStatusCard extends StatelessWidget {
color: const Color.fromRGBO(10, 13, 20, 1.0), color: const Color.fromRGBO(10, 13, 20, 1.0),
), ),
), ),
SizedBox(height: 20.h),
GridView.builder( GridView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
...@@ -37,7 +37,7 @@ class RoomDeviceStatusCard extends StatelessWidget { ...@@ -37,7 +37,7 @@ class RoomDeviceStatusCard extends StatelessWidget {
crossAxisCount: 2, crossAxisCount: 2,
crossAxisSpacing: 16.w, crossAxisSpacing: 16.w,
mainAxisSpacing: 16.h, mainAxisSpacing: 16.h,
childAspectRatio: 2, childAspectRatio: 2.5,
), ),
itemCount: devices.length, itemCount: devices.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
...@@ -47,18 +47,20 @@ class RoomDeviceStatusCard extends StatelessWidget { ...@@ -47,18 +47,20 @@ class RoomDeviceStatusCard extends StatelessWidget {
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(28.r), borderRadius: BorderRadius.circular(28.r),
), ),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.h), padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8.h,
children: [ children: [
Row( Row(
spacing: 8.w,
children: [ children: [
Icon( Icon(
device.icon, device.icon,
color: const Color.fromRGBO(66, 165, 245, 1.0), color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 36.sp, size: 36.sp,
), ),
SizedBox(width: 8.w),
Text( Text(
device.name, device.name,
style: TextStyle( style: TextStyle(
...@@ -69,7 +71,6 @@ class RoomDeviceStatusCard extends StatelessWidget { ...@@ -69,7 +71,6 @@ class RoomDeviceStatusCard extends StatelessWidget {
), ),
], ],
), ),
SizedBox(height: 12.h),
if (device.statusText != null) if (device.statusText != null)
Text( Text(
device.statusText!, device.statusText!,
......
...@@ -24,12 +24,13 @@ class RoomOverviewCard extends StatelessWidget { ...@@ -24,12 +24,13 @@ class RoomOverviewCard extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h), padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 24.h,
children: [ children: [
Row( Row(
children: [ children: [
Container( Container(
width: 88.w, width: 64.w,
height: 88.h, height: 53.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color.fromRGBO(235, 244, 255, 1.0), color: const Color.fromRGBO(235, 244, 255, 1.0),
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
...@@ -41,34 +42,24 @@ class RoomOverviewCard extends StatelessWidget { ...@@ -41,34 +42,24 @@ class RoomOverviewCard extends StatelessWidget {
), ),
), ),
SizedBox(width: 20.w), SizedBox(width: 20.w),
Column( Text(
crossAxisAlignment: CrossAxisAlignment.start, roomNumber,
children: [ style: TextStyle(
Row( fontSize: 36.sp,
children: [ fontWeight: FontWeight.bold,
Text( color: const Color.fromRGBO(10, 13, 20, 1.0),
roomNumber, ),
style: TextStyle( ),
fontSize: 36.sp, SizedBox(width: 12.w),
fontWeight: FontWeight.bold, Text(
color: const Color.fromRGBO(10, 13, 20, 1.0), roomStatus,
), style: TextStyle(
), fontSize: 28.sp,
SizedBox(width: 12.w), color: const Color.fromRGBO(66, 165, 245, 1.0),
Text( ),
roomStatus,
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(66, 165, 245, 1.0),
),
),
],
),
],
), ),
], ],
), ),
SizedBox(height: 24.h),
Wrap( Wrap(
spacing: 8.w, spacing: 8.w,
children: statusTags.map((tag) { children: statusTags.map((tag) {
...@@ -80,13 +71,13 @@ class RoomOverviewCard extends StatelessWidget { ...@@ -80,13 +71,13 @@ class RoomOverviewCard extends StatelessWidget {
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
spacing: 4.w,
children: [ children: [
Icon( Icon(
Icons.check, Icons.check,
color: const Color.fromRGBO(26, 188, 156, 1.0), color: const Color.fromRGBO(26, 188, 156, 1.0),
size: 20.sp, size: 20.sp,
), ),
SizedBox(width: 4.w),
Text( Text(
_getTagLabel(tag), _getTagLabel(tag),
style: TextStyle( style: TextStyle(
......
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