You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

511 lines
15 KiB

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';
class ExploreView extends GetView<ExploreController> {
const ExploreView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[50],
body: SafeArea(
child: Column(
children: [
// 标题和搜索
_buildHeaderAndSearch(),
// 主要内容(可滚动)
Expanded(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 80.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 特色功能
_buildFeaturedCard(),
// AI功能列表
SizedBox(height: 24.h),
_buildAIFeaturesSection(),
// 热门功能场景
SizedBox(height: 24.h),
_buildFunctionScenesSection(),
// 新功能推荐
SizedBox(height: 24.h),
_buildNewFeatureSection(),
],
),
),
),
),
],
),
),
bottomNavigationBar: const CommonBottomNav(currentIndex: 1),
);
}
// 标题和搜索
Widget _buildHeaderAndSearch() {
return Padding(
padding: EdgeInsets.all(16.w),
child: Column(
children: [
// 标题和菜单按钮
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'发现',
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: Colors.grey[200],
shape: BoxShape.circle,
),
child: IconButton(
icon: Icon(Icons.more_vert, size: 16.sp),
padding: EdgeInsets.zero,
onPressed: () {},
),
),
],
),
// 搜索框
SizedBox(height: 16.h),
Container(
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12.r),
),
child: TextField(
controller: controller.searchController,
decoration: InputDecoration(
hintText: '搜索AI功能...',
hintStyle: TextStyle(
fontSize: 14.sp,
color: Colors.grey[400],
),
prefixIcon: Icon(
Icons.search,
size: 20.sp,
color: Colors.grey[400],
),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 12.h),
),
textInputAction: TextInputAction.search,
onSubmitted: (_) => controller.search(),
),
),
],
),
);
}
// 特色功能卡片
Widget _buildFeaturedCard() {
return Container(
height: 180.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24.r),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Stack(
children: [
// 背景图片
ClipRRect(
borderRadius: BorderRadius.circular(24.r),
child: Container(
color: Colors.blue.shade900, // 预设颜色,图片加载失败时显示
child: Image.asset(
'assets/images/explore.png',
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),
],
),
),
),
// 文本内容
Padding(
padding: EdgeInsets.all(24.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'智能耳机,无限可能',
style: TextStyle(
fontSize: 22.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(height: 4.h),
Text(
'探索DeepVoice提供的AI功能',
style: TextStyle(
fontSize: 14.sp,
color: Colors.white.withOpacity(0.8),
),
),
],
),
),
],
),
);
}
// AI功能部分
Widget _buildAIFeaturesSection() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'AI功能',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: Colors.grey[800],
),
),
SizedBox(height: 16.h),
GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16.w,
mainAxisSpacing: 16.h,
childAspectRatio: 1.0,
),
itemCount: controller.aiFeatures.length,
itemBuilder: (context, index) {
final feature = controller.aiFeatures[index];
return _buildAIFeatureItem(feature, index);
},
),
],
);
}
// AI功能项
Widget _buildAIFeatureItem(AIFeature feature, int index) {
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,
feature.endColor,
],
),
borderRadius: BorderRadius.circular(20.r),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
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: 18.sp,
fontWeight: FontWeight.w600,
color: Colors.grey[800],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 4.h),
// 描述
Text(
feature.description,
style: TextStyle(
fontSize: 13.sp,
color: Colors.grey[600],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
);
}
// 热门功能场景部分
Widget _buildFunctionScenesSection() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'热门功能场景',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: Colors.grey[800],
),
),
SizedBox(height: 16.h),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: controller.functionScenes.length,
itemBuilder: (context, index) {
final scene = controller.functionScenes[index];
return Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: _buildFunctionSceneItem(scene, index),
);
},
),
],
);
}
// 功能场景项
Widget _buildFunctionSceneItem(FunctionScene scene, int index) {
return GestureDetector(
onTap: () => controller.onFunctionSceneTap(index),
child: Container(
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
child: Row(
children: [
// 图标
Container(
width: 48.w,
height: 48.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
scene.startColor,
scene.endColor,
],
),
borderRadius: BorderRadius.circular(12.r),
),
child: Icon(
scene.icon,
size: 24.sp,
color: scene.iconColor,
),
),
SizedBox(width: 16.w),
// 文本内容
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
scene.title,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
color: Colors.grey[800],
),
),
SizedBox(height: 4.h),
Text(
scene.description,
style: TextStyle(
fontSize: 12.sp,
color: Colors.grey[600],
),
),
],
),
),
],
),
),
);
}
// 新功能推荐部分
Widget _buildNewFeatureSection() {
return Container(
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.purple.shade100,
Colors.purple.shade200,
],
),
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 图标
Container(
width: 48.w,
height: 48.w,
decoration: BoxDecoration(
color: Colors.purple.shade200,
borderRadius: BorderRadius.circular(12.r),
),
child: Icon(
Icons.lightbulb_outline,
size: 24.sp,
color: Colors.purple.shade600,
),
),
SizedBox(height: 16.h),
// 标题
Text(
'AI歌手模式',
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
SizedBox(height: 8.h),
// 描述
Text(
'用你喜欢的歌手声音演唱任何歌曲,甚至是你自己创作的歌曲',
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey[600],
),
),
SizedBox(height: 16.h),
// 按钮
ElevatedButton(
onPressed: controller.tryNewFeature,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.purple.shade500,
foregroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.r),
),
),
child: Text(
'立即尝试',
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w500,
),
),
),
],
),
);
}
}