|
|
@ -52,10 +52,23 @@ class _RecommendTabState extends State<RecommendTab> |
|
|
if (shouldShrink != _shrink) { |
|
|
if (shouldShrink != _shrink) { |
|
|
setState(() { |
|
|
setState(() { |
|
|
_shrink = shouldShrink; |
|
|
_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 |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
super.build(context); |
|
|
super.build(context); |
|
|
@ -63,6 +76,16 @@ class _RecommendTabState extends State<RecommendTab> |
|
|
final bottomPadding = MediaQuery.of(context).padding.bottom; |
|
|
final bottomPadding = MediaQuery.of(context).padding.bottom; |
|
|
final tabBarHeight = 64.0; |
|
|
final tabBarHeight = 64.0; |
|
|
final totalBottomPadding = bottomPadding + tabBarHeight; |
|
|
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( |
|
|
return Stack( |
|
|
children: [ |
|
|
children: [ |
|
|
Obx(() { |
|
|
Obx(() { |
|
|
@ -180,72 +203,93 @@ class _RecommendTabState extends State<RecommendTab> |
|
|
}), |
|
|
}), |
|
|
Obx(() { |
|
|
Obx(() { |
|
|
if(controller.friendFootprintInfo.isNotEmpty) { |
|
|
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 { |
|
|
} else { |
|
|
return SizedBox(); |
|
|
return SizedBox(); |
|
|
|