From 8d21b8755a1ba5fde32522ae1bed01acfec1a975 Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Sun, 21 Jul 2024 16:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=88=97=E8=A1=A8=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E9=81=AE=E7=BD=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools/chat/chat_page.dart | 32 +++++++++++++------ lib/tools/find/recommend_page.dart | 50 ++++++++++++++++-------------- lib/tools/home/home_chat_page.dart | 33 ++++++++++++++------ pubspec.yaml | 1 + 4 files changed, 73 insertions(+), 43 deletions(-) diff --git a/lib/tools/chat/chat_page.dart b/lib/tools/chat/chat_page.dart index 81d23ee..2b65ae5 100644 --- a/lib/tools/chat/chat_page.dart +++ b/lib/tools/chat/chat_page.dart @@ -354,15 +354,29 @@ class _ChatPageState extends State { ///聊天列表 Expanded( child: Align( - alignment: Alignment.bottomCenter, - child: ListView.builder( - shrinkWrap: true, - controller: _scrollController, - itemCount: chatList.length, - itemBuilder: (BuildContext context, int index) { - return _item(index); - }), - )), + alignment: Alignment.bottomCenter, + child: ShaderMask( + shaderCallback: (Rect bounds) { + return const LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + Colors.white, + ], + stops: [0.0, 0.1], // 调整透明的范围 + ).createShader(bounds); + }, + blendMode: BlendMode.dstIn, + child: ListView.builder( + shrinkWrap: true, + controller: _scrollController, + itemCount: chatList.length, + itemBuilder: (BuildContext context, int index) { + return _item(index); + }), + ), + )), // Container( // alignment: Alignment.centerLeft, // margin: EdgeInsets.only(left: 16, bottom: 3), diff --git a/lib/tools/find/recommend_page.dart b/lib/tools/find/recommend_page.dart index df76997..1a32906 100644 --- a/lib/tools/find/recommend_page.dart +++ b/lib/tools/find/recommend_page.dart @@ -89,39 +89,41 @@ class _RecommendPageState extends State with AutomaticKeepAliveCl Widget build(BuildContext context) { return Stack( children: [ - Container( + SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: SingleChildScrollView( - physics: BouncingScrollPhysics(), + // physics: BouncingScrollPhysics(), child: Column( children: [ SizedBox( height: 270, - child: Swiper( - itemBuilder: (BuildContext context, int index) { - return Container( - key: ValueKey(index), - padding: EdgeInsets.only(bottom: 30), - child: GestureDetector( - onTap: () { - goChatPage(bannerList[index].actionId.toString()); + child: bannerList.isNotEmpty + ? Swiper( + itemBuilder: (BuildContext context, int index) { + return Container( + key: ValueKey(index), + padding: EdgeInsets.only(bottom: 30), + child: GestureDetector( + onTap: () { + goChatPage(bannerList[index].actionId.toString()); + }, + child: CachedNetworkImage( + fit: BoxFit.fill, + imageUrl: bannerList[index].imageUrl!, + errorWidget: (context, url, error) => const Icon(Icons.error), + ), + ), + ); }, - child: CachedNetworkImage( - fit: BoxFit.fill, - imageUrl: bannerList[index].imageUrl!, - errorWidget: (context, url, error) => const Icon(Icons.error), + itemCount: bannerList.length, + pagination: SwiperPagination( + // 此处使用自己编写的样式 + builder: CustomSwiperPaginationBuilder( + alignment: Alignment.bottomRight, color: Color(0xFF646464), activeColor: Color(0xFFCFCFCF)), ), - ), - ); - }, - itemCount: bannerList.length, - pagination: SwiperPagination( - // 此处使用自己编写的样式 - builder: - CustomSwiperPaginationBuilder(alignment: Alignment.bottomRight, color: Color(0xFF646464), activeColor: Color(0xFFCFCFCF)), - ), - ), + ) + : Container(), ), Container( alignment: Alignment.centerLeft, diff --git a/lib/tools/home/home_chat_page.dart b/lib/tools/home/home_chat_page.dart index 8b660a5..64443c8 100644 --- a/lib/tools/home/home_chat_page.dart +++ b/lib/tools/home/home_chat_page.dart @@ -141,7 +141,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie } ///删除消息 - delChat(int id, index) { + deleteChat(int id, index) { EasyLoading.show(status: 'loading...'); delIndex = index; List ids = [id]; @@ -348,13 +348,27 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie Expanded( child: Align( alignment: Alignment.bottomCenter, - child: ListView.builder( - shrinkWrap: true, - controller: _scrollController, - itemCount: chatList.length, - itemBuilder: (BuildContext context, int index) { - return _item(index); - }), + child: ShaderMask( + shaderCallback: (Rect bounds) { + return const LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + Colors.white, + ], + stops: [0.0, 0.1], // 调整透明的范围 + ).createShader(bounds); + }, + blendMode: BlendMode.dstIn, + child: ListView.builder( + shrinkWrap: true, + controller: _scrollController, + itemCount: chatList.length, + itemBuilder: (BuildContext context, int index) { + return _item(index); + }), + ), )), // Container( // alignment: Alignment.centerLeft, @@ -555,7 +569,6 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie ], ), ), - ], ), ); @@ -622,7 +635,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie ///聊天内容 return Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), + padding: const EdgeInsets.only(bottom: 8), child: chatList[index].role != 'user' ? Container( ///AI diff --git a/pubspec.yaml b/pubspec.yaml index 001a31f..49f981e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,6 +47,7 @@ dependencies: card_swiper: ^3.0.1 flutter_slidable: ^3.1.0 flutter_keyboard_visibility: ^6.0.0 + custom_pop_up_menu: ^1.2.4 dev_dependencies: flutter_test: