feat: custom horizontal member page

Closes #51

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-25 21:22:44 +08:00
parent 513a3d2175
commit eee7eda1a2
11 changed files with 676 additions and 121 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:math';
import 'package:PiliPalaX/common/constants.dart';
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
@@ -42,9 +43,7 @@ class ListSheetContent extends StatefulWidget {
class _ListSheetContentState extends State<ListSheetContent>
with TickerProviderStateMixin {
late List<ItemScrollController> itemScrollController = [];
late int currentIndex =
widget.episodes!.indexWhere((dynamic e) => e.cid == widget.currentCid) ??
0;
int? currentIndex;
late List<bool> reverse;
int get _index => widget.index ?? 0;
@@ -60,11 +59,12 @@ class _ListSheetContentState extends State<ListSheetContent>
@override
void didUpdateWidget(ListSheetContent oldWidget) {
super.didUpdateWidget(oldWidget);
currentIndex = widget.episodes!
.indexWhere((dynamic e) => e.cid == widget.currentCid) ??
0;
currentIndex = _currentIndex;
}
int get _currentIndex =>
max(0, widget.episodes.indexWhere((e) => e.cid == widget.currentCid));
@override
void initState() {
super.initState();
@@ -85,9 +85,7 @@ class _ListSheetContentState extends State<ListSheetContent>
reverse = _isList
? List.generate(widget.season.sections.length, (_) => false)
: [false];
WidgetsBinding.instance.addPostFrameCallback((_) {
itemScrollController[_index].jumpTo(index: currentIndex);
});
currentIndex = _currentIndex;
if (widget.bvid != null && widget.season != null) {
_favStream ??= StreamController<int>();
() async {
@@ -98,6 +96,11 @@ class _ListSheetContentState extends State<ListSheetContent>
}
}();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (currentIndex != null) {
itemScrollController[_index].jumpTo(index: currentIndex!);
}
});
}
@override
@@ -312,10 +315,12 @@ class _ListSheetContentState extends State<ListSheetContent>
_ctr?.animateTo(_index);
await Future.delayed(const Duration(milliseconds: 225));
}
itemScrollController[_ctr?.index ?? 0].scrollTo(
index: currentIndex,
duration: const Duration(milliseconds: 200),
);
if (currentIndex != null) {
itemScrollController[_ctr?.index ?? 0].scrollTo(
index: currentIndex!,
duration: const Duration(milliseconds: 200),
);
}
},
),
const Spacer(),

View File

@@ -17,10 +17,14 @@ class VideoCardHMemberVideo extends StatelessWidget {
required this.videoItem,
this.longPress,
this.longPressEnd,
this.onTap,
this.bvid,
});
final Item videoItem;
final Function()? longPress;
final Function()? longPressEnd;
final VoidCallback? onTap;
final dynamic bvid;
@override
Widget build(BuildContext context) {
@@ -32,6 +36,10 @@ class VideoCardHMemberVideo extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
onLongPress: longPress,
onTap: () async {
if (onTap != null) {
onTap!();
return;
}
try {
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.firstCid}',
arguments: {'heroTag': heroTag});
@@ -115,10 +123,15 @@ class VideoCardHMemberVideo extends StatelessWidget {
videoItem.title ?? '',
textAlign: TextAlign.start,
style: TextStyle(
fontWeight: FontWeight.w400,
fontWeight: videoItem.bvid == bvid
? FontWeight.bold
: FontWeight.w400,
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
height: 1.42,
letterSpacing: 0.3,
color: videoItem.bvid == bvid
? Theme.of(context).colorScheme.primary
: null,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,