diff --git a/lib/pages/article/view.dart b/lib/pages/article/view.dart index 6d0e364fd..3d650a935 100644 --- a/lib/pages/article/view.dart +++ b/lib/pages/article/view.dart @@ -71,9 +71,10 @@ class _ArticlePageState extends CommonDynPageState { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final isPortrait = context.isPortrait; return Scaffold( resizeToAvoidBottomInset: false, - appBar: _buildAppBar, + appBar: _buildAppBar(isPortrait), body: SafeArea( top: false, bottom: false, @@ -85,8 +86,6 @@ class _ArticlePageState extends CommonDynPageState { bottom: false, child: Builder( builder: (context) { - final isPortrait = - context.orientation == Orientation.portrait; double padding = max( context.width / 2 - Grid.smallCardWidth, 0, @@ -495,7 +494,7 @@ class _ArticlePageState extends CommonDynPageState { }; } - PreferredSizeWidget get _buildAppBar => AppBar( + PreferredSizeWidget _buildAppBar(bool isPortrait) => AppBar( title: Obx(() { if (controller.isLoaded.value && controller.showTitle.value) { return Text(controller.summary.title ?? ''); @@ -504,7 +503,7 @@ class _ArticlePageState extends CommonDynPageState { }), actions: [ const SizedBox(width: 4), - if (context.orientation == Orientation.landscape) + if (!isPortrait) IconButton( tooltip: '页面比例调节', onPressed: () => showDialog( diff --git a/lib/pages/common/dyn/common_dyn_page.dart b/lib/pages/common/dyn/common_dyn_page.dart index ed0c728c3..461086266 100644 --- a/lib/pages/common/dyn/common_dyn_page.dart +++ b/lib/pages/common/dyn/common_dyn_page.dart @@ -24,8 +24,7 @@ abstract class CommonDynPageState extends State late final scaffoldKey = GlobalKey(); bool get horizontalPreview => - context.orientation == Orientation.landscape && - controller.horizontalPreview; + context.isLandscape && controller.horizontalPreview; Function(List imgList, int index)? imageCallback; dynamic get arguments; @@ -191,7 +190,7 @@ abstract class CommonDynPageState extends State ), ), ); - if (this.context.orientation == Orientation.portrait) { + if (this.context.isPortrait) { Get.to( replyReplyPage, routeName: 'dynamicDetail-Copy', diff --git a/lib/pages/dynamics/widgets/vote.dart b/lib/pages/dynamics/widgets/vote.dart index bdd0880f3..594ee428f 100644 --- a/lib/pages/dynamics/widgets/vote.dart +++ b/lib/pages/dynamics/widgets/vote.dart @@ -44,8 +44,7 @@ class _VotePanelState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); - final usePortrait = - context.orientation == Orientation.portrait || context.isTablet; + final usePortrait = context.isPortrait || context.isTablet; final right = [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/pages/dynamics_detail/view.dart b/lib/pages/dynamics_detail/view.dart index 29e44d663..6cb8032e7 100644 --- a/lib/pages/dynamics_detail/view.dart +++ b/lib/pages/dynamics_detail/view.dart @@ -53,6 +53,7 @@ class _DynamicDetailPageState extends CommonDynPageState { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final isPortrait = context.isPortrait; return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -75,8 +76,9 @@ class _DynamicDetailPageState extends CommonDynPageState { }, ), ), - actions: context.orientation == Orientation.landscape - ? [ + actions: isPortrait + ? null + : [ IconButton( tooltip: '页面比例调节', onPressed: () => showDialog( @@ -119,53 +121,51 @@ class _DynamicDetailPageState extends CommonDynPageState { ), ), const SizedBox(width: 16), - ] - : null, + ], ), body: SafeArea( top: false, bottom: false, - child: context.orientation == Orientation.portrait + child: isPortrait ? refreshIndicator( onRefresh: controller.onRefresh, - child: _buildBody(context.orientation, theme), + child: _buildBody(isPortrait, theme), ) - : _buildBody(context.orientation, theme), + : _buildBody(isPortrait, theme), ), ); } - Widget _buildBody(Orientation orientation, ThemeData theme) => Stack( + Widget _buildBody(bool isPortrait, ThemeData theme) => Stack( clipBehavior: Clip.none, children: [ Builder( builder: (context) { double padding = max(context.width / 2 - Grid.smallCardWidth, 0); - if (orientation == Orientation.portrait) { + if (isPortrait) { return CustomScrollView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), - slivers: - [ - SliverToBoxAdapter( - child: DynamicPanel( - item: controller.dynItem, - isDetail: true, - callback: imageCallback, - ), + slivers: [ + SliverPadding( + padding: EdgeInsets.symmetric(horizontal: padding), + sliver: SliverMainAxisGroup( + slivers: [ + SliverToBoxAdapter( + child: DynamicPanel( + item: controller.dynItem, + isDetail: true, + callback: imageCallback, ), - buildReplyHeader(theme), - Obx( - () => replyList(theme, controller.loadingState.value), - ), - ] - .map( - (e) => SliverPadding( - padding: EdgeInsets.symmetric(horizontal: padding), - sliver: e, - ), - ) - .toList(), + ), + buildReplyHeader(theme), + Obx( + () => replyList(theme, controller.loadingState.value), + ), + ], + ), + ), + ], ); } else { return Row( diff --git a/lib/pages/fav/note/child_view.dart b/lib/pages/fav/note/child_view.dart index ba4c26866..96c65fbd3 100644 --- a/lib/pages/fav/note/child_view.dart +++ b/lib/pages/fav/note/child_view.dart @@ -31,6 +31,7 @@ class _FavNoteChildPageState extends State Widget build(BuildContext context) { super.build(context); final theme = Theme.of(context); + final padding = MediaQuery.paddingOf(context); return LayoutBuilder( builder: (context, constraints) => Stack( clipBehavior: Clip.none, @@ -42,9 +43,7 @@ class _FavNoteChildPageState extends State physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverPadding( - padding: EdgeInsets.only( - bottom: MediaQuery.paddingOf(context).bottom + 80, - ), + padding: EdgeInsets.only(bottom: padding.bottom + 80), sliver: Obx( () => _buildBody(_favNoteController.loadingState.value), ), @@ -63,7 +62,7 @@ class _FavNoteChildPageState extends State : Offset.zero, duration: const Duration(milliseconds: 150), child: Container( - padding: MediaQuery.paddingOf(context), + padding: padding, decoration: BoxDecoration( color: theme.colorScheme.onInverseSurface, border: Border( diff --git a/lib/pages/fav/pgc/child_view.dart b/lib/pages/fav/pgc/child_view.dart index 7d45dfdf6..38be14aba 100644 --- a/lib/pages/fav/pgc/child_view.dart +++ b/lib/pages/fav/pgc/child_view.dart @@ -36,6 +36,7 @@ class _FavPgcChildPageState extends State Widget build(BuildContext context) { super.build(context); final theme = Theme.of(context); + final padding = MediaQuery.paddingOf(context); return LayoutBuilder( builder: (context, constraints) => Stack( clipBehavior: Clip.none, @@ -47,9 +48,7 @@ class _FavPgcChildPageState extends State physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverPadding( - padding: EdgeInsets.only( - bottom: MediaQuery.paddingOf(context).bottom + 80, - ), + padding: EdgeInsets.only(bottom: padding.bottom + 80), sliver: Obx( () => _buildBody(_favPgcController.loadingState.value), ), @@ -68,7 +67,7 @@ class _FavPgcChildPageState extends State : Offset.zero, duration: const Duration(milliseconds: 150), child: Container( - padding: MediaQuery.paddingOf(context), + padding: padding, decoration: BoxDecoration( color: theme.colorScheme.onInverseSurface, border: Border( diff --git a/lib/pages/follow/child/child_view.dart b/lib/pages/follow/child/child_view.dart index bfd1811ee..eaf177200 100644 --- a/lib/pages/follow/child/child_view.dart +++ b/lib/pages/follow/child/child_view.dart @@ -42,13 +42,28 @@ class _FollowChildPageState extends State @override Widget build(BuildContext context) { super.build(context); + final padding = MediaQuery.paddingOf(context); + Widget child = refreshIndicator( + onRefresh: _followController.onRefresh, + child: CustomScrollView( + controller: _followController.scrollController, + physics: const AlwaysScrollableScrollPhysics(), + slivers: [ + SliverPadding( + padding: EdgeInsets.only(bottom: padding.bottom + 80), + sliver: Obx( + () => _buildBody(_followController.loadingState.value), + ), + ), + ], + ), + ); if (widget.onSelect != null || (widget.controller?.isOwner == true && widget.tagid == null)) { - final padding = MediaQuery.paddingOf(context); return Stack( clipBehavior: Clip.none, children: [ - _child, + child, Positioned( right: 16 + padding.right, bottom: 16 + padding.bottom, @@ -66,25 +81,9 @@ class _FollowChildPageState extends State ], ); } - return _child; + return child; } - Widget get _child => refreshIndicator( - onRefresh: _followController.onRefresh, - child: CustomScrollView( - controller: _followController.scrollController, - physics: const AlwaysScrollableScrollPhysics(), - slivers: [ - SliverPadding( - padding: EdgeInsets.only( - bottom: MediaQuery.paddingOf(context).bottom + 80, - ), - sliver: Obx(() => _buildBody(_followController.loadingState.value)), - ), - ], - ), - ); - Widget _buildBody(LoadingState?> loadingState) { return switch (loadingState) { Loading() => SliverList.builder( diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 7ad23d3da..6cad430c4 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -32,8 +32,7 @@ class _HomePageState extends State final theme = Theme.of(context); return Column( children: [ - if (!_homeController.useSideBar && - context.orientation == Orientation.portrait) + if (!_homeController.useSideBar && context.isPortrait) customAppBar(theme), if (_homeController.tabs.length > 1) Material( diff --git a/lib/pages/live_dm_block/view.dart b/lib/pages/live_dm_block/view.dart index 1ca9e325d..dc1ba66f8 100644 --- a/lib/pages/live_dm_block/view.dart +++ b/lib/pages/live_dm_block/view.dart @@ -29,7 +29,7 @@ class _LiveDmBlockPageState extends State { @override Widget build(BuildContext context) { - isPortrait = context.orientation == Orientation.portrait; + isPortrait = context.isPortrait; final theme = Theme.of(context); Widget tabBar = TabBar( diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 891266130..5df66057c 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -49,7 +49,7 @@ class _MainAppState extends State _mainController ..checkUnreadDynamic() ..checkDefaultSearch(true) - ..checkUnread(context.orientation == Orientation.portrait); + ..checkUnread(context.isPortrait); super.didPopNext(); } @@ -65,7 +65,7 @@ class _MainAppState extends State _mainController ..checkUnreadDynamic() ..checkDefaultSearch(true) - ..checkUnread(context.orientation == Orientation.portrait); + ..checkUnread(context.isPortrait); } } @@ -89,7 +89,7 @@ class _MainAppState extends State @override Widget build(BuildContext context) { final theme = Theme.of(context); - final bool isPortrait = context.orientation == Orientation.portrait; + final bool isPortrait = context.isPortrait; final useBottomNav = isPortrait && !_mainController.useSideBar; Widget? bottomNav = useBottomNav ? _mainController.navigationBars.length > 1 diff --git a/lib/pages/member/view.dart b/lib/pages/member/view.dart index 5ace617da..96a05d2b6 100644 --- a/lib/pages/member/view.dart +++ b/lib/pages/member/view.dart @@ -331,15 +331,15 @@ class _MemberPageState extends State { ); Widget _buildAppBar({bool isV = true}) { + final top = MediaQuery.paddingOf(context).top; return DynamicSliverAppBar( pinned: true, primary: false, automaticallyImplyLeading: false, - toolbarHeight: kToolbarHeight + MediaQuery.paddingOf(context).top, + toolbarHeight: kToolbarHeight + top, flexibleSpace: _buildUserInfo(_userController.loadingState.value, isV), callback: (value) { - _userController.offset = - (value - 56 - MediaQuery.paddingOf(context).top).toInt(); + _userController.offset = (value - 56 - top).toInt(); listener(); }, ); diff --git a/lib/pages/member_home/view.dart b/lib/pages/member_home/view.dart index e2fd807e5..19b8251a1 100644 --- a/lib/pages/member_home/view.dart +++ b/lib/pages/member_home/view.dart @@ -44,7 +44,7 @@ class _MemberHomeState extends State } Widget _buildBody(LoadingState loadingState) { - final isVertical = context.orientation == Orientation.portrait; + final isVertical = context.isPortrait; final setting = _ctr.spaceSetting; final isOwner = setting != null; final color = Theme.of(context).colorScheme.outline; diff --git a/lib/pages/member_opus/view.dart b/lib/pages/member_opus/view.dart index 67233ba3c..eb93426a6 100644 --- a/lib/pages/member_opus/view.dart +++ b/lib/pages/member_opus/view.dart @@ -40,6 +40,7 @@ class _MemberOpusState extends State @override Widget build(BuildContext context) { super.build(context); + final bottom = MediaQuery.paddingOf(context).bottom; return Stack( children: [ refreshIndicator( @@ -52,7 +53,7 @@ class _MemberOpusState extends State top: widget.isSingle ? 12 : 0, left: StyleString.safeSpace, right: StyleString.safeSpace, - bottom: MediaQuery.paddingOf(context).bottom + 90, + bottom: bottom + 90, ), sliver: Obx(() => _buildBody(_controller.loadingState.value)), ), @@ -62,7 +63,7 @@ class _MemberOpusState extends State if (_controller.filter?.isNotEmpty == true) Positioned( right: 16, - bottom: MediaQuery.paddingOf(context).bottom + 16, + bottom: bottom + 16, child: FloatingActionButton.extended( onPressed: () => showDialog( context: context, diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index 51c7b3087..2dff57546 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -29,6 +29,7 @@ class _SearchPageState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final isPortrait = context.isPortrait; return Scaffold( appBar: AppBar( shape: Border( @@ -78,9 +79,9 @@ class _SearchPageState extends State { padding: MediaQuery.paddingOf(context).copyWith(top: 0), children: [ if (_searchController.searchSuggestion) _searchSuggest(), - if (context.orientation == Orientation.portrait) ...[ + if (isPortrait) ...[ if (_searchController.enableHotKey) hotSearch(theme), - _history(theme), + _history(theme, isPortrait), if (_searchController.enableSearchRcmd) hotSearch(theme, false), ] else Row( @@ -97,7 +98,7 @@ class _SearchPageState extends State { ], ), ), - Expanded(child: _history(theme)), + Expanded(child: _history(theme, isPortrait)), ], ), ], @@ -257,7 +258,7 @@ class _SearchPageState extends State { ); } - Widget _history(ThemeData theme) { + Widget _history(ThemeData theme, bool isPortrait) { return Obx( () { if (_searchController.historyList.isEmpty) { @@ -267,7 +268,7 @@ class _SearchPageState extends State { return Padding( padding: EdgeInsets.fromLTRB( 10, - context.orientation == Orientation.landscape + !isPortrait ? 25 : _searchController.enableHotKey ? 0 diff --git a/lib/pages/setting/view.dart b/lib/pages/setting/view.dart index 762a15264..9a16868cc 100644 --- a/lib/pages/setting/view.dart +++ b/lib/pages/setting/view.dart @@ -86,7 +86,7 @@ class _SettingPageState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); - _isPortrait = context.orientation == Orientation.portrait; + _isPortrait = context.isPortrait; return Scaffold( appBar: AppBar( title: _isPortrait ? const Text('设置') : Text(_type.title), @@ -168,9 +168,10 @@ class _SettingPageState extends State { TextStyle subTitleStyle = theme.textTheme.labelMedium!.copyWith( color: theme.colorScheme.outline, ); + final padding = MediaQuery.paddingOf(context); return ListView( children: [ - _buildSearchItem(theme), + _buildSearchItem(theme, padding), ..._items .sublist(0, _items.length - 1) .map( @@ -204,7 +205,7 @@ class _SettingPageState extends State { leading: Icon(_items.last.icon), title: Text(_items.last.type.title, style: titleStyle), ), - SizedBox(height: MediaQuery.paddingOf(context).bottom + 80), + SizedBox(height: padding.bottom + 80), ], ); } @@ -276,9 +277,9 @@ class _SettingPageState extends State { ); } - Widget _buildSearchItem(ThemeData theme) => Padding( + Widget _buildSearchItem(ThemeData theme, EdgeInsets padding) => Padding( padding: EdgeInsets.only( - left: 16 + MediaQuery.paddingOf(context).left, + left: 16 + padding.left, right: 16, bottom: 8, ), diff --git a/lib/pages/subscription_detail/view.dart b/lib/pages/subscription_detail/view.dart index 7d852e57d..2bb032688 100644 --- a/lib/pages/subscription_detail/view.dart +++ b/lib/pages/subscription_detail/view.dart @@ -28,6 +28,7 @@ class _SubDetailPageState extends State { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final padding = MediaQuery.paddingOf(context); return Scaffold( body: SafeArea( top: false, @@ -38,11 +39,11 @@ class _SubDetailPageState extends State { controller: _subDetailController.scrollController, physics: const AlwaysScrollableScrollPhysics(), slivers: [ - _buildAppBar(theme), + _buildAppBar(theme, padding), SliverPadding( padding: EdgeInsets.only( top: 7, - bottom: MediaQuery.paddingOf(context).bottom + 80, + bottom: padding.bottom + 80, ), sliver: Obx( () => _buildBody(_subDetailController.loadingState.value), @@ -90,7 +91,7 @@ class _SubDetailPageState extends State { }; } - Widget _buildAppBar(ThemeData theme) { + Widget _buildAppBar(ThemeData theme, EdgeInsets padding) { final style = TextStyle( fontSize: 12.5, color: theme.colorScheme.outline, @@ -125,7 +126,7 @@ class _SubDetailPageState extends State { ), ), padding: EdgeInsets.only( - top: kToolbarHeight + MediaQuery.paddingOf(context).top + 10, + top: kToolbarHeight + padding.top + 10, left: 12, right: 12, bottom: 12, diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index f1646d8f1..b9084ee2e 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -81,10 +81,11 @@ class _VideoIntroPanelState extends State fadeCurve: Curves.ease, sizeCurve: Curves.linear, ); + final isPortrait = context.isPortrait; return SliverLayoutBuilder( builder: (context, constraints) { bool isHorizontal = - context.orientation == Orientation.landscape && + !isPortrait && constraints.crossAxisExtent > constraints.viewportMainAxisExtent * 1.25; return SliverPadding( @@ -125,8 +126,7 @@ class _VideoIntroPanelState extends State () { if (mid != null) { feedBack(); - if (context.orientation == - Orientation.landscape && + if (!isPortrait && introController .horizontalMemberPage) { widget.onShowMemberPage(mid); @@ -151,7 +151,14 @@ class _VideoIntroPanelState extends State child: Row( spacing: 25, children: videoDetail.staff! - .map((e) => _buildStaff(theme, mid, e)) + .map( + (e) => _buildStaff( + theme, + isPortrait, + mid, + e, + ), + ) .toList(), ), ), @@ -304,11 +311,10 @@ class _VideoIntroPanelState extends State // 合集 if (!isLoading && videoDetail.ugcSeason != null && - (context.orientation != Orientation.landscape || - (context.orientation == Orientation.landscape && - !videoDetailCtr - .plPlayerController - .horizontalSeasonPanel))) + (isPortrait || + !videoDetailCtr + .plPlayerController + .horizontalSeasonPanel)) SeasonPanel( heroTag: widget.heroTag, changeFuc: introController.changeSeasonOrbangu, @@ -318,11 +324,10 @@ class _VideoIntroPanelState extends State if (!isLoading && videoDetail.pages != null && videoDetail.pages!.length > 1 && - (context.orientation != Orientation.landscape || - (context.orientation == Orientation.landscape && - !videoDetailCtr - .plPlayerController - .horizontalSeasonPanel))) ...[ + (isPortrait || + !videoDetailCtr + .plPlayerController + .horizontalSeasonPanel)) ...[ PagesPanel( heroTag: widget.heroTag, videoIntroController: introController, @@ -701,12 +706,17 @@ class _VideoIntroPanelState extends State return TextSpan(children: spanChildren); } - Widget _buildStaff(ThemeData theme, int? ownerMid, Staff item) { + Widget _buildStaff( + ThemeData theme, + bool isPortrait, + int? ownerMid, + Staff item, + ) { return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { if (item.mid == ownerMid && - context.orientation == Orientation.landscape && + !isPortrait && introController.horizontalMemberPage) { widget.onShowMemberPage(ownerMid); } else { diff --git a/lib/pages/video/post_panel/view.dart b/lib/pages/video/post_panel/view.dart index 4912655d6..61e77f117 100644 --- a/lib/pages/video/post_panel/view.dart +++ b/lib/pages/video/post_panel/view.dart @@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart'; import 'package:PiliPlus/pages/video/controller.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/utils/duration_util.dart'; +import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart' show kDebugMode; @@ -39,10 +40,10 @@ class PostPanel extends CommonCollapseSlidePage { } class _PostPanelState extends CommonCollapseSlidePageState { - VideoDetailController get videoDetailController => + late final VideoDetailController videoDetailController = widget.videoDetailController; - PlPlayerController get plPlayerController => widget.plPlayerController; - List? get list => videoDetailController.postList; + late final PlPlayerController plPlayerController = widget.plPlayerController; + late final List? list = videoDetailController.postList; late final double videoDuration = plPlayerController.durationSeconds.value.inMilliseconds / 1000; @@ -95,60 +96,58 @@ class _PostPanelState extends CommonCollapseSlidePageState { @override Widget buildList(ThemeData theme) { - return list?.isNotEmpty == true - ? Stack( - clipBehavior: Clip.none, - children: [ - SingleChildScrollView( - controller: ScrollController(), - physics: const AlwaysScrollableScrollPhysics(), - padding: EdgeInsets.only( - bottom: 88 + MediaQuery.paddingOf(context).bottom, - ), - child: Column( - children: List.generate( - list!.length, - (index) { - return _buildItem(theme, index, list![index]); - }, - ), - ), - ), - Positioned( - right: 16, - bottom: 16 + MediaQuery.paddingOf(context).bottom, - child: FloatingActionButton( - tooltip: '提交', - onPressed: () => showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('确定无误再提交'), - actions: [ - TextButton( - onPressed: Get.back, - child: Text( - '取消', - style: TextStyle( - color: theme.colorScheme.outline, - ), - ), - ), - TextButton( - onPressed: () { - Get.back(); - _onPost(); - }, - child: const Text('确定提交'), - ), - ], + if (list.isNullOrEmpty) { + return errorWidget(); + } + final bottom = MediaQuery.paddingOf(context).bottom; + return Stack( + clipBehavior: Clip.none, + children: [ + SingleChildScrollView( + controller: ScrollController(), + physics: const AlwaysScrollableScrollPhysics(), + padding: EdgeInsets.only(bottom: 88 + bottom), + child: Column( + children: List.generate( + list!.length, + (index) { + return _buildItem(theme, index, list![index]); + }, + ), + ), + ), + Positioned( + right: 16, + bottom: 16 + bottom, + child: FloatingActionButton( + tooltip: '提交', + onPressed: () => showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('确定无误再提交'), + actions: [ + TextButton( + onPressed: Get.back, + child: Text( + '取消', + style: TextStyle(color: theme.colorScheme.outline), ), ), - child: const Icon(Icons.check), - ), + TextButton( + onPressed: () { + Get.back(); + _onPost(); + }, + child: const Text('确定提交'), + ), + ], ), - ], - ) - : errorWidget(); + ), + child: const Icon(Icons.check), + ), + ), + ], + ); } void updateSegment({ @@ -225,9 +224,7 @@ class _PostPanelState extends CommonCollapseSlidePageState { content: TextFormField( initialValue: value, autofocus: true, - onChanged: (value) { - initV = value; - }, + onChanged: (value) => initV = value, inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r'[\d:.]+')), ], diff --git a/lib/pages/video/reply/view.dart b/lib/pages/video/reply/view.dart index 77875ff8b..4bae4ba0b 100644 --- a/lib/pages/video/reply/view.dart +++ b/lib/pages/video/reply/view.dart @@ -97,6 +97,7 @@ class _VideoReplyPanelState extends State Widget build(BuildContext context) { super.build(context); final theme = Theme.of(context); + final bottom = MediaQuery.paddingOf(context).bottom; return refreshIndicator( onRefresh: _videoReplyController.onRefresh, child: Stack( @@ -158,13 +159,16 @@ class _VideoReplyPanelState extends State ), ), Obx( - () => - _buildBody(theme, _videoReplyController.loadingState.value), + () => _buildBody( + theme, + bottom, + _videoReplyController.loadingState.value, + ), ), ], ), Positioned( - bottom: MediaQuery.paddingOf(context).bottom + 14, + bottom: bottom + 14, right: 14, child: SlideTransition( position: _videoReplyController.anim, @@ -188,7 +192,7 @@ class _VideoReplyPanelState extends State ); } - Widget _buildBody(ThemeData theme, LoadingState loadingState) { + Widget _buildBody(ThemeData theme, double bottom, LoadingState loadingState) { return switch (loadingState) { Loading() => SliverList.builder( itemBuilder: (BuildContext context, index) { @@ -200,7 +204,6 @@ class _VideoReplyPanelState extends State response?.isNotEmpty == true ? SliverList.builder( itemBuilder: (context, index) { - double bottom = MediaQuery.paddingOf(context).bottom; if (index == response.length) { _videoReplyController.onLoadMore(); return Container( diff --git a/lib/pages/video/reply_reply/view.dart b/lib/pages/video/reply_reply/view.dart index e08728151..9ad5d9788 100644 --- a/lib/pages/video/reply_reply/view.dart +++ b/lib/pages/video/reply_reply/view.dart @@ -57,9 +57,8 @@ class _VideoReplyReplyPanelState ReplyInfo? get firstFloor => widget.firstFloor ?? _controller.firstFloor; bool get _horizontalPreview => - _controller.horizontalPreview && - context.orientation == Orientation.landscape; - late Function(List imgList, int index)? _imageCallback; + _controller.horizontalPreview && context.isLandscape; + Function(List imgList, int index)? _imageCallback; Animation? colorAnimation; diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index cb205312c..0eb497ccf 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -104,12 +104,12 @@ class _VideoDetailPageVState extends State return videoDetailController.plPlayerController.horizontalSeasonPanel && (videoDetail.ugcSeason != null || ((videoDetail.pages?.length ?? 0) > 1)) && - context.orientation == Orientation.landscape; + context.isLandscape; } bool get _horizontalPreview => videoDetailController.plPlayerController.horizontalPreview && - context.orientation == Orientation.landscape; + context.isLandscape; StreamSubscription? _listenerFS; diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 2e8ebcbea..49379311e 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -255,8 +255,7 @@ class _PLVideoPlayerState extends State bool isPage = videoDetail?.pages != null && videoDetail!.pages!.length > 1; bool isPgc = pgcIntroController != null; bool anySeason = isSeason || isPage || isPgc; - double widgetWidth = - isFullScreen && context.orientation == Orientation.landscape ? 42 : 35; + double widgetWidth = isFullScreen && context.isLandscape ? 42 : 35; Map videoProgressWidgets = { /// 上一集 BottomControlType.pre: Container(