fix: ios, chat window position, wrong member value (#8464)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-06-24 22:56:13 +08:00 committed by GitHub
parent 1765c7bbf4
commit 00ddd63372
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -486,7 +486,7 @@ class IOSDraggableState extends State<IOSDraggable> {
_height = widget.height; _height = widget.height;
} }
get position => widget.position; DraggableKeyPosition get position => widget.position;
checkKeyboard() { checkKeyboard() {
final bottomHeight = MediaQuery.of(context).viewInsets.bottom; final bottomHeight = MediaQuery.of(context).viewInsets.bottom;
@ -494,13 +494,13 @@ class IOSDraggableState extends State<IOSDraggable> {
// save // save
if (!_keyboardVisible && currentVisible) { if (!_keyboardVisible && currentVisible) {
_saveHeight = position.value.dy; _saveHeight = position.pos.dy;
} }
// reset // reset
if (_lastBottomHeight > 0 && bottomHeight == 0) { if (_lastBottomHeight > 0 && bottomHeight == 0) {
setState(() { setState(() {
position.value = Offset(position.value.dx, _saveHeight); position.update(Offset(position.pos.dx, _saveHeight));
}); });
} }
@ -508,10 +508,10 @@ class IOSDraggableState extends State<IOSDraggable> {
if (_keyboardVisible && currentVisible) { if (_keyboardVisible && currentVisible) {
final sumHeight = bottomHeight + _height; final sumHeight = bottomHeight + _height;
final contextHeight = MediaQuery.of(context).size.height; final contextHeight = MediaQuery.of(context).size.height;
if (sumHeight + position.value.dy > contextHeight) { if (sumHeight + position.pos.dy > contextHeight) {
final y = contextHeight - sumHeight; final y = contextHeight - sumHeight;
setState(() { setState(() {
position.value = Offset(position.value.dx, y); position.update(Offset(position.pos.dx, y));
}); });
} }
} }
@ -526,14 +526,14 @@ class IOSDraggableState extends State<IOSDraggable> {
return Stack( return Stack(
children: [ children: [
Positioned( Positioned(
left: position.value.dx, left: position.pos.dx,
top: position.value.dy, top: position.pos.dy,
child: GestureDetector( child: GestureDetector(
onPanUpdate: (details) { onPanUpdate: (details) {
setState(() { setState(() {
position.value += details.delta; position.update(position.pos + details.delta);
}); });
_chatModel?.setChatWindowPosition(position.value); _chatModel?.setChatWindowPosition(position.pos);
}, },
child: Material( child: Material(
child: Container( child: Container(