mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-08 21:41:02 +03:00
feat(flutter): add mobile canvas lock (#15877)
* feat: add mobile canvas lock * Update flutter/lib/models/model.dart Remove redundant canvas-lock comment Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * remove redundant logic Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com> Co-authored-by: Krik Jin <isjinhk@outlook.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -115,6 +115,7 @@ class _RawTouchGestureDetectorRegionState
|
||||
InputModel get inputModel => widget.inputModel;
|
||||
bool get handleTouch => (isDesktop || isWebDesktop) || ffiModel.touchMode;
|
||||
SessionID get sessionId => ffi.sessionId;
|
||||
bool get canvasLocked => isMobile && ffi.canvasModel.locked;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -471,6 +472,8 @@ class _RawTouchGestureDetectorRegionState
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvasLocked) return;
|
||||
|
||||
if ((isDesktop || isWebDesktop)) {
|
||||
final scale = ((d.scale - _scale) * 1000).toInt();
|
||||
_scale = d.scale;
|
||||
|
||||
@@ -1276,6 +1276,14 @@ void showOptions(
|
||||
List<TToggleMenu> cursorToggles = await toolbarCursor(context, id, gFFI);
|
||||
List<TToggleMenu> displayToggles =
|
||||
await toolbarDisplayToggle(context, id, gFFI);
|
||||
if (isMobile) {
|
||||
displayToggles.insert(
|
||||
0,
|
||||
TToggleMenu(
|
||||
child: Text(translate('Lock canvas')),
|
||||
value: gFFI.canvasModel.locked,
|
||||
onChanged: (value) => gFFI.canvasModel.setLocked(value == true)));
|
||||
}
|
||||
|
||||
List<TToggleMenu> privacyModeList = [];
|
||||
if ((gFFI.ffiModel.pi.features.privacyMode && gFFI.ffiModel.keyboard) ||
|
||||
|
||||
@@ -2213,6 +2213,7 @@ class CanvasModel with ChangeNotifier {
|
||||
double _y = 0;
|
||||
// image scale
|
||||
double _scale = 1.0;
|
||||
bool _locked = false;
|
||||
double _devicePixelRatio = 1.0;
|
||||
Size _size = Size.zero;
|
||||
// the tabbar over the image
|
||||
@@ -2261,12 +2262,19 @@ class CanvasModel with ChangeNotifier {
|
||||
double get x => _x;
|
||||
double get y => _y;
|
||||
double get scale => _scale;
|
||||
bool get locked => _locked;
|
||||
double get devicePixelRatio => _devicePixelRatio;
|
||||
Size get size => _size;
|
||||
ScrollStyle get scrollStyle => _scrollStyle;
|
||||
ViewStyle get viewStyle => _lastViewStyle;
|
||||
RxBool get imageOverflow => _imageOverflow;
|
||||
|
||||
void setLocked(bool value) {
|
||||
if (_locked == value) return;
|
||||
_locked = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
_resetScroll() => setScrollPercent(0.0, 0.0);
|
||||
|
||||
void setScrollPercent(double x, double y) {
|
||||
@@ -2727,6 +2735,7 @@ class CanvasModel with ChangeNotifier {
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
_scale = 1.0;
|
||||
_locked = false;
|
||||
_lastViewStyle = ViewStyle.defaultViewStyle();
|
||||
_timerMobileFocusCanvasCursor?.cancel();
|
||||
_timerMobileRestoreCanvasOffset?.cancel();
|
||||
|
||||
Reference in New Issue
Block a user