一次大的提交
This commit is contained in:
@@ -3,11 +3,15 @@ import 'package:maibu_satabot_v2/core/localization/app_localizations.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});
|
||||
const AlarmCountCard({
|
||||
super.key,
|
||||
required this.count,
|
||||
this.isCountLoading = false,
|
||||
});
|
||||
|
||||
final AlarmCountEntity count;
|
||||
final bool isCountLoading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -25,9 +29,7 @@ class AlarmCountCard extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unprocessed'),
|
||||
label: '待处理',
|
||||
value: count.unprocessed,
|
||||
color: AlarmColors.danger,
|
||||
bgColor: AlarmColors.unprocessedBg,
|
||||
@@ -37,15 +39,7 @@ class AlarmCountCard extends StatelessWidget {
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '处理中',
|
||||
value: count.processing,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '已确认',
|
||||
label: '已关闭',
|
||||
value: count.confirmed,
|
||||
color: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -88,14 +82,25 @@ class AlarmCountCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
isCountLoading
|
||||
? const SizedBox(
|
||||
height: 24,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
value.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -85,12 +85,10 @@ class AlarmItemCard extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
_getStatusLabel(context, alarm.status),
|
||||
alarm.status.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: alarm.status == AlarmStatus.unconfirmed
|
||||
? AlarmColors.warning
|
||||
: AlarmColors.textTertiary,
|
||||
color: _getStatusColor(alarm.status),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -98,9 +96,7 @@ class AlarmItemCard extends StatelessWidget {
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: alarm.status == AlarmStatus.unconfirmed
|
||||
? AlarmColors.warning
|
||||
: AlarmColors.textTertiary,
|
||||
color: _getStatusColor(alarm.status),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -125,16 +121,14 @@ class AlarmItemCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatusLabel(BuildContext context, AlarmStatus status) {
|
||||
Color _getStatusColor(AlarmStatus status) {
|
||||
switch (status) {
|
||||
case AlarmStatus.unconfirmed:
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unconfirmed');
|
||||
case AlarmStatus.confirmed:
|
||||
return AppLocalizations.of(context).translate('alarm_center.confirmed');
|
||||
case AlarmStatus.recovered:
|
||||
return AppLocalizations.of(context).translate('alarm_center.recovered');
|
||||
case AlarmStatus.pending:
|
||||
return AlarmColors.danger;
|
||||
case AlarmStatus.processing:
|
||||
case AlarmStatus.closed:
|
||||
case AlarmStatus.ignored:
|
||||
return AlarmColors.textTertiary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警筛选标签栏
|
||||
/// 告警筛选标签栏 - 全部/未处理/已确认/已恢复
|
||||
class AlarmTabBar extends StatelessWidget {
|
||||
const AlarmTabBar({
|
||||
super.key,
|
||||
@@ -15,6 +15,14 @@ class AlarmTabBar extends StatelessWidget {
|
||||
final ValueChanged<AlarmFilterTab> onFilterChanged;
|
||||
final Color backgroundColor;
|
||||
|
||||
// 待显示的标签列表(已注释掉"已确认"标签)
|
||||
static const List<AlarmFilterTab> _visibleTabs = [
|
||||
AlarmFilterTab.all,
|
||||
AlarmFilterTab.unprocessed,
|
||||
// AlarmFilterTab.confirmed, // 已确认 - 暂不显示
|
||||
AlarmFilterTab.recovered,
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@@ -23,44 +31,14 @@ class AlarmTabBar extends StatelessWidget {
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: AlarmFilterTab.values.length,
|
||||
itemCount: _visibleTabs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final filter = AlarmFilterTab.values[index];
|
||||
final isSelected = selectedFilter == filter;
|
||||
|
||||
return GestureDetector(
|
||||
final filter = _visibleTabs[index];
|
||||
return _buildTabItem(
|
||||
context,
|
||||
label: _getFilterLabel(context, filter),
|
||||
isSelected: selectedFilter == filter,
|
||||
onTap: () => onFilterChanged(filter),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
_getFilterLabel(context, filter),
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -72,13 +50,49 @@ class AlarmTabBar extends StatelessWidget {
|
||||
case AlarmFilterTab.all:
|
||||
return AppLocalizations.of(context).translate('alarm_center.all');
|
||||
case AlarmFilterTab.unprocessed:
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unprocessed');
|
||||
return '待处理';
|
||||
case AlarmFilterTab.confirmed:
|
||||
return AppLocalizations.of(context).translate('alarm_center.confirmed');
|
||||
case AlarmFilterTab.recovered:
|
||||
return AppLocalizations.of(context).translate('alarm_center.recovered');
|
||||
return '已关闭(已恢复)';
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTabItem(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required bool isSelected,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
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