|
|
|
@ -1,3 +1,4 @@ |
|
|
|
import 'package:common_utils/common_utils.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:intl/intl.dart'; |
|
|
|
@ -211,8 +212,19 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
//音乐播放列表 |
|
|
|
return _buildMusicContent(context, playlist); |
|
|
|
} else if (mate!.keys.contains('card_weather')) { |
|
|
|
final city = mate!['card_weather']['city'] as String; |
|
|
|
|
|
|
|
final rawList = mate!['card_weather']['dayweather'] as List; |
|
|
|
final daylist = |
|
|
|
rawList.map((e) => Map<String, dynamic>.from(e)).toList(); |
|
|
|
final now = daylist[0]; |
|
|
|
//天气 |
|
|
|
return _buildWeatherContent(context); |
|
|
|
return _buildWeatherContent( |
|
|
|
context, |
|
|
|
city, |
|
|
|
now, |
|
|
|
daylist, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// if (message.contains('播放列表') || message.contains('音乐')) { |
|
|
|
@ -659,7 +671,8 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建天气内容卡片 |
|
|
|
Widget _buildWeatherContent(BuildContext context) { |
|
|
|
Widget _buildWeatherContent(BuildContext context, String city, |
|
|
|
Map<String, dynamic> now, List<Map<String, dynamic>> days) { |
|
|
|
return Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
@ -701,7 +714,7 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
'北京', |
|
|
|
city, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
@ -710,7 +723,7 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
), |
|
|
|
SizedBox(height: 4), |
|
|
|
Text( |
|
|
|
'晴朗', |
|
|
|
now["weatherCondition"], |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14, |
|
|
|
color: Colors.white.withOpacity(0.9), |
|
|
|
@ -720,7 +733,7 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
Row( |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
'25°', |
|
|
|
"${now["temperature"]}°", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 36, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
@ -732,14 +745,14 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
'最高: 29°', |
|
|
|
'最高: ${now["maxTemperature"]}°', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12, |
|
|
|
color: Colors.white.withOpacity(0.9), |
|
|
|
), |
|
|
|
), |
|
|
|
Text( |
|
|
|
'最低: 18°', |
|
|
|
'最低: ${now["minTemperature"]}°', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12, |
|
|
|
color: Colors.white.withOpacity(0.9), |
|
|
|
@ -773,15 +786,31 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 8), |
|
|
|
// Row( |
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
// children: [ |
|
|
|
// _buildForecastDay('周一', Icons.wb_sunny, '28°'), |
|
|
|
// _buildForecastDay('周二', Icons.cloud, '25°'), |
|
|
|
// _buildForecastDay('周三', Icons.wb_cloudy, '26°'), |
|
|
|
// _buildForecastDay('周四', Icons.grain, '24°'), |
|
|
|
// _buildForecastDay('周五', Icons.wb_sunny, '27°'), |
|
|
|
// ], |
|
|
|
// ), |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: [ |
|
|
|
_buildForecastDay('周一', Icons.wb_sunny, '28°'), |
|
|
|
_buildForecastDay('周二', Icons.cloud, '25°'), |
|
|
|
_buildForecastDay('周三', Icons.wb_cloudy, '26°'), |
|
|
|
_buildForecastDay('周四', Icons.grain, '24°'), |
|
|
|
_buildForecastDay('周五', Icons.wb_sunny, '27°'), |
|
|
|
], |
|
|
|
children: List.generate( |
|
|
|
days.length, |
|
|
|
(index) { |
|
|
|
String dateStr = days[index]['date']; |
|
|
|
DateTime? date = DateUtil.getDateTime(dateStr); |
|
|
|
String weekday = DateUtil.getWeekday(date); |
|
|
|
return _buildForecastDay( |
|
|
|
weekday, |
|
|
|
Icons.wb_sunny, |
|
|
|
days[index]['temperature'], |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 16), |
|
|
|
Container( |
|
|
|
@ -790,7 +819,7 @@ class MessageBubble extends GetView<AgentController> { |
|
|
|
color: Colors.white.withOpacity(0.2), |
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
), |
|
|
|
child: Row( |
|
|
|
child: const Row( |
|
|
|
children: [ |
|
|
|
Icon( |
|
|
|
Icons.info_outline, |
|
|
|
|