Commit 4794c6da authored by 张宏's avatar 张宏

.

parent f3f8e77a
......@@ -14,12 +14,13 @@ class AppRouter extends $AppRouter {
page: DefaultLayoutRoute.page,
children: [
AutoRoute(page: HomeRoute.page, initial: true),
AutoRoute(page: NewsRoute.page),
AutoRoute(page: ServiceIndexRoute.page),
AutoRoute(page: MessageRoute.page),
AutoRoute(page: ProfileRoute.page),
],
),
AutoRoute(page: SearchRoute.page),
AutoRoute(page: AbnormalDetailRoute.page),
AutoRoute(page:DeviceDetailRoute.page),
];
}
......@@ -8,61 +8,63 @@
// coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:auto_route/auto_route.dart' as _i9;
import 'package:flutter/material.dart' as _i10;
import 'package:auto_route/auto_route.dart' as _i10;
import 'package:flutter/material.dart' as _i11;
import 'package:smart_hotel_app/views/home/abnormal/abnormal_detail_view.dart'
as _i1;
import 'package:smart_hotel_app/views/home/index/index_view.dart' as _i3;
import 'package:smart_hotel_app/views/home/device/device_detail_view.dart'
as _i3;
import 'package:smart_hotel_app/views/home/index/index_view.dart' as _i4;
import 'package:smart_hotel_app/views/layout/default_view.dart' as _i2;
import 'package:smart_hotel_app/views/login/login_view.dart' as _i4;
import 'package:smart_hotel_app/views/message/index_view.dart' as _i5;
import 'package:smart_hotel_app/views/news/index_view.dart' as _i6;
import 'package:smart_hotel_app/views/login/login_view.dart' as _i5;
import 'package:smart_hotel_app/views/message/index_view.dart' as _i6;
import 'package:smart_hotel_app/views/profile/index_view.dart' as _i7;
import 'package:smart_hotel_app/views/search/index_view.dart' as _i8;
import 'package:smart_hotel_app/views/service/index/index_view.dart' as _i9;
abstract class $AppRouter extends _i9.RootStackRouter {
abstract class $AppRouter extends _i10.RootStackRouter {
$AppRouter({super.navigatorKey});
@override
final Map<String, _i9.PageFactory> pagesMap = {
final Map<String, _i10.PageFactory> pagesMap = {
AbnormalDetailRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i1.AbnormalDetailView(),
);
},
DefaultLayoutRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i2.DefaultLayoutView(),
);
},
HomeRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
DeviceDetailRoute.name: (routeData) {
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i3.HomeView(),
child: const _i3.DeviceDetailView(),
);
},
LoginRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
HomeRoute.name: (routeData) {
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i4.LoginView(),
child: const _i4.HomeView(),
);
},
MessageRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
LoginRoute.name: (routeData) {
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i5.MessageView(),
child: const _i5.LoginView(),
);
},
NewsRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
MessageRoute.name: (routeData) {
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i6.NewsView(),
child: const _i6.MessageView(),
);
},
ProfileRoute.name: (routeData) {
return _i9.AutoRoutePage<dynamic>(
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i7.ProfileView(),
);
......@@ -70,7 +72,7 @@ abstract class $AppRouter extends _i9.RootStackRouter {
SearchRoute.name: (routeData) {
final args = routeData.argsAs<SearchRouteArgs>(
orElse: () => const SearchRouteArgs());
return _i9.AutoRoutePage<dynamic>(
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: _i8.SearchView(
key: args.key,
......@@ -78,13 +80,19 @@ abstract class $AppRouter extends _i9.RootStackRouter {
),
);
},
ServiceIndexRoute.name: (routeData) {
return _i10.AutoRoutePage<dynamic>(
routeData: routeData,
child: const _i9.ServiceIndexView(),
);
},
};
}
/// generated route for
/// [_i1.AbnormalDetailView]
class AbnormalDetailRoute extends _i9.PageRouteInfo<void> {
const AbnormalDetailRoute({List<_i9.PageRouteInfo>? children})
class AbnormalDetailRoute extends _i10.PageRouteInfo<void> {
const AbnormalDetailRoute({List<_i10.PageRouteInfo>? children})
: super(
AbnormalDetailRoute.name,
initialChildren: children,
......@@ -92,13 +100,13 @@ class AbnormalDetailRoute extends _i9.PageRouteInfo<void> {
static const String name = 'AbnormalDetailRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i2.DefaultLayoutView]
class DefaultLayoutRoute extends _i9.PageRouteInfo<void> {
const DefaultLayoutRoute({List<_i9.PageRouteInfo>? children})
class DefaultLayoutRoute extends _i10.PageRouteInfo<void> {
const DefaultLayoutRoute({List<_i10.PageRouteInfo>? children})
: super(
DefaultLayoutRoute.name,
initialChildren: children,
......@@ -106,69 +114,69 @@ class DefaultLayoutRoute extends _i9.PageRouteInfo<void> {
static const String name = 'DefaultLayoutRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i3.HomeView]
class HomeRoute extends _i9.PageRouteInfo<void> {
const HomeRoute({List<_i9.PageRouteInfo>? children})
/// [_i3.DeviceDetailView]
class DeviceDetailRoute extends _i10.PageRouteInfo<void> {
const DeviceDetailRoute({List<_i10.PageRouteInfo>? children})
: super(
HomeRoute.name,
DeviceDetailRoute.name,
initialChildren: children,
);
static const String name = 'HomeRoute';
static const String name = 'DeviceDetailRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i4.LoginView]
class LoginRoute extends _i9.PageRouteInfo<void> {
const LoginRoute({List<_i9.PageRouteInfo>? children})
/// [_i4.HomeView]
class HomeRoute extends _i10.PageRouteInfo<void> {
const HomeRoute({List<_i10.PageRouteInfo>? children})
: super(
LoginRoute.name,
HomeRoute.name,
initialChildren: children,
);
static const String name = 'LoginRoute';
static const String name = 'HomeRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i5.MessageView]
class MessageRoute extends _i9.PageRouteInfo<void> {
const MessageRoute({List<_i9.PageRouteInfo>? children})
/// [_i5.LoginView]
class LoginRoute extends _i10.PageRouteInfo<void> {
const LoginRoute({List<_i10.PageRouteInfo>? children})
: super(
MessageRoute.name,
LoginRoute.name,
initialChildren: children,
);
static const String name = 'MessageRoute';
static const String name = 'LoginRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i6.NewsView]
class NewsRoute extends _i9.PageRouteInfo<void> {
const NewsRoute({List<_i9.PageRouteInfo>? children})
/// [_i6.MessageView]
class MessageRoute extends _i10.PageRouteInfo<void> {
const MessageRoute({List<_i10.PageRouteInfo>? children})
: super(
NewsRoute.name,
MessageRoute.name,
initialChildren: children,
);
static const String name = 'NewsRoute';
static const String name = 'MessageRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i7.ProfileView]
class ProfileRoute extends _i9.PageRouteInfo<void> {
const ProfileRoute({List<_i9.PageRouteInfo>? children})
class ProfileRoute extends _i10.PageRouteInfo<void> {
const ProfileRoute({List<_i10.PageRouteInfo>? children})
: super(
ProfileRoute.name,
initialChildren: children,
......@@ -176,16 +184,16 @@ class ProfileRoute extends _i9.PageRouteInfo<void> {
static const String name = 'ProfileRoute';
static const _i9.PageInfo<void> page = _i9.PageInfo<void>(name);
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
/// generated route for
/// [_i8.SearchView]
class SearchRoute extends _i9.PageRouteInfo<SearchRouteArgs> {
class SearchRoute extends _i10.PageRouteInfo<SearchRouteArgs> {
SearchRoute({
_i10.Key? key,
_i11.Key? key,
String? searchKey,
List<_i9.PageRouteInfo>? children,
List<_i10.PageRouteInfo>? children,
}) : super(
SearchRoute.name,
args: SearchRouteArgs(
......@@ -197,8 +205,8 @@ class SearchRoute extends _i9.PageRouteInfo<SearchRouteArgs> {
static const String name = 'SearchRoute';
static const _i9.PageInfo<SearchRouteArgs> page =
_i9.PageInfo<SearchRouteArgs>(name);
static const _i10.PageInfo<SearchRouteArgs> page =
_i10.PageInfo<SearchRouteArgs>(name);
}
class SearchRouteArgs {
......@@ -207,7 +215,7 @@ class SearchRouteArgs {
this.searchKey,
});
final _i10.Key? key;
final _i11.Key? key;
final String? searchKey;
......@@ -216,3 +224,17 @@ class SearchRouteArgs {
return 'SearchRouteArgs{key: $key, searchKey: $searchKey}';
}
}
/// generated route for
/// [_i9.ServiceIndexView]
class ServiceIndexRoute extends _i10.PageRouteInfo<void> {
const ServiceIndexRoute({List<_i10.PageRouteInfo>? children})
: super(
ServiceIndexRoute.name,
initialChildren: children,
);
static const String name = 'ServiceIndexRoute';
static const _i10.PageInfo<void> page = _i10.PageInfo<void>(name);
}
......@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/views/home/abnormal/child/alarm_info_block.dart';
import 'package:smart_hotel_app/views/home/abnormal/child/temperature_block.dart';
import 'package:smart_hotel_app/views/home/abnormal/child/temperature_char_block.dart';
import 'package:smart_hotel_app/views/home/abnormal/controller.dart';
@RoutePage()
class AbnormalDetailView extends StatefulWidget {
......@@ -14,10 +15,37 @@ class AbnormalDetailView extends StatefulWidget {
}
class _AbnormalDetailViewState extends State<AbnormalDetailView> {
late final HomeAbnormalController _controller;
@override
void initState() {
super.initState();
_controller = HomeAbnormalController(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(15, 23, 42, 1),
appBar: AppBar(
backgroundColor: Color.fromRGBO(15, 23, 42, 1),
elevation: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
context.popRoute();
},
),
title: Text(
'告警详情',
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
),
centerTitle: true,
),
body: SingleChildScrollView(
child: Column(
children: [
......@@ -80,38 +108,36 @@ class _AbnormalDetailViewState extends State<AbnormalDetailView> {
borderRadius: BorderRadius.circular(15.r),
),
),
onPressed: () {
print("转派工单");
},
onPressed: _controller.navigateToDeviceDetail,
child: Text(
"转派工单",
"查看关联设备 →",
style: TextStyle(fontSize: 16.sp, color: Colors.white),
),
),
),
],
),
SizedBox(height: 10.h),
Container(
width: double.infinity,
height: 55.h,
decoration: BoxDecoration(
color: Color.fromRGBO(30, 41, 59, 1),
borderRadius: BorderRadius.circular(15.r),
),
child: TextButton(
onPressed: () {
print("查看关联设备");
},
child: Text(
"查看关联设备 →",
style: TextStyle(
fontSize: 16.sp,
color: Colors.grey,
),
),
),
),
// SizedBox(height: 10.h),
// Container(
// width: double.infinity,
// height: 55.h,
// decoration: BoxDecoration(
// color: Color.fromRGBO(30, 41, 59, 1),
// borderRadius: BorderRadius.circular(15.r),
// ),
// child: TextButton(
// onPressed: () {
// print("查看关联设备");
// },
// child: Text(
// "查看关联设备 →",
// style: TextStyle(
// fontSize: 16.sp,
// color: Colors.grey,
// ),
// ),
// ),
// ),
],
),
);
......
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';
class HomeAbnormalController {
final BuildContext context;
HomeAbnormalController(this.context);
void navigateToDeviceDetail() {
context.pushRoute(const DeviceDetailRoute());
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class DeviceParmsBlock extends StatefulWidget {
const DeviceParmsBlock({super.key});
@override
State<DeviceParmsBlock> createState() => _DeviceParmsBlockState();
}
class _DeviceParmsBlockState extends State<DeviceParmsBlock> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h, left: 20.w, right: 20.w),
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
color: Color.fromRGBO(30, 41, 59, 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'实时参数',
style: TextStyle(
fontSize: 18.sp,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 15.h),
Row(
children: [
Expanded(
child: _buildParamCard('220V', '电压'),
),
SizedBox(width: 12.w),
Expanded(
child: _buildParamCard('2.36A', '电流'),
),
],
),
SizedBox(height: 12.h),
Row(
children: [
Expanded(
child: _buildParamCard('520W', '有功功率', isGreen: true),
),
SizedBox(width: 12.w),
Expanded(
child: _buildParamCard('38°C', '设备温度'),
),
],
),
],
),
);
}
Widget _buildParamCard(String value, String label, {bool isGreen = false}) {
return Container(
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.r),
color: Color.fromRGBO(45, 55, 72, 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
value,
style: TextStyle(
fontSize: 28.sp,
color: isGreen ? Color.fromRGBO(34, 197, 94, 1) : Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 8.h),
Text(
label,
style: TextStyle(
fontSize: 15.sp,
color: Colors.grey,
),
),
],
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fl_chart/fl_chart.dart';
class PowerCharBlock extends StatefulWidget {
const PowerCharBlock({super.key});
@override
State<PowerCharBlock> createState() => _PowerCharBlockState();
}
class _PowerCharBlockState extends State<PowerCharBlock> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h, left: 20.w, right: 20.w),
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
color: Color.fromRGBO(30, 41, 59, 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'24h 功率趋势',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
color: Color.fromRGBO(45, 55, 72, 1),
),
child: Row(
children: [
_buildTab('功率', 0),
_buildTab('温度', 1),
],
),
),
],
),
SizedBox(height: 20.h),
Container(
height: 200.h,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: 100,
minY: 0,
groupsSpace: 8,
barTouchData: BarTouchData(enabled: false),
titlesData: FlTitlesData(
show: true,
rightTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
leftTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
bottomTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
),
borderData: FlBorderData(show: false),
barGroups: _buildBarGroups(_selectedIndex),
),
),
),
],
),
);
}
Widget _buildTab(String title, int index) {
final isSelected = _selectedIndex == index;
return GestureDetector(
onTap: () {
setState(() {
_selectedIndex = index;
});
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
color: isSelected ? Color.fromRGBO(59, 130, 246, 1) : Colors.transparent,
),
child: Text(
title,
style: TextStyle(
fontSize: 14.sp,
color: isSelected ? Colors.white : Colors.grey,
),
),
),
);
}
List<BarChartGroupData> _buildBarGroups(int index) {
final powerData = [30, 45, 55, 65, 75, 80, 70, 60, 45, 30, 25];
final tempData = [25, 28, 30, 32, 35, 38, 36, 34, 32, 29, 26];
final data = index == 0 ? powerData : tempData;
final Color mainColor = index == 0
? Color.fromRGBO(59, 130, 246, 1)
: Color.fromRGBO(246, 158, 11, 1.0);
final Color highlightColor = index == 0
? Color.fromRGBO(34, 197, 94, 1)
: Color.fromRGBO(239, 68, 68, 1);
return List.generate(
data.length,
(i) => BarChartGroupData(
x: i,
barRods: [
BarChartRodData(
toY: data[i].toDouble(),
color: i == 5 ? highlightColor : mainColor,
width: 20.w,
borderRadius: BorderRadius.vertical(top: Radius.circular(4.r)),
),
],
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class StateInfoBlock extends StatelessWidget {
const StateInfoBlock({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h, left: 20.w, right: 20.w),
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
color: Color.fromRGBO(30, 41, 59, 1),
),
child: Row(
children: [
Container(
width: 70.w,
height: 70.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
color: Color.fromRGBO(51, 65, 85, 1),
),
child: Icon(
Icons.power,
color: Color.fromRGBO(59, 130, 246, 1),
size: 32.sp,
),
),
SizedBox(width: 20.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'客房 305 智能空开',
style: TextStyle(
fontSize: 18.sp,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 8.h),
Text(
'A-305 · 位置:3楼客房区',
style: TextStyle(
fontSize: 15.sp,
color: Colors.grey,
),
),
],
),
),
Text(
'在线',
style: TextStyle(
fontSize: 16.sp,
color: Color.fromRGBO(34, 197, 94, 1),
fontWeight: FontWeight.bold,
),
),
],
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
class HomeDeviceController {
final BuildContext context;
HomeDeviceController(this.context);
void remotePowerOn() {
// 远程送电
}
void remotePowerOff() {
// 远程断电
}
}
\ No newline at end of file
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/views/home/device/child/device_parms_block.dart';
import 'package:smart_hotel_app/views/home/device/child/power_char_block.dart';
import 'package:smart_hotel_app/views/home/device/child/state_info_block.dart';
import 'package:smart_hotel_app/views/home/device/controller.dart';
@RoutePage()
class DeviceDetailView extends StatefulWidget {
const DeviceDetailView({super.key});
@override
State<DeviceDetailView> createState() => _DeviceDetailViewState();
}
class _DeviceDetailViewState extends State<DeviceDetailView> {
late final HomeDeviceController _controller;
@override
void initState() {
super.initState();
_controller = HomeDeviceController(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(15, 23, 42, 1),
appBar: AppBar(
backgroundColor: Color.fromRGBO(15, 23, 42, 1),
elevation: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
context.popRoute();
},
),
title: Text(
'设备详情',
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
),
centerTitle: true,
),
body: SingleChildScrollView(
child: Column(
children: [
StateInfoBlock(),
SizedBox(height: 10.h),
DeviceParmsBlock(),
SizedBox(height: 10.h),
PowerCharBlock(),
SizedBox(height: 120.h),
],
),
),
bottomNavigationBar: _buildBottomButtons(),
);
}
Widget _buildBottomButtons() {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 15.h),
decoration: BoxDecoration(
color: Color.fromRGBO(15, 23, 42, 1),
border: Border(
top: BorderSide(
color: Color.fromRGBO(30, 41, 59, 1),
width: 1.w,
),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Expanded(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Color.fromRGBO(34, 197, 94, 1),
minimumSize: Size(double.infinity, 55.h),
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.r),
),
),
onPressed: _controller.remotePowerOn,
child: Text(
"远程送电",
style: TextStyle(fontSize: 16.sp, color: Colors.white, fontWeight: FontWeight.bold),
),
),
),
SizedBox(width: 12.w),
Expanded(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Color.fromRGBO(239, 68, 68, 1),
minimumSize: Size(double.infinity, 55.h),
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.r),
),
),
onPressed: _controller.remotePowerOff,
child: Text(
"远程断电",
style: TextStyle(fontSize: 16.sp, color: Colors.white, fontWeight: FontWeight.bold),
),
),
),
],
),
],
),
);
}
}
\ No newline at end of file
......@@ -10,10 +10,16 @@ class VoltageOperateBlock extends StatefulWidget {
}
class _VoltageOperateBlockState extends State<VoltageOperateBlock> {
final HomeIndexController _controller = HomeIndexController();
late final HomeIndexController _controller;
@override
Widget build(BuildContext context) {
void initState() {
super.initState();
_controller = HomeIndexController(context);
}
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
// height: 280.h,
......@@ -133,7 +139,7 @@ class _VoltageOperateBlockState extends State<VoltageOperateBlock> {
),
),
onPressed: () {
_controller.handleToAbnormalDetail(context);
_controller.handleToAbnormalDetail();
},
child: Text("查看详情",style: TextStyle(fontSize: 14.sp,color: Colors.white),),
),
......
......@@ -4,10 +4,10 @@ import 'package:flutter/material.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';
class HomeIndexController {
// final AppRouter _appRouter = AppRouter();
HomeIndexController();
final BuildContext context;
HomeIndexController(this.context);
void handleToAbnormalDetail(BuildContext context) {
context.router.push(const AbnormalDetailRoute());
void handleToAbnormalDetail() {
context.pushRoute(const AbnormalDetailRoute());
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ class _HomeViewState extends State<HomeView> {
@override
void initState() {
super.initState();
_controller = HomeIndexController();
_controller = HomeIndexController(context);
}
@override
......
......@@ -14,7 +14,7 @@ class _DefaultLayoutViewState extends State<DefaultLayoutView> {
@override
Widget build(BuildContext context) {
return AutoTabsScaffold(
routes: const [HomeRoute(), NewsRoute(), MessageRoute(), ProfileRoute()],
routes: const [HomeRoute(), ServiceIndexRoute(), MessageRoute(), ProfileRoute()],
transitionBuilder: (context, child, animation) => child,
bottomNavigationBuilder: (context, tabsRouter) {
return Container(
......
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
@RoutePage()
class NewsView extends StatefulWidget {
const NewsView({super.key});
@override
State<NewsView> createState() => _NewsViewState();
}
class _NewsViewState extends State<NewsView> {
@override
Widget build(BuildContext context) {
return const Center(
child: Text('NewsView'),
);
}
}
This diff is collapsed.
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ServiceHeadBlock extends StatefulWidget {
const ServiceHeadBlock({super.key});
@override
State<ServiceHeadBlock> createState() => _ServiceHeadBlockState();
}
class _ServiceHeadBlockState extends State<ServiceHeadBlock> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 140.h,
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight, left: 20.w, right: 20.w),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(30, 41, 59, 1),
width: 1.w,
),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 4.w,
height: 20.h,
decoration: BoxDecoration(
color: Color.fromRGBO(239, 68, 68, 1),
borderRadius: BorderRadius.circular(2.r),
),
),
SizedBox(width: 10.w),
Text(
'客房服务看板',
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
SizedBox(height: 8.h),
Text(
'服务员视角 · 2条待响应需求',
style: TextStyle(
fontSize: 16.sp,
color: Color.fromRGBO(61, 79, 106, 1.0),
),
),
],
),
Container(
width: 50.w,
height: 50.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
color: Color.fromRGBO(51, 65, 85, 1),
border: Border.all(
color: Color.fromRGBO(71, 85, 105, 1),
width: 1.w,
),
),
child: Icon(
Icons.person,
color: Colors.white,
size: 24.sp,
),
),
],
),
],
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ServiceStatsBlock extends StatefulWidget {
const ServiceStatsBlock({super.key});
@override
State<ServiceStatsBlock> createState() => _ServiceStatsBlockState();
}
class _ServiceStatsBlockState extends State<ServiceStatsBlock> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h),
child: Row(
children: [
Expanded(
child: _buildStatCard(
'2',
'待响应',
Color.fromRGBO(59, 130, 246, 1),
),
),
SizedBox(width: 12.w),
Expanded(
child: _buildStatCard(
'45',
'入住中',
Color.fromRGBO(34, 197, 94, 1),
),
),
SizedBox(width: 12.w),
Expanded(
child: _buildStatCard(
'7',
'空闲可清洁',
Colors.white,
),
),
],
),
);
}
Widget _buildStatCard(String value, String label, Color valueColor) {
return Container(
padding: EdgeInsets.symmetric(vertical: 20.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
color: Color.fromRGBO(30, 41, 59, 1),
),
child: Column(
children: [
Text(
value,
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.bold,
color: valueColor,
),
),
SizedBox(height: 8.h),
Text(
label,
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey,
),
),
],
),
);
}
}
import 'dart:math';
import 'package:flutter/material.dart';
class ServiceIndexController {
final BuildContext context;
ServiceIndexController(this.context);
int getPendingCount() {
// 获取待响应需求数量
return 2;
}
int getOccupiedRooms() {
// 获取入住中房间数
return 45;
}
int getVacantRooms() {
// 获取空闲可清洁房间数
return 7;
}
List<String> getFloors() {
// 获取楼层列表
return ['1楼', '2楼', '3楼', '4楼', '5楼', '6楼'];
}
List<Map<String, dynamic>> getRoomsByFloor(String floor) {
// 根据楼层获取房间列表
final roomData = {
'1楼': _generateRooms(1, 40),
'2楼': _generateRooms(2, Random().nextInt(41) + 10),
'3楼': _generateRooms(3, Random().nextInt(41) + 10),
'4楼': _generateRooms(4, Random().nextInt(41) + 10),
'5楼': _generateRooms(5, Random().nextInt(5) + 10),
'6楼': _generateRooms(6, Random().nextInt(41) + 10),
};
return roomData[floor] ?? [];
}
List<Map<String, dynamic>> _generateRooms(int floor, int count) {
final statuses = ['空闲', '入住', '待清洁'];
final List<Map<String, dynamic>> rooms = [];
for (int i = 1; i <= count; i++) {
final roomNum = floor * 100 + i;
// 随机分配状态,但保持一定比例
final statusIndex = (roomNum % 3);
rooms.add({
'number': roomNum.toString(),
'status': statuses[statusIndex],
});
}
return rooms;
}
void powerOnRoom(String roomNumber) {
// 房间送电
print('给 $roomNumber 号房送电');
}
void powerOffRoom(String roomNumber) {
// 房间断电
print('给 $roomNumber 号房断电');
}
void viewRoom(String roomNumber) {
// 查看房间详情
print('查看 $roomNumber 号房详情');
}
}
\ No newline at end of file
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/views/service/index/child/service_head_block.dart';
import 'package:smart_hotel_app/views/service/index/child/service_stats_block.dart';
import 'package:smart_hotel_app/views/service/index/child/room_management_block.dart';
import 'package:smart_hotel_app/views/service/index/controller.dart';
@RoutePage()
class ServiceIndexView extends StatefulWidget {
const ServiceIndexView({super.key});
@override
State<ServiceIndexView> createState() => _ServiceIndexViewState();
}
class _ServiceIndexViewState extends State<ServiceIndexView> {
late final ServiceIndexController _controller;
@override
void initState() {
super.initState();
_controller = ServiceIndexController(context);
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: Container(
width: double.infinity,
color: Color.fromRGBO(15, 23, 42, 1),
child: Column(
children: [
ServiceHeadBlock(),
ServiceStatsBlock(),
SizedBox(height: 10.h),
RoomManagementBlock(controller: _controller),
SizedBox(height: 10.h),
],
),
),
),
);
},
);
}
}
\ No newline at end of file
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