From 4ac05caa2833a9ba77472b10f9ec6136e0bcb2d3 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 31 May 2025 11:22:11 +0800 Subject: [PATCH] opt pages Signed-off-by: bggRGjQaUbCoE --- lib/http/video.dart | 3 +- lib/pages/bangumi/view.dart | 73 ++++++-------- lib/pages/common/common_publish_page.dart | 2 +- lib/pages/contact/view.dart | 12 +-- lib/pages/dynamics/view.dart | 19 +--- lib/pages/dynamics_create/view.dart | 35 ++++++- lib/pages/dynamics_topic/view.dart | 21 +++++ lib/pages/home/view.dart | 75 +++++++-------- lib/pages/live/view.dart | 96 +++++++++---------- lib/pages/main/view.dart | 110 ++++++++++------------ lib/pages/media/view.dart | 14 +-- lib/pages/share/view.dart | 6 +- lib/pages/sponsor_block/view.dart | 2 +- lib/utils/page_utils.dart | 8 +- 14 files changed, 236 insertions(+), 240 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 32b12afc..9e2c250f 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -15,6 +15,7 @@ import 'package:PiliPlus/models/pgc/pgc_rank/pgc_rank_item_model.dart'; import 'package:PiliPlus/models/pgc_lcf.dart'; import 'package:PiliPlus/models/play_info/data.dart'; import 'package:PiliPlus/models/triple/pgc_triple.dart'; +import 'package:PiliPlus/models/triple/ugc_triple.dart'; import 'package:PiliPlus/models/user/fav_folder.dart'; import 'package:PiliPlus/models/video/ai.dart'; import 'package:PiliPlus/models/video/note_list/data.dart'; @@ -428,7 +429,7 @@ class VideoHttp { ), ); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']}; + return {'status': true, 'data': UgcTriple.fromJson(res.data['data'])}; } else { return {'status': false, 'msg': res.data['message']}; } diff --git a/lib/pages/bangumi/view.dart b/lib/pages/bangumi/view.dart index 0f243247..2e6d634d 100644 --- a/lib/pages/bangumi/view.dart +++ b/lib/pages/bangumi/view.dart @@ -141,39 +141,32 @@ class _BangumiPageState extends CommonPageState ], ), Expanded( - child: MediaQuery.removePadding( - context: context, - removeLeft: - context.orientation == Orientation.landscape, - child: TabBarView( - physics: const NeverScrollableScrollPhysics(), - children: response.map((item) { - if (item.episodes!.isNullOrEmpty) { - return const SizedBox.shrink(); - } - return ListView.builder( - physics: - const AlwaysScrollableScrollPhysics(), - scrollDirection: Axis.horizontal, - itemCount: item.episodes!.length, - itemBuilder: (context, index) { - return Container( - width: Grid.smallCardWidth / 2, - margin: EdgeInsets.only( - left: StyleString.safeSpace, - right: - index == item.episodes!.length - 1 - ? StyleString.safeSpace - : 0, - ), - child: BangumiCardVTimeline( - item: item.episodes![index], - ), - ); - }, - ); - }).toList()), - ), + child: TabBarView( + physics: const NeverScrollableScrollPhysics(), + children: response.map((item) { + if (item.episodes!.isNullOrEmpty) { + return const SizedBox.shrink(); + } + return ListView.builder( + physics: const AlwaysScrollableScrollPhysics(), + scrollDirection: Axis.horizontal, + itemCount: item.episodes!.length, + itemBuilder: (context, index) { + return Container( + width: Grid.smallCardWidth / 2, + margin: EdgeInsets.only( + left: StyleString.safeSpace, + right: index == item.episodes!.length - 1 + ? StyleString.safeSpace + : 0, + ), + child: BangumiCardVTimeline( + item: item.episodes![index], + ), + ); + }, + ); + }).toList()), ), ], ), @@ -347,15 +340,11 @@ class _BangumiPageState extends CommonPageState ? Column( children: [ _buildFollowTitle(theme), - MediaQuery.removePadding( - context: context, - removeLeft: context.orientation == Orientation.landscape, - child: SizedBox( - height: Grid.smallCardWidth / 2 / 0.75 + - MediaQuery.textScalerOf(context).scale(50), - child: Obx( - () => _buildFollowBody(controller.followState.value), - ), + SizedBox( + height: Grid.smallCardWidth / 2 / 0.75 + + MediaQuery.textScalerOf(context).scale(50), + child: Obx( + () => _buildFollowBody(controller.followState.value), ), ), ], diff --git a/lib/pages/common/common_publish_page.dart b/lib/pages/common/common_publish_page.dart index b11f8895..f13e987a 100644 --- a/lib/pages/common/common_publish_page.dart +++ b/lib/pages/common/common_publish_page.dart @@ -227,7 +227,7 @@ abstract class CommonPublishPageState Widget? get customPanel => null; Widget buildEmojiPickerPanel() { - double height = 170; + double height = context.isTablet ? 300 : 170; final keyboardHeight = controller.keyboardHeight; if (keyboardHeight != 0) { height = max(height, keyboardHeight); diff --git a/lib/pages/contact/view.dart b/lib/pages/contact/view.dart index 1349d4b0..f8d14c4c 100644 --- a/lib/pages/contact/view.dart +++ b/lib/pages/contact/view.dart @@ -46,13 +46,13 @@ class _ContactPageState extends State actions: [ IconButton( onPressed: () async { - UserModel? userModel = await Get.dialog( - FollowSearchPage( - mid: mid, - isFromSelect: widget.isFromSelect, + UserModel? userModel = await Navigator.of(context).push( + GetPageRoute( + page: () => FollowSearchPage( + mid: mid, + isFromSelect: widget.isFromSelect, + ), ), - useSafeArea: false, - transitionDuration: const Duration(milliseconds: 120), ); if (userModel != null) { Get.back(result: userModel); diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index d843aaec..f89f152d 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -1,5 +1,3 @@ -import 'package:PiliPlus/common/widgets/draggable_sheet/draggable_scrollable_sheet_dyn.dart' - show DraggableScrollableSheet; import 'package:PiliPlus/common/widgets/scroll_physics.dart'; import 'package:PiliPlus/models/common/dynamic/dynamics_type.dart'; import 'package:PiliPlus/models/common/dynamic/up_panel_position.dart'; @@ -42,21 +40,7 @@ class _DynamicsPageState extends State ), onPressed: () { if (_dynamicsController.isLogin.value) { - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - builder: (context) => DraggableScrollableSheet( - snap: true, - expand: false, - initialChildSize: 1, - minChildSize: 0, - maxChildSize: 1, - snapSizes: const [1], - builder: (context, scrollController) => - CreateDynPanel(scrollController: scrollController), - ), - ); + CreateDynPanel.onCreateDyn(context); } }, icon: Icon( @@ -130,6 +114,7 @@ class _DynamicsPageState extends State super.build(context); ThemeData theme = Theme.of(context); return Scaffold( + backgroundColor: Colors.transparent, appBar: AppBar( leading: upPanelPosition == UpPanelPosition.rightDrawer ? _createDynamicBtn(theme, false) diff --git a/lib/pages/dynamics_create/view.dart b/lib/pages/dynamics_create/view.dart index 9603219a..f10639e6 100644 --- a/lib/pages/dynamics_create/view.dart +++ b/lib/pages/dynamics_create/view.dart @@ -3,8 +3,10 @@ import 'dart:math'; import 'package:PiliPlus/common/widgets/button/icon_button.dart'; import 'package:PiliPlus/common/widgets/button/toolbar_icon_button.dart'; import 'package:PiliPlus/common/widgets/custom_icon.dart'; +import 'package:PiliPlus/common/widgets/draggable_sheet/draggable_scrollable_sheet_dyn.dart' + as dyn_sheet; import 'package:PiliPlus/common/widgets/draggable_sheet/draggable_scrollable_sheet_topic.dart' - show DraggableScrollableSheet; + as topic_sheet; import 'package:PiliPlus/common/widgets/pair.dart'; import 'package:PiliPlus/http/dynamics.dart'; import 'package:PiliPlus/models/common/publish_panel_type.dart'; @@ -28,12 +30,33 @@ class CreateDynPanel extends CommonPublishPage { super.key, super.imageLengthLimit = 18, this.scrollController, + this.topic, }); final ScrollController? scrollController; + final Pair? topic; @override State createState() => _CreateDynPanelState(); + + static void onCreateDyn(BuildContext context, {Pair? topic}) => + showModalBottomSheet( + context: context, + useSafeArea: true, + isScrollControlled: true, + builder: (context) => dyn_sheet.DraggableScrollableSheet( + snap: true, + expand: false, + initialChildSize: 1, + minChildSize: 0, + maxChildSize: 1, + snapSizes: const [1], + builder: (context, scrollController) => CreateDynPanel( + scrollController: scrollController, + topic: topic, + ), + ), + ); } class _CreateDynPanelState extends CommonPublishPageState { @@ -41,7 +64,13 @@ class _CreateDynPanelState extends CommonPublishPageState { final Rx _publishTime = Rx(null); final Rx _replyOption = ReplyOptionType.allow.obs; final _titleEditCtr = TextEditingController(); - Rx?> topic = Rx?>(null); + final Rx?> topic = Rx?>(null); + + @override + void initState() { + super.initState(); + topic.value = widget.topic; + } @override void dispose() { @@ -598,7 +627,7 @@ class _CreateDynPanelState extends CommonPublishPageState { constraints: BoxConstraints( maxWidth: min(600, context.mediaQueryShortestSide), ), - builder: (context) => DraggableScrollableSheet( + builder: (context) => topic_sheet.DraggableScrollableSheet( expand: false, snap: true, minChildSize: 0, diff --git a/lib/pages/dynamics_topic/view.dart b/lib/pages/dynamics_topic/view.dart index deeeab71..26128a0f 100644 --- a/lib/pages/dynamics_topic/view.dart +++ b/lib/pages/dynamics_topic/view.dart @@ -1,14 +1,17 @@ import 'package:PiliPlus/common/constants.dart'; +import 'package:PiliPlus/common/widgets/custom_icon.dart'; import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart'; import 'package:PiliPlus/common/widgets/dynamic_sliver_appbar_medium.dart'; import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart'; +import 'package:PiliPlus/common/widgets/pair.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/common/image_type.dart'; import 'package:PiliPlus/models/dynamics/dyn_topic_feed/item.dart'; import 'package:PiliPlus/models/dynamics/dyn_topic_top/top_details.dart'; import 'package:PiliPlus/pages/dynamics/widgets/dynamic_panel.dart'; +import 'package:PiliPlus/pages/dynamics_create/view.dart'; import 'package:PiliPlus/pages/dynamics_tab/view.dart'; import 'package:PiliPlus/pages/dynamics_topic/controller.dart'; import 'package:PiliPlus/utils/grid.dart'; @@ -39,6 +42,24 @@ class _DynTopicPageState extends State { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); return Scaffold( + resizeToAvoidBottomInset: false, + floatingActionButton: FloatingActionButton.extended( + onPressed: () { + if (_controller.isLogin) { + CreateDynPanel.onCreateDyn( + context, + topic: Pair( + first: int.parse(_controller.topicId), + second: _controller.topicName, + ), + ); + } else { + SmartDialog.showToast('账号未登录'); + } + }, + icon: const Icon(CustomIcon.topic_tag, size: 20), + label: const Text('参与话题'), + ), body: SafeArea( top: false, bottom: false, diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 02437a7e..27147e04 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -31,49 +31,44 @@ class _HomePageState extends State Widget build(BuildContext context) { super.build(context); final theme = Theme.of(context); - return Scaffold( - appBar: AppBar(toolbarHeight: 0), - body: Column( - children: [ - if (!_homeController.useSideBar && - context.orientation == Orientation.portrait) - customAppBar(theme), - if (_homeController.tabs.length > 1) - Material( - color: theme.colorScheme.surface, - child: Container( - height: 42, - padding: const EdgeInsets.only(top: 4), - child: TabBar( - controller: _homeController.tabController, - tabs: [ - for (var i in _homeController.tabs) Tab(text: i.label) - ], - isScrollable: true, - dividerColor: Colors.transparent, - dividerHeight: 0, - enableFeedback: true, - splashBorderRadius: StyleString.mdRadius, - tabAlignment: TabAlignment.center, - onTap: (value) { - feedBack(); - if (!_homeController.tabController.indexIsChanging) { - _homeController.animateToTop(); - } - }, - ), + return Column( + children: [ + if (!_homeController.useSideBar && + context.orientation == Orientation.portrait) + customAppBar(theme), + if (_homeController.tabs.length > 1) + Material( + color: theme.colorScheme.surface, + child: Container( + height: 42, + padding: const EdgeInsets.only(top: 4), + child: TabBar( + controller: _homeController.tabController, + tabs: [for (var i in _homeController.tabs) Tab(text: i.label)], + isScrollable: true, + dividerColor: Colors.transparent, + dividerHeight: 0, + enableFeedback: true, + splashBorderRadius: StyleString.mdRadius, + tabAlignment: TabAlignment.center, + onTap: (value) { + feedBack(); + if (!_homeController.tabController.indexIsChanging) { + _homeController.animateToTop(); + } + }, ), - ) - else - const SizedBox(height: 6), - Expanded( - child: tabBarView( - controller: _homeController.tabController, - children: _homeController.tabs.map((e) => e.page).toList(), ), + ) + else + const SizedBox(height: 6), + Expanded( + child: tabBarView( + controller: _homeController.tabController, + children: _homeController.tabs.map((e) => e.page).toList(), ), - ], - ), + ), + ], ); } diff --git a/lib/pages/live/view.dart b/lib/pages/live/view.dart index 55dea2b2..aad254b7 100644 --- a/lib/pages/live/view.dart +++ b/lib/pages/live/view.dart @@ -43,9 +43,7 @@ class _LivePageState extends CommonPageState clipBehavior: Clip.hardEdge, margin: const EdgeInsets.only( left: StyleString.safeSpace, right: StyleString.safeSpace), - decoration: const BoxDecoration( - borderRadius: StyleString.mdRadius, - ), + decoration: const BoxDecoration(borderRadius: StyleString.mdRadius), child: refreshIndicator( onRefresh: controller.onRefresh, child: CustomScrollView( @@ -275,58 +273,54 @@ class _LivePageState extends CommonPageState } Widget _buildFollowBody(ThemeData theme, List followList) { - return MediaQuery.removePadding( - context: context, - removeLeft: context.orientation == Orientation.landscape, - child: SelfSizedHorizontalList( - gapSize: 5, - childBuilder: (index) { - final item = followList[index]; - return SizedBox( - width: 65, - child: GestureDetector( - onTap: () => Get.toNamed('/liveRoom?roomid=${item.roomid}'), - onLongPress: () { - Feedback.forLongPress(context); - Get.toNamed('/member?mid=${item.uid}'); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(height: 8), - Container( - margin: const EdgeInsets.all(2), - padding: const EdgeInsets.all(2), - decoration: BoxDecoration( - border: Border.all( - width: 1.5, - color: theme.colorScheme.primary, - strokeAlign: BorderSide.strokeAlignOutside, - ), - shape: BoxShape.circle, - ), - child: NetworkImgLayer( - type: ImageType.avatar, - width: 45, - height: 45, - src: item.face, + return SelfSizedHorizontalList( + gapSize: 5, + childBuilder: (index) { + final item = followList[index]; + return SizedBox( + width: 65, + child: GestureDetector( + onTap: () => Get.toNamed('/liveRoom?roomid=${item.roomid}'), + onLongPress: () { + Feedback.forLongPress(context); + Get.toNamed('/member?mid=${item.uid}'); + }, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox(height: 8), + Container( + margin: const EdgeInsets.all(2), + padding: const EdgeInsets.all(2), + decoration: BoxDecoration( + border: Border.all( + width: 1.5, + color: theme.colorScheme.primary, + strokeAlign: BorderSide.strokeAlignOutside, ), + shape: BoxShape.circle, ), - const SizedBox(height: 4), - Text( - item.uname!, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 12), - textAlign: TextAlign.center, + child: NetworkImgLayer( + type: ImageType.avatar, + width: 45, + height: 45, + src: item.face, ), - ], - ), + ), + const SizedBox(height: 4), + Text( + item.uname!, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontSize: 12), + textAlign: TextAlign.center, + ), + ], ), - ); - }, - itemCount: followList.length, - ), + ), + ); + }, + itemCount: followList.length, ); } } diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index e8dcc856..73b7dd93 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -203,26 +203,25 @@ class _MainAppState extends State ), child: Scaffold( extendBody: true, - body: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (useSideBar || !isPortrait) ...[ - _mainController.navigationBars.length > 1 - ? context.isTablet && GStorage.optTabletNav - ? Column( - children: [ - SizedBox( - height: - MediaQuery.paddingOf(context).top + 50), - userAndSearchVertical(theme), - const Spacer(flex: 2), - Expanded( - flex: 5, - child: SizedBox( - width: 130, - child: MediaQuery.removePadding( - context: context, - removeRight: true, + resizeToAvoidBottomInset: false, + appBar: AppBar(toolbarHeight: 0), + body: SafeArea( + bottom: false, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (useSideBar || !isPortrait) ...[ + _mainController.navigationBars.length > 1 + ? context.isTablet && GStorage.optTabletNav + ? Column( + children: [ + const SizedBox(height: 25), + userAndSearchVertical(theme), + const Spacer(flex: 2), + Expanded( + flex: 5, + child: SizedBox( + width: 130, child: Obx( () => NavigationDrawer( backgroundColor: Colors.transparent, @@ -253,49 +252,40 @@ class _MainAppState extends State ), ), ), + ], + ) + : Obx( + () => NavigationRail( + groupAlignment: 0.5, + selectedIndex: + _mainController.selectedIndex.value, + onDestinationSelected: setIndex, + labelType: NavigationRailLabelType.selected, + leading: userAndSearchVertical(theme), + destinations: _mainController.navigationBars + .map((e) => NavigationRailDestination( + label: Text(e.label), + icon: _buildIcon(type: e), + selectedIcon: _buildIcon( + type: e, + selected: true, + ), + )) + .toList(), ), - ], - ) - : Obx( - () => NavigationRail( - groupAlignment: 0.5, - selectedIndex: - _mainController.selectedIndex.value, - onDestinationSelected: setIndex, - labelType: NavigationRailLabelType.selected, - leading: userAndSearchVertical(theme), - destinations: _mainController.navigationBars - .map((e) => NavigationRailDestination( - label: Text(e.label), - icon: _buildIcon(type: e), - selectedIcon: _buildIcon( - type: e, - selected: true, - ), - )) - .toList(), - ), - ) - : SafeArea( - right: false, - child: Container( + ) + : Container( padding: const EdgeInsets.only(top: 10), width: 80, child: userAndSearchVertical(theme), ), - ), - VerticalDivider( - width: 1, - indent: MediaQuery.of(context).padding.top, - endIndent: MediaQuery.of(context).padding.bottom, - color: theme.colorScheme.outline.withValues(alpha: 0.06), - ), - ], - Expanded( - child: SafeArea( - top: false, - bottom: false, - left: isPortrait, + VerticalDivider( + width: 1, + endIndent: MediaQuery.paddingOf(context).bottom, + color: theme.colorScheme.outline.withValues(alpha: 0.06), + ), + ], + Expanded( child: _mainController.mainTabBarView ? CustomTabBarView( scrollDirection: @@ -314,8 +304,8 @@ class _MainAppState extends State .toList(), ), ), - ), - ], + ], + ), ), bottomNavigationBar: useSideBar || !isPortrait ? null diff --git a/lib/pages/media/view.dart b/lib/pages/media/view.dart index a8c1cfd4..3c25b0d8 100644 --- a/lib/pages/media/view.dart +++ b/lib/pages/media/view.dart @@ -42,15 +42,11 @@ class _MediaPageState extends CommonPageState super.build(context); final theme = Theme.of(context); Color primary = theme.colorScheme.primary; - return MediaQuery.removePadding( - context: context, - removeLeft: context.orientation == Orientation.landscape, - child: Scaffold( - backgroundColor: Colors.transparent, - appBar: AppBar( - toolbarHeight: 30, - ), - body: ListView( + return Padding( + padding: const EdgeInsets.only(top: 30), + child: Material( + color: Colors.transparent, + child: ListView( controller: controller.scrollController, physics: const AlwaysScrollableScrollPhysics(), children: [ diff --git a/lib/pages/share/view.dart b/lib/pages/share/view.dart index 9751dc84..bd197371 100644 --- a/lib/pages/share/view.dart +++ b/lib/pages/share/view.dart @@ -173,10 +173,8 @@ class _SharePanelState extends State { GestureDetector( onTap: () async { _focusNode.unfocus(); - UserModel? userModel = await Get.dialog( - const ContactPage(), - useSafeArea: false, - transitionDuration: const Duration(milliseconds: 120), + UserModel? userModel = await Navigator.of(context).push( + GetPageRoute(page: () => const ContactPage()), ); if (userModel != null) { _userList diff --git a/lib/pages/sponsor_block/view.dart b/lib/pages/sponsor_block/view.dart index 115d70d8..a918ce31 100644 --- a/lib/pages/sponsor_block/view.dart +++ b/lib/pages/sponsor_block/view.dart @@ -443,7 +443,7 @@ class _SponsorBlockPageState extends State { divider, SliverToBoxAdapter(child: _blockToastItem(titleStyle)), divider, - SliverToBoxAdapter(child: _blockTrackItem(titleStyle, titleStyle)), + SliverToBoxAdapter(child: _blockTrackItem(titleStyle, subTitleStyle)), dividerL, SliverList.separated( itemCount: _blockSettings.length, diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 9eeedc27..63100a46 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -48,11 +48,9 @@ class PageUtils { avatar: item.talkerIcon, )) .toList()); - } else { - UserModel? userModel = await Get.dialog( - const ContactPage(), - useSafeArea: false, - transitionDuration: const Duration(milliseconds: 120), + } else if (context.mounted) { + UserModel? userModel = await Navigator.of(context).push( + GetPageRoute(page: () => const ContactPage()), ); if (userModel != null) { selectedIndex = 0;