Browse Source

上传天气预报卡片话修复

weicu
liwei1dao 1 year ago
parent
commit
ce43779114
  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();
//音乐播放列表
return buildMusicContent(context, playlist);
} else if (meta!.keys.contains('card_weather')) {
final city = meta!['card_weather']['city'] as String;
final rawList = meta!['card_weather']['dayweather'] as List;
} else if (meta!.keys.contains('maps_weather')) {
final city = meta!['maps_weather']['city'] as String;
final rawList = meta!['maps_weather']['forecasts'] as List;
final daylist =
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(
context,

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

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

Loading…
Cancel
Save