mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt: slide gesture
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -123,65 +123,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GStorage.slideDismissReplyPage
|
return GStorage.slideDismissReplyPage
|
||||||
? GestureDetector(
|
? Padding(
|
||||||
onPanDown: (event) {
|
padding: EdgeInsets.only(top: padding.value),
|
||||||
if (event.localPosition.dx > 30) {
|
child: _buildPage,
|
||||||
_isSliding = false;
|
|
||||||
} else {
|
|
||||||
_downPos = event.localPosition;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPanUpdate: (event) {
|
|
||||||
if (_isSliding == false) {
|
|
||||||
return;
|
|
||||||
} else if (_isSliding == null) {
|
|
||||||
if (_downPos != null) {
|
|
||||||
Offset cumulativeDelta = event.localPosition - _downPos!;
|
|
||||||
if (cumulativeDelta.dx.abs() >= cumulativeDelta.dy.abs()) {
|
|
||||||
_isSliding = true;
|
|
||||||
setState(() {
|
|
||||||
padding.value = event.localPosition.dx;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_isSliding = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (_isSliding == true) {
|
|
||||||
setState(() {
|
|
||||||
padding.value = event.localPosition.dx;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPanCancel: () {
|
|
||||||
if (_isSliding == true) {
|
|
||||||
if (padding.value >= 100) {
|
|
||||||
Get.back();
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
padding.value = 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_downPos = null;
|
|
||||||
_isSliding = null;
|
|
||||||
},
|
|
||||||
onPanEnd: (event) {
|
|
||||||
if (_isSliding == true) {
|
|
||||||
if (padding.value >= 100) {
|
|
||||||
Get.back();
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
padding.value = 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_downPos = null;
|
|
||||||
_isSliding = null;
|
|
||||||
},
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(top: padding.value),
|
|
||||||
child: _buildPage,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: _buildPage;
|
: _buildPage;
|
||||||
}
|
}
|
||||||
@@ -221,100 +165,157 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ClipRect(
|
child: GStorage.slideDismissReplyPage
|
||||||
child: refreshIndicator(
|
? GestureDetector(
|
||||||
onRefresh: () async {
|
onPanDown: (event) {
|
||||||
await _videoReplyReplyController.onRefresh();
|
if (event.localPosition.dx > 30) {
|
||||||
},
|
_isSliding = false;
|
||||||
child: Obx(
|
} else {
|
||||||
() => Stack(
|
_downPos = event.localPosition;
|
||||||
children: [
|
}
|
||||||
ScrollablePositionedList.builder(
|
},
|
||||||
key: _listKey,
|
onPanUpdate: (event) {
|
||||||
itemPositionsListener: itemPositionsListener,
|
if (_isSliding == false) {
|
||||||
itemCount: _itemCount(
|
return;
|
||||||
_videoReplyReplyController.loadingState.value),
|
} else if (_isSliding == null) {
|
||||||
itemScrollController:
|
if (_downPos != null) {
|
||||||
_videoReplyReplyController.itemScrollCtr,
|
Offset cumulativeDelta =
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
event.localPosition - _downPos!;
|
||||||
itemBuilder: (context, index) {
|
if (cumulativeDelta.dx.abs() >=
|
||||||
if (widget.isDialogue) {
|
cumulativeDelta.dy.abs()) {
|
||||||
return _buildBody(
|
_isSliding = true;
|
||||||
_videoReplyReplyController.loadingState.value,
|
setState(() {
|
||||||
index);
|
padding.value = event.localPosition.dx;
|
||||||
} else if (firstFloor != null) {
|
});
|
||||||
if (index == 0) {
|
|
||||||
return GlobalData().grpcReply
|
|
||||||
? ReplyItemGrpc(
|
|
||||||
replyItem: firstFloor,
|
|
||||||
replyLevel: '2',
|
|
||||||
showReplyRow: false,
|
|
||||||
replyType: widget.replyType,
|
|
||||||
needDivider: false,
|
|
||||||
onReply: () {
|
|
||||||
_onReply(firstFloor, -1);
|
|
||||||
},
|
|
||||||
upMid: _videoReplyReplyController.upMid,
|
|
||||||
isTop: widget.isTop,
|
|
||||||
onViewImage: widget.onViewImage,
|
|
||||||
onDismissed: widget.onDismissed,
|
|
||||||
callback: _getImageCallback,
|
|
||||||
)
|
|
||||||
: ReplyItem(
|
|
||||||
replyItem: firstFloor,
|
|
||||||
replyLevel: '2',
|
|
||||||
showReplyRow: false,
|
|
||||||
replyType: widget.replyType,
|
|
||||||
needDivider: false,
|
|
||||||
onReply: () {
|
|
||||||
_onReply(firstFloor, -1);
|
|
||||||
},
|
|
||||||
onViewImage: widget.onViewImage,
|
|
||||||
onDismissed: widget.onDismissed,
|
|
||||||
callback: _getImageCallback,
|
|
||||||
);
|
|
||||||
} else if (index == 1) {
|
|
||||||
return Divider(
|
|
||||||
height: 20,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.dividerColor
|
|
||||||
.withOpacity(0.1),
|
|
||||||
thickness: 6,
|
|
||||||
);
|
|
||||||
} else if (index == 2) {
|
|
||||||
return _sortWidget;
|
|
||||||
} else {
|
|
||||||
return _buildBody(
|
|
||||||
_videoReplyReplyController
|
|
||||||
.loadingState.value,
|
|
||||||
index - 3);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (index == 0) {
|
_isSliding = false;
|
||||||
return _sortWidget;
|
|
||||||
} else {
|
|
||||||
return _buildBody(
|
|
||||||
_videoReplyReplyController
|
|
||||||
.loadingState.value,
|
|
||||||
index - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
),
|
} else if (_isSliding == true) {
|
||||||
if (!widget.isDialogue &&
|
setState(() {
|
||||||
_videoReplyReplyController.loadingState.value
|
padding.value = event.localPosition.dx;
|
||||||
is Success)
|
});
|
||||||
_header,
|
}
|
||||||
],
|
},
|
||||||
),
|
onPanCancel: () {
|
||||||
),
|
if (_isSliding == true) {
|
||||||
),
|
if (padding.value >= 100) {
|
||||||
),
|
Get.back();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
padding.value = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downPos = null;
|
||||||
|
_isSliding = null;
|
||||||
|
},
|
||||||
|
onPanEnd: (event) {
|
||||||
|
if (_isSliding == true) {
|
||||||
|
if (padding.value >= 100) {
|
||||||
|
Get.back();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
padding.value = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downPos = null;
|
||||||
|
_isSliding = null;
|
||||||
|
},
|
||||||
|
child: _buildList,
|
||||||
|
)
|
||||||
|
: _buildList,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Widget get _buildList => ClipRect(
|
||||||
|
child: refreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await _videoReplyReplyController.onRefresh();
|
||||||
|
},
|
||||||
|
child: Obx(
|
||||||
|
() => Stack(
|
||||||
|
children: [
|
||||||
|
ScrollablePositionedList.builder(
|
||||||
|
key: _listKey,
|
||||||
|
itemPositionsListener: itemPositionsListener,
|
||||||
|
itemCount:
|
||||||
|
_itemCount(_videoReplyReplyController.loadingState.value),
|
||||||
|
itemScrollController:
|
||||||
|
_videoReplyReplyController.itemScrollCtr,
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (widget.isDialogue) {
|
||||||
|
return _buildBody(
|
||||||
|
_videoReplyReplyController.loadingState.value, index);
|
||||||
|
} else if (firstFloor != null) {
|
||||||
|
if (index == 0) {
|
||||||
|
return GlobalData().grpcReply
|
||||||
|
? ReplyItemGrpc(
|
||||||
|
replyItem: firstFloor,
|
||||||
|
replyLevel: '2',
|
||||||
|
showReplyRow: false,
|
||||||
|
replyType: widget.replyType,
|
||||||
|
needDivider: false,
|
||||||
|
onReply: () {
|
||||||
|
_onReply(firstFloor, -1);
|
||||||
|
},
|
||||||
|
upMid: _videoReplyReplyController.upMid,
|
||||||
|
isTop: widget.isTop,
|
||||||
|
onViewImage: widget.onViewImage,
|
||||||
|
onDismissed: widget.onDismissed,
|
||||||
|
callback: _getImageCallback,
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: firstFloor,
|
||||||
|
replyLevel: '2',
|
||||||
|
showReplyRow: false,
|
||||||
|
replyType: widget.replyType,
|
||||||
|
needDivider: false,
|
||||||
|
onReply: () {
|
||||||
|
_onReply(firstFloor, -1);
|
||||||
|
},
|
||||||
|
onViewImage: widget.onViewImage,
|
||||||
|
onDismissed: widget.onDismissed,
|
||||||
|
callback: _getImageCallback,
|
||||||
|
);
|
||||||
|
} else if (index == 1) {
|
||||||
|
return Divider(
|
||||||
|
height: 20,
|
||||||
|
color:
|
||||||
|
Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
|
thickness: 6,
|
||||||
|
);
|
||||||
|
} else if (index == 2) {
|
||||||
|
return _sortWidget;
|
||||||
|
} else {
|
||||||
|
return _buildBody(
|
||||||
|
_videoReplyReplyController.loadingState.value,
|
||||||
|
index - 3);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index == 0) {
|
||||||
|
return _sortWidget;
|
||||||
|
} else {
|
||||||
|
return _buildBody(
|
||||||
|
_videoReplyReplyController.loadingState.value,
|
||||||
|
index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (!widget.isDialogue &&
|
||||||
|
_videoReplyReplyController.loadingState.value is Success)
|
||||||
|
_header,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Widget get _sortWidget => Container(
|
Widget get _sortWidget => Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
||||||
|
|||||||
Reference in New Issue
Block a user