Commit 5a154d67 authored by huqu's avatar huqu

修改样式 & 告警列表

parent fb8b7110
import java.util.Properties
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
def localProperties = new Properties()
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
localPropertiesFile.withInputStream { localProperties.load(it) }
}
def mStoreFile = rootProject.file("smart_hotel.jks")
def mStorePassword = localProperties.getProperty("storePassword")
def mKeyAlias = localProperties.getProperty("keyAlias")
def mKeyPassword = localProperties.getProperty("keyPassword")
def isRelease = mStoreFile.exists()
&& mStorePassword != null
&& mKeyAlias != null
&& mKeyPassword != null
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
......@@ -40,6 +49,17 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}
signingConfigs {
if (isRelease) {
release {
storePassword = mStorePassword
keyAlias = mKeyAlias
keyPassword = mKeyPassword
storeFile = mStoreFile
}
}
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.smart_hotel_app"
......@@ -76,9 +96,20 @@ android {
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
minifyEnabled true
debuggable false
shrinkResources true
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
)
signingConfig = isRelease
? signingConfigs.getByName("release")
: signingConfigs.getByName("debug")
}
debug {
signingConfig = signingConfigs.getByName("debug")
minifyEnabled false
}
}
......@@ -98,4 +129,4 @@ flutter {
source '../..'
}
dependencies {}
dependencies {}
\ No newline at end of file
......@@ -83,7 +83,7 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Size(750, 1334),
designSize: const Size(750, 1334),//figma ui size: 375 * 812,倍率:2:1.6
builder: (context, child) {
return MultiBlocProvider(
providers: [
......
......@@ -59,17 +59,19 @@ class AlertListItemBO extends Equatable {
final int alertId;
final String alertTitle;
final String alertIcon;
final String deviceLocationText;
final String deviceName;
final String deviceLocation;
final String alertTime;
final String handleTime;
final String alertLevel;
final String alertStatus;
final String alertLevel;//1=中警 3=高警
final String alertStatus;//0=待处理 1=处理中 2=已确认 3=已关闭 4=误报关闭
const AlertListItemBO({
required this.alertId,
required this.alertTitle,
required this.alertIcon,
required this.deviceLocationText,
required this.deviceName,
required this.deviceLocation,
required this.alertTime,
required this.handleTime,
required this.alertLevel,
......@@ -81,7 +83,8 @@ class AlertListItemBO extends Equatable {
alertId: json['alertId'] as int? ?? 0,
alertTitle: json['alertTitle'] as String? ?? '',
alertIcon: json['alertIcon'] as String? ?? '',
deviceLocationText: json['deviceLocationText'] as String? ?? '',
deviceName: json['deviceName'] as String? ?? '',
deviceLocation: json['deviceLocation'] as String? ?? '',
alertTime: json['alertTime'] as String? ?? '',
handleTime: json['handleTime'] as String? ?? '',
alertLevel: json['alertLevel'] as String? ?? '',
......@@ -94,7 +97,8 @@ class AlertListItemBO extends Equatable {
alertId,
alertTitle,
alertIcon,
deviceLocationText,
deviceName,
deviceLocation,
alertTime,
handleTime,
alertLevel,
......
......@@ -12,6 +12,8 @@ import 'package:auto_route/auto_route.dart' as _i21;
import 'package:flutter/material.dart' as _i22;
import 'package:smart_hotel_app/views/home/abnormal/abnormal_detail_view.dart'
as _i1;
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart'
as _i23;
import 'package:smart_hotel_app/views/home/abnormal_list/index_view.dart'
as _i2;
import 'package:smart_hotel_app/views/home/device/device_detail_view.dart'
......@@ -56,6 +58,7 @@ abstract class $AppRouter extends _i21.RootStackRouter {
child: _i1.AbnormalDetailView(
key: args.key,
alertId: args.alertId,
alarmStatus: args.alarmStatus,
),
);
},
......@@ -220,12 +223,14 @@ class AbnormalDetailRoute extends _i21.PageRouteInfo<AbnormalDetailRouteArgs> {
AbnormalDetailRoute({
_i22.Key? key,
required int alertId,
required _i23.AlarmStatus alarmStatus,
List<_i21.PageRouteInfo>? children,
}) : super(
AbnormalDetailRoute.name,
args: AbnormalDetailRouteArgs(
key: key,
alertId: alertId,
alarmStatus: alarmStatus,
),
initialChildren: children,
);
......@@ -240,15 +245,18 @@ class AbnormalDetailRouteArgs {
const AbnormalDetailRouteArgs({
this.key,
required this.alertId,
required this.alarmStatus,
});
final _i22.Key? key;
final int alertId;
final _i23.AlarmStatus alarmStatus;
@override
String toString() {
return 'AbnormalDetailRouteArgs{key: $key, alertId: $alertId}';
return 'AbnormalDetailRouteArgs{key: $key, alertId: $alertId, alarmStatus: $alarmStatus}';
}
}
......
......@@ -10,11 +10,18 @@ import 'package:smart_hotel_app/views/home/abnormal/widget/temperature_block.dar
import 'package:smart_hotel_app/views/home/abnormal/widget/temperature_char_block.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart';
import '../abnormal_list/cubit/abnormal_list_state.dart';
@RoutePage()
class AbnormalDetailView extends StatelessWidget {
final int alertId;
final AlarmStatus alarmStatus;
const AbnormalDetailView({super.key, required this.alertId});
const AbnormalDetailView({
super.key,
required this.alertId,
required this.alarmStatus,
});
@override
Widget build(BuildContext context) {
......@@ -33,11 +40,11 @@ class AbnormalDetailView extends StatelessWidget {
},
),
title: Text(
'告警详情',
'查看告警详情',
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......@@ -91,43 +98,45 @@ class AbnormalDetailView extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BlocBuilder<AbnormalCubit, AbnormalState>(
builder: (context, state) {
final isDisabled = state.isHandling || state.isHandled;
return Container(
width: double.infinity,
height: 88.h,
decoration: BoxDecoration(
color: isDisabled
? const Color.fromRGBO(73, 149, 234, 0.4)
: const Color.fromRGBO(73, 149, 234, 1),
borderRadius: BorderRadius.circular(16.r),
),
child: TextButton(
onPressed: isDisabled
? null
: () => _handleConfirm(context, cubit),
child: state.isHandling
? SizedBox(
width: 32.sp,
height: 32.sp,
child: CircularProgressIndicator(
strokeWidth: 3,
color: const Color.fromRGBO(237, 245, 255, 1),
),
)
: Text(
state.isHandled ? '已处理' : '确认处理',
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(237, 245, 255, 1),
),
),
),
);
},
),
SizedBox(height: 20.h),
if (alarmStatus != AlarmStatus.processed) ...[
BlocBuilder<AbnormalCubit, AbnormalState>(
builder: (context, state) {
final isDisabled = state.isHandling || state.isHandled;
return Container(
width: double.infinity,
height: 88.h,
decoration: BoxDecoration(
color: isDisabled
? const Color.fromRGBO(73, 149, 234, 0.4)
: const Color.fromRGBO(73, 149, 234, 1),
borderRadius: BorderRadius.circular(16.r),
),
child: TextButton(
onPressed: isDisabled
? null
: () => _handleConfirm(context, cubit),
child: state.isHandling
? SizedBox(
width: 32.sp,
height: 32.sp,
child: const CircularProgressIndicator(
strokeWidth: 3,
color: Color.fromRGBO(237, 245, 255, 1),
),
)
: Text(
state.isHandled ? '已处理' : '确认处理',
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(237, 245, 255, 1),
),
),
),
);
},
),
SizedBox(height: 20.h),
],
Container(
width: double.infinity,
height: 88.h,
......
......@@ -39,7 +39,7 @@ class AbnormalCubit extends Cubit<AbnormalState> {
return AlarmInfo(
alarmType: basic.alertTitle,
deviceInfo: basic.alertDeviceLocation,
alarmLevel: basic.alertLevelText,
alertLevelText: basic.alertLevelText,
urgency: _mapUrgency(basic.alertLevel),
currentTemp: info.alertValue,
voltage: '',
......@@ -59,17 +59,18 @@ class AbnormalCubit extends Cubit<AbnormalState> {
return FlSpot(entry.key.toDouble(), entry.value.value);
}).toList(),
alertDeviceId: basic.alertDeviceId,
alertCount: basic.alertCount,
);
}
String _mapUrgency(String level) {
switch (level) {
case 'high':
return '紧急';
case 'medium':
return '一般';
case 'danger':
return '高警';
case 'warning':
return '中警';
default:
return '一般';
return '普通';
}
}
......
......@@ -3,7 +3,7 @@ import 'package:fl_chart/fl_chart.dart';
class AlarmInfo {
final String alarmType;
final String deviceInfo;
final String alarmLevel;
final String alertLevelText;
final String urgency;
final String currentTemp;
final String voltage;
......@@ -21,11 +21,12 @@ class AlarmInfo {
final List<String> temperatureTimes;
final List<FlSpot> temperatureSpots;
final String alertDeviceId;
final int alertCount;
const AlarmInfo({
required this.alarmType,
required this.deviceInfo,
required this.alarmLevel,
required this.alertLevelText,
required this.urgency,
required this.currentTemp,
required this.voltage,
......@@ -43,6 +44,7 @@ class AlarmInfo {
required this.temperatureTimes,
required this.temperatureSpots,
required this.alertDeviceId,
required this.alertCount,
});
}
......
......@@ -33,8 +33,8 @@ class AlarmInfoBlock extends StatelessWidget {
SizedBox(height: 25.h),
_buildInfoRow(
'告警级别',
'${alarmInfo.alarmLevel}(Level 3)',
valueColor: Color.fromRGBO(255, 100, 101, 1),
alarmInfo.alertLevelText,
valueColor: const Color.fromRGBO(255, 100, 101, 1),
),
SizedBox(height: 25.h),
_buildInfoRow('闭值设置', alarmInfo.threshold),
......@@ -44,13 +44,13 @@ class AlarmInfoBlock extends StatelessWidget {
_buildInfoRow(
'峰值记录',
alarmInfo.peak,
valueColor: Color.fromRGBO(250, 204, 21, 1),
valueColor: const Color.fromRGBO(250, 204, 21, 1),
),
SizedBox(height: 25.h),
_buildInfoRow(
'关联联动',
alarmInfo.linkAction,
valueColor: Color.fromRGBO(73, 149, 234, 1),
valueColor: const Color.fromRGBO(73, 149, 234, 1),
),
],
),
......@@ -71,14 +71,14 @@ class AlarmInfoBlock extends StatelessWidget {
label,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(100, 116, 139, 1),
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
Text(
displayValue,
style: TextStyle(
fontSize: 24.sp,
color: valueColor ?? Color.fromRGBO(100, 116, 139, 1),
color: valueColor ?? const Color.fromRGBO(100, 116, 139, 1),
),
),
],
......
......@@ -11,81 +11,108 @@ class TemperatureBlock extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h),
margin: EdgeInsets.only(top: 20.h),
padding: EdgeInsets.all(25.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
color: Colors.white,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
child: Column(
children: [
Container(
width: 64.w,
height: 66.h,
decoration: BoxDecoration(
color: Color.fromRGBO(219, 234, 254, 1),
borderRadius: BorderRadius.circular(15.r),
),
child: Icon(
Icons.thermostat_outlined,
color: Color.fromRGBO(59, 130, 246, 1),
size: 35.sp,
),
),
SizedBox(width: 15.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
alarmInfo.alarmType,
style: TextStyle(
fontSize: 28.sp,
color: Colors.black,
fontWeight: FontWeight.bold,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 70.w,
height: 66.h,
decoration: BoxDecoration(
color: const Color.fromRGBO(219, 234, 254, 1),
borderRadius: BorderRadius.circular(8.r),
),
SizedBox(height: 8.h),
Text(
alarmInfo.deviceInfo,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(100, 116, 139, 1),
),
child: Icon(
Icons.thermostat_outlined,
color: const Color.fromRGBO(59, 130, 246, 1),
size: 40.sp,
),
SizedBox(height: 15.h),
Row(
),
SizedBox(width: 15.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
alarmInfo.alarmType,
style: TextStyle(
fontSize: 28.sp,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
Row(
children: [
Text(
'${alarmInfo.alertLevelText} · ',
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(255, 100, 101, 1),
fontWeight: FontWeight.bold,
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h),
decoration: BoxDecoration(
color: const Color.fromRGBO(255, 158, 159, 0.5),
borderRadius: BorderRadius.circular(16.r),
),
child: Text(
alarmInfo.urgency,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(255, 100, 101, 1),
),
),
),
],
),
],
),
Text(
'${alarmInfo.alarmLevel}·',
alarmInfo.deviceInfo,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(255, 100, 101, 1),
fontWeight: FontWeight.bold,
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h),
decoration: BoxDecoration(
color: Color.fromRGBO(255, 158, 159, 0.5),
borderRadius: BorderRadius.circular(16.r),
),
child: Text(
alarmInfo.urgency,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(255, 100, 101, 1),
),
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
],
),
],
),
),
],
),
SizedBox(height: 5.h),
Row(
children: [
SizedBox(width: 85.w),
Text(
'告警数量:',
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
Text(
alarmInfo.alertCount.toString(),
style: TextStyle(
fontSize: 28.sp,
color: const Color.fromRGBO(255, 100, 101, 1),
),
),
],
),
],
),
)
);
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import 'package:smart_hotel_app/routes/app_router.gr.dart';
import 'package:smart_hotel_app/services/alert_list_service.dart';
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart';
/// AlarmStatus → 告警状态码(API 入参)
/// AlarmStatus → 告警状态码: 0=待处理 1=处理中 2=已确认 3=已关闭 4=误报关闭
String? alarmStatusToApi(AlarmStatus filter) {
switch (filter) {
case AlarmStatus.all:
......@@ -17,7 +17,7 @@ String? alarmStatusToApi(AlarmStatus filter) {
case AlarmStatus.processed:
return '2';
case AlarmStatus.falseAlarm:
return '3';
return '4';
}
}
......@@ -77,6 +77,6 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
void onAlarmItemTap(AlarmItem item, BuildContext context) {
final alertId = int.tryParse(item.id) ?? 0;
context.pushRoute(AbnormalDetailRoute(alertId: alertId));
context.pushRoute(AbnormalDetailRoute(alertId: alertId, alarmStatus: item.status));
}
}
......@@ -28,22 +28,21 @@ class AlarmItem extends Equatable {
return AlarmItem(
id: item.alertId.toString(),
title: item.alertTitle,
deviceInfo: item.deviceLocationText,
alarmTime: item.alertTime,
deviceInfo: '${item.deviceName}·${item.deviceLocation}',
alarmTime: item.alertTime.isEmpty ? '--' : item.alertTime,
processTime: item.handleTime.isEmpty ? '--' : item.handleTime,
status: _mapAlertStatus(item.alertStatus),
level: item.alertLevel,
level: _mapAlertLevel(item.alertLevel),
urgency: '',
);
}
static AlarmStatus _mapAlertStatus(String status) {
switch (status) {
// 0=待处理 1=处理中 2=已确认 3=已关闭 4=误报关闭
static AlarmStatus _mapAlertStatus(String alertStatus) {
switch (alertStatus) {
case '0':
case '1':
return AlarmStatus.pending;
case '2':
case '3':
return AlarmStatus.processed;
case '4':
return AlarmStatus.falseAlarm;
......@@ -52,6 +51,25 @@ class AlarmItem extends Equatable {
}
}
static String _mapAlertLevel(String alertLevel) {
switch (alertLevel) {
case '3':
case 'danger':
return '高警';
case '2':
case 'warning':
return '中警';
case '1':
case 'info':
return '普通';
default:
return '';
}
}
@override
List<Object?> get props =>
[id, title, deviceInfo, alarmTime, processTime, status, level, urgency];
......
......@@ -82,7 +82,7 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......@@ -95,18 +95,13 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> {
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 28.w),
child: Column(
children: [
FilterTabBlock(
currentFilter: state.currentFilter,
onFilterChanged: cubit.setFilter,
allCount: state.allCount,
pendingCount: state.pendingCount,
processedCount: state.processedCount,
falseAlarmCount: state.falseAlarmCount,
),
SizedBox(height: 10.h),
],
child: FilterTabBlock(
currentFilter: state.currentFilter,
onFilterChanged: cubit.setFilter,
allCount: state.allCount,
pendingCount: state.pendingCount,
processedCount: state.processedCount,
falseAlarmCount: state.falseAlarmCount,
),
),
),
......@@ -115,8 +110,7 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> {
sliver: PagedSliverList<int, AlarmItem>(
state: pagingState,
fetchNextPage: fetchNextPage,
builderDelegate:
PagedChildBuilderDelegate<AlarmItem>(
builderDelegate: PagedChildBuilderDelegate<AlarmItem>(
firstPageErrorIndicatorBuilder: (_) => Center(
child: Column(
mainAxisSize: MainAxisSize.min,
......@@ -179,8 +173,7 @@ class _AbnormalListBodyState extends State<_AbnormalListBody> {
itemBuilder: (_, item, __) {
return AlarmListItem(
item: item,
onTap: (i) =>
cubit.onAlarmItemTap(i, context),
onTap: (i) => cubit.onAlarmItemTap(i, context),
);
},
),
......
......@@ -35,12 +35,24 @@ class AlarmListItem extends StatelessWidget {
children: [
_buildTitleRow(),
SizedBox(height: 15.h),
Text(
item.deviceInfo,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item.deviceInfo,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
Text(
item.level,
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(255, 100, 101, 1),
),
),
],
),
SizedBox(height: 10.h),
Text(
......@@ -73,7 +85,7 @@ class AlarmListItem extends StatelessWidget {
height: 96.w,
decoration: BoxDecoration(
color: const Color.fromRGBO(237, 245, 255, 1),
borderRadius: BorderRadius.circular(16.r),
borderRadius: BorderRadius.circular(8.r),
),
child: Icon(
Icons.thermostat,
......@@ -95,15 +107,16 @@ class AlarmListItem extends StatelessWidget {
fontWeight: FontWeight.bold,
),
),
Row(
children: [
_buildStatusBadge(),
SizedBox(width: 12.w),
_buildLevelBadge(),
SizedBox(width: 8.w),
_buildUrgencyBadge(),
],
),
_buildStatusBadge(),
// Row(
// children: [
// _buildStatusBadge(),
// SizedBox(width: 12.w),
// _buildLevelBadge(),
// SizedBox(width: 8.w),
// _buildUrgencyBadge(),
// ],
// ),
],
);
}
......@@ -116,7 +129,7 @@ class AlarmListItem extends StatelessWidget {
switch (item.status) {
case AlarmStatus.pending:
bgColor = const Color.fromRGBO(250, 204, 21, 0.15);
bgColor = const Color.fromRGBO(254, 247, 217, 1);
textColor = const Color.fromRGBO(250, 204, 21, 1);
text = '待处理';
icon = Icons.error_outline;
......@@ -134,29 +147,28 @@ class AlarmListItem extends StatelessWidget {
icon = Icons.cancel_outlined;
break;
default:
bgColor = const Color.fromRGBO(100, 116, 139, 0.15);
bgColor = const Color.fromRGBO(100, 116, 139, 0.0);//完全透明
textColor = const Color.fromRGBO(100, 116, 139, 1);
text = '';
}
return Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 4.h),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(12.r),
borderRadius: BorderRadius.circular(40.r),
),
child: Row(
mainAxisSize: MainAxisSize.min,
spacing: 6.w,
children: [
if (icon != null) ...[
Icon(icon, size: 20.w, color: textColor),
SizedBox(width: 6.w),
],
Icon(icon, size: 30.w, color: textColor),
Text(
text,
style: TextStyle(
fontSize: 22.sp,
fontSize: 24.sp,
color: textColor,
fontWeight: FontWeight.w500,
),
),
],
......
......@@ -24,7 +24,7 @@ class FilterTabBlock extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h),
margin: EdgeInsets.only(top: 20.h),
child: Row(
children: [
_buildTab('全部', AlarmStatus.all, allCount),
......@@ -48,9 +48,14 @@ class FilterTabBlock extends StatelessWidget {
height: 72.h,
decoration: BoxDecoration(
color: isSelected
? const Color.fromRGBO(73, 149, 234, 1)
: const Color.fromRGBO(100, 116, 139, 0.1),
? const Color(0x334995EA)
: const Color(0xFFFFFFFF),
borderRadius: BorderRadius.circular(16.r),
border: isSelected ? Border.all(
color: const Color(0x804995EA),
width: 1.w,
style: BorderStyle.solid,
) : null
),
alignment: Alignment.center,
child: Row(
......@@ -59,24 +64,25 @@ class FilterTabBlock extends StatelessWidget {
Text(
label,
style: TextStyle(
fontSize: 26.sp,
fontSize: 28.sp,
color: isSelected
? Colors.white
: const Color.fromRGBO(100, 116, 139, 1),
? const Color(0xFF4995EA)
: const Color(0xFF64748B),
fontWeight: FontWeight.w500,
),
),
if (count > 0) ...[
SizedBox(width: 6.w),
Text(
'$count',
style: TextStyle(
fontSize: 22.sp,
color: isSelected
? Colors.white
: const Color.fromRGBO(100, 116, 139, 0.8),
),
),
],
// if (count > 0) ...[
// SizedBox(width: 6.w),
// Text(
// '$count',
// style: TextStyle(
// fontSize: 26.sp,
// color: isSelected
// ? Colors.white
// : const Color.fromRGBO(100, 116, 139, 0.8),
// ),
// ),
// ],
],
),
),
......
......@@ -44,7 +44,7 @@ class DeviceDetailView extends StatelessWidget {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......
......@@ -11,7 +11,7 @@ class StateInfoBlock extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10.h),
margin: EdgeInsets.only(top: 20.h),
padding: EdgeInsets.all(25.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.r),
......@@ -20,15 +20,15 @@ class StateInfoBlock extends StatelessWidget {
child: Row(
children: [
Container(
width: 70.w,
width: 80.w,
height: 70.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.r),
color: Color.fromRGBO(219, 234, 254, 1),
color: const Color.fromRGBO(219, 234, 254, 1),
),
child: Icon(
Icons.power,
color: Color.fromRGBO(59, 130, 246, 1),
color: const Color.fromRGBO(59, 130, 246, 1),
size: 32.sp,
),
),
......@@ -47,10 +47,10 @@ class StateInfoBlock extends StatelessWidget {
),
SizedBox(height: 8.h),
Text(
'${deviceInfo.deviceId}·位置: ${deviceInfo.location}',
deviceInfo.location,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(100, 116, 139, 1),
color: const Color.fromRGBO(100, 116, 139, 1),
),
),
],
......@@ -60,7 +60,7 @@ class StateInfoBlock extends StatelessWidget {
deviceInfo.status,
style: TextStyle(
fontSize: 24.sp,
color: Color.fromRGBO(20, 184, 166, 1),
color: const Color.fromRGBO(20, 184, 166, 1),
fontWeight: FontWeight.bold,
),
),
......
......@@ -5,6 +5,7 @@ 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/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/index/cubit/home_index_cubit.dart';
import 'package:smart_hotel_app/utils/toast_utils.dart';
......@@ -140,7 +141,7 @@ class VoltageOperateBlock extends StatelessWidget {
Expanded(
child: GestureDetector(
onTap: () {
context.pushRoute(AbnormalDetailRoute(alertId: alertId));
context.pushRoute(AbnormalDetailRoute(alertId: alertId, alarmStatus: AlarmStatus.pending));
},
child: Container(
height: 88.h,
......
......@@ -184,7 +184,7 @@ class _InspectionDetailBodyState extends State<_InspectionDetailBody> {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......
......@@ -51,7 +51,7 @@ class InspectionDeviceView extends StatelessWidget {
style: TextStyle(
color: const Color.fromRGBO(100, 116, 139, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
Icon(
......
......@@ -87,7 +87,7 @@ class _InspectionHistoryBodyState extends State<_InspectionHistoryBody> {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:smart_hotel_app/models/bo/user_info_bo.dart';
import 'package:smart_hotel_app/views/profile/index/cubit/profile_state.dart';
class ProfileCubit extends Cubit<ProfileState> {
ProfileCubit() : super(const ProfileState()) {
final UserInfoBO? _userInfo;
ProfileCubit({UserInfoBO? userInfo})
: _userInfo = userInfo,
super(const ProfileState()) {
initData();
}
void initData() {
emit(state.copyWith(
username: '15391514233',
username: _userInfo?.phonenumber ?? '',
welcomeText: '欢迎来到智能酒店',
menuList: [
const MenuItem(icon: Icons.list, title: '设备列表'),
const MenuItem(icon: Icons.warning_rounded, title: '告警信息'),
const MenuItem(icon: Icons.info_outline, title: '帮助'),
const MenuItem(icon: Icons.person_outline, title: '关于'),
const MenuItem(icon: Icons.logout, title: '退出登录'),
const MenuItem(icon: Icons.logout, title: '注销账号'),
// const MenuItem(icon: Icons.list, title: '设备列表'),
// const MenuItem(icon: Icons.warning_rounded, title: '告警信息'),
// const MenuItem(icon: Icons.info_outline, title: '帮助'),
// const MenuItem(icon: Icons.person_outline, title: '关于'),
// const MenuItem(icon: Icons.logout, title: '退出登录'),
// const MenuItem(icon: Icons.logout, title: '注销账号'),
const MenuItem(icon: 'lib/assets/icon/device_list_bg.png', title: '设备列表'),
const MenuItem(icon: 'lib/assets/icon/alarm_info_bg.png', title: '告警信息'),
const MenuItem(icon: 'lib/assets/icon/help_bg.png', title: '帮助'),
const MenuItem(icon: 'lib/assets/icon/about_bg.png', title: '关于'),
const MenuItem(icon: 'lib/assets/icon/exit_login_bg.png', title: '退出登录'),
const MenuItem(icon: 'lib/assets/icon/logout_account_bg.png', title: '注销账号'),
],
));
}
......
......@@ -2,7 +2,7 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
class MenuItem {
final IconData icon;
final String icon;
final String title;
final VoidCallback? onTap;
......
......@@ -5,10 +5,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/blocs/auth/auth_bloc.dart';
import 'package:smart_hotel_app/blocs/auth/auth_event.dart';
import 'package:smart_hotel_app/views/profile/index/cubit/profile_cubit.dart';
import 'package:smart_hotel_app/views/profile/index/cubit/profile_state.dart';
import 'package:smart_hotel_app/blocs/auth/auth_state.dart';
import 'package:smart_hotel_app/views/profile/index/widget/profile_header_block.dart';
import 'package:smart_hotel_app/views/profile/index/widget/profile_menu_block.dart';
import 'cubit/profile_state.dart';
@RoutePage()
class ProfileView extends StatelessWidget {
const ProfileView({super.key});
......@@ -16,7 +18,11 @@ class ProfileView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => ProfileCubit(),
create: (context) {
final authState = context.read<AuthBloc>().state;
final userInfo = authState is AuthSuccess ? authState.userInfo : null;
return ProfileCubit(userInfo: userInfo);
},
child: _ProfileContent(),
);
}
......@@ -43,14 +49,13 @@ class _ProfileContent extends StatelessWidget {
username: state.username,
welcomeText: state.welcomeText,
),
SizedBox(height: 10.h),
SizedBox(height: 16.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 28.w),
child: ProfileMenuBlock(
menuList: state.menuList,
onLogout: () {
context
.read<AuthBloc>()
context.read<AuthBloc>()
.add(const AuthLogoutRequestedEvent());
},
),
......
......@@ -31,27 +31,24 @@ class ProfileHeaderBlock extends StatelessWidget {
SizedBox(height: 40.h),
Row(
children: [
Container(
width: 100.w,
height: 100.h,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color.fromRGBO(235, 244, 255, 1.0),
),
child: ClipOval(
child: Image.network(
'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face',
width: 100.w,
height: 100.h,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Icon(
ClipOval(
child: Image.network(
'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face',
width: 100.r,
height: 100.r,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Container(
width: 100.r,
height: 100.r,
color: const Color.fromRGBO(235, 244, 255, 1.0),
child: Icon(
Icons.person,
size: 48.sp,
color: const Color.fromRGBO(66, 165, 245, 1.0),
);
},
),
),
);
},
),
),
SizedBox(width: 24.w),
......
......@@ -21,7 +21,7 @@ class ProfileMenuBlock extends StatelessWidget {
},
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 28.h),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h),
margin: EdgeInsets.only(bottom: 16.h),
decoration: BoxDecoration(
color: Colors.white,
......@@ -30,16 +30,17 @@ class ProfileMenuBlock extends StatelessWidget {
child: Row(
children: [
Container(
width: 68.w,
height: 68.h,
width: 112.w,
height: 90.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color.fromRGBO(229, 241, 255, 1),
borderRadius: BorderRadius.circular(28.r),
borderRadius: BorderRadius.circular(24.r),
),
child: Icon(
child: Image.asset(
item.icon,
color: const Color.fromRGBO(66, 165, 245, 1.0),
size: 40.sp,
width: 48.w,
height: 48.h,
),
),
SizedBox(width: 24.w),
......@@ -53,12 +54,11 @@ class ProfileMenuBlock extends StatelessWidget {
),
),
),
if (item.title == '告警信息' || item.title == '设备列表')
// if (item.title == '告警信息' || item.title == '设备列表')
Icon(Icons.chevron_right,
color: const Color.fromRGBO(100, 116, 139, 1.0),
size: 32.sp,
size: 56.sp,
),
],
),
),
......@@ -83,13 +83,10 @@ class ProfileMenuBlock extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: Column(
children: [
...menuList.map((item) => _buildMenuItem(context, item)).toList(),
],
),
return Column(
children: [
...menuList.map((item) => _buildMenuItem(context, item)).toList(),
],
);
}
}
\ No newline at end of file
......@@ -35,7 +35,7 @@ class ServiceDeviceDetailView extends StatelessWidget {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......
......@@ -46,7 +46,7 @@ class ServiceRoomDetailView extends StatelessWidget {
style: TextStyle(
color: const Color.fromRGBO(10, 13, 20, 1),
fontSize: 32.sp,
fontWeight: FontWeight.w200,
fontWeight: FontWeight.w500,
),
),
centerTitle: true,
......
This diff is collapsed.
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