mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-25 13:19:04 +08:00
opt chat window on its overlay, make window focusable as a desktop app
This commit is contained in:
parent
c6269b54af
commit
c306ec3ba7
@ -1,6 +1,7 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../consts.dart';
|
||||
@ -91,28 +92,31 @@ class DraggableChatWindow extends StatelessWidget {
|
||||
bottom: BorderSide(
|
||||
color: Theme.of(context).hintColor.withOpacity(0.4)))),
|
||||
height: 38,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Row(children: [
|
||||
Icon(Icons.chat_bubble_outline,
|
||||
size: 20, color: Theme.of(context).colorScheme.primary),
|
||||
SizedBox(width: 6),
|
||||
Text(translate("Chat"))
|
||||
])),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
onTap: chatModel.hideChatWindowOverlay,
|
||||
isClose: true,
|
||||
boxSize: 32,
|
||||
))
|
||||
],
|
||||
),
|
||||
child: Obx(() => Opacity(
|
||||
opacity: chatModel.isWindowFocus.value ? 1.0 : 0.4,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Row(children: [
|
||||
Icon(Icons.chat_bubble_outline,
|
||||
size: 20, color: Theme.of(context).colorScheme.primary),
|
||||
SizedBox(width: 6),
|
||||
Text(translate("Chat"))
|
||||
])),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
onTap: chatModel.hideChatWindowOverlay,
|
||||
isClose: true,
|
||||
boxSize: 32,
|
||||
))
|
||||
],
|
||||
))),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -304,15 +308,17 @@ class _DraggableState extends State<Draggable> {
|
||||
if (widget.checkKeyboard) {
|
||||
checkKeyboard();
|
||||
}
|
||||
if (widget.checkKeyboard) {
|
||||
if (widget.checkScreenSize) {
|
||||
checkScreenSize();
|
||||
}
|
||||
return Positioned(
|
||||
top: _position.dy,
|
||||
left: _position.dx,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: widget.builder(context, onPanUpdate));
|
||||
return Stack(children: [
|
||||
Positioned(
|
||||
top: _position.dy,
|
||||
left: _position.dx,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: widget.builder(context, onPanUpdate))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import 'package:dash_chat_2/dash_chat_2.dart';
|
||||
import 'package:draggable_float_widget/draggable_float_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../consts.dart';
|
||||
@ -37,6 +39,8 @@ class ChatModel with ChangeNotifier {
|
||||
OverlayEntry? chatWindowOverlayEntry;
|
||||
bool isConnManager = false;
|
||||
|
||||
RxBool isWindowFocus = true.obs;
|
||||
|
||||
final ChatUser me = ChatUser(
|
||||
id: "",
|
||||
firstName: "Me",
|
||||
@ -133,11 +137,28 @@ class ChatModel with ChangeNotifier {
|
||||
final overlayState = _getOverlayState();
|
||||
if (overlayState == null) return;
|
||||
final overlay = OverlayEntry(builder: (context) {
|
||||
return DraggableChatWindow(
|
||||
position: const Offset(20, 80),
|
||||
width: 250,
|
||||
height: 350,
|
||||
chatModel: this);
|
||||
bool innerClicked = false;
|
||||
return Listener(
|
||||
onPointerDown: (_) {
|
||||
if (!innerClicked) {
|
||||
isWindowFocus.value = false;
|
||||
}
|
||||
innerClicked = false;
|
||||
},
|
||||
child: Obx(() => Container(
|
||||
color: isWindowFocus.value ? Colors.red.withOpacity(0.3) : null,
|
||||
child: Listener(
|
||||
onPointerDown: (_) {
|
||||
innerClicked = true;
|
||||
if (!isWindowFocus.value) {
|
||||
isWindowFocus.value = true;
|
||||
}
|
||||
},
|
||||
child: DraggableChatWindow(
|
||||
position: const Offset(20, 80),
|
||||
width: 250,
|
||||
height: 350,
|
||||
chatModel: this)))));
|
||||
});
|
||||
overlayState.insert(overlay);
|
||||
chatWindowOverlayEntry = overlay;
|
||||
|
Loading…
Reference in New Issue
Block a user