Merge branch 'rustdesk:master' into fix/frequent_loginctl_calls

This commit is contained in:
Sahil Yeole 2023-09-07 01:53:42 +05:30 committed by GitHub
commit d582af8cb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 32 deletions

View File

@ -46,7 +46,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.carriez.flutter_hbb" applicationId "com.carriez.flutter_hbb"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 31 targetSdkVersion 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }

View File

@ -48,6 +48,7 @@ class DraggableChatWindow extends StatelessWidget {
position: position, position: position,
width: width, width: width,
height: height, height: height,
chatModel: chatModel,
builder: (context, onPanUpdate) { builder: (context, onPanUpdate) {
final child = final child =
Scaffold( Scaffold(
@ -242,6 +243,7 @@ class Draggable extends StatefulWidget {
this.position = Offset.zero, this.position = Offset.zero,
required this.width, required this.width,
required this.height, required this.height,
this.chatModel,
required this.builder}) required this.builder})
: super(key: key); : super(key: key);
@ -250,6 +252,7 @@ class Draggable extends StatefulWidget {
final Offset position; final Offset position;
final double width; final double width;
final double height; final double height;
final ChatModel? chatModel;
final Widget Function(BuildContext, GestureDragUpdateCallback) builder; final Widget Function(BuildContext, GestureDragUpdateCallback) builder;
@override @override
@ -258,6 +261,7 @@ class Draggable extends StatefulWidget {
class _DraggableState extends State<Draggable> { class _DraggableState extends State<Draggable> {
late Offset _position; late Offset _position;
late ChatModel? _chatModel;
bool _keyboardVisible = false; bool _keyboardVisible = false;
double _saveHeight = 0; double _saveHeight = 0;
double _lastBottomHeight = 0; double _lastBottomHeight = 0;
@ -266,6 +270,7 @@ class _DraggableState extends State<Draggable> {
void initState() { void initState() {
super.initState(); super.initState();
_position = widget.position; _position = widget.position;
_chatModel = widget.chatModel;
} }
void onPanUpdate(DragUpdateDetails d) { void onPanUpdate(DragUpdateDetails d) {
@ -292,6 +297,7 @@ class _DraggableState extends State<Draggable> {
setState(() { setState(() {
_position = Offset(x, y); _position = Offset(x, y);
}); });
_chatModel?.setChatWindowPosition(_position);
} }
checkScreenSize() {} checkScreenSize() {}
@ -351,14 +357,14 @@ class IOSDraggable extends StatefulWidget {
const IOSDraggable({ const IOSDraggable({
Key? key, Key? key,
this.position = Offset.zero, this.position = Offset.zero,
required this.chatModel, this.chatModel,
required this.width, required this.width,
required this.height, required this.height,
required this.builder}) required this.builder})
: super(key: key); : super(key: key);
final Offset position; final Offset position;
final ChatModel chatModel; final ChatModel? chatModel;
final double width; final double width;
final double height; final double height;
final Widget Function(BuildContext) builder; final Widget Function(BuildContext) builder;
@ -368,22 +374,58 @@ class IOSDraggable extends StatefulWidget {
} }
class _IOSDraggableState extends State<IOSDraggable> { class _IOSDraggableState extends State<IOSDraggable> {
late Offset _position; late Offset _position;
late ChatModel _chatModel; late ChatModel? _chatModel;
late double _width; late double _width;
late double _height; late double _height;
bool _keyboardVisible = false;
double _saveHeight = 0;
double _lastBottomHeight = 0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_position = widget.position; _position = widget.position;
_chatModel = widget.chatModel; _chatModel = widget.chatModel;
_width = widget.width; _width = widget.width;
_height = widget.height; _height = widget.height;
} }
checkKeyboard() {
final bottomHeight = MediaQuery.of(context).viewInsets.bottom;
final currentVisible = bottomHeight != 0;
// save
if (!_keyboardVisible && currentVisible) {
_saveHeight = _position.dy;
}
// reset
if (_lastBottomHeight > 0 && bottomHeight == 0) {
setState(() {
_position = Offset(_position.dx, _saveHeight);
});
}
// onKeyboardVisible
if (_keyboardVisible && currentVisible) {
final sumHeight = bottomHeight + _height;
final contextHeight = MediaQuery.of(context).size.height;
if (sumHeight + _position.dy > contextHeight) {
final y = contextHeight - sumHeight;
setState(() {
_position = Offset(_position.dx, y);
});
}
}
_keyboardVisible = currentVisible;
_lastBottomHeight = bottomHeight;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
checkKeyboard();
return Stack( return Stack(
children: [ children: [
Positioned( Positioned(
@ -394,13 +436,15 @@ void initState() {
setState(() { setState(() {
_position += details.delta; _position += details.delta;
}); });
_chatModel?.setChatWindowPosition(_position);
}, },
child: Material( child: Material(
child: child:
Container( Container(
width: _width, width: _width,
height: _height, height: _height,
child: widget.builder(context), decoration: BoxDecoration(border: Border.all(color: MyTheme.border)),
child: widget.builder(context),
), ),
), ),
), ),

View File

@ -72,6 +72,13 @@ class ChatModel with ChangeNotifier {
RxInt mobileUnreadSum = 0.obs; RxInt mobileUnreadSum = 0.obs;
MessageKey? latestReceivedKey; MessageKey? latestReceivedKey;
Offset chatWindowPosition = Offset(20, 80);
void setChatWindowPosition(Offset position) {
chatWindowPosition = position;
notifyListeners();
}
@override @override
void dispose() { void dispose() {
textController.dispose(); textController.dispose();
@ -210,7 +217,7 @@ class ChatModel with ChangeNotifier {
} }
}, },
child: DraggableChatWindow( child: DraggableChatWindow(
position: chatInitPos ?? Offset(20, 80), position: chatInitPos ?? chatWindowPosition,
width: 250, width: 250,
height: 350, height: 350,
chatModel: this)); chatModel: this));

View File

@ -300,11 +300,12 @@ packages:
dash_chat_2: dash_chat_2:
dependency: "direct main" dependency: "direct main"
description: description:
name: dash_chat_2 path: "."
sha256: e9e08b2a030d340d60f7adbeb977d3d6481db1f172b51440bfa02488b92fa19c ref: HEAD
url: "https://pub.dev" resolved-ref: bd6b5b41254e57c5bcece202ebfb234de63e6487
source: hosted url: "https://github.com/rustdesk-org/Dash-Chat-2"
version: "0.0.17" source: git
version: "0.0.18"
debounce_throttle: debounce_throttle:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1398,10 +1399,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: video_player name: video_player
sha256: "59f7f31c919c59cbedd37c617317045f5f650dc0eeb568b0b0de9a36472bdb28" sha256: d3910a8cefc0de8a432a4411dcf85030e885d8fef3ddea291f162253a05dbf01
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.5.1" version: "2.7.1"
video_player_android: video_player_android:
dependency: transitive dependency: transitive
description: description:
@ -1422,10 +1423,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: video_player_platform_interface name: video_player_platform_interface
sha256: "42bb75de5e9b79e1f20f1d95f688fac0f95beac4d89c6eb2cd421724d4432dae" sha256: be72301bf2c0150ab35a8c34d66e5a99de525f6de1e8d27c0672b836fe48f73a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.1" version: "6.2.1"
video_player_web: video_player_web:
dependency: transitive dependency: transitive
description: description:

View File

@ -39,7 +39,9 @@ dependencies:
package_info_plus: ^3.1.2 package_info_plus: ^3.1.2
url_launcher: ^6.0.9 url_launcher: ^6.0.9
toggle_switch: ^2.1.0 toggle_switch: ^2.1.0
dash_chat_2: ^0.0.17 dash_chat_2:
git:
url: https://github.com/rustdesk-org/Dash-Chat-2
draggable_float_widget: ^0.0.2 draggable_float_widget: ^0.0.2
settings_ui: ^2.0.2 settings_ui: ^2.0.2
flutter_breadcrumb: ^1.0.1 flutter_breadcrumb: ^1.0.1

View File

@ -779,12 +779,18 @@ pub fn get_sysinfo() -> serde_json::Value {
os = format!("{os} - {}", system.os_version().unwrap_or_default()); os = format!("{os} - {}", system.os_version().unwrap_or_default());
} }
let hostname = hostname(); // sys.hostname() return localhost on android in my test let hostname = hostname(); // sys.hostname() return localhost on android in my test
serde_json::json!({ use serde_json::json;
let mut out = json!({
"cpu": format!("{cpu}{num_cpus}/{num_pcpus} cores"), "cpu": format!("{cpu}{num_cpus}/{num_pcpus} cores"),
"memory": format!("{memory}GB"), "memory": format!("{memory}GB"),
"os": os, "os": os,
"hostname": hostname, "hostname": hostname,
}) });
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
out["username"] = json!(crate::platform::get_active_username());
}
out
} }
#[inline] #[inline]

View File

@ -538,8 +538,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("pull_ab_failed_tip", "No se ha podido refrescar el directorio"), ("pull_ab_failed_tip", "No se ha podido refrescar el directorio"),
("push_ab_failed_tip", "No se ha podido sincronizar el directorio con el servidor"), ("push_ab_failed_tip", "No se ha podido sincronizar el directorio con el servidor"),
("synced_peer_readded_tip", "Los dispositivos presentes en sesiones recientes se sincronizarán con el directorio."), ("synced_peer_readded_tip", "Los dispositivos presentes en sesiones recientes se sincronizarán con el directorio."),
("Change Color", ""), ("Change Color", "Cambiar Color"),
("Primary Color", ""), ("Primary Color", "Color Primario"),
("HSV Color", ""), ("HSV Color", "Color HSV"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }