mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-24 10:08:41 +00:00
94
lib/common/widgets/extra_hittest_stack.dart
Normal file
94
lib/common/widgets/extra_hittest_stack.dart
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart'
|
||||||
|
show RenderStack, BoxHitTestResult, BoxHitTestEntry;
|
||||||
|
|
||||||
|
class ExtraHitTestStack extends Stack {
|
||||||
|
const ExtraHitTestStack({
|
||||||
|
super.key,
|
||||||
|
super.alignment,
|
||||||
|
super.textDirection,
|
||||||
|
super.fit,
|
||||||
|
super.clipBehavior,
|
||||||
|
super.children,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
RenderExtraHitTestStack createRenderObject(BuildContext context) {
|
||||||
|
return RenderExtraHitTestStack(
|
||||||
|
alignment: alignment,
|
||||||
|
textDirection: textDirection ?? Directionality.maybeOf(context),
|
||||||
|
fit: fit,
|
||||||
|
clipBehavior: clipBehavior,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void updateRenderObject(
|
||||||
|
BuildContext context,
|
||||||
|
RenderExtraHitTestStack renderObject,
|
||||||
|
) {
|
||||||
|
renderObject
|
||||||
|
..alignment = alignment
|
||||||
|
..textDirection = textDirection ?? Directionality.maybeOf(context)
|
||||||
|
..fit = fit
|
||||||
|
..clipBehavior = clipBehavior;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RenderExtraHitTestStack extends RenderStack {
|
||||||
|
RenderExtraHitTestStack({
|
||||||
|
super.children,
|
||||||
|
super.alignment,
|
||||||
|
super.textDirection,
|
||||||
|
super.fit,
|
||||||
|
super.clipBehavior,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hitTest(BoxHitTestResult result, {required Offset position}) {
|
||||||
|
assert(() {
|
||||||
|
if (!hasSize) {
|
||||||
|
if (debugNeedsLayout) {
|
||||||
|
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||||
|
ErrorSummary(
|
||||||
|
'Cannot hit test a render box that has never been laid out.',
|
||||||
|
),
|
||||||
|
describeForError(
|
||||||
|
'The hitTest() method was called on this RenderBox',
|
||||||
|
),
|
||||||
|
ErrorDescription(
|
||||||
|
"Unfortunately, this object's geometry is not known at this time, "
|
||||||
|
'probably because it has never been laid out. '
|
||||||
|
'This means it cannot be accurately hit-tested.',
|
||||||
|
),
|
||||||
|
ErrorHint(
|
||||||
|
'If you are trying '
|
||||||
|
'to perform a hit test during the layout phase itself, make sure '
|
||||||
|
"you only hit test nodes that have completed layout (e.g. the node's "
|
||||||
|
'children, after their layout() method has been called).',
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||||
|
ErrorSummary('Cannot hit test a render box with no size.'),
|
||||||
|
describeForError('The hitTest() method was called on this RenderBox'),
|
||||||
|
ErrorDescription(
|
||||||
|
'Although this node is not marked as needing layout, '
|
||||||
|
'its size is not set.',
|
||||||
|
),
|
||||||
|
ErrorHint(
|
||||||
|
'A RenderBox object must have an '
|
||||||
|
'explicit size before it can be hit-tested. Make sure '
|
||||||
|
'that the RenderBox in question sets its size during layout.',
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
|
if (hitTestChildren(result, position: position) || hitTestSelf(position)) {
|
||||||
|
result.add(BoxHitTestEntry(this, position));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/common/assets.dart';
|
import 'package:PiliPlus/common/assets.dart';
|
||||||
import 'package:PiliPlus/common/style.dart';
|
import 'package:PiliPlus/common/style.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/extra_hittest_stack.dart';
|
||||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/models/common/avatar_badge_type.dart';
|
import 'package:PiliPlus/models/common/avatar_badge_type.dart';
|
||||||
import 'package:PiliPlus/models/common/image_type.dart';
|
import 'package:PiliPlus/models/common/image_type.dart';
|
||||||
@@ -82,7 +83,7 @@ class PendantAvatar extends StatelessWidget {
|
|||||||
child: avatar,
|
child: avatar,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Widget child = Stack(
|
Widget child = ExtraHitTestStack(
|
||||||
clipBehavior: .none,
|
clipBehavior: .none,
|
||||||
alignment: .center,
|
alignment: .center,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import 'package:PiliPlus/utils/extension/num_ext.dart';
|
|||||||
import 'package:PiliPlus/utils/num_utils.dart';
|
import 'package:PiliPlus/utils/num_utils.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get_core/src/get_main.dart';
|
||||||
|
import 'package:get/get_navigation/src/extension_navigation.dart';
|
||||||
|
|
||||||
class SearchUserItem extends StatelessWidget {
|
class SearchUserItem extends StatelessWidget {
|
||||||
const SearchUserItem({
|
const SearchUserItem({
|
||||||
|
|||||||
Reference in New Issue
Block a user