|
|
|
@ -1,29 +1,32 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
/// 构建旅游内容卡片 |
|
|
|
Widget buildTravelContent( |
|
|
|
BuildContext context, List<Map<String, dynamic>> travellist) { |
|
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
|
|
|
|
return Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
const Text( |
|
|
|
'以下是一些推搜索结果:', |
|
|
|
Text( |
|
|
|
'以下是一些推荐搜索结果:', |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black87, |
|
|
|
fontSize: 14, |
|
|
|
color: isDarkMode ? Colors.white.withValues(alpha: 0.9) : Colors.black87, |
|
|
|
fontSize: 14.sp, |
|
|
|
height: 1.4, |
|
|
|
fontWeight: FontWeight.w400, |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 12), |
|
|
|
SizedBox(height: 12.h), |
|
|
|
Container( |
|
|
|
padding: const EdgeInsets.all(12), |
|
|
|
padding: EdgeInsets.all(12.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.white, |
|
|
|
borderRadius: BorderRadius.circular(12), |
|
|
|
color: isDarkMode ? const Color(0xFF1E1E1E) : Colors.white, |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withOpacity(0.03), |
|
|
|
color: Colors.black.withValues(alpha: isDarkMode ? 0.2 : 0.03), |
|
|
|
blurRadius: 3, |
|
|
|
spreadRadius: 1, |
|
|
|
offset: const Offset(0, 1), |
|
|
|
@ -53,16 +56,16 @@ Widget buildTravelContent( |
|
|
|
// ), |
|
|
|
// const SizedBox(height: 10), |
|
|
|
|
|
|
|
// 动态生成音乐条目 |
|
|
|
// 动态生成旅游景点条目 |
|
|
|
...travellist.asMap().entries.map((entry) { |
|
|
|
final index = entry.key; |
|
|
|
final item = entry.value; |
|
|
|
final name = item["name"] ?? "未知歌曲"; //名字 |
|
|
|
final name = item["name"] ?? "未知景点"; //名字 |
|
|
|
final addr = item["addr"] ?? ""; //地址 |
|
|
|
final tag = item["tag"] ?? "未知歌手"; //标签 |
|
|
|
final rating = item["rating"] ?? ""; //评分 |
|
|
|
final distance = item["distance"] ?? ""; //距离 |
|
|
|
final images = item["images"] ?? []; // 图片列表 |
|
|
|
// final tag = item["tag"] ?? "未知标签"; //标签 |
|
|
|
// final rating = item["rating"] ?? ""; //评分 |
|
|
|
// final distance = item["distance"] ?? ""; //距离 |
|
|
|
// final images = item["images"] ?? []; // 图片列表 |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
buildLocationItem( |
|
|
|
@ -71,7 +74,11 @@ Widget buildTravelContent( |
|
|
|
addr, |
|
|
|
), |
|
|
|
if (index != travellist.length - 1) |
|
|
|
Divider(height: 1, thickness: 1, color: Colors.grey[100]), |
|
|
|
Divider( |
|
|
|
height: 1.h, |
|
|
|
thickness: 1, |
|
|
|
color: isDarkMode ? Colors.grey[700] : Colors.grey[100] |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
}).toList(), |
|
|
|
@ -82,19 +89,19 @@ Widget buildTravelContent( |
|
|
|
// Divider(height: 1, thickness: 1, color: Colors.grey[100]), |
|
|
|
// _buildLocationItem('浅草寺', '东京最古老的寺庙', context), |
|
|
|
|
|
|
|
const SizedBox(height: 8), |
|
|
|
SizedBox(height: 8.h), |
|
|
|
Center( |
|
|
|
child: TextButton( |
|
|
|
onPressed: () {}, |
|
|
|
style: TextButton.styleFrom( |
|
|
|
minimumSize: Size.zero, |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h), |
|
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap, |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'查看更多景点', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12, |
|
|
|
fontSize: 12.sp, |
|
|
|
color: Theme.of(context).primaryColor, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
@ -104,41 +111,41 @@ Widget buildTravelContent( |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 10), |
|
|
|
SizedBox(height: 10.h), |
|
|
|
Row( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
child: OutlinedButton.icon( |
|
|
|
onPressed: () {}, |
|
|
|
icon: Icon(Icons.map, size: 16), |
|
|
|
label: Text('查看地图'), |
|
|
|
icon: Icon(Icons.map, size: 16.sp), |
|
|
|
label: const Text('查看地图'), |
|
|
|
style: OutlinedButton.styleFrom( |
|
|
|
foregroundColor: Theme.of(context).primaryColor, |
|
|
|
side: BorderSide( |
|
|
|
color: Theme.of(context).primaryColor.withOpacity(0.5)), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4), |
|
|
|
color: Theme.of(context).primaryColor.withValues(alpha: 0.5)), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 4.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16), |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
textStyle: TextStyle(fontSize: 12), |
|
|
|
textStyle: TextStyle(fontSize: 12.sp), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 8), |
|
|
|
SizedBox(width: 8.w), |
|
|
|
Expanded( |
|
|
|
child: OutlinedButton.icon( |
|
|
|
onPressed: () {}, |
|
|
|
icon: Icon(Icons.bookmark_border, size: 16), |
|
|
|
label: Text('保存到收藏'), |
|
|
|
icon: Icon(Icons.bookmark_border, size: 16.sp), |
|
|
|
label: const Text('保存到收藏'), |
|
|
|
style: OutlinedButton.styleFrom( |
|
|
|
foregroundColor: Colors.grey[700], |
|
|
|
side: BorderSide(color: Colors.grey[400]!), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4), |
|
|
|
foregroundColor: isDarkMode ? Colors.grey[400] : Colors.grey[700], |
|
|
|
side: BorderSide(color: isDarkMode ? Colors.grey[600]! : Colors.grey[400]!), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 4.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16), |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
textStyle: TextStyle(fontSize: 12), |
|
|
|
textStyle: TextStyle(fontSize: 12.sp), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
@ -154,23 +161,25 @@ Widget buildLocationItem( |
|
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
|
|
|
|
return Padding( |
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8), |
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.h), |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
width: 38, |
|
|
|
height: 38, |
|
|
|
width: 38.w, |
|
|
|
height: 38.h, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode ? Color(0xFF1A365D) : Colors.blue[50], |
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
color: isDarkMode |
|
|
|
? const Color(0xFF2A2A2A) |
|
|
|
: Theme.of(context).primaryColor.withValues(alpha: 0.1), |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
Icons.place, |
|
|
|
size: 18, |
|
|
|
color: Color(0xFFE11D48), |
|
|
|
size: 18.sp, |
|
|
|
color: Theme.of(context).primaryColor, |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(width: 12), |
|
|
|
SizedBox(width: 12.w), |
|
|
|
Expanded( |
|
|
|
child: Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
@ -178,19 +187,19 @@ Widget buildLocationItem( |
|
|
|
Text( |
|
|
|
name, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13, |
|
|
|
fontSize: 13.sp, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
color: isDarkMode |
|
|
|
? Colors.white.withOpacity(0.9) |
|
|
|
? Colors.white.withValues(alpha: 0.9) |
|
|
|
: Colors.grey[800], |
|
|
|
), |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
), |
|
|
|
SizedBox(height: 2), |
|
|
|
SizedBox(height: 2.h), |
|
|
|
Text( |
|
|
|
description, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12, |
|
|
|
fontSize: 12.sp, |
|
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[600], |
|
|
|
), |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
@ -200,10 +209,13 @@ Widget buildLocationItem( |
|
|
|
), |
|
|
|
IconButton( |
|
|
|
onPressed: () {}, |
|
|
|
icon: Icon(Icons.arrow_forward, color: Colors.grey[400]), |
|
|
|
icon: Icon( |
|
|
|
Icons.arrow_forward, |
|
|
|
color: isDarkMode ? Colors.grey[500] : Colors.grey[400] |
|
|
|
), |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
constraints: BoxConstraints(), |
|
|
|
iconSize: 20, |
|
|
|
constraints: const BoxConstraints(), |
|
|
|
iconSize: 20.sp, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
|