mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
tweaks (#1806)
* opt: nonnull case * fix: ImageGrid * opt: distanceSquared
This commit is contained in:
committed by
GitHub
parent
4eae7e698f
commit
923af32c96
@@ -79,7 +79,7 @@ class ImmediateTapGestureRecognizer extends OneSequenceGestureRecognizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handlePointerMove(PointerMoveEvent event) {
|
void _handlePointerMove(PointerMoveEvent event) {
|
||||||
if ((event.position - _initialPosition!).distance > 2.0) {
|
if ((event.position - _initialPosition!).distanceSquared > 4.0) {
|
||||||
resolve(GestureDisposition.rejected);
|
resolve(GestureDisposition.rejected);
|
||||||
stopTrackingPointer(event.pointer);
|
stopTrackingPointer(event.pointer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ class CustomGridView extends StatelessWidget {
|
|||||||
height: imageHeight * row + space * (row - 1),
|
height: imageHeight * row + space * (row - 1),
|
||||||
child: ImageGrid(
|
child: ImageGrid(
|
||||||
space: space,
|
space: space,
|
||||||
itemCount: length,
|
|
||||||
column: column,
|
column: column,
|
||||||
width: imageWidth,
|
width: imageWidth,
|
||||||
height: imageHeight,
|
height: imageHeight,
|
||||||
@@ -318,14 +317,12 @@ class ImageGrid extends MultiChildRenderObjectWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
super.children,
|
super.children,
|
||||||
required this.space,
|
required this.space,
|
||||||
required this.itemCount,
|
|
||||||
required this.column,
|
required this.column,
|
||||||
required this.width,
|
required this.width,
|
||||||
required this.height,
|
required this.height,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double space;
|
final double space;
|
||||||
final int itemCount;
|
|
||||||
final int column;
|
final int column;
|
||||||
final double width;
|
final double width;
|
||||||
final double height;
|
final double height;
|
||||||
@@ -334,7 +331,6 @@ class ImageGrid extends MultiChildRenderObjectWidget {
|
|||||||
RenderObject createRenderObject(BuildContext context) {
|
RenderObject createRenderObject(BuildContext context) {
|
||||||
return RenderImageGrid(
|
return RenderImageGrid(
|
||||||
space: space,
|
space: space,
|
||||||
itemCount: itemCount,
|
|
||||||
column: column,
|
column: column,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@@ -345,7 +341,6 @@ class ImageGrid extends MultiChildRenderObjectWidget {
|
|||||||
void updateRenderObject(BuildContext context, RenderImageGrid renderObject) {
|
void updateRenderObject(BuildContext context, RenderImageGrid renderObject) {
|
||||||
renderObject
|
renderObject
|
||||||
..space = space
|
..space = space
|
||||||
..itemCount = itemCount
|
|
||||||
..column = column
|
..column = column
|
||||||
..width = width
|
..width = width
|
||||||
..height = height;
|
..height = height;
|
||||||
@@ -358,12 +353,10 @@ class RenderImageGrid extends RenderBox
|
|||||||
RenderBoxContainerDefaultsMixin<RenderBox, MultiChildLayoutParentData> {
|
RenderBoxContainerDefaultsMixin<RenderBox, MultiChildLayoutParentData> {
|
||||||
RenderImageGrid({
|
RenderImageGrid({
|
||||||
required double space,
|
required double space,
|
||||||
required int itemCount,
|
|
||||||
required int column,
|
required int column,
|
||||||
required double width,
|
required double width,
|
||||||
required double height,
|
required double height,
|
||||||
}) : _space = space,
|
}) : _space = space,
|
||||||
_itemCount = itemCount,
|
|
||||||
_column = column,
|
_column = column,
|
||||||
_width = width,
|
_width = width,
|
||||||
_height = height;
|
_height = height;
|
||||||
@@ -373,23 +366,15 @@ class RenderImageGrid extends RenderBox
|
|||||||
set space(double value) {
|
set space(double value) {
|
||||||
if (_space == value) return;
|
if (_space == value) return;
|
||||||
_space = value;
|
_space = value;
|
||||||
markNeedsPaint();
|
markNeedsLayout();
|
||||||
}
|
|
||||||
|
|
||||||
int _itemCount;
|
|
||||||
int get itemCount => _itemCount;
|
|
||||||
set itemCount(int value) {
|
|
||||||
if (_itemCount == value) return;
|
|
||||||
_itemCount = value;
|
|
||||||
markNeedsPaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _column;
|
int _column;
|
||||||
int get column => _column;
|
int get column => _column;
|
||||||
set column(int value) {
|
set column(int value) {
|
||||||
if (_space == value) return;
|
if (_column == value) return;
|
||||||
_column = value;
|
_column = value;
|
||||||
markNeedsPaint();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
double _width;
|
double _width;
|
||||||
@@ -397,7 +382,7 @@ class RenderImageGrid extends RenderBox
|
|||||||
set width(double value) {
|
set width(double value) {
|
||||||
if (_width == value) return;
|
if (_width == value) return;
|
||||||
_width = value;
|
_width = value;
|
||||||
markNeedsPaint();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
double _height;
|
double _height;
|
||||||
@@ -405,7 +390,7 @@ class RenderImageGrid extends RenderBox
|
|||||||
set height(double value) {
|
set height(double value) {
|
||||||
if (_height == value) return;
|
if (_height == value) return;
|
||||||
_height = value;
|
_height = value;
|
||||||
markNeedsPaint();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -67,124 +67,121 @@ class _MatchInfoPageState extends CommonDynPageState<MatchInfoPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInfo(ThemeData theme, LoadingState<MatchContest?> infoState) {
|
Widget _buildInfo(ThemeData theme, LoadingState<MatchContest?> infoState) {
|
||||||
if (infoState case Success(:final response)) {
|
if (infoState case Success(:final response?)) {
|
||||||
if (response != null) {
|
try {
|
||||||
try {
|
Widget teamInfo(MatchTeam team) {
|
||||||
Widget teamInfo(MatchTeam team) {
|
return Column(
|
||||||
return Column(
|
spacing: 5,
|
||||||
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,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
Center(
|
||||||
width: 50,
|
child: Text(
|
||||||
height: 50,
|
'${response.season?.title ?? ''} ${response.gameStage ?? ''}',
|
||||||
src: 'https://i1.hdslb.com${team.logo}',
|
),
|
||||||
type: ImageType.emote,
|
|
||||||
),
|
),
|
||||||
Text(team.title!),
|
Row(
|
||||||
],
|
spacing: 20,
|
||||||
);
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
}
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
return SliverToBoxAdapter(
|
if (response.homeId != 0)
|
||||||
child: Padding(
|
Expanded(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
child: Align(
|
||||||
child: Column(
|
alignment: const Alignment(0.8, 1),
|
||||||
spacing: 12,
|
child: teamInfo(response.homeTeam!),
|
||||||
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!),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
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)
|
Column(
|
||||||
Expanded(
|
spacing: 10,
|
||||||
child: Align(
|
mainAxisSize: MainAxisSize.min,
|
||||||
alignment: const Alignment(-0.8, -1),
|
children: [
|
||||||
child: teamInfo(response.awayTeam!),
|
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();
|
return const SliverToBoxAdapter();
|
||||||
|
|||||||
@@ -29,18 +29,16 @@ class SpaceSettingController
|
|||||||
|
|
||||||
Future<void> onMod() async {
|
Future<void> onMod() async {
|
||||||
if (hasMod ?? false) {
|
if (hasMod ?? false) {
|
||||||
if (loadingState.value case Success(:final response)) {
|
if (loadingState.value case Success(:final response?)) {
|
||||||
if (response != null) {
|
final res = await UserHttp.spaceSettingMod(
|
||||||
final res = await UserHttp.spaceSettingMod(
|
{
|
||||||
{
|
for (final e in response.list1) e.key: e.value,
|
||||||
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.list2) e.key: e.value,
|
for (final e in response.list3) e.key: e.value,
|
||||||
for (final e in response.list3) e.key: e.value,
|
},
|
||||||
},
|
);
|
||||||
);
|
if (!res.isSuccess) {
|
||||||
if (!res.isSuccess) {
|
res.toast();
|
||||||
res.toast();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
: null,
|
: null,
|
||||||
onTapUp: _onTapUp,
|
onTapUp: _onTapUp,
|
||||||
onTapCancel: _removeDmAction,
|
onTapCancel: _removeDmAction,
|
||||||
allowedButtonsFilter: (buttons) => buttons == kPrimaryButton,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
_danmakuListener = plPlayerController.enableShowDanmaku.listen((value) {
|
_danmakuListener = plPlayerController.enableShowDanmaku.listen((value) {
|
||||||
@@ -251,10 +250,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
_tapGestureRecognizer.onTapDown = value ? _onTapDown : null;
|
_tapGestureRecognizer.onTapDown = value ? _onTapDown : null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_tapGestureRecognizer = ImmediateTapGestureRecognizer(
|
_tapGestureRecognizer = ImmediateTapGestureRecognizer(onTapUp: _onTapUp);
|
||||||
onTapUp: _onTapUp,
|
|
||||||
allowedButtonsFilter: (buttons) => buttons == kPrimaryButton,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_doubleTapGestureRecognizer = DoubleTapGestureRecognizer()
|
_doubleTapGestureRecognizer = DoubleTapGestureRecognizer()
|
||||||
@@ -956,7 +952,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
}
|
}
|
||||||
Offset cumulativeDelta =
|
Offset cumulativeDelta =
|
||||||
details.localFocalPoint - plPlayerController.initialFocalPoint;
|
details.localFocalPoint - plPlayerController.initialFocalPoint;
|
||||||
if (details.pointerCount > 1 && cumulativeDelta.distance < 1.5) {
|
if (details.pointerCount > 1 && cumulativeDelta.distanceSquared < 2.25) {
|
||||||
interacting = true;
|
interacting = true;
|
||||||
_gestureType = null;
|
_gestureType = null;
|
||||||
return;
|
return;
|
||||||
@@ -966,7 +962,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
if (plPlayerController.controlsLock.value) return;
|
if (plPlayerController.controlsLock.value) return;
|
||||||
|
|
||||||
if (_gestureType == null) {
|
if (_gestureType == null) {
|
||||||
if (cumulativeDelta.distance < 1) return;
|
if (cumulativeDelta.distanceSquared < 1) return;
|
||||||
final dx = cumulativeDelta.dx.abs();
|
final dx = cumulativeDelta.dx.abs();
|
||||||
final dy = cumulativeDelta.dy.abs();
|
final dy = cumulativeDelta.dy.abs();
|
||||||
if (dx > 3 * dy) {
|
if (dx > 3 * dy) {
|
||||||
@@ -1292,7 +1288,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
if (plPlayerController.controlsLock.value) return;
|
if (plPlayerController.controlsLock.value) return;
|
||||||
if (_gestureType == null) {
|
if (_gestureType == null) {
|
||||||
final pan = event.pan;
|
final pan = event.pan;
|
||||||
if (pan.distance < 1) return;
|
if (pan.distanceSquared < 1) return;
|
||||||
final dx = pan.dx.abs();
|
final dx = pan.dx.abs();
|
||||||
final dy = pan.dy.abs();
|
final dy = pan.dy.abs();
|
||||||
if (dx > 3 * dy) {
|
if (dx > 3 * dy) {
|
||||||
|
|||||||
@@ -281,24 +281,22 @@ abstract final class RequestUtils {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
static Future<void> insertCreatedDyn(dynamic id) async {
|
static Future<void> insertCreatedDyn(dynamic id) async {
|
||||||
try {
|
if (id != null) {
|
||||||
if (id != null) {
|
try {
|
||||||
await Future.delayed(const Duration(milliseconds: 450));
|
await Future.delayed(const Duration(milliseconds: 450));
|
||||||
final res = await DynamicsHttp.dynamicDetail(id: id);
|
final res = await DynamicsHttp.dynamicDetail(id: id);
|
||||||
if (res case final Success<DynamicItemModel> e) {
|
if (res case final Success<DynamicItemModel> e) {
|
||||||
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
||||||
if (ctr.loadingState.value case Success(:final response)) {
|
if (ctr.loadingState.value case Success(:final response?)) {
|
||||||
if (response != null) {
|
response.insert(0, e.response);
|
||||||
response.insert(0, e.response);
|
ctr.loadingState.refresh();
|
||||||
ctr.loadingState.refresh();
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctr.loadingState.value = Success([e.response]);
|
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,
|
validate: captchaData.validate,
|
||||||
);
|
);
|
||||||
if (res case Success(:final response)) {
|
if (res case Success(:final response)) {
|
||||||
if (response?['is_valid'] == 1) {
|
if (response != null && response['is_valid'] == 1) {
|
||||||
final griskId = response?['grisk_id'];
|
final griskId = response['grisk_id'];
|
||||||
if (griskId != null) {
|
if (griskId is String) {
|
||||||
onSuccess(griskId);
|
onSuccess(griskId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user