mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
opt: reply2reply: sort widget
This commit is contained in:
@@ -163,7 +163,7 @@ class VideoReplyReplyController extends CommonController
|
|||||||
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
||||||
? Mode.MAIN_LIST_TIME
|
? Mode.MAIN_LIST_TIME
|
||||||
: Mode.MAIN_LIST_HOT;
|
: Mode.MAIN_LIST_HOT;
|
||||||
loadingState.value = LoadingState.loading();
|
// loadingState.value = LoadingState.loading();
|
||||||
onRefresh();
|
onRefresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
|||||||
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||||
late VideoReplyReplyController _videoReplyReplyController;
|
late VideoReplyReplyController _videoReplyReplyController;
|
||||||
late final _savedReplies = {};
|
late final _savedReplies = {};
|
||||||
|
final itemPositionsListener = ItemPositionsListener.create();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -64,6 +65,27 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget get _header => ValueListenableBuilder<Iterable<ItemPosition>>(
|
||||||
|
valueListenable: itemPositionsListener.itemPositions,
|
||||||
|
builder: (context, positions, child) {
|
||||||
|
int min = -1;
|
||||||
|
if (positions.isNotEmpty) {
|
||||||
|
min = positions
|
||||||
|
.where((ItemPosition position) => position.itemTrailingEdge > 0)
|
||||||
|
.reduce((ItemPosition min, ItemPosition position) =>
|
||||||
|
position.itemTrailingEdge < min.itemTrailingEdge
|
||||||
|
? position
|
||||||
|
: min)
|
||||||
|
.index;
|
||||||
|
}
|
||||||
|
return widget.firstFloor == null
|
||||||
|
? _sortWidget
|
||||||
|
: min >= 2
|
||||||
|
? _sortWidget
|
||||||
|
: const SizedBox.shrink();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -98,9 +120,12 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
await _videoReplyReplyController.onRefresh();
|
await _videoReplyReplyController.onRefresh();
|
||||||
},
|
},
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => ScrollablePositionedList.builder(
|
() => Stack(
|
||||||
itemCount:
|
children: [
|
||||||
_itemCount(_videoReplyReplyController.loadingState.value),
|
ScrollablePositionedList.builder(
|
||||||
|
itemPositionsListener: itemPositionsListener,
|
||||||
|
itemCount: _itemCount(
|
||||||
|
_videoReplyReplyController.loadingState.value),
|
||||||
itemScrollController:
|
itemScrollController:
|
||||||
_videoReplyReplyController.itemScrollCtr,
|
_videoReplyReplyController.itemScrollCtr,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
@@ -121,8 +146,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
} else if (index == 1) {
|
} else if (index == 1) {
|
||||||
return Divider(
|
return Divider(
|
||||||
height: 20,
|
height: 20,
|
||||||
color:
|
color: Theme.of(context)
|
||||||
Theme.of(context).dividerColor.withOpacity(0.1),
|
.dividerColor
|
||||||
|
.withOpacity(0.1),
|
||||||
thickness: 6,
|
thickness: 6,
|
||||||
);
|
);
|
||||||
} else if (index == 2) {
|
} else if (index == 2) {
|
||||||
@@ -143,6 +169,11 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (_videoReplyReplyController.loadingState.value
|
||||||
|
is Success)
|
||||||
|
_header,
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user