所有一级页面和不分二级页面
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/usecases/get_alarm_count_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/usecases/get_alarm_list_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/bloc/alarm_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警中心 Cubit
|
||||
class AlarmCubit extends Cubit<AlarmState> {
|
||||
AlarmCubit({
|
||||
required GetAlarmListUseCase getAlarmListUseCase,
|
||||
required GetAlarmCountUseCase getAlarmCountUseCase,
|
||||
}) : _getAlarmListUseCase = getAlarmListUseCase,
|
||||
_getAlarmCountUseCase = getAlarmCountUseCase,
|
||||
super(AlarmInitial());
|
||||
|
||||
final GetAlarmListUseCase _getAlarmListUseCase;
|
||||
final GetAlarmCountUseCase _getAlarmCountUseCase;
|
||||
|
||||
/// 加载告警数据
|
||||
Future<void> loadAlarms({AlarmFilterTab? filter}) async {
|
||||
// 如果不是初始加载,保留旧数据
|
||||
final isInitialLoad = state is AlarmInitial;
|
||||
if (isInitialLoad) {
|
||||
emit(AlarmLoading());
|
||||
}
|
||||
|
||||
try {
|
||||
// 并行获取告警列表和统计
|
||||
final alarmsResult = await _getAlarmListUseCase(filter: filter);
|
||||
final countResult = await _getAlarmCountUseCase();
|
||||
|
||||
final alarms = alarmsResult.fold(
|
||||
(failure) => <AlarmEntity>[],
|
||||
(alarms) => alarms,
|
||||
);
|
||||
|
||||
final count = countResult.fold(
|
||||
(failure) => null,
|
||||
(count) => count,
|
||||
);
|
||||
|
||||
if (count == null) {
|
||||
emit(const AlarmError('获取告警统计失败'));
|
||||
return;
|
||||
}
|
||||
|
||||
emit(AlarmLoaded(
|
||||
alarms: alarms,
|
||||
count: count,
|
||||
selectedFilter: filter ?? AlarmFilterTab.all,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(AlarmError('加载告警数据失败: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换筛选标签
|
||||
Future<void> changeFilter(AlarmFilterTab filter) async {
|
||||
final currentState = state;
|
||||
if (currentState is AlarmLoaded) {
|
||||
emit(currentState.copyWith(selectedFilter: filter));
|
||||
await loadAlarms(filter: filter);
|
||||
}
|
||||
}
|
||||
|
||||
/// 刷新数据
|
||||
Future<void> refresh() async {
|
||||
final currentState = state;
|
||||
if (currentState is AlarmLoaded) {
|
||||
await loadAlarms(filter: currentState.selectedFilter);
|
||||
} else {
|
||||
await loadAlarms();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_count_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警中心状态
|
||||
abstract class AlarmState extends Equatable {
|
||||
const AlarmState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// 初始状态
|
||||
class AlarmInitial extends AlarmState {}
|
||||
|
||||
/// 加载中状态
|
||||
class AlarmLoading extends AlarmState {}
|
||||
|
||||
/// 加载成功状态
|
||||
class AlarmLoaded extends AlarmState {
|
||||
const AlarmLoaded({
|
||||
required this.alarms,
|
||||
required this.count,
|
||||
this.selectedFilter = AlarmFilterTab.all,
|
||||
});
|
||||
|
||||
final List<AlarmEntity> alarms;
|
||||
final AlarmCountEntity count;
|
||||
final AlarmFilterTab selectedFilter;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [alarms, count, selectedFilter];
|
||||
|
||||
AlarmLoaded copyWith({
|
||||
List<AlarmEntity>? alarms,
|
||||
AlarmCountEntity? count,
|
||||
AlarmFilterTab? selectedFilter,
|
||||
}) {
|
||||
return AlarmLoaded(
|
||||
alarms: alarms ?? this.alarms,
|
||||
count: count ?? this.count,
|
||||
selectedFilter: selectedFilter ?? this.selectedFilter,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载失败状态
|
||||
class AlarmError extends AlarmState {
|
||||
const AlarmError(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/// 告警中心全局常量
|
||||
/// 包含颜色、尺寸、枚举等全局配置
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 颜色常量
|
||||
class AlarmColors {
|
||||
/// 主色调
|
||||
static const Color primary = Color(0xFF165DFF);
|
||||
|
||||
/// 高危色 - 红色告警
|
||||
static const Color danger = Color(0xFFF53F3F);
|
||||
|
||||
/// 中危色 - 橙色告警
|
||||
static const Color warning = Color(0xFFFF7D00);
|
||||
|
||||
/// 低危色 - 绿色告警
|
||||
static const Color success = Color(0xFF00B42A);
|
||||
|
||||
/// 提示色 - 蓝色提示
|
||||
static const Color info = Color(0xFF69b1ff);
|
||||
|
||||
/// 背景色
|
||||
static const Color background = Color(0xFFFFFFFF);
|
||||
|
||||
/// 主要文字色
|
||||
static const Color textPrimary = Color(0xFF1D2129);
|
||||
|
||||
/// 次要文字色
|
||||
static const Color textSecondary = Color(0xFF4E5969);
|
||||
|
||||
/// 辅助文字色
|
||||
static const Color textTertiary = Color(0xFF86909C);
|
||||
|
||||
/// 未处理背景色
|
||||
static const Color unprocessedBg = Color(0xFFFFF0F0);
|
||||
|
||||
/// AI诊断卡片背景色
|
||||
static const Color aiCardBg = Color(0xFFF0F7FF);
|
||||
}
|
||||
|
||||
/// 尺寸常量
|
||||
class AlarmDimensions {
|
||||
/// 通用圆角
|
||||
static const double borderRadius = 16.0;
|
||||
|
||||
/// 水平边距
|
||||
static const double horizontalPadding = 16.0;
|
||||
|
||||
/// 模块间距
|
||||
static const double moduleSpacing = 20.0;
|
||||
|
||||
/// 导航栏高度
|
||||
static const double appBarHeight = 44.0;
|
||||
|
||||
/// 卡片阴影
|
||||
static BoxShadow cardShadow = const BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
);
|
||||
}
|
||||
|
||||
/// 告警等级枚举
|
||||
enum AlarmLevel {
|
||||
/// 高危
|
||||
danger('高危', AlarmColors.danger, Icons.warning_rounded),
|
||||
|
||||
/// 中危
|
||||
warning('中危', AlarmColors.warning, Icons.warning_amber_rounded),
|
||||
|
||||
/// 低危
|
||||
low('低危', AlarmColors.success, Icons.info_rounded),
|
||||
|
||||
/// 提示
|
||||
info('提示', AlarmColors.info, Icons.info_outline_rounded);
|
||||
|
||||
const AlarmLevel(this.label, this.color, this.icon);
|
||||
|
||||
/// 显示文本
|
||||
final String label;
|
||||
|
||||
/// 颜色
|
||||
final Color color;
|
||||
|
||||
/// 图标
|
||||
final IconData icon;
|
||||
}
|
||||
|
||||
/// 告警状态枚举
|
||||
enum AlarmStatus {
|
||||
/// 未确认
|
||||
unconfirmed('未确认'),
|
||||
|
||||
/// 已确认
|
||||
confirmed('已确认'),
|
||||
|
||||
/// 已恢复
|
||||
recovered('已恢复');
|
||||
|
||||
const AlarmStatus(this.label);
|
||||
|
||||
/// 显示文本
|
||||
final String label;
|
||||
}
|
||||
|
||||
/// 筛选标签枚举
|
||||
enum AlarmFilterTab {
|
||||
all('全部'),
|
||||
unprocessed('未处理'),
|
||||
confirmed('已确认'),
|
||||
recovered('已恢复');
|
||||
|
||||
const AlarmFilterTab(this.label);
|
||||
|
||||
/// 显示文本
|
||||
final String label;
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/bloc/alarm_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/bloc/alarm_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/widgets/alarm_count_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/widgets/alarm_item_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/widgets/alarm_tab_bar.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/widgets/ai_diagnosis_card.dart';
|
||||
|
||||
/// 告警中心页面
|
||||
class AlarmCenterPage extends StatefulWidget {
|
||||
const AlarmCenterPage({super.key});
|
||||
|
||||
@override
|
||||
State<AlarmCenterPage> createState() => _AlarmCenterPageState();
|
||||
}
|
||||
|
||||
class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
late AlarmCubit _cubit;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cubit = context.read<AlarmCubit>();
|
||||
// 首次加载数据
|
||||
if (_cubit.state is AlarmInitial) {
|
||||
_cubit.loadAlarms();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle.dark.copyWith(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
body: SafeArea(
|
||||
child: BlocBuilder<AlarmCubit, AlarmState>(
|
||||
builder: (context, state) {
|
||||
if (state is AlarmLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is AlarmError) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 48,
|
||||
color: AlarmColors.textTertiary,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(state.message),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => _cubit.loadAlarms(),
|
||||
child: const Text('重试'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is AlarmLoaded) {
|
||||
return Column(
|
||||
children: [
|
||||
// 顶部标题栏
|
||||
_buildAppBar(),
|
||||
// 横向标签栏
|
||||
_buildTabBar(state),
|
||||
// 内容区域
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _cubit.refresh();
|
||||
},
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: AlarmDimensions.moduleSpacing,
|
||||
bottom: 40,
|
||||
),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
//const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
// 告警统计卡片
|
||||
AlarmCountCard(count: state.count),
|
||||
const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
// 告警列表
|
||||
...state.alarms.map((alarm) {
|
||||
return AlarmItemCard(
|
||||
alarm: alarm,
|
||||
onTap: () {
|
||||
// TODO: 跳转到告警详情页
|
||||
debugPrint('点击告警: ${alarm.title}');
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
// AI 诊断建议(仅当有 AI 诊断内容时显示)
|
||||
if (state.alarms.any((alarm) => alarm.aiDiagnosis != null))
|
||||
AiDiagnosisCard(
|
||||
content: state.alarms
|
||||
.firstWhere((alarm) => alarm.aiDiagnosis != null)
|
||||
.aiDiagnosis ??
|
||||
'',
|
||||
onViewDetails: () {
|
||||
// TODO: 查看详情
|
||||
debugPrint('查看 AI 诊断详情');
|
||||
},
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示筛选弹窗
|
||||
void _showFilterDialog() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'筛选条件',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildFilterOption('告警等级', ['高危', '中危', '低危', '提示']),
|
||||
const SizedBox(height: 16),
|
||||
_buildFilterOption('时间范围', ['今天', '本周', '本月', '全部']),
|
||||
const SizedBox(height: 16),
|
||||
_buildFilterOption('区域', ['A区', 'B区', 'C区', 'D区', '全部']),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AlarmColors.primary,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'应用筛选',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar() {
|
||||
return Container(
|
||||
height: 44.0,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'告警中心',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.filter_list,
|
||||
size: 24,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
onPressed: _showFilterDialog,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabBar(AlarmLoaded state) {
|
||||
return AlarmTabBar(
|
||||
selectedFilter: state.selectedFilter,
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
onFilterChanged: (filter) {
|
||||
_cubit.changeFilter(filter);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFilterOption(String title, List<String> options) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: options.map((option) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AlarmColors.textTertiary),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
option,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AlarmColors.textSecondary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/pages/alarm_center_page.dart';
|
||||
|
||||
/// 告警中心路由配置
|
||||
class AlarmCenterRoutes {
|
||||
static List<RouteBase> get routes => [
|
||||
GoRoute(
|
||||
path: 'alarm_center',
|
||||
name: 'alarmCenter',
|
||||
builder: (context, state) => const AlarmCenterPage(),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// AI 诊断建议卡片
|
||||
class AiDiagnosisCard extends StatelessWidget {
|
||||
const AiDiagnosisCard({
|
||||
super.key,
|
||||
required this.content,
|
||||
this.onViewDetails,
|
||||
});
|
||||
|
||||
final String content;
|
||||
final VoidCallback? onViewDetails;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(AlarmDimensions.horizontalPadding),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AlarmColors.aiCardBg,
|
||||
borderRadius: BorderRadius.circular(AlarmDimensions.borderRadius),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: const BoxDecoration(
|
||||
color: AlarmColors.primary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.auto_awesome,
|
||||
color: Colors.white,
|
||||
size: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'AI诊断建议',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
content,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AlarmColors.textSecondary,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: onViewDetails,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'查看详情',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AlarmColors.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: AlarmColors.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_count_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警统计卡片
|
||||
class AlarmCountCard extends StatelessWidget {
|
||||
const AlarmCountCard({
|
||||
super.key,
|
||||
required this.count,
|
||||
});
|
||||
|
||||
final AlarmCountEntity count;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: AlarmDimensions.horizontalPadding),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AlarmColors.background,
|
||||
borderRadius: BorderRadius.circular(AlarmDimensions.borderRadius),
|
||||
boxShadow: [AlarmDimensions.cardShadow],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '未处理',
|
||||
value: count.unprocessed,
|
||||
color: AlarmColors.danger,
|
||||
bgColor: AlarmColors.unprocessedBg,
|
||||
labelColor: AlarmColors.danger,
|
||||
),
|
||||
),
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '处理中',
|
||||
value: count.processing,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '已确认',
|
||||
value: count.confirmed,
|
||||
color: const Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '今日新增',
|
||||
value: count.todayNew,
|
||||
color: const Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountItem({
|
||||
required String label,
|
||||
required int value,
|
||||
required Color color,
|
||||
Color? bgColor,
|
||||
Color? labelColor,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: labelColor ?? AlarmColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDivider() {
|
||||
return Container(
|
||||
width: 1,
|
||||
height: 50,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
color: const Color(0xFFE5E6EB),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警项卡片
|
||||
class AlarmItemCard extends StatelessWidget {
|
||||
const AlarmItemCard({
|
||||
super.key,
|
||||
required this.alarm,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final AlarmEntity alarm;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AlarmDimensions.horizontalPadding,
|
||||
vertical: 6,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AlarmColors.background,
|
||||
borderRadius: BorderRadius.circular(AlarmDimensions.borderRadius),
|
||||
boxShadow: [AlarmDimensions.cardShadow],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 第一行:图标 + 标题 + 等级标签
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
alarm.level.icon,
|
||||
color: alarm.level.color,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
alarm.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: alarm.level.color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
alarm.level.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: alarm.level.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 第二行:区域和设备
|
||||
Text(
|
||||
'区域:${alarm.area} / 设备:${alarm.device}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AlarmColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 第三行:时间和状态
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
alarm.time,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AlarmColors.textTertiary,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
alarm.status.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: alarm.status == AlarmStatus.unconfirmed
|
||||
? AlarmColors.warning
|
||||
: AlarmColors.textTertiary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: alarm.status == AlarmStatus.unconfirmed
|
||||
? AlarmColors.warning
|
||||
: AlarmColors.textTertiary,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警筛选标签栏
|
||||
class AlarmTabBar extends StatelessWidget {
|
||||
const AlarmTabBar({
|
||||
super.key,
|
||||
required this.selectedFilter,
|
||||
required this.onFilterChanged,
|
||||
this.backgroundColor = Colors.transparent,
|
||||
});
|
||||
|
||||
final AlarmFilterTab selectedFilter;
|
||||
final ValueChanged<AlarmFilterTab> onFilterChanged;
|
||||
final Color backgroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 44,
|
||||
color: backgroundColor,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: AlarmFilterTab.values.length,
|
||||
itemBuilder: (context, index) {
|
||||
final filter = AlarmFilterTab.values[index];
|
||||
final isSelected = selectedFilter == filter;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onFilterChanged(filter),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
filter.label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected ? AlarmColors.primary : AlarmColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
height: 2,
|
||||
width: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AlarmColors.primary : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user