move QualityMonitor widget to common
This commit is contained in:
parent
6b664d0965
commit
23f0f4e33a
@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../desktop/widgets/tabbar_widget.dart';
|
import '../../desktop/widgets/tabbar_widget.dart';
|
||||||
import '../../mobile/pages/chat_page.dart';
|
import '../../mobile/pages/chat_page.dart';
|
||||||
import '../../models/chat_model.dart';
|
import '../../models/chat_model.dart';
|
||||||
|
import '../../models/model.dart';
|
||||||
|
|
||||||
class DraggableChatWindow extends StatelessWidget {
|
class DraggableChatWindow extends StatelessWidget {
|
||||||
const DraggableChatWindow(
|
const DraggableChatWindow(
|
||||||
@ -311,3 +313,48 @@ class _DraggableState extends State<Draggable> {
|
|||||||
child: widget.builder(context, onPanUpdate));
|
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<QualityMonitorModel>(
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
|
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
|
||||||
|
|
||||||
|
import '../../common/widgets/overlay.dart';
|
||||||
import '../../common/widgets/remote_input.dart';
|
import '../../common/widgets/remote_input.dart';
|
||||||
import '../widgets/remote_menubar.dart';
|
import '../widgets/remote_menubar.dart';
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
@ -418,48 +419,3 @@ class ImagePainter extends CustomPainter {
|
|||||||
return oldDelegate != this;
|
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<QualityMonitorModel>(
|
|
||||||
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())));
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.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 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
|
import '../../common/widgets/overlay.dart';
|
||||||
import '../../common/widgets/remote_input.dart';
|
import '../../common/widgets/remote_input.dart';
|
||||||
import '../../models/input_model.dart';
|
import '../../models/input_model.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
@ -118,7 +118,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle mobile virtual keyboard
|
// handle mobile virtual keyboard
|
||||||
void handleInput(String newValue) {
|
void handleSoftKeyboardInput(String newValue) {
|
||||||
var oldValue = _value;
|
var oldValue = _value;
|
||||||
_value = newValue;
|
_value = newValue;
|
||||||
if (isIOS) {
|
if (isIOS) {
|
||||||
@ -495,7 +495,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
ImagePaint(),
|
ImagePaint(),
|
||||||
CursorPaint(),
|
CursorPaint(),
|
||||||
QualityMonitor(),
|
QualityMonitor(gFFI.qualityMonitorModel),
|
||||||
getHelpTools(),
|
getHelpTools(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 0,
|
width: 0,
|
||||||
@ -512,7 +512,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
initialValue: _value,
|
initialValue: _value,
|
||||||
// trick way to make backspace work always
|
// trick way to make backspace work always
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
onChanged: handleInput,
|
onChanged: handleSoftKeyboardInput,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]));
|
]));
|
||||||
@ -529,28 +529,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
color: MyTheme.canvasColor, child: Stack(children: paints));
|
color: MyTheme.canvasColor, child: Stack(children: paints));
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastMouseDownButtons = 0;
|
|
||||||
|
|
||||||
// 重复
|
|
||||||
Map<String, dynamic> getEvent(PointerEvent evt, String type) {
|
|
||||||
final Map<String, dynamic> 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 {
|
void showActions(String id) async {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
final x = 120.0;
|
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<QualityMonitorModel>(
|
|
||||||
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 {
|
void showOptions(String id, OverlayDialogManager dialogManager) async {
|
||||||
String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced';
|
String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced';
|
||||||
if (quality == '') quality = 'balanced';
|
if (quality == '') quality = 'balanced';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user