refa persistent header & dynamic sliver appbar

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-02 16:16:17 +08:00
parent 1dbc54f063
commit 9c7b18710c
30 changed files with 1691 additions and 883 deletions

View File

@@ -1,8 +1,9 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_reply.dart';
import 'package:PiliPlus/common/widgets/colored_box_transition.dart';
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
show ReplyInfo, Mode;
@@ -240,52 +241,43 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
}
Widget _sortWidget(ThemeData theme) {
return SliverPersistentHeader(
pinned: true,
delegate: CustomSliverPersistentHeaderDelegate(
extent: 40,
bgColor: theme.colorScheme.surface,
child: Container(
height: 40,
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() {
final count = _controller.count.value;
return count != -1
? Text(
'相关回复共${NumUtils.numFormat(count)}',
style: const TextStyle(fontSize: 13),
)
: const SizedBox.shrink();
},
return SliverPinnedHeader(
backgroundColor: theme.colorScheme.surface,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 2.5, 6, 2.5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() {
final count = _controller.count.value;
return count != -1
? Text(
'相关回复共${NumUtils.numFormat(count)}',
style: const TextStyle(fontSize: 13),
)
: const SizedBox.shrink();
},
),
TextButton.icon(
style: StyleString.buttonStyle,
onPressed: _controller.queryBySort,
icon: Icon(
Icons.sort,
size: 16,
color: theme.colorScheme.secondary,
),
SizedBox(
height: 35,
child: TextButton.icon(
onPressed: _controller.queryBySort,
icon: Icon(
Icons.sort,
size: 16,
label: Obx(
() => Text(
_controller.mode.value == Mode.MAIN_LIST_HOT ? '按热度' : '按时间',
style: TextStyle(
fontSize: 13,
color: theme.colorScheme.secondary,
),
label: Obx(
() => Text(
_controller.mode.value == Mode.MAIN_LIST_HOT
? '按热度'
: '按时间',
style: TextStyle(
fontSize: 13,
color: theme.colorScheme.secondary,
),
),
),
),
),
],
),
),
],
),
),
);