一次大的提交
This commit is contained in:
@@ -40,27 +40,35 @@ class DeviceSelector extends StatelessWidget {
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
selectedDevice ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('report.please_select_device'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: selectedDevice != null
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textHint,
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
selectedDevice ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('report.please_select_device'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: selectedDevice != null
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textHint,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 20,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 20,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 问题等级选择器
|
||||
class LevelSelector extends StatelessWidget {
|
||||
final ProblemLevel? selectedLevel;
|
||||
final Function(ProblemLevel) onSelected;
|
||||
@@ -15,7 +13,6 @@ class LevelSelector extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
@@ -35,9 +32,9 @@ class LevelSelector extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
loc.translate('report.problem_level'),
|
||||
style: const TextStyle(
|
||||
const Text(
|
||||
'问题等级',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -54,8 +51,8 @@ class LevelSelector extends StatelessWidget {
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
height: AppDimensions.buttonHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected && level == ProblemLevel.urgent
|
||||
? AppColors.danger.withOpacity(0.1)
|
||||
color: isSelected
|
||||
? level.textColor.withOpacity(0.1)
|
||||
: AppColors.background,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
@@ -69,7 +66,7 @@ class LevelSelector extends StatelessWidget {
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
loc.translate(level.labelKey),
|
||||
level.label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected
|
||||
|
||||
@@ -53,127 +53,131 @@ class MediaUploader extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
// 拍照按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.camera_alt,
|
||||
label: loc.translate('report.take_photo'),
|
||||
onTap: onCameraTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 录像按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.videocam,
|
||||
label: loc.translate('report.record_video'),
|
||||
onTap: onVideoTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 已上传的媒体预览
|
||||
...mediaFiles.asMap().entries.map((entry) {
|
||||
final String filePath = entry.value;
|
||||
final bool isNetworkImage = filePath.startsWith('http');
|
||||
final bool isVideo = _isVideoFile(filePath);
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
child: Row(
|
||||
children: [
|
||||
// 拍照按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.camera_alt,
|
||||
label: loc.translate('report.take_photo'),
|
||||
onTap: onCameraTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 录像按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.videocam,
|
||||
label: loc.translate('report.record_video'),
|
||||
onTap: onVideoTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 已上传的媒体预览
|
||||
...mediaFiles.asMap().entries.map((entry) {
|
||||
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,
|
||||
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,
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
// 添加按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.add,
|
||||
label: '',
|
||||
onTap: onAddFromGallery,
|
||||
isAddButton: true,
|
||||
),
|
||||
],
|
||||
// 视频播放图标
|
||||
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(),
|
||||
// 添加按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.add,
|
||||
label: '',
|
||||
onTap: onAddFromGallery,
|
||||
isAddButton: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 上报类型选择器
|
||||
class ReportTypeSelector extends StatelessWidget {
|
||||
final ReportType? selectedType;
|
||||
final Function(ReportType) onSelected;
|
||||
@@ -19,22 +17,24 @@ class ReportTypeSelector extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: ReportType.values.map((type) {
|
||||
final isSelected = selectedType == type;
|
||||
return Flexible(
|
||||
flex: 1,
|
||||
child: GestureDetector(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
child: Row(
|
||||
children: ReportType.values.map((type) {
|
||||
final isSelected = selectedType == type;
|
||||
return GestureDetector(
|
||||
onTap: () => onSelected(type),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 3),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
horizontal: 16,
|
||||
vertical: 14,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.background,
|
||||
color: isSelected
|
||||
? AppColors.primary.withOpacity(0.1)
|
||||
: AppColors.background,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
@@ -60,13 +60,13 @@ class ReportTypeSelector extends StatelessWidget {
|
||||
color: isSelected
|
||||
? AppColors.primary
|
||||
: AppColors.textHint,
|
||||
size: 26,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate(type.labelKey),
|
||||
type.label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontSize: 12,
|
||||
height: 1.2,
|
||||
color: isSelected
|
||||
? AppColors.primary
|
||||
@@ -82,9 +82,9 @@ class ReportTypeSelector extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user