diff --git a/lib/common/widgets/gesture/immediate_tap_gesture_recognizer.dart b/lib/common/widgets/gesture/immediate_tap_gesture_recognizer.dart index ffc9a2b16..1ddf8f128 100644 --- a/lib/common/widgets/gesture/immediate_tap_gesture_recognizer.dart +++ b/lib/common/widgets/gesture/immediate_tap_gesture_recognizer.dart @@ -79,7 +79,7 @@ class ImmediateTapGestureRecognizer extends OneSequenceGestureRecognizer { } void _handlePointerMove(PointerMoveEvent event) { - if ((event.position - _initialPosition!).distance > 2.0) { + if ((event.position - _initialPosition!).distanceSquared > 4.0) { resolve(GestureDisposition.rejected); stopTrackingPointer(event.pointer); } diff --git a/lib/common/widgets/image/custom_grid_view.dart b/lib/common/widgets/image/custom_grid_view.dart index 0b0f7cde1..046f51d1a 100644 --- a/lib/common/widgets/image/custom_grid_view.dart +++ b/lib/common/widgets/image/custom_grid_view.dart @@ -251,7 +251,6 @@ class CustomGridView extends StatelessWidget { height: imageHeight * row + space * (row - 1), child: ImageGrid( space: space, - itemCount: length, column: column, width: imageWidth, height: imageHeight, @@ -318,14 +317,12 @@ class ImageGrid extends MultiChildRenderObjectWidget { super.key, super.children, required this.space, - required this.itemCount, required this.column, required this.width, required this.height, }); final double space; - final int itemCount; final int column; final double width; final double height; @@ -334,7 +331,6 @@ class ImageGrid extends MultiChildRenderObjectWidget { RenderObject createRenderObject(BuildContext context) { return RenderImageGrid( space: space, - itemCount: itemCount, column: column, width: width, height: height, @@ -345,7 +341,6 @@ class ImageGrid extends MultiChildRenderObjectWidget { void updateRenderObject(BuildContext context, RenderImageGrid renderObject) { renderObject ..space = space - ..itemCount = itemCount ..column = column ..width = width ..height = height; @@ -358,12 +353,10 @@ class RenderImageGrid extends RenderBox RenderBoxContainerDefaultsMixin { RenderImageGrid({ required double space, - required int itemCount, required int column, required double width, required double height, }) : _space = space, - _itemCount = itemCount, _column = column, _width = width, _height = height; @@ -373,23 +366,15 @@ class RenderImageGrid extends RenderBox set space(double value) { if (_space == value) return; _space = value; - markNeedsPaint(); - } - - int _itemCount; - int get itemCount => _itemCount; - set itemCount(int value) { - if (_itemCount == value) return; - _itemCount = value; - markNeedsPaint(); + markNeedsLayout(); } int _column; int get column => _column; set column(int value) { - if (_space == value) return; + if (_column == value) return; _column = value; - markNeedsPaint(); + markNeedsLayout(); } double _width; @@ -397,7 +382,7 @@ class RenderImageGrid extends RenderBox set width(double value) { if (_width == value) return; _width = value; - markNeedsPaint(); + markNeedsLayout(); } double _height; @@ -405,7 +390,7 @@ class RenderImageGrid extends RenderBox set height(double value) { if (_height == value) return; _height = value; - markNeedsPaint(); + markNeedsLayout(); } @override diff --git a/lib/pages/match_info/view.dart b/lib/pages/match_info/view.dart index c88f70d00..cea72e373 100644 --- a/lib/pages/match_info/view.dart +++ b/lib/pages/match_info/view.dart @@ -67,124 +67,121 @@ class _MatchInfoPageState extends CommonDynPageState { } Widget _buildInfo(ThemeData theme, LoadingState infoState) { - if (infoState case Success(:final response)) { - if (response != null) { - try { - Widget teamInfo(MatchTeam team) { - return Column( - spacing: 5, + if (infoState case Success(:final response?)) { + try { + Widget teamInfo(MatchTeam team) { + return Column( + spacing: 5, + mainAxisSize: MainAxisSize.min, + children: [ + NetworkImgLayer( + width: 50, + height: 50, + src: 'https://i1.hdslb.com${team.logo}', + type: ImageType.emote, + ), + Text(team.title!), + ], + ); + } + + return SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Column( + spacing: 12, mainAxisSize: MainAxisSize.min, children: [ - NetworkImgLayer( - width: 50, - height: 50, - src: 'https://i1.hdslb.com${team.logo}', - type: ImageType.emote, + Center( + child: Text( + '${response.season?.title ?? ''} ${response.gameStage ?? ''}', + ), ), - Text(team.title!), - ], - ); - } - - return SliverToBoxAdapter( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Column( - spacing: 12, - mainAxisSize: MainAxisSize.min, - children: [ - Center( - child: Text( - '${response.season?.title ?? ''} ${response.gameStage ?? ''}', - ), - ), - Row( - spacing: 20, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (response.homeId != 0) - Expanded( - child: Align( - alignment: const Alignment(0.8, 1), - child: teamInfo(response.homeTeam!), - ), + Row( + spacing: 20, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (response.homeId != 0) + Expanded( + child: Align( + alignment: const Alignment(0.8, 1), + child: teamInfo(response.homeTeam!), ), - Column( - spacing: 10, - mainAxisSize: MainAxisSize.min, - children: [ - if (response.homeId != 0) - Text( - response.contestStatus == 1 - ? 'VS' - : '${response.homeScore} : ${response.awayScore}', - style: const TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ) - else if (response.season?.logo != null) - NetworkImgLayer( - width: 50, - height: 50, - src: - 'https://i1.hdslb.com${response.season!.logo}', - type: ImageType.emote, - ), - if (response.contestStatus == 2) - FilledButton.tonal( - style: FilledButton.styleFrom( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(6), - ), - ), - visualDensity: VisualDensity.compact, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - ), - onPressed: () => - PageUtils.toLiveRoom(response.liveRoom), - child: const Text('看直播'), - ) - else if (response.contestStatus == 3) - Text( - '${DateFormatUtils.dateFormat(response.stime)}${response.contestStatus == 3 ? ' 已结束' : ''}', - style: TextStyle( - color: theme.colorScheme.outline, - ), - ) - else if (response.contestStatus == 1) - Text( - DateFormatUtils.format( - response.stime, - format: DateFormat('yy-MM-dd HH:mm'), - ), - style: TextStyle( - color: theme.colorScheme.outline, - ), - ), - ], ), - if (response.awayId != 0) - Expanded( - child: Align( - alignment: const Alignment(-0.8, -1), - child: teamInfo(response.awayTeam!), + Column( + spacing: 10, + mainAxisSize: MainAxisSize.min, + children: [ + if (response.homeId != 0) + Text( + response.contestStatus == 1 + ? 'VS' + : '${response.homeScore} : ${response.awayScore}', + style: const TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ) + else if (response.season?.logo != null) + NetworkImgLayer( + width: 50, + height: 50, + src: 'https://i1.hdslb.com${response.season!.logo}', + type: ImageType.emote, ), + if (response.contestStatus == 2) + FilledButton.tonal( + style: FilledButton.styleFrom( + padding: const EdgeInsets.symmetric( + horizontal: 12, + ), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(6), + ), + ), + visualDensity: VisualDensity.compact, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + onPressed: () => + PageUtils.toLiveRoom(response.liveRoom), + child: const Text('看直播'), + ) + else if (response.contestStatus == 3) + Text( + '${DateFormatUtils.dateFormat(response.stime)}${response.contestStatus == 3 ? ' 已结束' : ''}', + style: TextStyle( + color: theme.colorScheme.outline, + ), + ) + else if (response.contestStatus == 1) + Text( + DateFormatUtils.format( + response.stime, + format: DateFormat('yy-MM-dd HH:mm'), + ), + style: TextStyle( + color: theme.colorScheme.outline, + ), + ), + ], + ), + if (response.awayId != 0) + Expanded( + child: Align( + alignment: const Alignment(-0.8, -1), + child: teamInfo(response.awayTeam!), ), - ], - ), - ], - ), + ), + ], + ), + ], ), - ); - } catch (_) { - return const SliverToBoxAdapter(); - } + ), + ); + } catch (_) { + return const SliverToBoxAdapter(); } } return const SliverToBoxAdapter(); diff --git a/lib/pages/space_setting/controller.dart b/lib/pages/space_setting/controller.dart index 08905c7fd..83e683861 100644 --- a/lib/pages/space_setting/controller.dart +++ b/lib/pages/space_setting/controller.dart @@ -29,18 +29,16 @@ class SpaceSettingController Future onMod() async { if (hasMod ?? false) { - if (loadingState.value case Success(:final response)) { - if (response != null) { - final res = await UserHttp.spaceSettingMod( - { - for (final e in response.list1) e.key: e.value, - for (final e in response.list2) e.key: e.value, - for (final e in response.list3) e.key: e.value, - }, - ); - if (!res.isSuccess) { - res.toast(); - } + if (loadingState.value case Success(:final response?)) { + final res = await UserHttp.spaceSettingMod( + { + for (final e in response.list1) e.key: e.value, + for (final e in response.list2) e.key: e.value, + for (final e in response.list3) e.key: e.value, + }, + ); + if (!res.isSuccess) { + res.toast(); } } } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 9c8b2407d..5b15c64e3 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -243,7 +243,6 @@ class _PLVideoPlayerState extends State : null, onTapUp: _onTapUp, onTapCancel: _removeDmAction, - allowedButtonsFilter: (buttons) => buttons == kPrimaryButton, ); _danmakuListener = plPlayerController.enableShowDanmaku.listen((value) { @@ -251,10 +250,7 @@ class _PLVideoPlayerState extends State _tapGestureRecognizer.onTapDown = value ? _onTapDown : null; }); } else { - _tapGestureRecognizer = ImmediateTapGestureRecognizer( - onTapUp: _onTapUp, - allowedButtonsFilter: (buttons) => buttons == kPrimaryButton, - ); + _tapGestureRecognizer = ImmediateTapGestureRecognizer(onTapUp: _onTapUp); } _doubleTapGestureRecognizer = DoubleTapGestureRecognizer() @@ -956,7 +952,7 @@ class _PLVideoPlayerState extends State } Offset cumulativeDelta = details.localFocalPoint - plPlayerController.initialFocalPoint; - if (details.pointerCount > 1 && cumulativeDelta.distance < 1.5) { + if (details.pointerCount > 1 && cumulativeDelta.distanceSquared < 2.25) { interacting = true; _gestureType = null; return; @@ -966,7 +962,7 @@ class _PLVideoPlayerState extends State if (plPlayerController.controlsLock.value) return; if (_gestureType == null) { - if (cumulativeDelta.distance < 1) return; + if (cumulativeDelta.distanceSquared < 1) return; final dx = cumulativeDelta.dx.abs(); final dy = cumulativeDelta.dy.abs(); if (dx > 3 * dy) { @@ -1292,7 +1288,7 @@ class _PLVideoPlayerState extends State if (plPlayerController.controlsLock.value) return; if (_gestureType == null) { final pan = event.pan; - if (pan.distance < 1) return; + if (pan.distanceSquared < 1) return; final dx = pan.dx.abs(); final dy = pan.dy.abs(); if (dx > 3 * dy) { diff --git a/lib/utils/request_utils.dart b/lib/utils/request_utils.dart index 12b46cb4d..eb41b5a98 100644 --- a/lib/utils/request_utils.dart +++ b/lib/utils/request_utils.dart @@ -281,24 +281,22 @@ abstract final class RequestUtils { // } static Future insertCreatedDyn(dynamic id) async { - try { - if (id != null) { + if (id != null) { + try { await Future.delayed(const Duration(milliseconds: 450)); final res = await DynamicsHttp.dynamicDetail(id: id); if (res case final Success e) { final ctr = Get.find(tag: 'all'); - if (ctr.loadingState.value case Success(:final response)) { - if (response != null) { - response.insert(0, e.response); - ctr.loadingState.refresh(); - return; - } + if (ctr.loadingState.value case Success(:final response?)) { + response.insert(0, e.response); + ctr.loadingState.refresh(); + return; } ctr.loadingState.value = Success([e.response]); } + } catch (e) { + if (kDebugMode) debugPrint('create dyn $e'); } - } catch (e) { - if (kDebugMode) debugPrint('create dyn $e'); } } @@ -531,9 +529,9 @@ abstract final class RequestUtils { validate: captchaData.validate, ); if (res case Success(:final response)) { - if (response?['is_valid'] == 1) { - final griskId = response?['grisk_id']; - if (griskId != null) { + if (response != null && response['is_valid'] == 1) { + final griskId = response['grisk_id']; + if (griskId is String) { onSuccess(griskId); } } else {