Browse Source

fix(agent): 修复图片查看器路径处理并优化交互体验

- 处理图片路径拼接逻辑,支持相对路径和完整路径
- 移除AppBar改为点击图片退出查看器
- 优化图片查看器的交互方式
weicu
lxm 1 year ago
parent
commit
178d3d0a9b
  1. 2
      lib/data/services/novice_guide_service.dart
  2. 49
      lib/modules/agent/controllers/agent_controller.dart

2
lib/data/services/novice_guide_service.dart

@ -12,7 +12,7 @@ class NoviceGuideService extends GetxService {
StreamSubscription<dynamic>? _statusSubscription;
bool isHomeGuide = true;
bool isAIGuide = false;
bool isAIGuide = true;
RxBool isWakeup = false.obs;

49
lib/modules/agent/controllers/agent_controller.dart

@ -1759,21 +1759,52 @@ class AgentController extends GetxController {
// 打开图片查看器
void openImageViewer(BuildContext context, String imagePath) {
// 构建完整的图片路径
String fullImagePath;
if (imagePath.startsWith('/')) {
// 如果是相对路径(以/开头),需要拼接AppDir.value
fullImagePath = '${AppDir.value}$imagePath';
} else {
// 如果已经是完整路径,直接使用
fullImagePath = imagePath;
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
backgroundColor: Colors.black,
iconTheme: IconThemeData(color: Colors.white),
),
// appBar: AppBar(
// backgroundColor: Colors.black,
// leading: IconButton(
// icon: Icon(Icons.arrow_back_ios, color: Colors.white),
// onPressed: () => Navigator.of(context).pop(),
// ),
// iconTheme: IconThemeData(color: Colors.white),
// //title: Text('图片预览', style: TextStyle(color: Colors.white)),
// ),
body: Container(
color: Colors.black,
child: PhotoView(
imageProvider: FileImage(File(imagePath)),
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2,
backgroundDecoration: BoxDecoration(color: Colors.black),
child: GestureDetector(
onTap: () => Navigator.of(context).pop(), // 点击退出
child: PhotoView(
imageProvider: FileImage(File(fullImagePath)),
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2,
backgroundDecoration: BoxDecoration(color: Colors.black),
// errorBuilder: (context, error, stackTrace) {
// return const Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Icon(Icons.error, color: Colors.white, size: 64),
// SizedBox(height: 16),
// Text('图片加载失败', style: TextStyle(color: Colors.white)),
// ],
// ),
// );
// },
),
),
),
),

Loading…
Cancel
Save