Browse Source

上传天气预报卡片话修复

newdev_shunjiawei
liwei1dao 1 year ago
parent
commit
7f2e3894de
  1. 8
      lib/modules/agent/views/message_bubble.dart
  2. 16
      lib/modules/agent/views/weather_card.dart

8
lib/modules/agent/views/message_bubble.dart

@ -249,12 +249,12 @@ class MessageBubble extends GetView<AgentController> {
rawList.map((e) => Map<String, dynamic>.from(e)).toList(); rawList.map((e) => Map<String, dynamic>.from(e)).toList();
//音乐播放列表 //音乐播放列表
return buildMusicContent(context, playlist); return buildMusicContent(context, playlist);
} else if (meta!.keys.contains('card_weather')) { } else if (meta!.keys.contains('maps_weather')) {
final city = meta!['card_weather']['city'] as String; final city = meta!['maps_weather']['city'] as String;
final rawList = meta!['card_weather']['dayweather'] as List; final rawList = meta!['maps_weather']['forecasts'] as List;
final daylist = final daylist =
rawList.map((e) => Map<String, dynamic>.from(e)).toList(); rawList.map((e) => Map<String, dynamic>.from(e)).toList();
final now = meta!['card_weather']['day'] as Map<String, dynamic>; final now = daylist[0] as Map<String, dynamic>;
//天气 //天气
return buildWeatherContent( return buildWeatherContent(
context, context,

16
lib/modules/agent/views/weather_card.dart

@ -62,7 +62,7 @@ Widget buildWeatherContent(BuildContext context, String city,
), ),
SizedBox(height: 4), SizedBox(height: 4),
Text( Text(
now["weatherCondition"], now["dayweather"],
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.white.withOpacity(0.9), color: Colors.white.withOpacity(0.9),
@ -72,7 +72,7 @@ Widget buildWeatherContent(BuildContext context, String city,
Row( Row(
children: [ children: [
Text( Text(
"${now["temperature"]}°", "${now["daytemp"]}°",
style: const TextStyle( style: const TextStyle(
fontSize: 36, fontSize: 36,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -84,14 +84,14 @@ Widget buildWeatherContent(BuildContext context, String city,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'最高: ${now["maxTemperature"]}°', '最高: ${now["daytemp"]}°',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Colors.white.withOpacity(0.9), color: Colors.white.withOpacity(0.9),
), ),
), ),
Text( Text(
'最低: ${now["minTemperature"]}°', '最低: ${now["nighttemp"]}°',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Colors.white.withOpacity(0.9), color: Colors.white.withOpacity(0.9),
@ -103,8 +103,8 @@ Widget buildWeatherContent(BuildContext context, String city,
), ),
], ],
), ),
const Icon( Icon(
Icons.wb_sunny, getWeatherIcon(now['dayweather']),
size: 48, size: 48,
color: Colors.white, color: Colors.white,
), ),
@ -133,10 +133,10 @@ Widget buildWeatherContent(BuildContext context, String city,
String dateStr = days[index]['date']; String dateStr = days[index]['date'];
DateTime? date = DateUtil.getDateTime(dateStr); DateTime? date = DateUtil.getDateTime(dateStr);
IconData weatherIcon = IconData weatherIcon =
getWeatherIcon(days[index]['weatherCondition']); getWeatherIcon(days[index]['dayweather']);
String weekday = DateUtil.getWeekday(date, String weekday = DateUtil.getWeekday(date,
languageCode: "zh", short: true); languageCode: "zh", short: true);
String temp = "${days[index]['temperature']}°"; String temp = "${days[index]['daytemp']}°";
return _buildForecastDay( return _buildForecastDay(
weekday, weekday,
weatherIcon, weatherIcon,

Loading…
Cancel
Save