* opt: nonnull case

* fix: ImageGrid

* opt: distanceSquared
This commit is contained in:
My-Responsitories
2026-01-21 13:34:44 +08:00
committed by GitHub
parent 4eae7e698f
commit 923af32c96
6 changed files with 138 additions and 164 deletions

View File

@@ -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);
}

View File

@@ -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<RenderBox, MultiChildLayoutParentData> {
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

View File

@@ -67,124 +67,121 @@ class _MatchInfoPageState extends CommonDynPageState<MatchInfoPage> {
}
Widget _buildInfo(ThemeData theme, LoadingState<MatchContest?> 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();

View File

@@ -29,18 +29,16 @@ class SpaceSettingController
Future<void> 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();
}
}
}

View File

@@ -243,7 +243,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
: null,
onTapUp: _onTapUp,
onTapCancel: _removeDmAction,
allowedButtonsFilter: (buttons) => buttons == kPrimaryButton,
);
_danmakuListener = plPlayerController.enableShowDanmaku.listen((value) {
@@ -251,10 +250,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_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<PLVideoPlayer>
}
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<PLVideoPlayer>
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<PLVideoPlayer>
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) {

View File

@@ -281,24 +281,22 @@ abstract final class RequestUtils {
// }
static Future<void> 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<DynamicItemModel> e) {
final ctr = Get.find<DynamicsTabController>(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 {