Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ChatGPT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
关振斌
ChatGPT
Commits
ded174bb
Commit
ded174bb
authored
Apr 12, 2023
by
skeyboy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本消息长按菜单
parent
c69c35c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
+35
-9
lib/package/chat_dash/src/widgets/message_row/pop_menu.dart
lib/package/chat_dash/src/widgets/message_row/pop_menu.dart
+35
-9
No files found.
lib/package/chat_dash/src/widgets/message_row/pop_menu.dart
View file @
ded174bb
...
@@ -115,6 +115,7 @@ class _CustomPopupMenuState extends State<CustomPopupMenu> {
...
@@ -115,6 +115,7 @@ class _CustomPopupMenuState extends State<CustomPopupMenu> {
),
),
child:
CustomMultiChildLayout
(
child:
CustomMultiChildLayout
(
delegate:
_MenuLayoutDelegate
(
delegate:
_MenuLayoutDelegate
(
itemSize:
_childBox
?.
size
??
Size
.
zero
,
tapedPoint:
_controller
?.
localPosition
??
Offset
.
zero
,
tapedPoint:
_controller
?.
localPosition
??
Offset
.
zero
,
anchorSize:
_childBox
!.
size
,
anchorSize:
_childBox
!.
size
,
anchorOffset:
_childBox
!.
localToGlobal
(
anchorOffset:
_childBox
!.
localToGlobal
(
...
@@ -289,9 +290,14 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
...
@@ -289,9 +290,14 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
required
this
.
anchorOffset
,
required
this
.
anchorOffset
,
required
this
.
verticalMargin
,
required
this
.
verticalMargin
,
required
this
.
tapedPoint
,
required
this
.
tapedPoint
,
required
this
.
itemSize
,
this
.
position
,
this
.
position
,
});
});
// 消息列表的的大小
final
Size
itemSize
;
/// 消息列表点击的位置
final
Offset
tapedPoint
;
final
Offset
tapedPoint
;
final
Size
anchorSize
;
final
Size
anchorSize
;
final
Offset
anchorOffset
;
final
Offset
anchorOffset
;
...
@@ -328,7 +334,8 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
...
@@ -328,7 +334,8 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
BoxConstraints
.
loose
(
size
),
BoxConstraints
.
loose
(
size
),
);
);
}
}
print
(
"文本内容大小
$size
$contentSize
$anchorOffset
点击位置
$tapedPoint
"
);
print
(
"文本内容大小
$size
$contentSize
子
$itemSize
$anchorOffset
点击位置
$tapedPoint
"
);
bool
isTop
=
false
;
bool
isTop
=
false
;
if
(
position
==
null
)
{
if
(
position
==
null
)
{
// auto calculate position
// auto calculate position
...
@@ -336,6 +343,13 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
...
@@ -336,6 +343,13 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
}
else
{
}
else
{
isTop
=
position
==
PreferredPosition
.
top
;
isTop
=
position
==
PreferredPosition
.
top
;
}
}
// 长消息上滑后底部有充分的空间才可以
if
(
itemSize
.
height
+
anchorOffset
.
dy
-
size
.
height
<
-(
contentSize
.
height
*
1.2
+
arrowOffset
.
dy
+
verticalMargin
)
&&
anchorOffset
.
dy
<
0
)
{
isTop
=
false
;
}
if
(
anchorCenterX
-
contentSize
.
width
/
2
<
0
)
{
if
(
anchorCenterX
-
contentSize
.
width
/
2
<
0
)
{
menuPosition
=
isTop
?
_MenuPosition
.
topLeft
:
_MenuPosition
.
bottomLeft
;
menuPosition
=
isTop
?
_MenuPosition
.
topLeft
:
_MenuPosition
.
bottomLeft
;
}
else
if
(
anchorCenterX
+
contentSize
.
width
/
2
>
size
.
width
)
{
}
else
if
(
anchorCenterX
+
contentSize
.
width
/
2
>
size
.
width
)
{
...
@@ -373,19 +387,31 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
...
@@ -373,19 +387,31 @@ class _MenuLayoutDelegate extends MultiChildLayoutDelegate {
);
);
break
;
break
;
case
_MenuPosition
.
topCenter
:
case
_MenuPosition
.
topCenter
:
double
contentOffsetY
=
0.0
;
double
arrowOffsetY
=
0.0
;
if
(
anchorTopY
<=
contentSize
.
height
)
{
// 使用 点击位置
contentOffsetY
=
tapedPoint
.
dy
-
contentSize
.
height
+
anchorTopY
-
verticalMargin
;
arrowOffsetY
=
tapedPoint
.
dy
+
anchorTopY
-
verticalMargin
;
}
else
{
arrowOffsetY
=
math
.
max
(
anchorTopY
-
verticalMargin
-
arrowSize
.
height
,
contentSize
.
height
*
2
);
contentOffsetY
=
math
.
max
(
anchorTopY
-
verticalMargin
-
arrowSize
.
height
-
contentSize
.
height
,
contentSize
.
height
);
}
arrowOffset
=
Offset
(
arrowOffset
=
Offset
(
anchorCenterX
-
arrowSize
.
width
/
2
,
anchorCenterX
-
arrowSize
.
width
/
2
,
math
.
max
(
anchorTopY
-
verticalMargin
-
arrowSize
.
height
,
arrowOffsetY
,
contentSize
.
height
*
2
),
);
);
contentOffset
=
Offset
(
contentOffset
=
Offset
(
anchorCenterX
-
contentSize
.
width
/
2
,
anchorCenterX
-
contentSize
.
width
/
2
,
math
.
max
(
contentOffsetY
,
anchorTopY
-
verticalMargin
-
arrowSize
.
height
-
contentSize
.
height
,
contentSize
.
height
),
);
);
break
;
break
;
case
_MenuPosition
.
topLeft
:
case
_MenuPosition
.
topLeft
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment