fix: 视频详情页加载异常

This commit is contained in:
guozhigq
2023-08-09 09:04:47 +08:00
parent 5fe1bde539
commit 5d48ea5afb
2 changed files with 83 additions and 58 deletions

View File

@ -1,4 +1,3 @@
import 'package:flutter/gestures.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -103,13 +102,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
late double sheetHeight; late double sheetHeight;
late final bool loadingStatus; // 加载状态 late final bool loadingStatus; // 加载状态
late final int viewCount; // 观看
late final int danmakuCount; // 弹幕
late final String pubDate; // 发布日期
late final owner; late final dynamic owner;
late final follower; late final dynamic follower;
late final followStatus; late final dynamic followStatus;
@override @override
void initState() { void initState() {
@ -121,16 +117,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
sheetHeight = localCache.get('sheetHeight'); sheetHeight = localCache.get('sheetHeight');
loadingStatus = widget.loadingStatus; loadingStatus = widget.loadingStatus;
viewCount = !loadingStatus
? widget.videoDetail!.stat!.view
: videoItem['stat'].view;
danmakuCount = !loadingStatus
? widget.videoDetail!.stat!.danmaku
: videoItem['stat'].danmaku;
pubDate = Utils.dateFormat(
!loadingStatus ? widget.videoDetail!.pubdate : videoItem['pubdate'],
formatType: 'detail');
owner = loadingStatus ? videoItem['owner'] : widget.videoDetail!.owner; owner = loadingStatus ? videoItem['owner'] : widget.videoDetail!.owner;
follower = loadingStatus follower = loadingStatus
? '-' ? '-'
@ -235,14 +221,31 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
child: Row( child: Row(
children: [ children: [
StatView( StatView(
theme: 'gray', view: viewCount, size: 'medium'), theme: 'gray',
view: !widget.loadingStatus
? widget.videoDetail!.stat!.view
: videoItem['stat'].view,
size: 'medium',
),
const SizedBox(width: 10), const SizedBox(width: 10),
StatDanMu( StatDanMu(
theme: 'gray', danmu: danmakuCount, size: 'medium'), theme: 'gray',
danmu: !widget.loadingStatus
? widget.videoDetail!.stat!.danmaku
: videoItem['stat'].danmaku,
size: 'medium',
),
const SizedBox(width: 10), const SizedBox(width: 10),
Text( Text(
pubDate, Utils.dateFormat(
style: TextStyle(fontSize: 12, color: outline), !widget.loadingStatus
? widget.videoDetail!.pubdate
: videoItem['pubdate'],
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
), ),
], ],
), ),

View File

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'dart:ui';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -281,43 +280,66 @@ class _VideoDetailPageState extends State<VideoDetailPage>
onlyOneScrollInBody: true, onlyOneScrollInBody: true,
body: Container( body: Container(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: Expanded( child: Column(
child: TabBarView( children: [
controller: videoDetailController.tabCtr, Opacity(
children: [ opacity: 0,
Builder( child: SizedBox(
builder: (context) { width: double.infinity,
return CustomScrollView( height: 0,
key: const PageStorageKey<String>('简介'), child: Obx(
slivers: <Widget>[ () => TabBar(
if (videoDetailController.videoType == controller: videoDetailController.tabCtr,
SearchType.video) ...[ dividerColor: Colors.transparent,
const VideoIntroPanel(), indicatorColor:
] else if (videoDetailController.videoType == Theme.of(context).colorScheme.background,
SearchType.media_bangumi) ...[ tabs: videoDetailController.tabs
const BangumiIntroPanel() .map((String name) => Tab(text: name))
], .toList(),
if (videoDetailController.videoType == ),
SearchType.video) ...[ ),
SliverPersistentHeader(
floating: true,
pinned: true,
delegate: SliverHeaderDelegate(
height: 50,
child: const MenuRow(loadingStatus: false),
),
),
],
const RelatedVideoPanel(),
],
);
},
), ),
VideoReplyPanel( ),
bvid: videoDetailController.bvid, Expanded(
) child: TabBarView(
], controller: videoDetailController.tabCtr,
), children: [
Builder(
builder: (context) {
return CustomScrollView(
key: const PageStorageKey<String>('简介'),
slivers: <Widget>[
if (videoDetailController.videoType ==
SearchType.video) ...[
const VideoIntroPanel(),
] else if (videoDetailController.videoType ==
SearchType.media_bangumi) ...[
const BangumiIntroPanel()
],
if (videoDetailController.videoType ==
SearchType.video) ...[
SliverPersistentHeader(
floating: true,
pinned: true,
delegate: SliverHeaderDelegate(
height: 50,
child:
const MenuRow(loadingStatus: false),
),
),
],
const RelatedVideoPanel(),
],
);
},
),
VideoReplyPanel(
bvid: videoDetailController.bvid,
)
],
),
),
],
), ),
), ),
), ),