opt dyn desktop ctr

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-28 11:24:41 +08:00
parent 37c7d1f3cd
commit aac4524e81

View File

@@ -24,6 +24,7 @@ import 'package:PiliPlus/pages/dynamics_repost/view.dart';
import 'package:PiliPlus/utils/extension/get_ext.dart'; import 'package:PiliPlus/utils/extension/get_ext.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/num_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart'; import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/share_utils.dart'; import 'package:PiliPlus/utils/share_utils.dart';
import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/foundation.dart' show kDebugMode;
@@ -31,6 +32,12 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
const Set<TargetPlatform> _kDesktopPlatforms = <TargetPlatform>{
TargetPlatform.macOS,
TargetPlatform.windows,
TargetPlatform.linux,
};
class DynamicDetailPage extends StatefulWidget { class DynamicDetailPage extends StatefulWidget {
const DynamicDetailPage({super.key}); const DynamicDetailPage({super.key});
@@ -306,12 +313,14 @@ class _DynamicDetailPageState
if (postion.pixels >= postion.maxScrollExtent) { if (postion.pixels >= postion.maxScrollExtent) {
postion.jumpTo(postion.pixels); postion.jumpTo(postion.pixels);
} }
} switch (value) {
switch (value) { case 0:
case 0: _onRefresh(controller.onRefresh());
_onRefresh(controller.onRefresh()); case 1:
case 1: _onRefresh(_reactController.onRefresh());
_onRefresh(_reactController.onRefresh()); }
} else if (positions.length > 1) {
positions.elementAt(1).jumpTo(0);
} }
} }
}, },
@@ -346,56 +355,57 @@ class _DynamicDetailPageState
Obx(() => replyList(controller.loadingState.value)), Obx(() => replyList(controller.loadingState.value)),
], ],
); );
return Stack( final child = tabBarView(
clipBehavior: .none, controller: tabController,
children: [ children: [
tabBarView( isPortrait
controller: tabController, ? reply
children: [ : refreshIndicator(onRefresh: controller.onRefresh, child: reply),
isPortrait DynReactPage(
? reply isPortrait: isPortrait,
: refreshIndicator( id: controller.dynItem.idStr,
onRefresh: controller.onRefresh, controller: _reactController,
child: reply,
),
DynReactPage(
isPortrait: isPortrait,
id: controller.dynItem.idStr,
controller: _reactController,
),
],
), ),
Positioned( ],
left: 0, );
right: 0, if (isPortrait) {
top: displacement, return Stack(
child: Obx(() { clipBehavior: .none,
final isRefreshing = _isRefreshing.value; children: [
return AnimatedScale( child,
scale: isRefreshing ? 1 : 0, Positioned(
duration: const Duration(milliseconds: 200), left: 0,
child: Center( right: 0,
child: SizedBox.fromSize( top: displacement,
size: const .square(40), child: Obx(() {
child: Material( final isRefreshing = _isRefreshing.value;
type: .circle, return AnimatedScale(
color: theme.colorScheme.onSecondary, scale: isRefreshing ? 1 : 0,
elevation: 2.0, duration: const Duration(milliseconds: 200),
child: Padding( child: Center(
padding: const .all(6), child: SizedBox.fromSize(
child: CircularProgressIndicator( size: const .square(40),
strokeWidth: 2.5, child: Material(
controller: _refreshController, type: .circle,
color: theme.colorScheme.onSecondary,
elevation: 2.0,
child: Padding(
padding: const .all(6),
child: CircularProgressIndicator(
strokeWidth: 2.5,
controller: _refreshController,
),
), ),
), ),
), ),
), ),
), );
); }),
}), ),
), ],
], );
); }
return child;
} }
Widget _buildPortrait(double padding) { Widget _buildPortrait(double padding) {
@@ -432,7 +442,7 @@ class _DynamicDetailPageState
padding = padding / 4; padding = padding / 4;
final flex = controller.ratio[0].toInt(); final flex = controller.ratio[0].toInt();
final flex1 = controller.ratio[1].toInt(); final flex1 = controller.ratio[1].toInt();
return Row( final child = Row(
children: [ children: [
Expanded( Expanded(
flex: flex, flex: flex,
@@ -477,6 +487,14 @@ class _DynamicDetailPageState
), ),
], ],
); );
if (PlatformUtils.isDesktop) {
return PrimaryScrollController(
controller: PrimaryScrollController.of(context),
automaticallyInheritForPlatforms: _kDesktopPlatforms,
child: child,
);
}
return child;
} }
Widget _buildBody() { Widget _buildBody() {