1.优化补足了首页下拉刷新中对获取场站接口的加入,确保能够实时获取数据并渲染。

2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。
3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。
4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
This commit is contained in:
2026-07-02 16:04:30 +08:00
parent d5a83c1221
commit 0db64a96e7
69 changed files with 5018 additions and 1532 deletions

View File

@@ -27,26 +27,26 @@ class AppDimensions {
/// 上报类型枚举
enum ReportType {
deviceFault('设备故障', Icons.notifications_active),
patrolRecord('巡检记录', Icons.description),
hiddenDanger('隐患上报', Icons.shield),
defectReport('缺陷上报', Icons.build);
deviceFault('report.device_fault', Icons.notifications_active),
patrolRecord('report.patrol_record', Icons.description),
hiddenDanger('report.hidden_danger', Icons.shield),
defectReport('report.defect_report', Icons.build);
final String label;
final String labelKey;
final IconData icon;
const ReportType(this.label, this.icon);
const ReportType(this.labelKey, this.icon);
}
/// 问题等级枚举
enum ProblemLevel {
normal('一般', Color(0xFF86909C), Color(0xFFE5E6EB)),
important('重要', Color(0xFFFF7D00), Color(0xFFE5E6EB)),
urgent('紧急', Color(0xFFF53F3F), Color(0xFFF53F3F));
normal('report.normal', Color(0xFF86909C), Color(0xFFE5E6EB)),
important('report.important', Color(0xFFFF7D00), Color(0xFFE5E6EB)),
urgent('report.urgent', Color(0xFFF53F3F), Color(0xFFF53F3F));
final String label;
final String labelKey;
final Color textColor;
final Color borderColor;
const ProblemLevel(this.label, this.textColor, this.borderColor);
const ProblemLevel(this.labelKey, this.textColor, this.borderColor);
}

View File

@@ -9,18 +9,18 @@ class ReportCubit extends Cubit<ReportState> {
final SubmitReportUseCase submitReportUseCase;
ReportCubit({required this.submitReportUseCase})
: super(ReportFormState(report: ReportEntity()));
: super(ReportFormState(report: ReportEntity()));
/// 选择上报类型
void selectReportType(ReportType type) {
if (state is ReportFormState) {
final currentState = state as ReportFormState;
emit(currentState.copyWith(
selectedReportType: type,
report: currentState.report.copyWith(
reportType: type.label,
emit(
currentState.copyWith(
selectedReportType: type,
report: currentState.report.copyWith(reportType: type.labelKey),
),
));
);
}
}
@@ -28,10 +28,12 @@ class ReportCubit extends Cubit<ReportState> {
void selectDevice(String device) {
if (state is ReportFormState) {
final currentState = state as ReportFormState;
emit(currentState.copyWith(
selectedDevice: device,
report: currentState.report.copyWith(deviceId: device),
));
emit(
currentState.copyWith(
selectedDevice: device,
report: currentState.report.copyWith(deviceId: device),
),
);
}
}
@@ -39,10 +41,12 @@ class ReportCubit extends Cubit<ReportState> {
void updateLocation(String location) {
if (state is ReportFormState) {
final currentState = state as ReportFormState;
emit(currentState.copyWith(
location: location,
report: currentState.report.copyWith(location: location),
));
emit(
currentState.copyWith(
location: location,
report: currentState.report.copyWith(location: location),
),
);
}
}
@@ -50,9 +54,11 @@ class ReportCubit extends Cubit<ReportState> {
void updateDescription(String description) {
if (state is ReportFormState) {
final currentState = state as ReportFormState;
emit(currentState.copyWith(
report: currentState.report.copyWith(description: description),
));
emit(
currentState.copyWith(
report: currentState.report.copyWith(description: description),
),
);
}
}
@@ -60,12 +66,12 @@ class ReportCubit extends Cubit<ReportState> {
void selectProblemLevel(ProblemLevel level) {
if (state is ReportFormState) {
final currentState = state as ReportFormState;
emit(currentState.copyWith(
selectedProblemLevel: level,
report: currentState.report.copyWith(
problemLevel: level.label,
emit(
currentState.copyWith(
selectedProblemLevel: level,
report: currentState.report.copyWith(problemLevel: level.labelKey),
),
));
);
}
}
@@ -75,10 +81,12 @@ class ReportCubit extends Cubit<ReportState> {
final currentState = state as ReportFormState;
final updatedFiles = List<String>.from(currentState.mediaFiles)
..add(filePath);
emit(currentState.copyWith(
mediaFiles: updatedFiles,
report: currentState.report.copyWith(mediaUrls: updatedFiles),
));
emit(
currentState.copyWith(
mediaFiles: updatedFiles,
report: currentState.report.copyWith(mediaUrls: updatedFiles),
),
);
}
}
@@ -88,10 +96,12 @@ class ReportCubit extends Cubit<ReportState> {
final currentState = state as ReportFormState;
final updatedFiles = List<String>.from(currentState.mediaFiles)
..removeAt(index);
emit(currentState.copyWith(
mediaFiles: updatedFiles,
report: currentState.report.copyWith(mediaUrls: updatedFiles),
));
emit(
currentState.copyWith(
mediaFiles: updatedFiles,
report: currentState.report.copyWith(mediaUrls: updatedFiles),
),
);
}
}

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../cubit/report_cubit.dart';
import '../states/report_state.dart';
import '../constants/report_constants.dart';
@@ -46,9 +47,7 @@ class _ReportPageContent extends StatelessWidget {
builder: (context, state) {
if (state is ReportSubmitting) {
return const Center(
child: CircularProgressIndicator(
color: AppColors.primary,
),
child: CircularProgressIndicator(color: AppColors.primary),
);
}
@@ -57,9 +56,7 @@ class _ReportPageContent extends StatelessWidget {
return Column(
children: [
_buildAppBar(context, state.location, cubit),
Expanded(
child: _buildFormContent(context, state),
),
Expanded(child: _buildFormContent(context, state)),
],
);
}
@@ -72,7 +69,11 @@ class _ReportPageContent extends StatelessWidget {
}
/// 构建导航栏
PreferredSizeWidget _buildAppBar(BuildContext context, String location, ReportCubit cubit) {
PreferredSizeWidget _buildAppBar(
BuildContext context,
String location,
ReportCubit cubit,
) {
return PreferredSize(
preferredSize: const Size.fromHeight(100),
child: Container(
@@ -89,9 +90,9 @@ class _ReportPageContent extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'现场上报',
style: TextStyle(
Text(
AppLocalizations.of(context).translate('report.title'),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: AppColors.textPrimary,
@@ -101,9 +102,9 @@ class _ReportPageContent extends StatelessWidget {
onTap: () {
context.read<ReportCubit>().submitReport();
},
child: const Text(
'提交',
style: TextStyle(
child: Text(
AppLocalizations.of(context).translate('report.submit'),
style: const TextStyle(
color: AppColors.primary,
fontSize: 18,
fontWeight: FontWeight.w600,
@@ -240,19 +241,12 @@ class _ReportPageContent extends StatelessWidget {
),
child: Row(
children: [
const Icon(
Icons.location_on,
color: AppColors.primary,
size: 20,
),
const Icon(Icons.location_on, color: AppColors.primary, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
location,
style: TextStyle(
fontSize: 16,
color: AppColors.textPrimary,
),
style: TextStyle(fontSize: 16, color: AppColors.textPrimary),
),
),
],
@@ -270,7 +264,7 @@ class _ReportPageContent extends StatelessWidget {
maxHeight: 1080,
imageQuality: 85,
);
if (image != null) {
cubit.addMediaFile(image.path);
}
@@ -287,7 +281,7 @@ class _ReportPageContent extends StatelessWidget {
source: ImageSource.camera,
maxDuration: const Duration(minutes: 5),
);
if (video != null) {
cubit.addMediaFile(video.path);
}
@@ -301,10 +295,8 @@ class _ReportPageContent extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MediaPreviewPage(
mediaFiles: mediaFiles,
initialIndex: index,
),
builder: (context) =>
MediaPreviewPage(mediaFiles: mediaFiles, initialIndex: index),
),
);
}
@@ -322,7 +314,9 @@ class _ReportPageContent extends StatelessWidget {
children: [
ListTile(
leading: const Icon(Icons.image),
title: const Text('选择图片'),
title: Text(
AppLocalizations.of(context).translate('report.select_image'),
),
onTap: () async {
Navigator.pop(context);
final XFile? image = await picker.pickImage(
@@ -338,7 +332,9 @@ class _ReportPageContent extends StatelessWidget {
),
ListTile(
leading: const Icon(Icons.video_library),
title: const Text('选择视频'),
title: Text(
AppLocalizations.of(context).translate('report.select_video'),
),
onTap: () async {
Navigator.pop(context);
final XFile? video = await picker.pickVideo(
@@ -360,19 +356,20 @@ class _ReportPageContent extends StatelessWidget {
/// 显示位置选择器
void _showLocationPicker(BuildContext context, ReportCubit cubit) {
final loc = AppLocalizations.of(context);
final locations = [
'主厂房A区',
'主厂房B区',
'锅炉房',
'汽机房',
'控制室',
'配电室',
loc.translate('report.main_building_a'),
loc.translate('report.main_building_b'),
loc.translate('report.boiler_room'),
loc.translate('report.turbine_room'),
loc.translate('report.control_room'),
loc.translate('report.power_distribution_room'),
];
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('选择位置'),
title: Text(loc.translate('report.select_location')),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -390,7 +387,7 @@ class _ReportPageContent extends StatelessWidget {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消'),
child: Text(loc.translate('report.cancel')),
),
],
),
@@ -399,19 +396,20 @@ class _ReportPageContent extends StatelessWidget {
/// 显示设备选择器
void _showDevicePicker(BuildContext context, ReportCubit cubit) {
final loc = AppLocalizations.of(context);
final devices = [
'锅炉1号',
'锅炉2号',
'汽轮机1号',
'发电机1号',
'变压器1号',
'水泵1号',
loc.translate('report.boiler_1'),
loc.translate('report.boiler_2'),
loc.translate('report.turbine_1'),
loc.translate('report.generator_1'),
loc.translate('report.transformer_1'),
loc.translate('report.water_pump_1'),
];
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('选择设备'),
title: Text(loc.translate('report.select_device')),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -429,7 +427,7 @@ class _ReportPageContent extends StatelessWidget {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消'),
child: Text(loc.translate('report.cancel')),
),
],
),
@@ -438,19 +436,20 @@ class _ReportPageContent extends StatelessWidget {
/// 显示成功对话框
void _showSuccessDialog(BuildContext context) {
final loc = AppLocalizations.of(context);
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: const Text('提交成功'),
content: const Text('您的上报已成功提交'),
title: Text(loc.translate('report.submit_success')),
content: Text(loc.translate('report.submit_success_message')),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
Navigator.pop(context); // 返回上一页
},
child: const Text('确定'),
child: Text(loc.translate('report.confirm')),
),
],
),
@@ -459,15 +458,16 @@ class _ReportPageContent extends StatelessWidget {
/// 显示错误对话框
void _showErrorDialog(BuildContext context, String message) {
final loc = AppLocalizations.of(context);
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('提交失败'),
title: Text(loc.translate('report.submit_failed')),
content: Text(message),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('确定'),
child: Text(loc.translate('report.confirm')),
),
],
),

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../constants/report_constants.dart';
/// 问题描述输入模块
@@ -14,6 +15,7 @@ class DescriptionInput extends StatelessWidget {
@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Container(
margin: const EdgeInsets.symmetric(
horizontal: AppDimensions.horizontalPadding,
@@ -34,8 +36,8 @@ class DescriptionInput extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'问题描述',
style: TextStyle(
loc.translate('report.problem_description'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
@@ -47,35 +49,38 @@ class DescriptionInput extends StatelessWidget {
maxLength: 200,
onChanged: onChanged,
decoration: InputDecoration(
hintText: '请详细描述问题现象...',
hintStyle: TextStyle(color: AppColors.textHint),
hintText: loc.translate('report.description_hint'),
hintStyle: const TextStyle(color: AppColors.textHint),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
borderSide: BorderSide(color: AppColors.borderColor),
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
borderSide: const BorderSide(color: AppColors.borderColor),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
borderSide: BorderSide(color: AppColors.borderColor),
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
borderSide: const BorderSide(color: AppColors.borderColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
borderSide: BorderSide(color: AppColors.primary, width: 2),
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
borderSide: const BorderSide(
color: AppColors.primary,
width: 2,
),
),
counterText: '',
),
style: TextStyle(
fontSize: 14,
color: AppColors.textPrimary,
),
style: const TextStyle(fontSize: 14, color: AppColors.textPrimary),
),
Align(
alignment: Alignment.centerRight,
child: Text(
'${description?.length ?? 0}/200',
style: TextStyle(
fontSize: 12,
color: AppColors.textHint,
),
style: const TextStyle(fontSize: 12, color: AppColors.textHint),
),
),
],

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../constants/report_constants.dart';
/// 设备选择器
@@ -6,11 +7,7 @@ class DeviceSelector extends StatelessWidget {
final String? selectedDevice;
final VoidCallback onTap;
const DeviceSelector({
super.key,
this.selectedDevice,
required this.onTap,
});
const DeviceSelector({super.key, this.selectedDevice, required this.onTap});
@override
Widget build(BuildContext context) {
@@ -36,8 +33,8 @@ class DeviceSelector extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'设备选择',
style: TextStyle(
AppLocalizations.of(context).translate('report.select_device'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
@@ -46,7 +43,10 @@ class DeviceSelector extends StatelessWidget {
Row(
children: [
Text(
selectedDevice ?? '请选择设备',
selectedDevice ??
AppLocalizations.of(
context,
).translate('report.please_select_device'),
style: TextStyle(
fontSize: 14,
color: selectedDevice != null

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../constants/report_constants.dart';
/// 问题等级选择器
@@ -14,6 +15,7 @@ class LevelSelector extends StatelessWidget {
@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Container(
margin: const EdgeInsets.symmetric(
horizontal: AppDimensions.horizontalPadding,
@@ -34,8 +36,8 @@ class LevelSelector extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'问题等级',
style: TextStyle(
loc.translate('report.problem_level'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
@@ -55,19 +57,27 @@ class LevelSelector extends StatelessWidget {
color: isSelected && level == ProblemLevel.urgent
? AppColors.danger.withOpacity(0.1)
: AppColors.background,
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
border: Border.all(
color: isSelected ? level.borderColor : AppColors.borderColor,
color: isSelected
? level.borderColor
: AppColors.borderColor,
width: isSelected ? 2 : 1,
),
),
child: Center(
child: Text(
level.label,
loc.translate(level.labelKey),
style: TextStyle(
fontSize: 14,
color: isSelected ? level.textColor : level.textColor.withOpacity(0.6),
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected
? level.textColor
: level.textColor.withOpacity(0.6),
fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
),
),
),

View File

@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../constants/report_constants.dart';
/// 媒体上传模块
@@ -23,6 +24,7 @@ class MediaUploader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Container(
margin: const EdgeInsets.symmetric(
horizontal: AppDimensions.horizontalPadding,
@@ -43,8 +45,8 @@ class MediaUploader extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'上传图片/视频',
style: TextStyle(
loc.translate('report.upload_media'),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
@@ -58,14 +60,14 @@ class MediaUploader extends StatelessWidget {
// 拍照按钮
_buildUploadButton(
icon: Icons.camera_alt,
label: '拍照',
label: loc.translate('report.take_photo'),
onTap: onCameraTap,
),
const SizedBox(width: 8),
// 录像按钮
_buildUploadButton(
icon: Icons.videocam,
label: '录像',
label: loc.translate('report.record_video'),
onTap: onVideoTap,
),
const SizedBox(width: 8),
@@ -74,84 +76,94 @@ class MediaUploader extends StatelessWidget {
final String filePath = entry.value;
final bool isNetworkImage = filePath.startsWith('http');
final bool isVideo = _isVideoFile(filePath);
return GestureDetector(
onTap: () => onTap?.call(entry.key),
child: Stack(
children: [
Container(
width: 80,
height: 80,
margin: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
color: AppColors.cardBackground,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
child: isVideo
? _buildVideoThumbnail(filePath)
: (isNetworkImage
? Image.network(
filePath,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return _buildPlaceholderIcon(Icons.broken_image);
},
)
: Image.file(
File(filePath),
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return _buildPlaceholderIcon(Icons.broken_image);
},
)),
),
),
Positioned(
top: 4,
right: 12,
child: GestureDetector(
onTap: () => onRemove(entry.key),
child: Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Colors.black54,
shape: BoxShape.circle,
children: [
Container(
width: 80,
height: 80,
margin: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
child: const Icon(
Icons.close,
size: 14,
color: Colors.white,
color: AppColors.cardBackground,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
child: isVideo
? _buildVideoThumbnail(filePath)
: (isNetworkImage
? Image.network(
filePath,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
return _buildPlaceholderIcon(
Icons.broken_image,
);
},
)
: Image.file(
File(filePath),
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
return _buildPlaceholderIcon(
Icons.broken_image,
);
},
)),
),
),
),
// 视频播放图标
if (isVideo)
Positioned(
child: Container(
width: 80,
height: 80,
margin: const EdgeInsets.only(right: 8),
alignment: Alignment.center,
top: 4,
right: 12,
child: GestureDetector(
onTap: () => onRemove(entry.key),
child: Container(
padding: const EdgeInsets.all(8),
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Colors.black38,
color: Colors.black54,
shape: BoxShape.circle,
),
child: const Icon(
Icons.play_arrow,
Icons.close,
size: 14,
color: Colors.white,
size: 24,
),
),
),
),
],
),
// 视频播放图标
if (isVideo)
Positioned(
child: Container(
width: 80,
height: 80,
margin: const EdgeInsets.only(right: 8),
alignment: Alignment.center,
child: Container(
padding: const EdgeInsets.all(8),
decoration: const BoxDecoration(
color: Colors.black38,
shape: BoxShape.circle,
),
child: const Icon(
Icons.play_arrow,
color: Colors.white,
size: 24,
),
),
),
),
],
),
);
}).toList(),
// 添加按钮
@@ -228,17 +240,9 @@ class MediaUploader extends StatelessWidget {
fit: StackFit.expand,
children: [
// 灰色背景
Container(
color: Colors.grey[300],
),
Container(color: Colors.grey[300]),
// 视频图标
const Center(
child: Icon(
Icons.videocam,
color: Colors.grey,
size: 32,
),
),
const Center(child: Icon(Icons.videocam, color: Colors.grey, size: 32)),
],
);
}
@@ -247,13 +251,7 @@ class MediaUploader extends StatelessWidget {
Widget _buildPlaceholderIcon(IconData icon) {
return Container(
color: Colors.grey[300],
child: Center(
child: Icon(
icon,
color: Colors.grey,
size: 32,
),
),
child: Center(child: Icon(icon, color: Colors.grey, size: 32)),
);
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import '../constants/report_constants.dart';
/// 上报类型选择器
@@ -15,21 +16,32 @@ class ReportTypeSelector extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: AppDimensions.horizontalPadding),
padding: const EdgeInsets.symmetric(
horizontal: AppDimensions.horizontalPadding,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: ReportType.values.map((type) {
final isSelected = selectedType == type;
return Expanded(
return Flexible(
flex: 1,
child: GestureDetector(
onTap: () => onSelected(type),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.symmetric(vertical: 12),
margin: const EdgeInsets.symmetric(horizontal: 3),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 14,
),
decoration: BoxDecoration(
color: AppColors.background,
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
borderRadius: BorderRadius.circular(
AppDimensions.borderRadiusSmall,
),
border: Border.all(
color: isSelected ? AppColors.primary : AppColors.borderColor,
color: isSelected
? AppColors.primary
: AppColors.borderColor,
width: isSelected ? 2 : 1,
),
boxShadow: [
@@ -45,17 +57,27 @@ class ReportTypeSelector extends StatelessWidget {
children: [
Icon(
type.icon,
color: isSelected ? AppColors.primary : AppColors.textHint,
size: 24,
color: isSelected
? AppColors.primary
: AppColors.textHint,
size: 26,
),
const SizedBox(height: 8),
const SizedBox(height: 6),
Text(
type.label,
AppLocalizations.of(context).translate(type.labelKey),
style: TextStyle(
fontSize: 12,
color: isSelected ? AppColors.primary : AppColors.textSecondary,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
fontSize: 11,
height: 1.2,
color: isSelected
? AppColors.primary
: AppColors.textSecondary,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),