Browse Source

首页悬浮窗增加拖拽

dev-2.0
王子贤 1 month ago
parent
commit
b0b9109a28
2 changed files with 123 additions and 73 deletions
  1. 166
      lib/pages/home/recommend_tab.dart
  2. 30
      lib/rtc/rtc_manager.dart

166
lib/pages/home/recommend_tab.dart

@ -52,10 +52,23 @@ class _RecommendTabState extends State<RecommendTab>
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<RecommendTab>
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<RecommendTab>
}),
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();

30
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);
}
}
}

Loading…
Cancel
Save