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,7 +280,27 @@ 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(
children: [
Opacity(
opacity: 0,
child: SizedBox(
width: double.infinity,
height: 0,
child: Obx(
() => TabBar(
controller: videoDetailController.tabCtr,
dividerColor: Colors.transparent,
indicatorColor:
Theme.of(context).colorScheme.background,
tabs: videoDetailController.tabs
.map((String name) => Tab(text: name))
.toList(),
),
),
),
),
Expanded(
child: TabBarView( child: TabBarView(
controller: videoDetailController.tabCtr, controller: videoDetailController.tabCtr,
children: [ children: [
@ -304,7 +323,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
pinned: true, pinned: true,
delegate: SliverHeaderDelegate( delegate: SliverHeaderDelegate(
height: 50, height: 50,
child: const MenuRow(loadingStatus: false), child:
const MenuRow(loadingStatus: false),
), ),
), ),
], ],
@ -319,6 +339,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
], ],
), ),
), ),
],
),
), ),
), ),
), ),