From b0b9109a288a82ffbe93dfc4bf72946547c7b542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AD=90=E8=B4=A4?= Date: Mon, 13 Apr 2026 17:16:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=82=AC=E6=B5=AE=E7=AA=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8B=96=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home/recommend_tab.dart | 166 +++++++++++++++++++----------- lib/rtc/rtc_manager.dart | 30 +++--- 2 files changed, 123 insertions(+), 73 deletions(-) diff --git a/lib/pages/home/recommend_tab.dart b/lib/pages/home/recommend_tab.dart index 1dbbb21..e24c975 100644 --- a/lib/pages/home/recommend_tab.dart +++ b/lib/pages/home/recommend_tab.dart @@ -52,10 +52,23 @@ class _RecommendTabState extends State if (shouldShrink != _shrink) { setState(() { _shrink = shouldShrink; + if(_shrink){ + left = MediaQuery.of(context).size.width - 50; + } else { + left = MediaQuery.of(context).size.width - 142; + } }); } } + + // 当前位置 + double left = 0; + double top = 300; + + // 是否已经初始化过默认位置 + bool _inited = false; + @override Widget build(BuildContext context) { super.build(context); @@ -63,6 +76,16 @@ class _RecommendTabState extends State final bottomPadding = MediaQuery.of(context).padding.bottom; final tabBarHeight = 64.0; final totalBottomPadding = bottomPadding + tabBarHeight; + + final screenWidth = MediaQuery.of(context).size.width; + final screenHeight = MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top - totalBottomPadding - 56; + print(screenHeight); + // 首次进入时,默认放在右下角附近 + if (!_inited) { + left = screenWidth - 142; + top = screenHeight - 50 - 142; // 留一点底部空间,避免贴太底 + _inited = true; + } return Stack( children: [ Obx(() { @@ -180,72 +203,93 @@ class _RecommendTabState extends State }), Obx(() { if(controller.friendFootprintInfo.isNotEmpty) { - return Positioned( - right: 0, - bottom: 42, - child: AnimatedContainer( - duration: const Duration(milliseconds: 250), - width: _shrink ? 50 : 142, - height: 50, - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(50)), - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color(0xFF8359FF), - Color(0xFF3D8AE0), - ], + return AnimatedPositioned( + duration: const Duration(milliseconds: 100), + curve: Curves.easeOut, + left: left, + top: top, + child: GestureDetector( + onTap: (){ + Get.to(() => FriendFootprintPage()); + }, + onPanUpdate: (details) { + setState(() { + left += details.delta.dx; + top += details.delta.dy; + + // 限制不要拖出屏幕 + left = left.clamp(0.0, screenWidth - (_shrink ? 50 : 142)); + top = top.clamp(0.0, screenHeight - 50 - kToolbarHeight); + }); + }, + onPanEnd: (_) { + setState(() { + // 松手后自动贴到最右边 + left = screenWidth - (_shrink ? 50 : 142); + }); + }, + child: AnimatedContainer( + duration: const Duration(milliseconds: 250), + width: _shrink ? 50 : 142, + height: 50, + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(50)), + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xFF8359FF), + Color(0xFF3D8AE0), + ], + ), ), - ), - child: Row( - children: [ - SizedBox( - width: 40, - height: 40, - child: Swiper( - autoplay: true, - itemCount: controller.friendFootprintInfo.length, - loop: true, - itemBuilder: (BuildContext context, int index) { - return ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(40)), - child: CachedNetworkImage( - imageUrl: controller.friendFootprintInfo[index], - width: 40, - height: 40, - fit: BoxFit.cover, - ), - ); - }, + child: Row( + children: [ + SizedBox( + width: 40, + height: 40, + child: Swiper( + autoplay: true, + itemCount: controller.friendFootprintInfo.length, + loop: true, + itemBuilder: (BuildContext context, int index) { + return ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(40)), + child: CachedNetworkImage( + imageUrl: controller.friendFootprintInfo[index], + width: 40, + height: 40, + fit: BoxFit.cover, + ), + ); + }, + ), ), - ), - if(!_shrink) SizedBox(width: 4,), - if(!_shrink) Column( - children: [ - Text( - "与你匹配的", - style: TextStyle( - fontSize: 15, - color: Colors.white - ), - ), - Text( - "${controller.friendFootprintInfo.length}人正在连麦...", - style: TextStyle( - fontSize: 11, - color: Colors.white + if(!_shrink) SizedBox(width: 4,), + if(!_shrink) Column( + children: [ + Text( + "与你匹配的", + style: TextStyle( + fontSize: 15, + color: Colors.white + ), ), - ) - ], - ) - ], + Text( + "${controller.friendFootprintInfo.length}人正在连麦...", + style: TextStyle( + fontSize: 11, + color: Colors.white + ), + ) + ], + ) + ], + ), ), - ).onTap((){ - Get.to(() => FriendFootprintPage()); - }), + ), ); } else { return SizedBox(); diff --git a/lib/rtc/rtc_manager.dart b/lib/rtc/rtc_manager.dart index b6dabb5..ddab10a 100644 --- a/lib/rtc/rtc_manager.dart +++ b/lib/rtc/rtc_manager.dart @@ -613,18 +613,24 @@ class RTCManager { if (role == ClientRoleType.clientRoleBroadcaster) { await _engine?.enableFaceDetection(true); - await _engine?.enableContentInspect( - enabled: true, - config: ContentInspectConfig( - modules: [ - ContentInspectModule( - type: ContentInspectType.contentInspectSupervision, - interval: 15 - ) - ], - moduleCount: 1 - ) - ); + try{ + await _engine?.enableContentInspect( + enabled: true, + config: ContentInspectConfig( + modules: [ + ContentInspectModule( + type: ContentInspectType.contentInspectSupervision, + interval: 15 + ) + ], + moduleCount: 1 + ) + ); + print("截图开启成功"); + } catch (e){ + print("截图开启失败"); + print(e); + } } }