fix: 直播间布局异常、控制器初始化异常、imgQuality/cover取值异常
This commit is contained in:
@ -33,7 +33,11 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final int defaultImgQuality = GlobalDataCache().imgQuality;
|
int defaultImgQuality = 10;
|
||||||
|
try {
|
||||||
|
defaultImgQuality = GlobalDataCache().imgQuality;
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
if (src == '' || src == null) {
|
if (src == '' || src == null) {
|
||||||
return placeholder(context);
|
return placeholder(context);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class LiveRoomController extends GetxController {
|
|||||||
? liveItem.pic
|
? liveItem.pic
|
||||||
: (liveItem.cover != null && liveItem.cover != '')
|
: (liveItem.cover != null && liveItem.cover != '')
|
||||||
? liveItem.cover
|
? liveItem.cover
|
||||||
: null;
|
: '';
|
||||||
}
|
}
|
||||||
Request.getBuvid().then((value) => buvid = value);
|
Request.getBuvid().then((value) => buvid = value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,6 +108,12 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final mediaQuery = MediaQuery.of(context);
|
||||||
|
final isPortrait = mediaQuery.orientation == Orientation.portrait;
|
||||||
|
final isLandscape = mediaQuery.orientation == Orientation.landscape;
|
||||||
|
|
||||||
|
final padding = mediaQuery.padding;
|
||||||
|
|
||||||
Widget videoPlayerPanel = FutureBuilder(
|
Widget videoPlayerPanel = FutureBuilder(
|
||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
@ -187,10 +193,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => SizedBox(
|
() => SizedBox(
|
||||||
height: MediaQuery.of(context).padding.top +
|
height: padding.top +
|
||||||
(_liveRoomController.isPortrait.value ||
|
(_liveRoomController.isPortrait.value || isLandscape
|
||||||
MediaQuery.of(context).orientation ==
|
|
||||||
Orientation.landscape
|
|
||||||
? 0
|
? 0
|
||||||
: kToolbarHeight),
|
: kToolbarHeight),
|
||||||
),
|
),
|
||||||
@ -201,21 +205,18 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
if (plPlayerController.isFullScreen.value == true) {
|
if (plPlayerController.isFullScreen.value == true) {
|
||||||
plPlayerController.triggerFullScreen(status: false);
|
plPlayerController.triggerFullScreen(status: false);
|
||||||
}
|
}
|
||||||
if (MediaQuery.of(context).orientation ==
|
if (isLandscape) {
|
||||||
Orientation.landscape) {
|
|
||||||
verticalScreen();
|
verticalScreen();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Container(
|
() => Container(
|
||||||
width: Get.size.width,
|
width: Get.size.width,
|
||||||
height: MediaQuery.of(context).orientation ==
|
height: isLandscape
|
||||||
Orientation.landscape
|
|
||||||
? Get.size.height
|
? Get.size.height
|
||||||
: !_liveRoomController.isPortrait.value
|
: !_liveRoomController.isPortrait.value
|
||||||
? Get.size.width * 9 / 16
|
? Get.size.width * 9 / 16
|
||||||
: Get.size.height -
|
: Get.size.height - padding.top,
|
||||||
MediaQuery.of(context).padding.top,
|
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(6)),
|
borderRadius: BorderRadius.all(Radius.circular(6)),
|
||||||
@ -229,7 +230,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
// 定位 快速滑动到底部
|
// 定位 快速滑动到底部
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 20,
|
right: 20,
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
bottom: padding.bottom + 80,
|
||||||
child: SlideTransition(
|
child: SlideTransition(
|
||||||
position: Tween<Offset>(
|
position: Tween<Offset>(
|
||||||
begin: const Offset(0, 4),
|
begin: const Offset(0, 4),
|
||||||
@ -262,10 +263,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
toolbarHeight:
|
toolbarHeight: isPortrait ? 56 : 0,
|
||||||
MediaQuery.of(context).orientation == Orientation.portrait
|
|
||||||
? 56
|
|
||||||
: 0,
|
|
||||||
title: FutureBuilder(
|
title: FutureBuilder(
|
||||||
future: _futureBuilder,
|
future: _futureBuilder,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@ -317,15 +315,20 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
),
|
),
|
||||||
// 消息列表
|
// 消息列表
|
||||||
Obx(
|
Obx(
|
||||||
() => Positioned(
|
() => Align(
|
||||||
top: MediaQuery.of(context).padding.top +
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
bottom: 90 + padding.bottom,
|
||||||
|
),
|
||||||
|
height: Get.size.height -
|
||||||
|
(padding.top +
|
||||||
kToolbarHeight +
|
kToolbarHeight +
|
||||||
(_liveRoomController.isPortrait.value
|
(_liveRoomController.isPortrait.value
|
||||||
? Get.size.width
|
? Get.size.width
|
||||||
: Get.size.width * 9 / 16),
|
: Get.size.width * 9 / 16) +
|
||||||
bottom: 90 + MediaQuery.of(context).padding.bottom,
|
100 +
|
||||||
left: 0,
|
padding.bottom),
|
||||||
right: 0,
|
|
||||||
child: buildMessageListUI(
|
child: buildMessageListUI(
|
||||||
context,
|
context,
|
||||||
_liveRoomController,
|
_liveRoomController,
|
||||||
@ -333,19 +336,17 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
// 消息输入框
|
// 消息输入框
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: MediaQuery.of(context).orientation == Orientation.portrait,
|
visible: isPortrait,
|
||||||
child: Positioned(
|
child: Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 14,
|
left: 14, right: 14, top: 4, bottom: padding.bottom + 20),
|
||||||
right: 14,
|
|
||||||
top: 4,
|
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 20),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey.withOpacity(0.1),
|
color: Colors.grey.withOpacity(0.1),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
@ -421,6 +422,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
return PiPSwitcher(
|
return PiPSwitcher(
|
||||||
childWhenDisabled: childWhenDisabled,
|
childWhenDisabled: childWhenDisabled,
|
||||||
@ -438,8 +440,7 @@ Widget buildMessageListUI(
|
|||||||
LiveRoomController liveRoomController,
|
LiveRoomController liveRoomController,
|
||||||
ScrollController scrollController,
|
ScrollController scrollController,
|
||||||
) {
|
) {
|
||||||
return Expanded(
|
return Obx(
|
||||||
child: Obx(
|
|
||||||
() => MediaQuery.removePadding(
|
() => MediaQuery.removePadding(
|
||||||
context: context,
|
context: context,
|
||||||
removeTop: true,
|
removeTop: true,
|
||||||
@ -519,7 +520,6 @@ Widget buildMessageListUI(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,8 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
final MainController _mainController = Get.put(MainController());
|
final MainController _mainController = Get.put(MainController());
|
||||||
late HomeController _homeController;
|
late HomeController _homeController;
|
||||||
RankController? _rankController;
|
RankController? _rankController;
|
||||||
DynamicsController? _dynamicController;
|
late DynamicsController _dynamicController;
|
||||||
MediaController? _mediaController;
|
late MediaController _mediaController;
|
||||||
|
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -76,28 +76,30 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentPage is DynamicsPage) {
|
if (currentPage is DynamicsPage) {
|
||||||
if (_dynamicController!.flag) {
|
if (_dynamicController.flag) {
|
||||||
// 单击返回顶部 双击并刷新
|
// 单击返回顶部 双击并刷新
|
||||||
if (DateTime.now().millisecondsSinceEpoch - _lastSelectTime! < 500) {
|
if (DateTime.now().millisecondsSinceEpoch - _lastSelectTime! < 500) {
|
||||||
_dynamicController!.onRefresh();
|
_dynamicController.onRefresh();
|
||||||
} else {
|
} else {
|
||||||
_dynamicController!.animateToTop();
|
_dynamicController.animateToTop();
|
||||||
}
|
}
|
||||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
}
|
}
|
||||||
_dynamicController!.flag = true;
|
_dynamicController.flag = true;
|
||||||
_mainController.clearUnread();
|
_mainController.clearUnread();
|
||||||
} else {
|
} else {
|
||||||
_dynamicController?.flag = false;
|
_dynamicController.flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPage is MediaPage) {
|
if (currentPage is MediaPage) {
|
||||||
_mediaController!.queryFavFolder();
|
_mediaController.queryFavFolder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void controllerInit() {
|
void controllerInit() {
|
||||||
_homeController = Get.put(HomeController());
|
_homeController = Get.put(HomeController());
|
||||||
|
_dynamicController = Get.put(DynamicsController());
|
||||||
|
_mediaController = Get.put(MediaController());
|
||||||
if (_mainController.pagesIds.contains(1)) {
|
if (_mainController.pagesIds.contains(1)) {
|
||||||
_rankController = Get.put(RankController());
|
_rankController = Get.put(RankController());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user