diff --git a/flutter/lib/common/widgets/overlay.dart b/flutter/lib/common/widgets/overlay.dart index 89dbe2ea6..c5a3ad8b6 100644 --- a/flutter/lib/common/widgets/overlay.dart +++ b/flutter/lib/common/widgets/overlay.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_hbb/common.dart'; +import 'package:provider/provider.dart'; import '../../desktop/widgets/tabbar_widget.dart'; import '../../mobile/pages/chat_page.dart'; import '../../models/chat_model.dart'; +import '../../models/model.dart'; class DraggableChatWindow extends StatelessWidget { const DraggableChatWindow( @@ -311,3 +313,48 @@ class _DraggableState extends State { child: widget.builder(context, onPanUpdate)); } } + +class QualityMonitor extends StatelessWidget { + static const textStyle = TextStyle(color: MyTheme.grayBg); + final QualityMonitorModel qualityMonitorModel; + QualityMonitor(this.qualityMonitorModel); + + @override + Widget build(BuildContext context) => ChangeNotifierProvider.value( + value: qualityMonitorModel, + child: Consumer( + builder: (context, qualityMonitorModel, child) => Positioned( + top: 10, + right: 10, + child: qualityMonitorModel.show + ? Container( + padding: const EdgeInsets.all(8), + color: MyTheme.canvasColor.withAlpha(120), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Speed: ${qualityMonitorModel.data.speed ?? ''}", + style: textStyle, + ), + Text( + "FPS: ${qualityMonitorModel.data.fps ?? ''}", + style: textStyle, + ), + Text( + "Delay: ${qualityMonitorModel.data.delay ?? ''} ms", + style: textStyle, + ), + Text( + "Target Bitrate: ${qualityMonitorModel.data.targetBitrate ?? ''}kb", + style: textStyle, + ), + Text( + "Codec: ${qualityMonitorModel.data.codecFormat ?? ''}", + style: textStyle, + ), + ], + ), + ) + : const SizedBox.shrink()))); +} diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 8f3644ded..a7bed04ef 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -10,6 +10,7 @@ import 'package:provider/provider.dart'; import 'package:wakelock/wakelock.dart'; import 'package:flutter_custom_cursor/flutter_custom_cursor.dart'; +import '../../common/widgets/overlay.dart'; import '../../common/widgets/remote_input.dart'; import '../widgets/remote_menubar.dart'; import '../../common.dart'; @@ -418,48 +419,3 @@ class ImagePainter extends CustomPainter { return oldDelegate != this; } } - -class QualityMonitor extends StatelessWidget { - static const textStyle = TextStyle(color: MyTheme.grayBg); - final QualityMonitorModel qualityMonitorModel; - QualityMonitor(this.qualityMonitorModel); - - @override - Widget build(BuildContext context) => ChangeNotifierProvider.value( - value: qualityMonitorModel, - child: Consumer( - builder: (context, qualityMonitorModel, child) => Positioned( - top: 10, - right: 10, - child: qualityMonitorModel.show - ? Container( - padding: const EdgeInsets.all(8), - color: MyTheme.canvasColor.withAlpha(120), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Speed: ${qualityMonitorModel.data.speed ?? ''}", - style: textStyle, - ), - Text( - "FPS: ${qualityMonitorModel.data.fps ?? ''}", - style: textStyle, - ), - Text( - "Delay: ${qualityMonitorModel.data.delay ?? ''} ms", - style: textStyle, - ), - Text( - "Target Bitrate: ${qualityMonitorModel.data.targetBitrate ?? ''}kb", - style: textStyle, - ), - Text( - "Codec: ${qualityMonitorModel.data.codecFormat ?? ''}", - style: textStyle, - ), - ], - ), - ) - : const SizedBox.shrink()))); -} diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index 021c3fd6a..014266fb8 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:ui' as ui; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hbb/mobile/widgets/gesture_help.dart'; @@ -12,6 +11,7 @@ import 'package:provider/provider.dart'; import 'package:wakelock/wakelock.dart'; import '../../common.dart'; +import '../../common/widgets/overlay.dart'; import '../../common/widgets/remote_input.dart'; import '../../models/input_model.dart'; import '../../models/model.dart'; @@ -118,7 +118,7 @@ class _RemotePageState extends State { } // handle mobile virtual keyboard - void handleInput(String newValue) { + void handleSoftKeyboardInput(String newValue) { var oldValue = _value; _value = newValue; if (isIOS) { @@ -495,7 +495,7 @@ class _RemotePageState extends State { child: Stack(children: [ ImagePaint(), CursorPaint(), - QualityMonitor(), + QualityMonitor(gFFI.qualityMonitorModel), getHelpTools(), SizedBox( width: 0, @@ -512,7 +512,7 @@ class _RemotePageState extends State { initialValue: _value, // trick way to make backspace work always keyboardType: TextInputType.multiline, - onChanged: handleInput, + onChanged: handleSoftKeyboardInput, ), ), ])); @@ -529,28 +529,6 @@ class _RemotePageState extends State { color: MyTheme.canvasColor, child: Stack(children: paints)); } - int lastMouseDownButtons = 0; - - // 重复 - Map getEvent(PointerEvent evt, String type) { - final Map out = {}; - out['type'] = type; - out['x'] = evt.position.dx; - out['y'] = evt.position.dy; - if (inputModel.alt) out['alt'] = 'true'; - if (inputModel.shift) out['shift'] = 'true'; - if (inputModel.ctrl) out['ctrl'] = 'true'; - if (inputModel.command) out['command'] = 'true'; - out['buttons'] = evt - .buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right) - if (evt.buttons != 0) { - lastMouseDownButtons = evt.buttons; - } else { - out['buttons'] = lastMouseDownButtons; - } - return out; - } - void showActions(String id) async { final size = MediaQuery.of(context).size; final x = 120.0; @@ -895,49 +873,6 @@ class ImagePainter extends CustomPainter { } } -// TODO global widget -class QualityMonitor extends StatelessWidget { - static final textColor = Colors.grey.shade200; - @override - Widget build(BuildContext context) => ChangeNotifierProvider.value( - value: gFFI.qualityMonitorModel, - child: Consumer( - builder: (context, qualityMonitorModel, child) => Positioned( - top: 10, - right: 10, - child: qualityMonitorModel.show - ? Container( - padding: EdgeInsets.all(8), - color: MyTheme.canvasColor.withAlpha(120), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Speed: ${qualityMonitorModel.data.speed ?? ''}", - style: TextStyle(color: textColor), - ), - Text( - "FPS: ${qualityMonitorModel.data.fps ?? ''}", - style: TextStyle(color: textColor), - ), - Text( - "Delay: ${qualityMonitorModel.data.delay ?? ''} ms", - style: TextStyle(color: textColor), - ), - Text( - "Target Bitrate: ${qualityMonitorModel.data.targetBitrate ?? ''}kb", - style: TextStyle(color: textColor), - ), - Text( - "Codec: ${qualityMonitorModel.data.codecFormat ?? ''}", - style: TextStyle(color: textColor), - ), - ], - ), - ) - : SizedBox.shrink()))); -} - void showOptions(String id, OverlayDialogManager dialogManager) async { String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced'; if (quality == '') quality = 'balanced';