import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; //import 'dart:ui'; import '../controllers/explore_controller.dart'; import '../../../core/widgets/common_bottom_nav.dart'; import '../../../data/models/appconfig.dart'; class ExploreView extends GetView { const ExploreView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; return Scaffold( backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], body: SafeArea( child: Column( children: [ // 标题和搜索 _buildHeaderAndSearch(isDarkMode), // 主要内容(可滚动) Expanded( child: SingleChildScrollView( //physics: const BouncingScrollPhysics(), child: Padding( padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 0.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // 特色功能 Container( height: 180.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(24.r), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 10, offset: const Offset(0, 4), ), ], ), child: PageView( children: [ // _buildFeaturedCard( // 'assets/images/explore1.png', // 'exploreSlogan1'.tr, // 智能陪伴,无限可能 // 'exploreAi'.tr, // 探索voitrans提供的AI功能 // ), _buildFeaturedCard( 'assets/images/explore.png', 'exploreSlogan'.tr, // 智能耳机,无限可能 'exploreAi'.tr, // 探索voitrans提供的AI功能 ), // _buildFeaturedCard( // 'assets/images/explore2.jpg', // 'exploreSlogan2'.tr, // 智能眼镜,无限可能 // 'exploreAi'.tr, // 探索voitrans提供的AI功能 // ), ], ), ), // AI功能列表 SizedBox(height: 24.h), AppConfig.hideAiAssistant ? _buildSimplifiedAILayout(isDarkMode) : _buildCustomAILayout(isDarkMode), ], ), ), ), ), ], ), ), bottomNavigationBar: const CommonBottomNav(currentIndex: 1), ); } // 标题和搜索 Widget _buildHeaderAndSearch(bool isDarkMode) { return Padding( padding: EdgeInsets.all(16.w), child: Column( children: [ // 标题和菜单按钮 Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'explore'.tr, // 发现 style: TextStyle( fontSize: 20.sp, fontWeight: FontWeight.bold, color: isDarkMode ? Colors.white : Colors.grey[800], ), ), // Container( // width: 32.w, // height: 32.w, // decoration: BoxDecoration( // color: isDarkMode // ? Colors.white.withOpacity(0.1) // : Colors.grey[200], // shape: BoxShape.circle, // ), // child: IconButton( // icon: Icon( // Icons.analytics_outlined, // size: 16.sp, // color: isDarkMode ? Colors.white : Colors.grey[700], // ), // padding: EdgeInsets.zero, // onPressed: controller.goToUsageStats, // ), // ), ], ), ], ), ); } // 特色功能卡片 Widget _buildFeaturedCard(String image, String title, String description) { return Stack( children: [ // 背景图片 ClipRRect( borderRadius: BorderRadius.circular(24.r), child: Container( color: Colors.blue.shade900, // 预设颜色,图片加载失败时显示 child: Image.asset( image, width: double.infinity, height: 180.h, fit: BoxFit.cover, errorBuilder: (context, error, stackTrace) { return Container( color: Colors.blue.shade900, width: double.infinity, height: 180.h, child: Icon( Icons.image_not_supported, color: Colors.white, size: 40.sp, ), ); }, ), ), ), // 渐变遮罩 Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(24.r), gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Colors.black.withOpacity(0.1), Colors.black.withOpacity(0.6), ], ), ), ), // 文本内容 Positioned( bottom: 0, left: 0, right: 0, child: Padding( padding: EdgeInsets.all(24.w), child: Column( mainAxisSize: MainAxisSize.min, // 使用最小尺寸,避免占用过多空间 crossAxisAlignment: CrossAxisAlignment.start, children: [ // 标题文本 - 支持多行显示 Text( title, style: TextStyle( fontSize: 22.sp, fontWeight: FontWeight.bold, color: Colors.white, height: 1.2, // 设置行高,提升多行文本可读性 ), softWrap: true, // 启用软换行 overflow: TextOverflow.visible, // 确保文本完全显示 ), SizedBox(height: 6.h), // 稍微增加间距,适应多行布局 // 描述文本 - 支持多行显示 Text( description, style: TextStyle( fontSize: 14.sp, color: Colors.white.withOpacity(0.8), height: 1.3, // 设置行高,提升多行文本可读性 ), softWrap: true, // 启用软换行 overflow: TextOverflow.visible, // 确保文本完全显示 ), ], ), ), ), ], ); } // 自定义AI功能布局:2x2网格 Widget _buildCustomAILayout(bool isDarkMode) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'aiFunction'.tr, // AI功能 style: TextStyle( fontSize: 18.sp, fontWeight: FontWeight.w600, color: isDarkMode ? Colors.white : Colors.grey[800], ), ), SizedBox(height: 16.h), // 2x2网格布局 Column( children: [ // 上层:AI全能助手(左)和同声传译(右) Row( children: [ // 左上角:AI全能助手 Expanded( child: AspectRatio( aspectRatio: 1.0, // 正方形 child: _buildAIFeatureItem( controller.aiFeatures[0], 0, isDarkMode, ), ), ), SizedBox(width: 16.w), // 右上角:同声传译 Expanded( child: AspectRatio( aspectRatio: 1.0, // 正方形 child: _buildAIFeatureItem( controller.aiFeatures[1], 1, isDarkMode, ), ), ), ], ), SizedBox(height: 16.h), // 下层:商务会议助手(占据一行) AspectRatio( aspectRatio: 2.0, // 正方形 child: _buildAIFeatureItemWide( controller.aiFeatures[2], 2, isDarkMode, ), ), ], ), ], ); } // AI功能项 Widget _buildAIFeatureItem(AIFeature feature, int index, bool isDarkMode) { return GestureDetector( onTap: () => controller.onAIFeatureTap(index), child: Container( padding: EdgeInsets.all(20.w), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ feature.startColor.withOpacity(isDarkMode ? 0.3 : 0.3), feature.endColor.withOpacity(isDarkMode ? 0.3 : 0.3), ], ), borderRadius: BorderRadius.circular(20.r), boxShadow: [ BoxShadow( color: isDarkMode ? Colors.black.withOpacity(0.2) : Colors.grey.withOpacity(0.1), blurRadius: 8, offset: const Offset(0, 4), ), ], ), child: Stack( children: [ // 图标圆圈 Align( alignment: Alignment.topLeft, child: Container( width: 48.w, height: 48.w, decoration: BoxDecoration( color: feature.iconColor.withOpacity(0.2), shape: BoxShape.circle, ), child: Icon( feature.icon, size: 24.sp, color: feature.iconColor, ), ), ), // 文本内容 Padding( padding: EdgeInsets.only(top: 58.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ // 标题 Text( feature.title, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.w600, color: isDarkMode ? Colors.white : Colors.grey[800], ), maxLines: 1, overflow: TextOverflow.ellipsis, ), SizedBox(height: 4.h), // 描述 Text( feature.description, style: TextStyle( fontSize: 12.sp, color: isDarkMode ? Colors.grey[400] : Colors.grey[600], ), maxLines: 2, overflow: TextOverflow.ellipsis, ), ], ), ), ], ), ), ); } // AI功能项(宽版本) Widget _buildAIFeatureItemWide( AIFeature feature, int index, bool isDarkMode) { return GestureDetector( onTap: () => controller.onAIFeatureTap(index), child: Container( padding: EdgeInsets.all(20.w), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ feature.startColor.withValues(alpha: isDarkMode ? 0.3 : 0.3), feature.endColor.withValues(alpha: isDarkMode ? 0.3 : 0.3), ], ), borderRadius: BorderRadius.circular(20.r), boxShadow: [ BoxShadow( color: isDarkMode ? Colors.black.withValues(alpha: 0.2) : Colors.grey.withValues(alpha: 0.1), blurRadius: 8, offset: const Offset(0, 4), ), ], ), child: Row( children: [ // 图标圆圈 Container( width: 48.w, height: 48.w, decoration: BoxDecoration( color: feature.iconColor.withValues(alpha: 0.2), shape: BoxShape.circle, ), child: Icon( feature.icon, size: 24.sp, color: feature.iconColor, ), ), SizedBox(width: 16.w), // 文本内容 Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ // 标题 Text( feature.title, style: TextStyle( fontSize: 18.sp, fontWeight: FontWeight.w600, color: isDarkMode ? Colors.white : Colors.grey[800], ), maxLines: 2, overflow: TextOverflow.ellipsis, ), SizedBox(height: 4.h), // 描述 Text( feature.description, style: TextStyle( fontSize: 14.sp, color: isDarkMode ? Colors.grey[400] : Colors.grey[600], ), maxLines: 2, overflow: TextOverflow.ellipsis, ), ], ), ), ], ), ), ); } // 精简布局:隐藏"AI全能助手",仅保留翻译 + 会议助手,上下堆叠 banner 卡 // 复用 controller.aiFeatures 中索引 1(翻译)和 2(会议助手)的数据 Widget _buildSimplifiedAILayout(bool isDarkMode) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'aiFunction'.tr, // AI功能 style: TextStyle( fontSize: 18.sp, fontWeight: FontWeight.w600, color: isDarkMode ? Colors.white : Colors.grey[800], ), ), SizedBox(height: 16.h), // 翻译(banner 卡) _buildSimplifiedBannerCard(controller.aiFeatures[1], 1, isDarkMode), SizedBox(height: 12.h), // 会议助手(banner 卡) _buildSimplifiedBannerCard(controller.aiFeatures[2], 2, isDarkMode), ], ); } // 精简布局下的 banner 卡(图标右上角,标题/描述左下角) Widget _buildSimplifiedBannerCard( AIFeature feature, int index, bool isDarkMode) { return GestureDetector( onTap: () => controller.onAIFeatureTap(index), child: Container( height: 130.h, padding: EdgeInsets.all(16.w), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ feature.startColor.withOpacity(0.3), feature.endColor.withOpacity(0.3), ], ), borderRadius: BorderRadius.circular(20.r), boxShadow: [ BoxShadow( color: isDarkMode ? Colors.black.withOpacity(0.2) : Colors.grey.withOpacity(0.1), blurRadius: 8, offset: const Offset(0, 4), ), ], ), child: Stack( children: [ // 图标右上角 Positioned( top: 0, right: 0, child: Container( width: 44.w, height: 44.w, decoration: BoxDecoration( color: feature.iconColor.withOpacity(0.2), shape: BoxShape.circle, ), child: Icon( feature.icon, size: 22.sp, color: feature.iconColor, ), ), ), // 标题 + 描述左下角 Align( alignment: Alignment.bottomLeft, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( feature.title, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.w600, color: isDarkMode ? Colors.white : Colors.grey[800], ), maxLines: 1, overflow: TextOverflow.ellipsis, ), SizedBox(height: 4.h), Text( feature.description, style: TextStyle( fontSize: 12.sp, color: isDarkMode ? Colors.grey[400] : Colors.grey[600], ), maxLines: 2, overflow: TextOverflow.ellipsis, ), ], ), ), ], ), ), ); } }