Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

fix ios draggable chat window

Sahil Yeole9cc02d6fcb5b
diff --git a/flutter/lib/common/widgets/overlay.dart b/flutter/lib/common/widgets/overlay.dart
index a3c59d6b1..f2f3b8fb0 100644
--- a/flutter/lib/common/widgets/overlay.dart
+++ b/flutter/lib/common/widgets/overlay.dart
@@ -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);
diff --git a/flutter/lib/models/chat_model.dart b/flutter/lib/models/chat_model.dart
index 898427351..bffd9d426 100644
--- a/flutter/lib/models/chat_model.dart
+++ b/flutter/lib/models/chat_model.dart
@@ -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) {