Merge pull request #5573 from sahilyeole/ios_1.2.2

Fix ios draggable chat window
This commit is contained in:
RustDesk 2023-09-02 17:50:38 +08:00 committed by GitHub
commit d6950c680f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 6 deletions

View File

@ -26,15 +26,31 @@ class DraggableChatWindow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Draggable(
return isIOS
? IOSDraggable (
position: position,
chatModel: chatModel,
width: width,
height: height,
builder: (context) {
return Column(
children: [
_buildMobileAppBar(context),
Expanded(
child: ChatPage(chatModel: chatModel),
),
],
);
},
)
: Draggable(
checkKeyboard: true,
position: position,
width: width,
height: height,
builder: (context, onPanUpdate) {
final child = isIOS
? ChatPage(chatModel: chatModel)
: Scaffold(
final child =
Scaffold(
resizeToAvoidBottomInset: false,
appBar: CustomAppBar(
onPanUpdate: onPanUpdate,
@ -331,6 +347,69 @@ class _DraggableState extends State<Draggable> {
}
}
class IOSDraggable extends StatefulWidget {
const IOSDraggable({
Key? key,
this.position = Offset.zero,
required this.chatModel,
required this.width,
required this.height,
required this.builder})
: super(key: key);
final Offset position;
final ChatModel chatModel;
final double width;
final double height;
final Widget Function(BuildContext) builder;
@override
_IOSDraggableState createState() => _IOSDraggableState();
}
class _IOSDraggableState extends State<IOSDraggable> {
late Offset _position;
late ChatModel _chatModel;
late double _width;
late double _height;
@override
void initState() {
super.initState();
_position = widget.position;
_chatModel = widget.chatModel;
_width = widget.width;
_height = widget.height;
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned(
left: _position.dx,
top: _position.dy,
child: GestureDetector(
onPanUpdate: (details) {
setState(() {
_position += details.delta;
});
},
child: Material(
child:
Container(
width: _width,
height: _height,
child: widget.builder(context),
),
),
),
),
],
);
}
}
class QualityMonitor extends StatelessWidget {
final QualityMonitorModel qualityMonitorModel;
QualityMonitor(this.qualityMonitorModel);

View File

@ -63,7 +63,7 @@ class ChatModel with ChangeNotifier {
bool isConnManager = false;
RxBool isWindowFocus = true.obs;
BlockableOverlayState? _blockableOverlayState;
BlockableOverlayState _blockableOverlayState = BlockableOverlayState();
final Rx<VoiceCallStatus> _voiceCallStatus = Rx(VoiceCallStatus.notStarted);
Rx<VoiceCallStatus> get voiceCallStatus => _voiceCallStatus;
@ -154,7 +154,7 @@ class ChatModel with ChangeNotifier {
}
}
final overlayState = _blockableOverlayState?.state;
final overlayState = _blockableOverlayState.state;
if (overlayState == null) return;
final overlay = OverlayEntry(builder: (context) {