diff --git a/lib/common/widgets/image/custom_grid_view.dart b/lib/common/widgets/image/custom_grid_view.dart index d2d07a473..2a920712d 100644 --- a/lib/common/widgets/image/custom_grid_view.dart +++ b/lib/common/widgets/image/custom_grid_view.dart @@ -254,7 +254,7 @@ class _CustomGridViewDelegate extends MultiChildLayoutDelegate { @override void performLayout(Size size) { - final constraints = BoxConstraints.loose(Size(width, height)); + final constraints = BoxConstraints.expand(width: width, height: height); for (int i = 0; i < itemCount; i++) { layoutChild(i, constraints); positionChild( diff --git a/lib/pages/live_room/superchat/superchat_card.dart b/lib/pages/live_room/superchat/superchat_card.dart index 1b986b139..8c2451697 100644 --- a/lib/pages/live_room/superchat/superchat_card.dart +++ b/lib/pages/live_room/superchat/superchat_card.dart @@ -119,7 +119,6 @@ class _SuperChatCardState extends State { Text( "¥${item.price}", style: TextStyle( - fontSize: 12, color: Utils.parseColor(item.backgroundPriceColor), ), ), diff --git a/lib/pages/live_room/superchat/superchat_panel.dart b/lib/pages/live_room/superchat/superchat_panel.dart index b87ed8cad..f2bfb3b43 100644 --- a/lib/pages/live_room/superchat/superchat_panel.dart +++ b/lib/pages/live_room/superchat/superchat_panel.dart @@ -16,14 +16,17 @@ class SuperChatPanel extends StatefulWidget { State createState() => _SuperChatPanelState(); } -class _SuperChatPanelState extends DebounceStreamState { +class _SuperChatPanelState extends DebounceStreamState + with AutomaticKeepAliveClientMixin { @override Duration get duration => const Duration(milliseconds: 300); @override Widget build(BuildContext context) { + super.build(context); return Obx( () => ListView.separated( + key: const PageStorageKey('live-sc'), padding: const EdgeInsets.symmetric(horizontal: 12), physics: const ClampingScrollPhysics(), itemCount: widget.controller.superChatMsg.length, @@ -42,4 +45,7 @@ class _SuperChatPanelState extends DebounceStreamState { @override void onValueChanged(value) => widget.controller.clearSC(); + + @override + bool get wantKeepAlive => true; } diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 943ec4051..6d1f10555 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -77,6 +77,11 @@ class _LiveRoomPageState extends State this, ModalRoute.of(context)! as PageRoute, ); + padding = MediaQuery.viewPaddingOf(context); + final size = MediaQuery.sizeOf(context); + maxWidth = size.width; + maxHeight = size.height; + isPortrait = size.isPortrait; } @override @@ -173,11 +178,6 @@ class _LiveRoomPageState extends State @override Widget build(BuildContext context) { - padding = MediaQuery.viewPaddingOf(context); - final size = MediaQuery.sizeOf(context); - maxWidth = size.width; - maxHeight = size.height; - isPortrait = size.isPortrait; if (Platform.isAndroid) { return Floating().isPipMode ? videoPlayerPanel( @@ -254,7 +254,7 @@ class _LiveRoomPageState extends State "id": Utils.generateRandomString(8), "price": 66, "end_time": - DateTime.now().millisecondsSinceEpoch ~/ 1000 - 5, + DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, "message": Utils.generateRandomString(55), "user_info": { "face": "", @@ -733,11 +733,9 @@ class _LiveRoomPageState extends State _liveRoomController.pageIndex.value = value, children: [ KeepAliveWrapper(builder: (context) => chat()), - KeepAliveWrapper( - builder: (context) => SuperChatPanel( - key: scKey, - controller: _liveRoomController, - ), + SuperChatPanel( + key: scKey, + controller: _liveRoomController, ), ], ) diff --git a/lib/pages/live_room/widgets/chat_panel.dart b/lib/pages/live_room/widgets/chat_panel.dart index 3493b9d44..9b490a93f 100644 --- a/lib/pages/live_room/widgets/chat_panel.dart +++ b/lib/pages/live_room/widgets/chat_panel.dart @@ -35,6 +35,7 @@ class LiveRoomChatPanel extends StatelessWidget { children: [ Obx( () => ListView.separated( + key: const PageStorageKey('live-chat'), padding: const EdgeInsets.symmetric(horizontal: 12), controller: liveRoomController.scrollController, separatorBuilder: (context, index) => const SizedBox(height: 8), @@ -89,7 +90,7 @@ class LiveRoomChatPanel extends StatelessWidget { "id": Utils.generateRandomString(8), "price": 66, "end_time": - DateTime.now().millisecondsSinceEpoch ~/ 1000 - 5, + DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, "message": "message message message message message", "user_info": { "face": "", @@ -145,7 +146,7 @@ class LiveRoomChatPanel extends StatelessWidget { children: [ TextSpan( text: - 'SC: ${liveRoomController.superChatMsg.length}', + 'SC(${liveRoomController.superChatMsg.length})', ), const WidgetSpan( alignment: PlaceholderAlignment.middle, diff --git a/lib/pages/video/reply/view.dart b/lib/pages/video/reply/view.dart index 0142e4841..8177e129b 100644 --- a/lib/pages/video/reply/view.dart +++ b/lib/pages/video/reply/view.dart @@ -63,6 +63,7 @@ class _VideoReplyPanelState extends State } else { _videoReplyController.scrollController.removeListener(listener); } + bottom = MediaQuery.viewPaddingOf(context).bottom; } @override @@ -92,7 +93,6 @@ class _VideoReplyPanelState extends State @override Widget build(BuildContext context) { super.build(context); - bottom = MediaQuery.viewPaddingOf(context).bottom; final theme = Theme.of(context); return refreshIndicator( onRefresh: _videoReplyController.onRefresh,