Browse Source

修改天气卡片

weicu
tanlongsheng 2 years ago
parent
commit
120e8f8e12
  1. 6
      .mcp.json
  2. 4
      lib/modules/chat/controllers/chat_controller.dart
  3. 2
      lib/modules/chat/views/chat_navigation_card.dart
  4. 2
      lib/modules/chat/views/chat_view.dart
  5. 82
      lib/modules/chat/views/weather_day_card.dart

6
.mcp.json

@ -2,7 +2,9 @@
"mcpServers": {
"deepsound-mcp": {
"url": "https://api.deapsound.com/sse"
},
"voitrans-mcp": {
"url": "https://www.voitrans.net/sse"
}
}
}
}

4
lib/modules/chat/controllers/chat_controller.dart

@ -36,7 +36,7 @@ class ChatController extends GetxController {
final _amapFlutter = AmapFlutter();
StreamSubscription? _locationStream;
String _latLng = '';
String _city = '';
String _city = '深圳市';
// Agent 信息
late final Agent agent;
@ -456,7 +456,7 @@ class ChatController extends GetxController {
if (i == recentMessages.length - 2) {
messageHistory.add({
'role': 'user',
'content': '我当前在$_city,我的经纬度是$_latLng',
'content': '当需要获取我的位置时,我当前在$_city,我的经纬度是$_latLng',
});
}
}

2
lib/modules/chat/views/chat_navigation_card.dart

@ -41,7 +41,7 @@ class _ChatNavigationCardState extends State<ChatNavigationCard> {
}
void _getLocation() async {
List endPointList = widget.data?['location'].split(',');
List endPointList = widget.data?['companyName'].split(',');
endPoint = LatLng(
double.parse(endPointList[0]),
double.parse(endPointList[1]),

2
lib/modules/chat/views/chat_view.dart

@ -357,7 +357,7 @@ class ChatView extends GetView<ChatController> {
}
if (message.data != null) {
if (message.data?['card_weather'] != null) {
box = WeatherDayCard(message.data, isDarkMode);
box = WeatherDayCard(message.data?['card_weather'], isDarkMode);
}
if (message.data?['card_spotify'] != null) {
box = ChatMusicCard(message.data?['card_spotify'], isDarkMode);

82
lib/modules/chat/views/weather_day_card.dart

@ -9,8 +9,6 @@ class WeatherDayCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Map weatherDays = data?['weatherDays'].first;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
@ -19,14 +17,14 @@ class WeatherDayCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
weatherDays['date'],
data?['date'],
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp,
),
),
Text(
'${weatherDays['maxTemperature']}°',
'${data?['temperature']}°',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 30.sp,
@ -43,49 +41,49 @@ class WeatherDayCard extends StatelessWidget {
size: 18.w,
),
Text(
'${weatherDays['weatherCondition']},${weatherDays['windDirection']}',
'${data?['weatherCondition']},${data?['windDirection']}',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 14.sp,
),
),
Row(
children: [
Text(
'最\n高',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp,
height: 1,
),
),
5.horizontalSpace,
Text(
'${weatherDays['maxTemperature']}°',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 20.sp,
),
),
10.horizontalSpace,
Text(
'最\n低',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp,
height: 1,
),
),
5.horizontalSpace,
Text(
'${weatherDays['minTemperature']}°',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black,
fontSize: 20.sp,
),
),
],
),
// Row(
// children: [
// Text(
// '最\n高',
// style: TextStyle(
// color: isDarkMode ? Colors.white : Colors.black,
// fontSize: 10.sp,
// height: 1,
// ),
// ),
// 5.horizontalSpace,
// Text(
// '${data?['maxTemperature']}°',
// style: TextStyle(
// color: isDarkMode ? Colors.white : Colors.black,
// fontSize: 20.sp,
// ),
// ),
// 10.horizontalSpace,
// Text(
// '最\n低',
// style: TextStyle(
// color: isDarkMode ? Colors.white : Colors.black,
// fontSize: 10.sp,
// height: 1,
// ),
// ),
// 5.horizontalSpace,
// Text(
// '${data?['minTemperature']}°',
// style: TextStyle(
// color: isDarkMode ? Colors.white : Colors.black,
// fontSize: 20.sp,
// ),
// ),
// ],
// ),
],
),
],

Loading…
Cancel
Save