opt: 动态页up主点击
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
@ -30,6 +31,31 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
liveList = widget.upData.liveList!;
|
liveList = widget.upData.liveList!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onClickUp(data, i) {
|
||||||
|
currentMid = data.mid;
|
||||||
|
Get.find<DynamicsController>().mid.value = data.mid;
|
||||||
|
Get.find<DynamicsController>().upInfo.value = data;
|
||||||
|
Get.find<DynamicsController>().onSelectUp(data.mid);
|
||||||
|
int liveLen = liveList.length;
|
||||||
|
int upLen = upList.length;
|
||||||
|
double itemWidth = contentWidth + itemPadding.horizontal;
|
||||||
|
double screenWidth = MediaQuery.sizeOf(context).width;
|
||||||
|
double moveDistance = 0.0;
|
||||||
|
if (itemWidth * (upList.length + liveList.length) <= screenWidth) {
|
||||||
|
} else if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
||||||
|
moveDistance = (i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
||||||
|
} else {
|
||||||
|
moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
||||||
|
}
|
||||||
|
data.hasUpdate = false;
|
||||||
|
scrollController.animateTo(
|
||||||
|
moveDistance,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.linear,
|
||||||
|
);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
listFormat();
|
listFormat();
|
||||||
@ -120,30 +146,10 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
if (data.type == 'up') {
|
if (data.type == 'up') {
|
||||||
currentMid = data.mid;
|
EasyThrottle.throttle('follow', const Duration(milliseconds: 300),
|
||||||
Get.find<DynamicsController>().mid.value = data.mid;
|
() {
|
||||||
Get.find<DynamicsController>().upInfo.value = data;
|
onClickUp(data, i);
|
||||||
Get.find<DynamicsController>().onSelectUp(data.mid);
|
});
|
||||||
int liveLen = liveList.length;
|
|
||||||
int upLen = upList.length;
|
|
||||||
double itemWidth = contentWidth + itemPadding.horizontal;
|
|
||||||
double screenWidth = MediaQuery.sizeOf(context).width;
|
|
||||||
double moveDistance = 0.0;
|
|
||||||
if (itemWidth * (upList.length + liveList.length) <= screenWidth) {
|
|
||||||
} else if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
|
||||||
moveDistance =
|
|
||||||
(i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
|
||||||
} else {
|
|
||||||
moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
|
||||||
}
|
|
||||||
data.hasUpdate = false;
|
|
||||||
scrollController.animateTo(
|
|
||||||
moveDistance,
|
|
||||||
duration: const Duration(milliseconds: 500),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
} else if (data.type == 'live') {
|
} else if (data.type == 'live') {
|
||||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||||
'title': data.title,
|
'title': data.title,
|
||||||
|
Reference in New Issue
Block a user