update touch mode
This commit is contained in:
parent
0de614bdb3
commit
673991d7d5
@ -54,25 +54,25 @@ class _HomePageState extends State<HomePage> {
|
||||
this._menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
},
|
||||
onTap: () {
|
||||
List<PopupMenuItem<String>> items = [];
|
||||
items.add(PopupMenuItem<String>(
|
||||
child: Text(translate('ID Server')),
|
||||
value: 'id_server'));
|
||||
if (isAndroid){
|
||||
items.add(
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Share My Screen')),
|
||||
value: 'server')
|
||||
);
|
||||
}
|
||||
items.add(PopupMenuItem<String>(
|
||||
child: Text(translate('About') + ' RustDesk'),
|
||||
value: 'about'));
|
||||
() async {
|
||||
var value = await showMenu<dynamic>(
|
||||
context: context,
|
||||
position: this._menuPos,
|
||||
items: [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('ID Server')),
|
||||
value: 'id_server'),
|
||||
// TODO test
|
||||
isAndroid
|
||||
? PopupMenuItem<dynamic>(
|
||||
child: Text(translate('Share My Screen')),
|
||||
value: 'server')
|
||||
: PopupMenuItem<dynamic>(
|
||||
child: SizedBox.shrink(), value: ''),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('About') + ' RustDesk'),
|
||||
value: 'about'),
|
||||
],
|
||||
items: items,
|
||||
elevation: 8,
|
||||
);
|
||||
if (value == 'id_server') {
|
||||
|
@ -29,7 +29,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
double _bottom = 0;
|
||||
String _value = '';
|
||||
double _scale = 1;
|
||||
bool _mouseTools = false;
|
||||
|
||||
var _more = true;
|
||||
var _fn = false;
|
||||
@ -204,7 +203,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
void openKeyboard() {
|
||||
// destroy first, so that our _value trick can work
|
||||
_value = initText;
|
||||
resetMouse();
|
||||
setState(() => _showEdit = false);
|
||||
_timer?.cancel();
|
||||
_timer = Timer(Duration(milliseconds: 30), () {
|
||||
@ -220,10 +218,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
});
|
||||
}
|
||||
|
||||
void resetMouse() {
|
||||
_mouseTools = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pi = Provider.of<FfiModel>(context).pi;
|
||||
@ -300,29 +294,11 @@ class _RemotePageState extends State<RemotePage> {
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.keyboard),
|
||||
onPressed: openKeyboard),
|
||||
Container(
|
||||
color: _mouseTools ? Colors.blue[500] : null,
|
||||
child: IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.mouse),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_mouseTools = !_mouseTools;
|
||||
resetTool();
|
||||
});
|
||||
},
|
||||
)),
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.help),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showModalBottomSheet(
|
||||
backgroundColor: MyTheme.grayBg,
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
GestureHelp(initTouchMode: _touchMode));
|
||||
},
|
||||
icon: Icon(
|
||||
_touchMode ? Icons.touch_app : Icons.mouse),
|
||||
onPressed: changeTouchMode,
|
||||
)
|
||||
]) +
|
||||
<Widget>[
|
||||
@ -518,18 +494,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate('Paste')), value: 'paste'));
|
||||
}
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Row(
|
||||
children: ([
|
||||
Container(width: 100.0, child: Text(translate('Touch mode'))),
|
||||
Padding(padding: EdgeInsets.symmetric(horizontal: 16.0)),
|
||||
Icon(
|
||||
_touchMode
|
||||
? Icons.check_box_outlined
|
||||
: Icons.check_box_outline_blank,
|
||||
color: MyTheme.accent)
|
||||
])),
|
||||
value: 'touch_mode'));
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate('Reset canvas')), value: 'reset_canvas'));
|
||||
}
|
||||
@ -580,23 +544,43 @@ class _RemotePageState extends State<RemotePage> {
|
||||
} else {
|
||||
showSetOSPassword(context, true);
|
||||
}
|
||||
} else if (value == 'touch_mode') {
|
||||
_touchMode = !_touchMode;
|
||||
final v = _touchMode ? 'Y' : '';
|
||||
FFI.setByName('peer_option', '{"name": "touch-mode", "value": "$v"}');
|
||||
} else if (value == 'reset_canvas') {
|
||||
FFI.cursorModel.reset();
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
void changeTouchMode() {
|
||||
setState(() => _showEdit = false);
|
||||
showModalBottomSheet(
|
||||
backgroundColor: MyTheme.grayBg,
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(5))),
|
||||
builder: (context) => DraggableScrollableSheet(
|
||||
expand: false,
|
||||
builder: (context, scrollController) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureHelp(
|
||||
touchMode: _touchMode,
|
||||
onTouchModeChange: (t) {
|
||||
setState(() => _touchMode = t);
|
||||
final v = _touchMode ? 'Y' : '';
|
||||
FFI.setByName('peer_option',
|
||||
'{"name": "touch-mode", "value": "$v"}');
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
void close() {
|
||||
msgbox('', 'Close', 'Are you sure to close the connection?', context);
|
||||
}
|
||||
|
||||
Widget getHelpTools() {
|
||||
final keyboard = isKeyboardShown();
|
||||
if (!_mouseTools && !keyboard) {
|
||||
if (!keyboard) {
|
||||
return SizedBox();
|
||||
}
|
||||
final size = MediaQuery.of(context).size;
|
||||
|
@ -32,9 +32,12 @@ class GestureIcons {
|
||||
IconData(0xe691, fontFamily: _family);
|
||||
}
|
||||
|
||||
typedef OnTouchModeChange = void Function(bool);
|
||||
|
||||
class GestureHelp extends StatefulWidget {
|
||||
GestureHelp({Key? key,this.initTouchMode = false}) : super(key: key);
|
||||
final initTouchMode;
|
||||
GestureHelp({Key? key,required this.touchMode,required this.onTouchModeChange}) : super(key: key);
|
||||
final bool touchMode;
|
||||
final OnTouchModeChange onTouchModeChange;
|
||||
@override
|
||||
State<StatefulWidget> createState() => _GestureHelpState();
|
||||
}
|
||||
@ -45,7 +48,7 @@ class _GestureHelpState extends State<GestureHelp> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_touchMode = widget.initTouchMode;
|
||||
_touchMode = widget.touchMode;
|
||||
_selectedIndex = _touchMode ? 1 : 0;
|
||||
super.initState();
|
||||
}
|
||||
@ -61,20 +64,24 @@ class _GestureHelpState extends State<GestureHelp> {
|
||||
children: <Widget>[
|
||||
ToggleSwitch(
|
||||
initialLabelIndex: _selectedIndex,
|
||||
inactiveBgColor: MyTheme.darkGray,
|
||||
totalSwitches: 2,
|
||||
minWidth: 130,
|
||||
fontSize: 15,
|
||||
iconSize: 20,
|
||||
labels: ["触摸板模式", "触屏模式"],
|
||||
icons: [
|
||||
GestureIcons.icon_mouse,
|
||||
GestureIcons.icon_Tablet_Touch
|
||||
Icons.mouse,
|
||||
Icons.touch_app
|
||||
],
|
||||
onToggle: (index) {
|
||||
debugPrint(index.toString());
|
||||
setState(() {
|
||||
_touchMode = index == 0 ? false : true;
|
||||
_selectedIndex = index ?? 0;
|
||||
if (_selectedIndex != index){
|
||||
_selectedIndex = index ?? 0;
|
||||
_touchMode = index == 0 ? false : true;
|
||||
widget.onTouchModeChange(_touchMode);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user