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 'dart:math' show pi;
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_reply.dart';
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.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;
@@ -103,44 +104,33 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
Widget buildReplyHeader(ThemeData theme) {
final secondary = theme.colorScheme.secondary;
return SliverPersistentHeader(
pinned: true,
delegate: CustomSliverPersistentHeaderDelegate(
extent: 45,
bgColor: theme.colorScheme.surface,
child: Container(
height: 45,
padding: const EdgeInsets.only(left: 12, right: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() {
final count = controller.count.value;
return Text(
'${count == -1 ? 0 : NumUtils.numFormat(count)}条回复',
);
},
),
SizedBox(
height: 35,
child: TextButton.icon(
onPressed: controller.queryBySort,
icon: Icon(
Icons.sort,
size: 16,
color: secondary,
),
label: Obx(
() => Text(
controller.sortType.value.label,
style: TextStyle(fontSize: 13, color: secondary),
),
),
return SliverPinnedHeader(
backgroundColor: theme.colorScheme.surface,
child: Padding(
padding: const .fromLTRB(12, 2.5, 6, 2.5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() {
final count = controller.count.value;
return Text(
'${count == -1 ? 0 : NumUtils.numFormat(count)}条回复',
);
},
),
TextButton.icon(
style: StyleString.buttonStyle,
onPressed: controller.queryBySort,
icon: Icon(Icons.sort, size: 16, color: secondary),
label: Obx(
() => Text(
controller.sortType.value.label,
style: TextStyle(fontSize: 13, color: secondary),
),
),
],
),
),
],
),
),
);