178 lines
6.4 KiB
Dart
178 lines
6.4 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:airhub_app/theme/design_tokens.dart';
|
|
import 'package:airhub_app/widgets/ios_toast.dart';
|
|
import 'package:airhub_app/features/system/data/datasources/system_remote_data_source.dart';
|
|
|
|
class FeedbackDialog extends ConsumerStatefulWidget {
|
|
const FeedbackDialog({super.key});
|
|
|
|
@override
|
|
ConsumerState<FeedbackDialog> createState() => _FeedbackDialogState();
|
|
}
|
|
|
|
class _FeedbackDialogState extends ConsumerState<FeedbackDialog> {
|
|
final _contentController = TextEditingController();
|
|
final _contactController = TextEditingController();
|
|
bool _submitting = false;
|
|
|
|
@override
|
|
void dispose() {
|
|
_contentController.dispose();
|
|
_contactController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _submit() async {
|
|
final content = _contentController.text.trim();
|
|
if (content.isEmpty) {
|
|
AppToast.show(context, '请输入反馈内容', isError: true);
|
|
return;
|
|
}
|
|
|
|
setState(() => _submitting = true);
|
|
|
|
try {
|
|
final dataSource = ref.read(systemRemoteDataSourceProvider);
|
|
await dataSource.submitFeedback(
|
|
content,
|
|
contact: _contactController.text.trim(),
|
|
);
|
|
if (mounted) {
|
|
AppToast.show(context, '感谢您的反馈!');
|
|
Navigator.of(context).pop();
|
|
}
|
|
} catch (_) {
|
|
if (mounted) {
|
|
AppToast.show(context, '提交失败,请稍后重试', isError: true);
|
|
setState(() => _submitting = false);
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
insetPadding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.9),
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(color: Colors.white.withOpacity(0.5)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Center(
|
|
child: Text('意见反馈', style: AppTextStyles.modalTitle),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Container(
|
|
height: 120,
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF3F4F6),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: TextField(
|
|
controller: _contentController,
|
|
maxLines: null,
|
|
decoration: const InputDecoration(
|
|
hintText: '请输入您的意见或建议...',
|
|
border: InputBorder.none,
|
|
hintStyle: TextStyle(
|
|
color: Color(0xFF9CA3AF),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
style: const TextStyle(fontSize: 14),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF3F4F6),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: TextField(
|
|
controller: _contactController,
|
|
decoration: const InputDecoration(
|
|
hintText: '联系方式(选填)',
|
|
border: InputBorder.none,
|
|
hintStyle: TextStyle(
|
|
color: Color(0xFF9CA3AF),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
style: const TextStyle(fontSize: 14),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: _submitting ? null : () => Navigator.of(context).pop(),
|
|
style: TextButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
backgroundColor: const Color(0xFFF3F4F6),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: const Text(
|
|
'取消',
|
|
style: TextStyle(
|
|
color: Color(0xFF6B7280),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: _submitting ? null : _submit,
|
|
style: TextButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
backgroundColor: const Color(0xFF1F2937),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: _submitting
|
|
? const SizedBox(
|
|
width: 20,
|
|
height: 20,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
color: Colors.white,
|
|
),
|
|
)
|
|
: const Text(
|
|
'提交',
|
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|