opt change orientation

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-05-09 14:43:08 +08:00
parent e8ece0ed3d
commit 76388ad666
2 changed files with 17 additions and 14 deletions

View File

@@ -153,7 +153,7 @@ class VideoDetailController extends GetxController
PlayerStatus? playerStatus; PlayerStatus? playerStatus;
late final scrollKey = GlobalKey<ExtendedNestedScrollViewState>(); late final scrollKey = GlobalKey<ExtendedNestedScrollViewState>();
late final RxBool isVertical; late bool isVertical;
late final RxDouble scrollRatio = 0.0.obs; late final RxDouble scrollRatio = 0.0.obs;
ScrollController? _scrollCtr; ScrollController? _scrollCtr;
@@ -216,20 +216,23 @@ class VideoDetailController extends GetxController
return; return;
} }
} }
final isVertical = height > width; final newIsVertical = height > width;
if (_scrollCtr?.hasClients != true) { if (_scrollCtr?.hasClients != true) {
videoHeight = isVertical ? maxVideoHeight : minVideoHeight; videoHeight = newIsVertical ? maxVideoHeight : minVideoHeight;
this.isVertical.value = isVertical; if (isVertical != newIsVertical) {
isVertical = newIsVertical;
_needRefreshOnDimensionChanged(newIsVertical);
}
return; return;
} }
if (this.isVertical.value != isVertical) { if (isVertical != newIsVertical) {
this.isVertical.value = isVertical; isVertical = newIsVertical;
final newVideoHeight = isVertical ? maxVideoHeight : minVideoHeight; final newVideoHeight = newIsVertical ? maxVideoHeight : minVideoHeight;
if (videoHeight != newVideoHeight) { if (videoHeight != newVideoHeight) {
if (newVideoHeight > videoHeight) { if (newVideoHeight > videoHeight) {
// current minVideoHeight // current minVideoHeight
videoHeight = maxVideoHeight; videoHeight = maxVideoHeight;
if (_needRefreshOnDimensionChanged(isVertical)) { if (_needRefreshOnDimensionChanged(newIsVertical)) {
tmpVideoHeight = maxVideoHeight; tmpVideoHeight = maxVideoHeight;
refreshPage(); refreshPage();
} }
@@ -240,21 +243,21 @@ class VideoDetailController extends GetxController
double minVideoHeightPrecise = minVideoHeight.toPrecision(2); double minVideoHeightPrecise = minVideoHeight.toPrecision(2);
if (currentHeight == minVideoHeightPrecise) { if (currentHeight == minVideoHeightPrecise) {
videoHeight = minVideoHeight; videoHeight = minVideoHeight;
if (_needRefreshOnDimensionChanged(isVertical)) { if (_needRefreshOnDimensionChanged(newIsVertical)) {
tmpVideoHeight = minVideoHeight; tmpVideoHeight = minVideoHeight;
refreshPage(); refreshPage();
} }
} else if (currentHeight < minVideoHeightPrecise) { } else if (currentHeight < minVideoHeightPrecise) {
// expand // expand
videoHeight = minVideoHeight; videoHeight = minVideoHeight;
if (_needRefreshOnDimensionChanged(isVertical)) { if (_needRefreshOnDimensionChanged(newIsVertical)) {
tmpVideoHeight = minVideoHeight; tmpVideoHeight = minVideoHeight;
refreshPage(); refreshPage();
} }
} else { } else {
// collapse // collapse
videoHeight = minVideoHeight; videoHeight = minVideoHeight;
if (_needRefreshOnDimensionChanged(isVertical)) { if (_needRefreshOnDimensionChanged(newIsVertical)) {
tmpVideoHeight = minVideoHeight; tmpVideoHeight = minVideoHeight;
refreshPage(); refreshPage();
} }
@@ -345,7 +348,7 @@ class VideoDetailController extends GetxController
pgcType = args['pgcType']; pgcType = args['pgcType'];
heroTag = args['heroTag']; heroTag = args['heroTag'];
cover = RxString(args['cover'] ?? ''); cover = RxString(args['cover'] ?? '');
isVertical = RxBool(args['isVertical'] ?? false); isVertical = args['isVertical'] ?? false;
sourceType = args['sourceType'] ?? SourceType.normal; sourceType = args['sourceType'] ?? SourceType.normal;
isFileSource = sourceType == SourceType.file; isFileSource = sourceType == SourceType.file;
@@ -706,7 +709,7 @@ class VideoDetailController extends GetxController
(data.timeLength == null (data.timeLength == null
? null ? null
: Duration(milliseconds: data.timeLength!)), : Duration(milliseconds: data.timeLength!)),
isVertical: isVertical.value, isVertical: isVertical,
aid: aid, aid: aid,
bvid: bvid, bvid: bvid,
cid: cid.value, cid: cid.value,

View File

@@ -399,7 +399,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
..isPortrait = isPortrait = maxHeight >= maxWidth ..isPortrait = isPortrait = maxHeight >= maxWidth
..minVideoHeight = minVideoHeight ..minVideoHeight = minVideoHeight
..maxVideoHeight = maxVideoHeight ..maxVideoHeight = maxVideoHeight
..videoHeight = videoDetailController.isVertical.value ..videoHeight = videoDetailController.isVertical
? maxVideoHeight ? maxVideoHeight
: minVideoHeight; : minVideoHeight;