689 lines
21 KiB
Dart
689 lines
21 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
|
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
|
|
|
/// 帮助与反馈页面
|
|
class HelpFeedbackPage extends StatefulWidget {
|
|
const HelpFeedbackPage({super.key});
|
|
|
|
@override
|
|
State<HelpFeedbackPage> createState() => _HelpFeedbackPageState();
|
|
}
|
|
|
|
class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
|
with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
final TextEditingController _feedbackController = TextEditingController();
|
|
final TextEditingController _contactController = TextEditingController();
|
|
int _selectedFeedbackType = 0;
|
|
List<String> _selectedImages = [];
|
|
|
|
static const _feedbackTypes = [
|
|
{'icon': Icons.lightbulb_outline, 'label': 'type_feature'},
|
|
{'icon': Icons.bug_report_outlined, 'label': 'type_bug'},
|
|
{'icon': Icons.sentiment_dissatisfied_outlined, 'label': 'type_experience'},
|
|
{'icon': Icons.more_horiz, 'label': 'type_other'},
|
|
];
|
|
|
|
static const _faqList = [
|
|
{
|
|
'category': 'cat_bind',
|
|
'questions': [
|
|
{'q': 'q_bind_fail', 'a': 'a_bind_fail'},
|
|
{'q': 'q_bt_notfound', 'a': 'a_bt_notfound'},
|
|
]
|
|
},
|
|
{
|
|
'category': 'cat_path',
|
|
'questions': [
|
|
{'q': 'q_path_none', 'a': 'a_path_none'},
|
|
{'q': 'q_map_issue', 'a': 'a_map_issue'},
|
|
]
|
|
},
|
|
{
|
|
'category': 'cat_remote',
|
|
'questions': [
|
|
{'q': 'q_video_stutter', 'a': 'a_video_stutter'},
|
|
{'q': 'q_estop', 'a': 'a_estop'},
|
|
]
|
|
},
|
|
{
|
|
'category': 'cat_order',
|
|
'questions': [
|
|
{'q': 'q_order_submit', 'a': 'a_order_submit'},
|
|
{'q': 'q_order_status', 'a': 'a_order_status'},
|
|
]
|
|
},
|
|
{
|
|
'category': 'cat_account',
|
|
'questions': [
|
|
{'q': 'q_pwd_forget', 'a': 'a_pwd_forget'},
|
|
{'q': 'q_rebind_device', 'a': 'a_rebind_device'},
|
|
]
|
|
},
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_tabController = TabController(length: 2, vsync: this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabController.dispose();
|
|
_feedbackController.dispose();
|
|
_contactController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
value: const SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
statusBarIconBrightness: Brightness.light,
|
|
),
|
|
child: Scaffold(
|
|
backgroundColor: context.appColors.pageBackground,
|
|
appBar: AppBar(
|
|
elevation: 0,
|
|
leading: IconButton(
|
|
icon: Icon(Icons.arrow_back, color: context.appColors.textPrimary),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
title: Text(
|
|
AppLocalizations.of(context).translate('my_v2.help_feedback'),
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
bottom: TabBar(
|
|
controller: _tabController,
|
|
labelColor: const Color(0xFF165DFF),
|
|
unselectedLabelColor: context.appColors.textTertiary,
|
|
indicatorColor: const Color(0xFF165DFF),
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
tabs: [
|
|
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_faq')),
|
|
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_feedback')),
|
|
],
|
|
),
|
|
),
|
|
body: TabBarView(
|
|
controller: _tabController,
|
|
children: [
|
|
_buildFAQTab(),
|
|
_buildFeedbackTab(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// ==================== 常见问题 ====================
|
|
|
|
Widget _buildFAQTab() {
|
|
return ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
..._faqList.map((category) => _buildFAQCategory(category)),
|
|
const SizedBox(height: 20),
|
|
_buildContactSection(),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildFAQCategory(Map<String, dynamic> categoryData) {
|
|
final questions = categoryData['questions'] as List;
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
|
child: Text(
|
|
AppLocalizations.of(context).translate("help_feedback.${categoryData['category']}"),
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: context.appColors.cardBackground,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: context.appColors.cardShadow,
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
children: questions.asMap().entries.map((entry) {
|
|
final index = entry.key;
|
|
final item = entry.value as Map<String, dynamic>;
|
|
final isLast = index == questions.length - 1;
|
|
return _buildFAQItem(
|
|
AppLocalizations.of(context).translate("help_feedback.${item['q']}"),
|
|
AppLocalizations.of(context).translate("help_feedback.${item['a']}"),
|
|
isLast,
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildFAQItem(String question, String answer, bool isLast) {
|
|
return Column(
|
|
children: [
|
|
ExpansionTile(
|
|
tilePadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
|
shape: const Border(),
|
|
collapsedShape: const Border(),
|
|
title: Text(
|
|
question,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
children: [
|
|
Text(
|
|
answer,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
height: 1.6,
|
|
color: context.appColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (!isLast)
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 48),
|
|
child: Divider(
|
|
height: 1,
|
|
thickness: 0.5,
|
|
color: context.appColors.divider,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// ==================== 联系客服 ====================
|
|
|
|
Widget _buildContactSection() {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: context.appColors.cardBackground,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: context.appColors.cardShadow,
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
AppLocalizations.of(context).translate('help_feedback.contact_title'),
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
_buildContactItem(
|
|
Icons.phone_outlined,
|
|
AppLocalizations.of(context).translate('help_feedback.hotline'),
|
|
'400-000-0000',
|
|
onTap: () => _showPhoneDialog('400-000-0000'),
|
|
),
|
|
const Divider(height: 24),
|
|
_buildContactItem(
|
|
Icons.qr_code_2,
|
|
AppLocalizations.of(context).translate('help_feedback.wechat_work'),
|
|
AppLocalizations.of(context).translate('help_feedback.wechat_hint'),
|
|
onTap: () => debugPrint('显示企业微信二维码'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildContactItem(
|
|
IconData icon,
|
|
String title,
|
|
String subtitle, {
|
|
VoidCallback? onTap,
|
|
}) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
behavior: HitTestBehavior.opaque,
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, size: 22, color: context.appColors.textSecondary),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
),
|
|
const SizedBox(width: 6),
|
|
Icon(
|
|
Icons.chevron_right,
|
|
color: context.appColors.textTertiary,
|
|
size: 20,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// ==================== 意见反馈 ====================
|
|
|
|
Widget _buildFeedbackTab() {
|
|
return ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
// 反馈类型
|
|
_buildSectionCard(
|
|
title: AppLocalizations.of(context).translate('help_feedback.feedback_type'),
|
|
child: Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: _feedbackTypes.asMap().entries.map((entry) {
|
|
final index = entry.key;
|
|
final type = entry.value;
|
|
final isSelected = _selectedFeedbackType == index;
|
|
return GestureDetector(
|
|
onTap: () => setState(() => _selectedFeedbackType = index),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 14,
|
|
vertical: 8,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: isSelected
|
|
? const Color(0xFF165DFF).withOpacity(0.1)
|
|
: context.appColors.fillBackground,
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(
|
|
color: isSelected
|
|
? const Color(0xFF165DFF)
|
|
: Colors.transparent,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
type['icon'] as IconData,
|
|
size: 16,
|
|
color: isSelected
|
|
? const Color(0xFF165DFF)
|
|
: context.appColors.textSecondary,
|
|
),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
AppLocalizations.of(context).translate("help_feedback.${type['label']}"),
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
color: isSelected
|
|
? const Color(0xFF165DFF)
|
|
: context.appColors.textSecondary,
|
|
fontWeight:
|
|
isSelected ? FontWeight.w600 : FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// 问题描述
|
|
_buildSectionCard(
|
|
title: AppLocalizations.of(context).translate('help_feedback.problem_desc'),
|
|
child: TextField(
|
|
controller: _feedbackController,
|
|
maxLines: 5,
|
|
maxLength: 500,
|
|
decoration: InputDecoration(
|
|
hintText: AppLocalizations.of(context).translate('help_feedback.problem_hint'),
|
|
hintStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: BorderSide(color: context.appColors.divider),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: BorderSide(color: context.appColors.divider),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: const BorderSide(
|
|
color: Color(0xFF165DFF),
|
|
width: 1.5,
|
|
),
|
|
),
|
|
filled: true,
|
|
fillColor: context.appColors.fillBackground,
|
|
contentPadding: const EdgeInsets.all(12),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// 添加截图
|
|
_buildSectionCard(
|
|
title:
|
|
'${AppLocalizations.of(context).translate('help_feedback.add_screenshot')} (${_selectedImages.length}/6)',
|
|
child: Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
..._selectedImages.asMap().entries.map((entry) {
|
|
return _buildImageItem(entry.key, entry.value);
|
|
}),
|
|
if (_selectedImages.length < 6) _buildAddImageButton(),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// 联系方式
|
|
_buildSectionCard(
|
|
title: AppLocalizations.of(context).translate('help_feedback.contact_label'),
|
|
child: TextField(
|
|
controller: _contactController,
|
|
decoration: InputDecoration(
|
|
hintText: AppLocalizations.of(context).translate('help_feedback.contact_hint'),
|
|
hintStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: BorderSide(color: context.appColors.divider),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: BorderSide(color: context.appColors.divider),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: const BorderSide(
|
|
color: Color(0xFF165DFF),
|
|
width: 1.5,
|
|
),
|
|
),
|
|
filled: true,
|
|
fillColor: context.appColors.fillBackground,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
vertical: 14,
|
|
),
|
|
prefixIcon: const Icon(
|
|
Icons.phone_outlined,
|
|
size: 20,
|
|
color: Color(0xFF86909C),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// 提交按钮
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 48,
|
|
child: ElevatedButton(
|
|
onPressed: _submitFeedback,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF165DFF),
|
|
foregroundColor: Colors.white,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: Text(
|
|
AppLocalizations.of(context).translate('help_feedback.submit_feedback'),
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 32),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildSectionCard({
|
|
required String title,
|
|
required Widget child,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: context.appColors.cardBackground,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: context.appColors.cardShadow,
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.bold,
|
|
color: context.appColors.textPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
child,
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildImageItem(int index, String path) {
|
|
return Stack(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Image.file(
|
|
File(path),
|
|
width: 80,
|
|
height: 80,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (context, error, stackTrace) => Container(
|
|
width: 80,
|
|
height: 80,
|
|
color: context.appColors.fillBackground,
|
|
child: Icon(
|
|
Icons.broken_image_outlined,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 2,
|
|
right: 2,
|
|
child: GestureDetector(
|
|
onTap: () => setState(() => _selectedImages.removeAt(index)),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(2),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.black54,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.close,
|
|
size: 14,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildAddImageButton() {
|
|
return GestureDetector(
|
|
onTap: _pickImage,
|
|
child: Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
color: context.appColors.fillBackground,
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(
|
|
color: context.appColors.divider,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.add_photo_alternate_outlined,
|
|
size: 28,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
AppLocalizations.of(context).translate('help_feedback.add_screenshot'),
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
color: context.appColors.textTertiary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// ==================== 交互方法 ====================
|
|
|
|
void _showPhoneDialog(String phoneNumber) {
|
|
final loc = AppLocalizations.of(context);
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(loc.translate('help_feedback.hotline')),
|
|
content: SelectableText(
|
|
phoneNumber,
|
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(loc.translate('help_feedback.close')),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Clipboard.setData(ClipboardData(text: phoneNumber));
|
|
Navigator.pop(context);
|
|
ScaffoldMessenger.of(this.context).showSnackBar(
|
|
SnackBar(content: Text(loc.translate('help_feedback.number_copied'))),
|
|
);
|
|
},
|
|
child: Text(loc.translate('help_feedback.copy_number')),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void _pickImage() {
|
|
// 占位:接入 image_picker 后实现
|
|
debugPrint('选择图片');
|
|
setState(() {
|
|
_selectedImages.add('placeholder_${_selectedImages.length}');
|
|
});
|
|
}
|
|
|
|
void _submitFeedback() {
|
|
if (_feedbackController.text.trim().isEmpty) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(AppLocalizations.of(context).translate('help_feedback.please_input_desc')),
|
|
backgroundColor: const Color(0xFFF53F3F),
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
// TODO: 调用后端接口提交反馈
|
|
debugPrint('提交反馈: type=${_feedbackTypes[_selectedFeedbackType]['label']}, '
|
|
'content=${_feedbackController.text}, '
|
|
'images=${_selectedImages.length}, '
|
|
'contact=${_contactController.text}');
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(AppLocalizations.of(context).translate('help_feedback.submit_success')),
|
|
backgroundColor: context.appColors.success,
|
|
),
|
|
);
|
|
|
|
// 重置表单
|
|
_feedbackController.clear();
|
|
_contactController.clear();
|
|
setState(() {
|
|
_selectedFeedbackType = 0;
|
|
_selectedImages.clear();
|
|
});
|
|
}
|
|
}
|