From 3a79d7036860f0dd8b47d58be3a5dd427358de59 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 15 May 2025 21:23:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/agent/views/message_bubble.dart | 6 ++ .../views/message_bubble_navigation.dart | 96 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 lib/modules/agent/views/message_bubble_navigation.dart diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index 2c13b6f80..1610fd65c 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -1,4 +1,5 @@ import 'package:common_utils/common_utils.dart'; +import 'package:deep_voice/modules/agent/views/message_bubble_navigation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -230,6 +231,11 @@ class MessageBubble extends GetView { rawList.map((e) => Map.from(e)).toList(); // 旅游 return _buildTravelContent(context, travellist); + } else if (mate!.keys.contains('card_navigation')) { + final rawList = mate!['card_navigation']['items'] as List; + final list = rawList.map((e) => Map.from(e)).toList(); + // 导航 + return navigationCard(context, modes: list); } // if (message.contains('播放列表') || message.contains('音乐')) { diff --git a/lib/modules/agent/views/message_bubble_navigation.dart b/lib/modules/agent/views/message_bubble_navigation.dart new file mode 100644 index 000000000..8ee1cd4bd --- /dev/null +++ b/lib/modules/agent/views/message_bubble_navigation.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; + +/// A widget that displays a navigation card with different modes of transportation. +Widget navigationCard( + BuildContext context, { + required List> modes, + double height = 260, +}) { + int currentIndex = 0; + + return Container( + height: height, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + color: Colors.white, + boxShadow: const [ + BoxShadow( + blurRadius: 8, + color: Colors.black12, + offset: Offset(0, 4), + ), + ], + ), + child: StatefulBuilder( + builder: (context, setInnerState) { + return Column( + children: [ + // 路线图片 + ClipRRect( + borderRadius: + const BorderRadius.vertical(top: Radius.circular(16)), + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: Image.network( + modes[currentIndex]["image"] as String, + key: ValueKey(modes[currentIndex]["ntype"] as String), + height: 160, + width: double.infinity, + fit: BoxFit.cover, + ), + ), + ), + + // 导航方式切换按钮 + Padding( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: List.generate(modes.length, (index) { + final isSelected = index == currentIndex; + return GestureDetector( + onTap: () { + setInnerState(() => currentIndex = index); + }, + child: SizedBox( + width: 50, + child: Text( + modes[index]["ntype"] as String, + style: TextStyle( + color: isSelected ? Colors.blue : Colors.black87, + fontSize: 12, + fontWeight: FontWeight.w500, + ), + ), + ), + ); + }), + ), + ), + + // 距离和耗时 + Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('距离:${modes[currentIndex]["distance"]}', + style: const TextStyle(fontSize: 12, color: Colors.blue)), + Container( + decoration: BoxDecoration( + shape: BoxShape.circle, // 👈 圆形背景 + color: Colors.blue, + ), + child: Icon(Icons.turn_left, + color: Colors.white, // 👈 圆形图标 + size: 20), + ) + ], + ), + ), + ], + ); + }, + ), + ); +} From 16a5fca373fd13d7a46bff0ce792821116ec992c Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 16 May 2025 10:58:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/agent/views/message_bubble.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index 6143117f7..f7205a1a8 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -270,14 +270,14 @@ class MessageBubble extends GetView { now, daylist, ); - } else if (mate!.keys.contains('card_travel')) { - final rawList = mate!['card_travel']['items'] as List; + } else if (meta!.keys.contains('card_travel')) { + final rawList = meta!['card_travel']['items'] as List; final travellist = rawList.map((e) => Map.from(e)).toList(); // 旅游 return _buildTravelContent(context, travellist); - } else if (mate!.keys.contains('card_navigation')) { - final rawList = mate!['card_navigation']['items'] as List; + } else if (meta!.keys.contains('card_navigation')) { + final rawList = meta!['card_navigation']['items'] as List; final list = rawList.map((e) => Map.from(e)).toList(); // 导航 return navigationCard(context, modes: list);